Can someone write me code in picbasic for stepper motor control!
I would like to control a stepper motor, for example:
to turn through 360 degrees, and to stop, go back 180 degrees, and to stop, and so on,
I would need a program that works fine, I have tried with some, but always the first mistake and the engine moves a step forward for some step,is not precision.
I use pic 16f628,I forgot say that!
I use this code,but make some mistake after few circle work,not back in same point:
i var byte
k var byte
symbol brz=900 'speed
'360 circle-----------------------------------------
allcircle:
pause 500
For k = 1 to 4
For i = 1 to 128
PULSOUT PORTB.0,brz
PULSOUT PORTB.1,brz
PULSOUT PORTB.2,brz
PULSOUT PORTB.3,brz
next i
next k
pause 2500
goto halfcircle
'-----------------------------------------
'180circle-----------------------------------------
halfcircle:
For k = 1 to 2
For i = 1 to 128
PULSOUT PORTB.3,brz
PULSOUT PORTB.2,brz
PULSOUT PORTB.1,brz
PULSOUT PORTB.0,brz
NEXT I
next k
pause 2500
goto minushalfcircle
'-----------------------------------------
'minus180circle-----------------------------------------
minushalfcircle:
For k = 1 to 2
For i = 1 to 128
PULSOUT PORTB.3,brz
PULSOUT PORTB.2,brz
PULSOUT PORTB.1,brz
PULSOUT PORTB.0,brz
NEXT I
next k
pause 2500
'-----------------------------------------
GOTO allcircle
Bookmarks