[comp.robotics] Cheap servos.

mikec@wheaties.ai.mit.edu (Mike E. Ciholas) (05/25/90)

In article <8115@brazos.Rice.edu> adnan@rice.edu (Sarmad Adnan) writes:
>I need to control RC/Model-Aircraft type pwm servos from
>a computers parallel port. Specifically what I am looking for
>is a circuit to use an 8-bit TTL I/O port to control a few of these 
>servos for a robotic gripper. I remember seeing such a circuit 
>a long time back in a British electronics magazine but can's seem 
>to find anything like it now. 
>-Sarmad Adnan. 

It is actually very simple.  The servos expect three signals, ground, plus
5 volts, and a pulse signal which is TTL compatible for the most part.
Simply wire the servo power leads to a power source (best not use the same
one as for the computer with the motor noises on it) and then hook the signal
lead straight into the parallel port.  There, no circuit at all!  The
pusle signal carries no current, so you don't have to buffer it.

The servos expect a positive pulse that varies from 1 to 2 mS in duration.
They will operate best with a repeat period of about 16 to 20 mS which is
what they get from an rc radio receiver.  If you do not deliver any pulses,
the servo will become limp.  Generally, you can drive 8 servos from an
8 bit parallel port by sequencing through them one at a time and using an
interrupt generated by a timer.  It works like this:

interrupt routine:
	1. set all bits low
	2. get next servo value from servo value array (8 entries, say)
	3. set the bit high that corresponds to the servo
	4. load interrupt counter
	5. return from interrupt

main code:
	simply set the servo value you want in the servo value array.

In step 2, you just cycle through all the servo values.  You can expand this
idea to add another array that indicates whether a servo should be limp or
not for more flexibility.

Also, for inproved timing accuracy, you can use the "change an output bit"
option on most timers so that software overhead won't add variability to
the output pulse (liek the variable interrupt latency).

(Why, yes I have done this, why do you ask? :-)

Mike Ciholas

email:  mikec@ai.mit.edu
snail:  289 Highland Ave, #108/Somerville, MA 02144
phone:  (617) 623-3563 
air:    N1909C, 1954 Cessna 170B                               

nagle@well.sf.ca.us (John Nagle) (05/27/90)

In article <8115@brazos.Rice.edu> adnan@rice.edu (Sarmad Adnan) writes:
>Hi, 
>
>I need to control RC/Model-Aircraft type pwm servos from
>a computers parallel port. Specifically what I am looking for
>is a circuit to use an 8-bit TTL I/O port to control a few of these 
>servos for a robotic gripper.

      Electrically, R/C servos are really easy to drive.  There are
three wires, usually red, black, and some other color.  Black is
ground, red is power (+5 works fine) and the other color is the
control signal, which is a 5v pulse-width modulated signal.  Any
TTL output will usually work (you may need a pull-up resistor),
and even CMOS outputs will work; I've controlled servos directly
from the outputs of a MC68HC11 CMOS microcontroller.

      The waveform is a square wave of varying duty cycle.  The  
period should be 22ms, and the ON time is varied from 1 to 2 ms
to control the servo.  Note that the ON time is much shorter than
the full cycle; this is for compatability with the way multiple
servo control signals are sent over the R/C link.

      There's a full servomotor control system inside those little
things, with a position-sensing potentiometer, a motor, and appropriate
control electronics.  A wide range of servo sizes and speeds is
available; check your local hobby shop.

					John Nagle