stepper motor programming help
RPratt
Posts: 19
Hey Guys -
I have been working with the Stamp Works kit, and I am trying a modification on experiment 27 in the guide (stepper motor control). I am already starting to gear towards halloween gags ( I enjoy messing with the neighborhood kids lol) and I am looking to use the PIR's from Parallax along with some stepper motors to cause some skulls to turn towards who ever walks up to the table. should only be a 45 degree turn each time the PIR is tripped, then move back to the home position when the PIR goes to rest. but I am just not getting anywhere fast! I·am starting with just using a NO button·to step the motor using the sample code in the book (its written to use a POT to control direction and speed. I have one button set for each direction), but I can only get it to do one step each time the·button is pressed. I have tried with modifing the step scale in the EEPROM data, and changing the modifer for the step control variable in the sub routine, but it still only gives me the same result. I am sure I am missing something in the math, but what? the source code from the guide is attached. thanks.
I have been working with the Stamp Works kit, and I am trying a modification on experiment 27 in the guide (stepper motor control). I am already starting to gear towards halloween gags ( I enjoy messing with the neighborhood kids lol) and I am looking to use the PIR's from Parallax along with some stepper motors to cause some skulls to turn towards who ever walks up to the table. should only be a 45 degree turn each time the PIR is tripped, then move back to the home position when the PIR goes to rest. but I am just not getting anywhere fast! I·am starting with just using a NO button·to step the motor using the sample code in the book (its written to use a POT to control direction and speed. I have one button set for each direction), but I can only get it to do one step each time the·button is pressed. I have tried with modifing the step scale in the EEPROM data, and changing the modifer for the step control variable in the sub routine, but it still only gives me the same result. I am sure I am missing something in the math, but what? the source code from the guide is attached. thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Main:
DO
IF Button1 = 0 THEN
GOSUB HeadLeft
ELSEIF button2 = 0 THEN
GOSUB HeadRight
ENDIF
LOOP
HeadLeft:
FOR idx = 1 TO RevSteps ' 1 rev forward
GOSUB Step_Fwd
NEXT
PAUSE 2000
FOR idx = 1 TO RevSteps ' 1 rev back
GOSUB Step_Rev
NEXT
PAUSE 2000
RETURN
HeadRight:
FOR idx = 1 TO RevSteps
GOSUB Step_Rev
NEXT
PAUSE 2000
FOR idx = 1 TO RevSteps
GOSUB Step_Fwd
NEXT
PAUSE 2000
RETURN
I could maintain the same sub-routines as the example program and get the response I was looking for. and by modifying the variable for the motor, and the delay time, I can get the exact amount of steps I want along with the creepy "exorcist" style head crank.
Franklin - thanks again for the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen