Sir, i am using stepper motor of 2 degree step angle. I m using following c program:
#include<reg51.h> void main() { while(1) { void delay (int); P1=0xCC; delay(1); P1=0x66; delay(1); P1=0x33; delay(1); P1=0x99; delay(1); } } void delay(int a) { unsigned int x,y; for(x=0;x<10;x++) for(y=0;y<a;a++); }
But i want to rotate it to 80 degree only. I want to stop motor at 80 degree. Please give me the c program for this....??
on timer irq: * check counter-variable, if not zero you have a malfunctioning chip.
Erik
you msy not have zero in the timer, some timers keep running after triggering the interrupt which happened when the count passed zero.
Note that "counter variable" in the post you commented on was not the counter register for the timer, but a normal variable to keep track of total movement of the stepper motor.
And correct - better timers will support continuous operation while issuing an interrupt. So they do not leak time before the ISR have time to restart the timer again.
I just sketched an idea.
"counter variable" was not meant to be the timer itself rather a counter to count the steps of the motor. The timer should be running independently. Favoured with autoreload if supported.