Quadrature Encoder in a Servo

This work is based on Giuseppe Marullo's here.

The technique is to assemble two copies of this Hamamatsu P5587 circuit on some protoboard. Unscrew the servo and under the gears drill two holes as follows so that the P5587 can be placed underneath facing through the holes as follows:

Lower part of servo without encoder wheel.

In order to get the encoder board into place I head to ream out much of the plastic inside the servo using a Dremel and I also had to cut the protoboard right down so that the P5587s were snug right next to the motor. It took some experimentation to angle the board correctly so don't glue anything into place until it works.

(Note that in my incompetence I drilled an extra hole in the wrong place!)

Next use a black marker pen to blacken half of the gear wheel that lies over the P5587s:

Lower servo with encoder wheel.

Upper part of servo with wheel attached.

I removed the servo potentiometer along with the part of the PCB holding the usual servo electronics. The red and black servo wires are connected directly to the motor so I can use PWM to control it.


I used lots of hot glue to hold the encoder protoboard in place at the correct angle. The protoboard has its own 5V and GND connections as well as the two outputs from the P5587s. You can just about see the 6.8KΩ and 470Ω resistors from the P5587 support circuit as well as part of one of the copper tracks.

Total cost (in 2004): Less than $15. Not bad for a small gearmotor with encoder.


Feel free to email me (Dan Piponi) at stirfry (at) sigfpe.com.
Back to Robotics. Back to Home.