In this section we will hacking a servo by adding an extra wire, so that we can read the servo position with the Arduino.
Servos are normally used as output devices, you write some code which sends pulses to the servos, and the servo determines where to move based on the pulse you sent. This project is kind of unique in that we want to actually use the servos as input devices as well, that is we want to be able to read the current position of the servo. I’ve never seen a servo that was able to do this, at least not the hobbyist kind of servos. To get around this were going to have to take our servos apart and hack them. This really isn’t very hard and even if you’re not using the exact same servos, you should be able to get this to work, you will have to do a very small amount of soldering. What we need to do is add a fourth wire to the servo that will connect to an internal potentiometer. The voltage on this wire can be used to determine the servo’s position.
I’m going to take the servo completely apart to show you what the it looks like, but you don’t have to take it completely apart to add the extra wire. You can just take the bottom plate off, and I recommend you do this because it’s while only takes 4 screws to reassemble, getting the the little gears in the top to align can be little tricky. I suggest you read through this until you get to the last picture where we actually solder a new wire on.
first I removed the four screws on the bottom and took the bottom plate off.
After these four screws are removed the entire servo assembly will come out of the housing. It can be a little bit tricky to get it out. I had to jimmy it a little bit with a screwdriver first. ( again you don’t actually need to disassemble it like this).
Here’s what the innards of the servo look like. You can see the stepper motor on the left, and thing on the right is a potentiometer, you can see that it has three pins.
To verify this would work, I just use a multimeter set to measure resistance, then using some many grabbers I connected one to the middle pin (a.k.a wiper ) and wire to one of the other pins.
Here I turned the potentiometer all the way to one direction, and you can see the measurement is .123K or 120 ohms.
Next I turned the potentiometer all the way the other direction, and you can see we have 2.02 K.
We need to add a fourth wire to the middle pin of the potentiometer. I grabbed a scrap of wire, you want it to be the same gauge the existing wires on the servo, if it’s too large you won’t be able to get the case reassembled. All I did was strip a little bit off of the end of the wire, got my soldering iron warmed up, then held the wire over the circuit board connection for the middle pin of the potentiometer. I just touched the soldering iron to press the bare end of the wire down on top the solder joint on the circuit board, as soon as the solder melted I lifted iron away, the solder solidified and the connection was made. The black thing in the picture is a little piece of electrical tape, just to make sure the solder didn’t stick to anything else.
Finally we need to do this for the other servo and reassemble them.
hacking a servo!
The last thing we need to do is verify that it works. Hook power up to the servo and measure the voltage on her new wire, we should see the voltage change as the servo turns. Here I am using the Arduino for a power supply, only the PWR and GND connections are being used.
With the Servo hooked up to 5V I get a voltage that ranges from .29 volts to 2.06 volts. This will work nicely since the inputs on the Arduino Due are 0 to 3.3 v.