It has been awhile since I stamped, but this should get you going with PIC BASIC.
http://www.picbasic.co.uk/forum/show...hlight=stepper
It has been awhile since I stamped, but this should get you going with PIC BASIC.
http://www.picbasic.co.uk/forum/show...hlight=stepper
Dave
Always wear safety glasses while programming.
Thanks for that, got it working not as elegantly as the first program but it does the job.
Here is the code, any suggestions on making it a bit more elegant wouild be appreciated.
DEFINE OSC 4
TRISB = %00000000
speed var word
i var byte
speed = 10
Main:
FOR i = 1 TO 50 ' one revolution
GOSUB Step_Fwd ' rotate clockwise
NEXT i
PAUSE 500 ' wait 1/2 second
FOR i = 1 TO 50 ' one revolution
GOSUB Step_Rev ' rotate counter-clockwise
NEXT i
PAUSE 500 ' wait 1/2 second
GOTO Main
END
Step_Fwd:
portb = %1001
pause speed
portb = %1100
pause speed
portb = %0110
pause speed
portb = %0011
pause speed
return
Step_Rev:
portb = %0011
pause speed
portb = %0110
pause speed
portb = %1100
pause speed
portb = %1001
pause speed
return
Bookmarks