556 Based Servo Exerciser
Servos are very useful parts in any robot system (See How A Servo Works), especially when hacked to provide full rotation, instead of a limited +- 180 degrees (See Hacking a Servo). This circuit is made to "exercise" a servo. Or in other words, test a servo. It works for both hacked and standard servos since its rotation (on a standard servo) will be directly proportional to the position of the pot used to set the circuit's duty cycle.
Many controller circuits are available on the net, from single channel to 16 channel microcontroller based controllers. While a controller is very nice, is seldom has the sole intention of testing a servo. This is exactly what I wanted to have. There is also a few circuits available to test servo with, based on single 555's and PIC's, but I wanted precise timing without the frequency varying at all. Yet it had to be cheap and easy to build. This is my solution.
The concept behind this exerciser is that it uses two multivibrators to generate the output Pulse Width Modulated signal to drive the servo with. The first multivibrator 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 my circuit overcomes the varying frequency of most single 555 circuits.
The first timer should determine the frequency, as stated above. But, since the second timer will be trigger by the first, the output should generally be high, and trigger a short low pulse. The trigger pulse should be shorter than minimum pulse width generated by the second timer, which will vary from 1ms to 2ms.
The second timer acts as a monostable multivibrator. This means that it is required to be triggered before it generates 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:
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 50Hz to 60Hz, from where a duty cycle will be added by the right hand timer, or pulse width generator. Very important! We want the time that the output is low to be shorter than the minimum pulse width of the pulse width generator. C1 charges through R2, R6 (used for setting the frequency) and R1. During this time, the output is high. The formula for the charging time is
t = 0.693(Ra + Rb)C
Then C1 discharges through R1, and the output is low. The formula for the discharge is
t = 0.693(Rb)C
Since the discharge goes through R1 only, it can be fixed, and will determine the output low time. Using the formula above and the given component values, the discharge time that the output will be low will always be:
t = 0.693(Rb)C
t = 0.693 x 3900 x 0.00000022
t = 0.59ms
The total time is t = 0.693(Ra + 2Rb)C and the frequency is given by
F = 1.44 / ((Ra + 2Rb)C)
Ra is the value of R2 and R6, and Rb is the value of R1.
So, when the pot is set to minimum (0 ohms), the frequency will be
F = 1.44 / ((Ra + 2Rb)C
F= 1.44 / ((100000 + 7800)0.00000022)
F = 60.7 Hz
When R2 is set to maximum, 50k, then
F = 1.44 / ((150000 + 7800)0.00000022)
F = 41.5 Hz
And enables us to adjust the frequency anywhere from 41.5Hz to 60.7Hz. You can adjust the frequency as needed, but I prefer keeping it on 50Hz. JP3 has been added to the circuit as a test point where a frequency meter can be connected to calibrate the frequency. Most modern multimeters can measure frequency, and these will suffice, since we are not trying to build an atomic clock.
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 R4, R3 and C3. R4 is a pot, and therefore the pulse time can be adjusted as necessary. This is where an external pot is connected to determine the pulse width, which will determine the rotation and extend of rotation on the servo. The formula used is as follow:
t = 1.1RaC
Ra is the total of R4 and R3. So, the minimum pulse time when R4 is set to 0, is:
t = 1.1 x 8200 x 0.0000001
t = 0.902 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.65ms pulses one after the other, but at a steady +- 50Hz interval.
When R4 is set to maximum, the time is
t = 1.1 x 18200x 0.0000001
t = 2.002 ms
The pulse time when the pot is centred, is 1.452ms, which is very close to the required 1.5 ms, and practically close enough to eliminate the error. I'm anyway still waiting to see the person who can set a pot dead centre without measuring the output.
JP4 has been added as a test point for the final signal. This time, it should however be tested with an oscilloscope, which will be able to not only show the frequency, but the pulse width as well. On general R/C equipment the pulse width only varies from 1ms to 2ms. The duty cycle of the timing is determined by the following formula:
Duty Cycle = Pulse Width / Interval.
So at a frequency of 50Hz, the pulse interval is 20ms. So the Duty Cycle varies from 5% to 10%, with the centre being 7.5%.
The circuit board and component layout for the circuit is given below. The board is a bitmap with a 600dpi resolution, which should be adequate to print it directly onto a transparency to create the board. The size from the edge to edge should be 43.8mm x 39.4mm (1.725" x 1.55").
When things go seriously wrong... I built the original circuit directly onto a manufactured PC Board, done by a local board house. It didn't work. Instead of generating a carrier frequency in the range of 40Hz to 60Hz, I got 50000 Hz signal (50kHz). I was confused. I initially thought that my calculations were off, and that I accidentally swapped a nano and pico somewhere. Double-checked all calculations, all components and the whole circuit. Nothing wrong! Eventually, after 3 hours of headaches, it turned out that there was a bug in my circuit. Where pin 6 and pin 2 had to be connected on the first stage of the 556, I accidentally connected pin 6 to pin 1, causing erratic and incorrect behaviour on the timer. Once corrected, the circuit worked like a dream.
A word of warning though... The traces on the board are rather thin, and not really made to handle large amounts of current. A smallish servo can easily draw 200mA, and I would recommend either enlarging the traces that deliver the current to the servo connector, solder filling or tinning the tracks, or to connect the servo's power directly to the input power feed. On my final boxed version, I took the power for the servo directly from the power input socket. Care should be taken to avoid incorrect polarity if used like this and the input voltage should not exceed the specified voltage of the servo. I normally run the circuit at about 5 volts, but most servos (correct me if I'm wrong) will easily go up to 7.2 volts. An added power input diode has been added to the circuit board to protect it against reverse polarity.
For the boxed version I built, I decided to use 3 wires with croc clip to connect to the servo, since I had trouble finding the proper IDC header that could be mounted on the box. Almost always, I cut the connection plug from the servo's wires, so the croc clips were ideal. I also added a power LED with a current limiting resistor for it and a 10uF cap to reduce power line noise and ripple. The wiring looks very dirty, but fortunately when the box is closed, it is all hidden!
Here is three photo's of the one I built:
Insides of the box. Luckily, my *very* cheap digital camera can't take pictures any closer without the focus being any worse. Most of the wiring has been done directly onto the power input socket. The board was fixed to the base of the box using a glue gun.
Tada! Everything inside the box. The power input socket is at the top, flush mount with the box. Power LED, output wires and clips and the pot showing. The pot still needs a knob, which will be added some day.
The Servo Exerciser in action. The multimeter is showing the calibrated 50Hz output signal. The servo shown here is a SuperTec servo, with an aeroplane wheel attached, and will be used in my first robot to be completed within the next 3 months. I had nowhere else to work but in the kitchen, hence the sugar & coffee containers in the back.
Be sure to check the datasheet of the LM555 and LM556, which provides more details on the modes of operation of the 555. This circuit follows the rules of R/C more precisely than other circuits made of single 555's, by ensuring that the output frequency stays the same at all times, and doesn't vary when the pulse width varies. It is a bit more complex, and uses a lot more components than the single 555 controller circuit. It is however less complicated and expensive than microcontroller based circuits. The reason I built this circuit was to have an exerciser to test my servos with, before I use them in robots. And it works.