tech_pro
Member level 2

Hi
I m using AT89C51/AT89S51 to drive the motor
the circuit is like controller generates the PWM on two pins( 50% duty cycle + equal and opposite)
that is fed into a latch and in turn latch drives the transistor + relay circuit
The relay in the response runs the motor in CW/ACW direction depending on PWM signal
my problem is that some times the program collapse and the controller does not accept and interrupt or input and starts rotating motor in single direction at very high speed. At that point the only way out is the complete shut down of circuit nothing else works
It is more likely to happen with 89c51 and less with 89s51
what cud be the possible reason
the program i wrote is
#include<reg51.h>
#include<stdio.h>
sbit out1=P2^0;
sbit out2=P2^1;
sbit sel1=P2^6;
sbit sel2=P2^7;
void main()
{
unsigned int count,initial;
P0=0;
P1=0;
P2=0;
P3=0;
//p0=0,p1=0;
for(initial=0;initial<100;initial++)
{
out2=0;
out1=0;
}
while(1)
{
if((sel1==1) && (sel2==0))
{
//sel1=0;
for(count=0;count<6500;count++)
{
out2=1;
out1=0;
}
for(count=0;count<50;count++)
{
out2=0;
out1=0;
}
for(count=0;count<6500;count++)
{
out2=0;
out1=1;
}
}
else if((sel1==0) && (sel2==1))
{
//sel2=0;
for(count=0;count<13500;count++)
{
out2=1;
out1=0;
}
for(count=0;count<500;count++)
{
out2=0;
out1=0;
}
for(count=0;count<13500;count++)
{
out2=0;
out1=1;
}
for(count=0;count<500;count++)
{
out2=0;
out1=0;
}
}
else if (((sel1==0) && (sel2==0)) ||((sel1==1) && (sel2==1)))
{
out1=0;
out2=0;
}
}
}
plz point out any mistake in the program . Plz also note that this problem occur when i connect the load on the circuit other wise it runs fine on no load
I m using AT89C51/AT89S51 to drive the motor
the circuit is like controller generates the PWM on two pins( 50% duty cycle + equal and opposite)
that is fed into a latch and in turn latch drives the transistor + relay circuit
The relay in the response runs the motor in CW/ACW direction depending on PWM signal
my problem is that some times the program collapse and the controller does not accept and interrupt or input and starts rotating motor in single direction at very high speed. At that point the only way out is the complete shut down of circuit nothing else works
It is more likely to happen with 89c51 and less with 89s51
what cud be the possible reason
the program i wrote is
#include<reg51.h>
#include<stdio.h>
sbit out1=P2^0;
sbit out2=P2^1;
sbit sel1=P2^6;
sbit sel2=P2^7;
void main()
{
unsigned int count,initial;
P0=0;
P1=0;
P2=0;
P3=0;
//p0=0,p1=0;
for(initial=0;initial<100;initial++)
{
out2=0;
out1=0;
}
while(1)
{
if((sel1==1) && (sel2==0))
{
//sel1=0;
for(count=0;count<6500;count++)
{
out2=1;
out1=0;
}
for(count=0;count<50;count++)
{
out2=0;
out1=0;
}
for(count=0;count<6500;count++)
{
out2=0;
out1=1;
}
}
else if((sel1==0) && (sel2==1))
{
//sel2=0;
for(count=0;count<13500;count++)
{
out2=1;
out1=0;
}
for(count=0;count<500;count++)
{
out2=0;
out1=0;
}
for(count=0;count<13500;count++)
{
out2=0;
out1=1;
}
for(count=0;count<500;count++)
{
out2=0;
out1=0;
}
}
else if (((sel1==0) && (sel2==0)) ||((sel1==1) && (sel2==1)))
{
out1=0;
out2=0;
}
}
}
plz point out any mistake in the program . Plz also note that this problem occur when i connect the load on the circuit other wise it runs fine on no load