Here's the program.
NWUpgrades
Posts: 292
' {$STAMP BS2} ' {$PBASIC 2.5} StepperDir PIN 0 ' direction control StepperMove PIN 1 ' movement CW CON 0 CCW CON 1 idx VAR Byte Reset: OUTPUT StepperDir HIGH StepperMove ' move on high-to-low transition Main: StepperDir = CW FOR idx = 1 TO 100 PULSOUT StepperMove, 500 PAUSE 5 NEXT StepperDir = CCW FOR idx = 1 TO 100 PULSOUT StepperMove, 500 PAUSE 5 NEXT GOTO Main
Comments
·· This post looks like it should be in the other thread you posted asking for Stepper Motor code.· And by the way, this code requires a Stepper Motor controller.· This code is not for direct control of a Stepper Motor as the example I posted in your other thread.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Since 360 / 1.8 = 200, there are 200 steps in an entire circle (360 degrees) using this particlar stepper motor. Forward step (CW) the motor 200 steps and you will complete the circle in one direction. Reverse (CCW) step the motor 200 steps and you return to the original position.
So, presently, as your program is written, it will turn 180 degrees (+ 100 steps) in a CW direction, and then turn 180 degrees (- 100 steps) in a CCW direction.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 2/14/2006 9:16:05 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
P0 is direction control and P1 is the step pulse.
That's eaxctly what I need.
I have a stepper driver with PLS & Dir input, so will use stamp to send the pulse.
thanks
thanks
thanks
Ok, thanks
how do I reverse direction for the BS1 code,
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL StepperDir = PIN0 ' direction control
SYMBOL StepperMove = PIN1 ' movement
SYMBOL CW = 0
SYMBOL CCW = 1
SYMBOL idx = B0
Reset:
OUTPUT StepperDir
HIGH StepperMove ' move on high-to-low transition
Main:
StepperDir = CW
FOR idx = 1 TO 100
PULSOUT StepperMove, 500
PAUSE 5
NEXT
StepperDir = CCW
FOR idx = 1 TO 100
PULSOUT StepperMove, 500
PAUSE 5
NEXT
GOTO Main
I tried PWM command, is faster:
http://www.youtube.com/watch?v=n4G9u6sqr24
As for direction, if your direction line was connected to P0 in the original cod you should have observed the stepper motor stepping one way for 100 pulses and then turning the other way. The line StepperDir = CW or CCW is what set direction.