bhadmanathan
Junior Member level 1
Hi
i am using 8051 uc and 1.8 degree motor which is 4 wired hybrid bi polar stepper motor.
Done a coding to control a stepper motor and it is working fine in the frequency of 10-50 Hz.
Like wise one more above 4 lines for another 4 pins.
But pulse is not coming correctly.
Above every lines of code is in ISR.
Other alternative i used is single bit access, but that is also not helping.
Now i completed the task by using separate ports, But i want to know "why bit clear and bit set was not working ?"
Thanks
i am using 8051 uc and 1.8 degree motor which is 4 wired hybrid bi polar stepper motor.
Done a coding to control a stepper motor and it is working fine in the frequency of 10-50 Hz.
Code:
void T0_ISR (void) interrupt 1 //Timer0 interrupt
{
TL0=0x65; // comes to ISR 1ms once
TH0=0xFC;
count1++;
if(count1>=10)
{
xx++;
count1=0;
}
if(xx==1) P3=0x60;
else if(xx==2) P3=0xa0;
else if(xx==3) P3=0x90;
else if(xx==4) {P3=0x50;xx=0;}
}
In Port3 i need to connect two stepper motors .
one is connected in P3.0 to P3.3.
Another is connected in P3.4 to P3.7.
Coding wise i need to give pulses without disturbing the other motor's pulse.
I modified the code like,
if(xx==1) {P3 &= 0x0f;P3 |= 0x60;}
else if(xx==2) {P3 &= 0x0f;P3 |= 0xa0;}
else if(xx==3) {P3 &= 0x0f;P3 |= 0x90;}
else if(xx==4) {P3 &= 0x0f;P3 |= 0x50;xx=0;}
Like wise one more above 4 lines for another 4 pins.
But pulse is not coming correctly.
Above every lines of code is in ISR.
Other alternative i used is single bit access, but that is also not helping.
Now i completed the task by using separate ports, But i want to know "why bit clear and bit set was not working ?"
Thanks