Shop OBEX P1 Docs P2 Docs Learn Events
Pulsout and Pause Question — Parallax Forums

Pulsout and Pause Question

ajwardajward Posts: 1,130
edited 2011-04-28 15:30 in Robotics
Hi All...

Fiddling with the servos on my Boe Bot and I've encountered something odd (odd to me anyway)!

I started sending a single pulsout to the servo to see how far it would turn.

PULSOUT 13, 850
PAUSE 20

Then hitting reset repeatedly to find one-quarter turn I find 12 pulses is real close to 90 degrees. So... 48 should give a full rotation. Ah... no. Sending...

for counter = 1 to 48
PULSOUT 13, 850
PAUSE 20
next

... gives me about 305 degrees of rotation. Changing 'counter' to 57 gives me close to 360 degrees. (If I send a single pulse 48 times with the reset switch, I get ~360 degrees.)

More fiddling...

Next, I tried changing increasing pause, thinking 'maybe' the servo needed more time to execute the pulsout commands. Setting pause at 26 lets counter = 40 complete ~ 360 degrees of rotation.

Reading somewhere you should not have a pause of more than 20, I inserted a short timing delay in the pulsout 'loop'.

FOR counter = 1 TO 48

PULSOUT 13, 850
PAUSE 20

FOR counter2 = 1 TO 8
NEXT

NEXT

This gives me ~ 360 degrees of rotation.

The setup is my 'Bot on a test stand. Batteries are new as are the servos. I have an 8 inch pointer attached to the servo so my angles are pretty accurate.

I'm somewhat befuddled! Can anyone point me to where I can find out more about how the servos work?

Many Thanks,

Amanda

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-28 10:38
    The main "how does it work" stuff is in Chapter 4 of "What's a Microcontroller?" and in "Robotics with the BoeBot". Remember that these servos are what are called "continuous motion servos". The feedback mechanism for the servo's position is disabled in these so they rotate continuously and the servo control pulse width sets the direction and speed of the servo. Usually, < 1.5ms turns the servo one way and > 1.5ms turns it the other way. The further away the pulse width is from 1.5ms, the faster the servo moves, but the relationship is not a smooth linear function. Friction and supply voltage are important determinants of the servo's speed. You also have to provide a steady sequence of servo pulses or the servo will shut off (and 'stutter'). You can't trust servo on-time to determine rotation or distance travelled. For any kind of accuracy, you have to use some kind of wheel encoder (like the one Parallax sells).
  • ajwardajward Posts: 1,130
    edited 2011-04-28 10:51
    Mike Green wrote: »
    The main "how does it work" stuff is in Chapter 4 of "What's a Microcontroller?" and in "Robotics with the BoeBot". Remember that these servos are what are called "continuous motion servos". The feedback mechanism for the servo's position is disabled in these so they rotate continuously and the servo control pulse width sets the direction and speed of the servo. Usually, < 1.5ms turns the servo one way and > 1.5ms turns it the other way. The further away the pulse width is from 1.5ms, the faster the servo moves, but the relationship is not a smooth linear function. Friction and supply voltage are important determinants of the servo's speed. You also have to provide a steady sequence of servo pulses or the servo will shut off (and 'stutter'). You can't trust servo on-time to determine rotation or distance travelled. For any kind of accuracy, you have to use some kind of wheel encoder (like the one Parallax sells).

    Always a source of great information. Thanks Mike! Guess I assumed that the servos were more of a precision device.

    In my first foray into the forums, someone mentioned wheel encoders and Erco. Looks like some research is needed.

    Thanks again!

    Amanda
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2011-04-28 15:30
    Adding to what Mike said, with analog servos the PAUSE of 20 provide a "refresh" rate of 50 Hz, which is more or less the standard. What actually powers the servo (analog variety here, like the kind you're using) is the pulse. With fewer pulses the motor is powered less often, so not only will it be slower, it'll have far less torque.

    Analog servos can usually work with a fairly wide range of refresh rates, though anything under 25 Hz (PAUSE=40) will cause poor performance. Anything above 60-80 Hz may cause the motor to behave erratically, though this depends entirely on the servo.

    You can get approximate distance measurement if you use a voltage regulated supply for the servos. Keep the refresh rate constant. The distances that are traveled will be approximate only, and will apply only to the make and model of servos you use. Expect an error of at least 10%, if not 20%. But it will get you in the ballpark for coarse distances.

    As Mike says, for anything more wheel encoders are preferred, but even those don't detect errors caused by slippage. You need an optical or ultrasonic method for that.

    -- Gordon
Sign In or Register to comment.