PDA

View Full Version : servos



foamjet
10-23-2009, 05:40 AM
·Hello.· I'm hoping to get some feedback from those of you smarter than me.·

Going through the "What's a microcontroller" book for a basic stamp, I am stumbling on the servo commands.

·"FOR counter = 1 TO 150
···· PULSOUT 14, 1000
···· PAUSE 20
NEXT"

·sends 150 pulses out of pin 14, each of which last 1000 x 2us or 2.0 ms.· The book says that this corelates to moving the servo horn to the 10:00 position.·

·Later in the program a command is "PULSOUT 14, 750" and 750 x 2us = 1.5 ms.· 1.5 ms turns the servo horn to the 12:00 position.

I get the math, but what are the upper and lower limits of the servo horn travel (in milliseconds) and how does a given millisecond command translate to a certain position on the clock face.
·

Mike Green
10-23-2009, 05:53 AM
Read the "Robotics with the BoeBot" tutorial and the Wikipedia article on RC servo motors.

Basically, standard servos use a pulse between 1ms and 2ms in width to control the servo position. This has to be repeated about 50 times a second or the servo typically will shut off until the next control pulse comes in. The 1ms to 2ms range is not absolute and some servos will respond to pulses as short as 0.5ms and as long as 2.5ms. The exact range of motion is also variable with most servos moving through about 180 degrees over that pulse width range, but some (called "winch" servos) may rotate 2 or 3 turns over the same range of control pulses. The exact range of pulses and motion will vary from manufacturer to manufacturer and from model to model and even from servo to servo. The datasheet for the servo will give you some parameters.

foamjet
10-23-2009, 05:59 AM
Thanks for the quick response.

If I just put any value in the "FOR counter 1 TO 150" line or the PULSOUT line can I damage the servo? That's why I was asking about the limits.

But I will read the tutorial. Thanks again .

Mike Green
10-23-2009, 06:36 AM
The FOR line just sets how long the servo will move. With the PAUSE 20, you're talking about 3 seconds.

The PULSOUT does set the position and you can force the servo to move beyond its mechanical stops. Typically you test your particular servo starting with the usual limits of 1ms to 2ms to see how far it moves. If it hasn't gotten to its mechanical stops, you can gradually increase the range to as much as 0.5ms to 2.5ms. You're not likely to damage a servo by briefly attempting to move a little bit beyond its stops, but repeatedly or continuously doing that could possibly damage it.