Recently I hacked some servos for fun. While I had the servos open and had removed all the electronics, it occurred to me that there was a lot of space in there now. I had seen some previous attempts by some on this site to add optical encoders inside gear motors. However, with all the room available inside the servo, I thought a rotary encoder might fit.
Videos:
- Testing the gear motor after adding the encoder
- Testinge the encoder with a simple circuit
Some searching found me these rotary encoders from allelectronics.com for only 75 cents each! The size looked like it would fit. I ordered four of them, and they arrived today.
First, opened up my hacked servo, and removed all the gears. This is a GWS S03N STD servo.
You can see the unmodified rotary encoder next to the servo parts. So innocent and unaware of what is about to happen.
In the picture below, you can see the servo bearing in the upper part of the case. The 6mm encoder shaft fits in there perfectly.
Unfortunately, the plastic hole in the center part of the servo case is only about 4mm. I had to drill it out to fit the shaft. Use of a drill press and very careful positioning is highly recommended.
Now the encoder shaft fit the middle of the servo body. However, when I tried to reassemble the gears, I discovered that the middle gear rubbed up against the encoder shaft. I needed 1 or 2 more mm. If you look carefully at the encoder shaft in the picture above, you can see that there is a portion of the shaft that I had to grind away with a dremel tool. I needed to leave some of the 6mm diameter above and below this grinding, because this is where the shaft rides in the enlarged 6mm hole in the plastic body of the servo.
Next I had to cut down the length of the encoder shaft. It has to end up just about flush with the metal bearing when assembled.
In the picture below you can see the encoder in the center servo body piece with the bearing installed.
Next came what might have been the biggest challenge of the whole project. In the picture below, you can see the slotted top of the encoder shaft, and also the slot inside the last driven gear of the servo.
The slot inside the gear is wider, but shorter than the slot in the encoder shaft. I needed a piece of metal to mate these two parts together so the encoder would turn with the gear.
After some thinking, I decided to try to fabricate the part I needed using a left over piece of metal from when I cut down the encoder shaft.
Below is the result.
This took a lot of careful work with the Dremel. Grind a little and test fit. Grind and test fit. It is easier to take away material than it is to put it back. I also widened the slot in the shaft of the encoder.
Below you can see the new piece installed in the encoder shaft, with the bearing around the encoder shaft. The little white plastic bit sitting on the servo body gets placed over the new piece.
Next, the final gear in the servo gear train has to fit on top. There are little plastic tabs inside the gear that match the two indents in the white plastic sleeve that sits on top of the encoder shaft.
In the picture below, you can see the encoder in place along with the servo motor with blue wires attached.
That basically completes the mechanical build. Next, it was time to solder the wires.
The center pin of the encoder is ground, wired in green. The left (yellow) and right (orange) pins are Channel A and Channel B. It doesn't matter too much which is which. The blue wires are for the motor.
I hot glued the encoder firmly in place, since otherwise it will try to turn inside the servo case. I also used some hot glue to serve as a strain relief for all the wires.
Below is the finished product, all ready for testing.
The video shows my first test, which was just to determine if the servo motor and gears still turned OK after all of my hacking and bending. I don't want to give away the ending, but it seemed to work OK.
Next test will be to try out the encoder itself. That will be for another day, and I will update this post then.
https://www.youtube.com/watch?v=jhI2o9lsvbY