servo problem

in BASIC Stamp
When the GOSUB nine is executed and program ends the pointer on the servo moves a couple degrees clockwise. Why does the servo move just
before end statement? Could somebody please explain? I would like the pointer not to move when program ends. I also couldn't figure out how to post a video of the servo. Thanks in advance.
before end statement? Could somebody please explain? I would like the pointer not to move when program ends. I also couldn't figure out how to post a video of the servo. Thanks in advance.
' {$STAMP BS2}
' {$PBASIC 2.5}
'servoclock1
counter VAR Word
GOSUB three
GOSUB two
GOSUB noon
GOSUB ten
GOSUB nine
END
two:
FOR counter = 1 TO 100 '2pm position
PULSOUT 14, 500
PAUSE 20
NEXT
RETURN
noon:
FOR counter = 1 TO 100 'noon position
PULSOUT 14, 700
PAUSE 20
NEXT
RETURN
nine:
FOR counter = 1 TO 100 '9pm position
PULSOUT 14, 1250
PAUSE 20
NEXT
RETURN
ten:
FOR counter = 1 TO 100 '10pm position
PULSOUT 14, 900
PAUSE 20
NEXT
RETURN
three:
FOR counter = 1 TO 100 'threepm position
PULSOUT 14, 250
PAUSE 20
NEXT
RETURN
Comments
DO : LOOP
after the GOSUB nine and before the END
The catch, though, is that every 2.3 seconds, the output switches to an input for 18 ms, which could cause the servo to twitch. So, in fact, your cure should work as prescribed.
-Phil
I solved the problem by replacing " PULSOUT 14, 1250" with "PULSOUT 14, 1100."
Thanks for the effort anyway.
' {$STAMP BS2} ' {$PBASIC 2.5} 'servoclock1 three CON 250 two CON 500 noon CON 700 ten CON 900 nine CON 1100 servo PIN 14 pos VAR Word pos = three GOSUB movearm pos = two GOSUB movearm pos = noon GOSUB movearm pos = ten GOSUB movearm pos = nine GOSUB movearm END ' ---------------------- movearm: counter VAR Word FOR counter = 1 TO 100 PULSOUT servo, pos PAUSE 20 NEXT RETURN ' ======================