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

Servo question

LautarocondorLautarocondor Posts: 15
edited 2007-08-13 21:24 in BASIC Stamp
I am using the BS2 to control a set of servos, but the movement jerks too much. I am using the PULSOUT command similar to:
·
Start:
·· PULSOUT 0, 190·· PAUSE 20GOTO StartIt either moves too fast (smooth) or when I increase the PAUSE command it (jerks) to the next position. Is there a way to smoothly control a servo at slow speed? I am using a push button like control, not a pot. THANKS!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-13 13:20
    Yes, you have to change the pulse width slowly ... whatever that means for you. The servo is just trying to reach the new position as quickly as possible. Perhaps change the pulse width by no more than 10 for each 20ms cycle like this:
    goal var word ' desired pulse width
    srvP var word ' actual pulse width
    start:
       srvp = 750
       goal = 750
    cycle:
       ' calculate a new goal
       if srvp < goal then
          if goal - srvp > 10 then
             srvp = srvp + 10
          else
             srvp = goal
          endif
       endif
       if srvp > goal then
          if srvp - goal > 10 then
             srvp = srvp - 10
          else
             srvp = goal
          endif
       endif
       pulsout 0,srvp
       pause 20
       goto cycle
    
    
  • LautarocondorLautarocondor Posts: 15
    edited 2007-08-13 21:24
    Thanks alot. I'll try this tonight.
Sign In or Register to comment.