How to pause a servo motor in the middle location.
Maintenance man
Posts: 17
I was wondering how I can make a servo motor stop midway,pause for a second or so then continue all the way to one side then come back,pause for a second or so midway, then continue all the way in other direction.I would like to continue this action where the servo turns one way then the other way in which it pauses for a second or so every time it is in the middle.Thank you all for your help.
Comments
this should be close its a newer version http://www.parallax.com/Portals/0/Downloads/docs/prod/edu/28123-WAM-v3.0.pdf
Use 1000 for Counter Clockwise, than 750 for Center, then 500 for clockwise, then 750 for center. (750 will always return to center)
Rinse repeat.
for b0=500 to 1000 step 1
pulsout 1,b0
pause 20
next
then try step 2 or anything larger. And obviously you could stop mistroke using
for b0=500 to 750
etc....
' {$STAMP BS2}
' {$PBASIC 2.0}
x VAR Word
OUTPUT 14
here:
FOR x = 1 TO 100
PULSOUT 14, 250
PAUSE 10
NEXT
PAUSE 500
FOR x = 1 TO 100
PULSOUT 14, 750
PAUSE 10
NEXT
PAUSE 1000
FOR x = 1 TO 100
PULSOUT 14, 1090
PAUSE 10
NEXT
PAUSE 500
FOR x = 1 TO 100
PULSOUT 14, 750
PAUSE 10
NEXT
PAUSE 1000
GOTO here
The following code should perform exactly as before except the servo will hold position better.
Try to avoid using GOTO. DO..LOOP will accomplish what you need.
You might want to try subroutines next.
Partial example;
This is more advanced than what you are talking about but it works like a charm. You can run a servo and in the pauses of the servo run sonar like PING. The pauses may need to be increased by a couple ms but it will not be visually noticeable and will not affect the speed of your code. So instead of saying Pause 19 you might say Pause 20 or Pause 21.
My sonar was not a PING and ran a bit slower than PING and the servo loop could easily handle the timing.