Intro: 556 Servo Driver
Servos (also RC servos) are small, cheap, mass-produced servomotors used for radio control and small-scale robotics. The are designed to be easily controlled: the position of the internal potentiometer is continually compared to the commanded position from the control device (i.e., the radio control). Any difference gives rise to an error signal in the appropriate direction, which drives the electric motor either forwards or backwards, and moving the shaft to the commanded position. When the servo reaches this position, the error signal reduces and then becomes zero, at which point the servo stops moving.
Radio control servos are connected through a standard three-wire connection: two wires for a DC power supply and one for control, carrying a pulse-width modulation (PWM) signal. The standard voltage is 4.8 V DC, however 6 V and 12 V is also used on a few servos. The control signal is a digital PWM signal with a 50 Hz frame rate. Within each 20 ms timeframe, an active-high digital pulse controls the position. The pulse nominally ranges from 1.0 ms to 2.0 ms with 1.5 ms always being center of range.
You don’t need a microcontroller or computer to control a servo. You can use the venerable 555 timer IC to provide the required pulses to a servo.
Many microcontroller based circuits are available on the net. There is also a few circuits available to test servo with based on single 555's, but I wanted precise timing without the frequency varying at all. Yet it had to be cheap and easy to build.
Step 1: PWM What?
As its name suggests, pulse width modulation speed control works by driving the motor with a series of “ON-OFF” pulses and varying the duty cycle, the fraction of time that the output voltage is “ON” compared to when it is “OFF”, of the pulses while keeping the frequency constant.
The concept behind this circuit is that it uses two timers to generate the output PWM (Pulse Width Modulation) signal to drive the servo with.
The first timer operates as an astable multivibrator and it generates the "carrier frequency", or the frequency of the pulses. Sounds confusing? Well, while the pulse width of the output can vary, we want the time from the start of the first pulse to the start of the second pulse to be the same. This is the frequency of the pulse occurrences. And this is where this circuit overcomes the varying frequency of most single 555 circuits.
The second timer acts as a monostable multivibrator. This means that it is required to be triggered to generate a pulse of its own. As said above, the first timer will trigger the second at a fixed, user definable interval. The second timer however, has an external pot that is used to set the output pulse width, or in effect determine the duty cycle and in turn the rotation of the servo. Let's get to the schematic...
Step 2: A Little Bit of Math... Frequency
The circuit uses a LM556 or NE556, which can be substituted with two 555's. I just decided to use the 556 because it is a dual 555 in one package. The left timer circuit, or frequency generator, is set up as an astable multivibrator. The idea is to get it to produce a carrier frequency of about 50Hz, from where a duty cycle will be added by the right hand timer, or pulse width generator.
C1 charges through R1, R4 (used for setting the frequency) and R2. During this time, the output is high. Then C1 discharges through R1, and the output is low.
F = 1.44 / ( (R2+R4 + 2*R1) * C1)
F= 64Hz for R1 = 0
F= 33Hz for R1 = 47k
On the simplified simulated circuit however R1 is omitted, and the frequency is a fixed 64 Hz.
Very important! We want the time that the output is low to be shorter than the minimum pulse width of the pulse width generator.
Step 3: A Little Bit of Math... Pulse
The pulse width generator, or right hand timer, is set up in monostable mode. This means that every time the timer is triggered, it gives an output pulse. The pulse time is determined by R3, R5, R6 and C3 . An external potentiometer (100k LIN POT) is connected to determine the pulse width, which will determine the rotation and extend of rotation on the servo. R5 and R6 are used to finely tune the outermost positions for the servo, avoiding it to chatter. The formula used is as follow:
t = 1.1 * (R3 + R5 + ( R6 * POT)/(R6 + POT)) * C4
So, the minimum pulse time when all the variable resistors are set to zero is:
t = 1.1 * R3 * C4
t = 0.36 ms
Note that this minimum pulse width time is longer than the trigger pulse to ensure that the pulse width generator doesn't constantly generate 0.36ms pulses one after the other, but at a steady +- 64Hz frequency.
When the potentiometers are set to maximum, the time is
t = 1.1 * (R3 + R5 + ( R6 * POT)/(R6 + POT)) * C4
t = 13 ms
Duty Cycle = Pulse Width / Interval.
So at a frequency of 64Hz, the pulse interval is 15.6ms. So the Duty Cycle varies from 2% to 20%, with the centre being 10% (remember that 1.5ms pulse is center position).
For the sake of clarity potentiometers R5 and R6 have been removed from the simulation and replaced with a single resistor and a single potentiometer.
Step 4: Enough With the Math! Now Let's Play!
You can play with the simulation here: just click on the "Start simulation" button and click and hold the left mouse button on the potentiometer. Drag the mouse and move the potentiometer to control the servo.
You can note the pulse width changing on the upper oscilloscope, while the frequency of the pulse stays the same on the second oscilloscope.
Step 5: Last But Not Least... the Real Thing!
If you want to go further and build the circuit itself here you can find schematic, PCB layout (it's a single side PCB that you can easily fabricate at home), components layout, copper layout and parts list.
A little note about the trimmers:
- the blue trimmer sets the frequency of the signal
- the middle black trimmer sets the lower rotation limit
- the remaining black trimmer set the upper rotation limit
A quick note useful to calibrate the circuit for a particular servo:
- set the main potentiometer to zero
- adjust the middle black trimmer until the servo is steadily set at the lower limit without chattering
- now set the main potentiometer to maximum
- adjust the remaining black trimmer until the servo is steadily set at the higher limit without chattering
If you enjoyed this instructable please vote for me in the contest! :)
This is an entry in the
Electronics Tips & Tricks Challenge