HI I AM WORKING ON STEPPER MOTOR WITH MICROCONTROLLOR(P89V51RD2BN).THIS IS MY PROGRAM. #include<reg52.h>
#define ST_CNTRL P1;
void delay(void);
void main() { unsigned char k; for(k=0;k<30;k++) { P1 = 0x66; delay(); P1 = 0xcc; delay(); P1 = 0x99; delay(); P1 = 0x33; delay(); } }
void delay(void) { unsigned int i,j;
for(i = 0; i<0x20; i++) { for(j = 0; j<0x20; j++) { } } } PROBLEM IS THE STEPPER MOTOR DOESNT STOP AFTER 30 STEPS AS GIVEN IN FOR LOOP.IT JUST JERKS AFTER 30 STEPS AND CONTINUE ROTATING,I WANT TO STOP IS AFTER 30 STEPS. CAN ANY ONE HELP?
You're falling off the bottom of main.
i am sorry i din get u..can u please elaborate as to wer i am goin wrong?
What do you think happens after your 30 steps?
When the for loop ends - do you think your program will end and your prcessor reach any command line waiting for receiving a new command to run?
You should add an infinite loop at the bottom of the main() function, or your program may (depending on used compiler, architecture, startup file etc) restart again and again and again. That is a major think to think about when developing embedded applications - there are no desktop or command line prompt that will take over if you let the program end.
Thank you very much for the response sir..but if u could write me the code,it'l be helpful sir, me new to electronics field.please do help
but if u could write me the code
You lost soul! You should have immediately asked that instead of giving us the false hope that you actually intend to learn something new.
well i tried my best,tried to use a break,abort and return statements to exit from loop neither of them worked..so pls do help me with the code.
View all questions in Keil forum