Hello and hi all,
I made this post due to the fact that i need a program to give the step signal for L297 Ic. I know that most of the step sequence have been done by the L297 Ic but now the problem that i am having is how to make the step sequence for the L297 is such a way that i could count the number of step that i am giving to the L297 and how to make it non blocking,
I know that using a For loop is consider as blocking and using do while is also consider as blocking. How may i approach this problem and how can i make the program expandable.
I have a stepper motor application that uses switches that manually command movement of the motor. The software uses a while loop like this:
while(CWCommand()) rotate(CW);//Single step CW while switch is ON.
while(CCWCommand()) rotate(CCW);//Single step CCW while switch is ON.
The CWCommand() and CCWCommand() functions test the two switches returning true if the either is ON. The rotate() function looks like this:
void rotate (int whichway){
if (whichway == CW){
motor.step(1);//Single step CW and increment position counter
++Position;}
else if (whichway == CCW){
motor.step(-1);//Single step CCW and increment position counter
--Position;}}
The motor only does one step each time thru the loop so doesn't block you from doing other stuff inbetween steps.