2009-01-13

Turn a servo into 1-wire-control bi-directional motor



It is often a pain building H-bridges or getting a motor shield just because you want to control a few motors. This is where servos come in: they are cheap(ish), have motor and gearbox, and they are controlled ysing only a single wire.



The only problem is of course, servos aren't designed for continuous motion. Servos are designed to respond to PWM pulses which encode the desired position for the servo to be in, not a desired speed or direction. So some modification is required.



Now there are many articles on the intertubes on how to do this, but they mostly concern themselves with making the servo into little more than a normal motor with a gearbox - you still need a H-bridge to control the direction. This modification is a little different: it leaves you with a servo that behaves like a bi-directional motor where the direction is controlled by a single wire.



Due to the variety of servos out there, I will present only the general idea, which applies to servos which use a potentiometer to determine position.



Firstly, a quick explanation of how these servos work. The principle behind these servos is that the potentiometer is connected to the output gear such that the voltage of the sweeper (connected to the middle pin usually) depends on the angular position of the output gear. The onboard controller converts the input PWM signal into a target voltage, then it powers the motor so it turns the output gear until the voltage of the sweeper matches the target voltage. This is kind of control action is relatively easy to achieve using an operational amplifier.



The basis of the modification is essentially this: if we fix the sweeper voltage, then any input asking the servo to move away from the sweeper voltage will result in the onboard controller continuously attempt to match sweeper voltage to target voltage. By making the target voltage higher or lower than the sweeper voltage, we get directional control.



To fix the sweeper voltage, the potentiometer will need to be disconnected and replaced with a voltage divider. I assume that when the output gear is in centre position, sweeper voltage is half the supplied power because the potentiometer will be in its centre position. Since I wanted 0 degree rotation to map to stop, I fixed the sweeper voltage at this value by using 2x1.5K resistors in series. This is all you need to do electronically. There should be enough room to fit in 2 extra resistors, even in small 8g servos (what I had).



The last thing to do is to remove any physical obstructions which prevent the output gear from completing a full revolution.



Once the electronic and physical modifications are complete, you should have a servo which can turn in either direction continuously and controlled via single wire. Two of these would be perfect for say powering a small rover...




Cheers,

Steve