stepper motor in a loop
eman53132
Posts: 6
i am trying to have a stepper motor do 40 steps clockwise when the input goes high, then do nothing until the input goes low. the low would then turn the motor 40 steps counterclockwise.
i have the stepper motor turning in both directions. i am stuck on on what to do next. i need the program to keep checking if the input has changed.
thanks,
e
i have the stepper motor turning in both directions. i am stuck on on what to do next. i need the program to keep checking if the input has changed.
thanks,
e
Comments
PAR
·
·· All you need to do is have a conditional in your loop checking the status of the input.· When it is HIGH you GOSUB to a subroutine to step the Stepper Motor one way then return.· The ELSEIF section of the conditional will call the reverse subroutine which moves 40 steps.· This assumes you don’t need to stop once you start the 40 steps.· But the loop would do nothing until the input changed.
·
·· The other part of this equation is a flag variable.· This flag will be set when one routine runs and cleared when the other runs.· Your IF…THEN routine will check the state of the input AND the flag.· I will see if I can explain with some sample code…
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
one more question.....how do i compare variables (ex. dsdata and s1)
what i want them to do is if they are the same out10 goes low.· if they are different out10 goes high.·
thanks
e
·
·· This should work fine…Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support