Shop OBEX P1 Docs P2 Docs Learn Events
Servo Position — Parallax Forums

Servo Position

NavicNavic Posts: 38
edited 2008-07-05 17:55 in BASIC Stamp
I'm using the standard servo with a BS2px and have a sweep function that rotates the horn from full left to full right and then full right to full left. I'm inserting breakpoints at random spots that will stop the servo from rotating and after than I want to horn to go back to the full left position, but I can't figure out how to do that.

Here's the turning code:

'Full left to full right
FOR I = 1 TO 24
PULSOUT 14,250
PAUSE 20
'Full right to full left
FOR I = 1 TO 22
PULSOUT 14,2750
PAUSE 20




The pulse values I had experimented with to get, perhaps there's a better method. I tried to use the variable I to figure out where the horn was when stopped, but it doesn't work if the horn is past the 90 degree mark. Any help as to how to figure out horn position and movement would be much appreciated. Thanks!

Navic

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-05 17:55
    The servo doesn't quite work like you think. When you do a PULSOUT, the width of the pulse specifies the desired destination of the servo and the servo will stop moving once it reaches that position regardless of how long you continue to send it the same pulse. If the servo stops seeing pulses, it will turn itself off.

    Your second loop, with the PULSOUT 14,2750 will cause the servo to immediately begin moving to the full left position regardless of what it was doing or what position it was at. You may or may not need more than 22 loops to allow the servo to move through its complete range. You'll have to figure that out. More loops just take more time, they don't result in more movement.
Sign In or Register to comment.