Make your own free website on Tripod.com

Hacking a Servo to  add an Optical Encoder

This page is an extract from a paper published by Richard Vannoy of the San Diego Robotics Society which covered the servo hack described elsewhere on this site and also the modifications to install an optical encoder on the servo.  To see his original paper, go to  www.trainprogrammers.com.

This extract covers just the modification to install the encoders.

Parts required for the encoder mod:

2 Cirrus CS-60 Servos, previously modified for continuous rotation.

2 Omron Ultra-Compact Reflective Sensor, EE-SY124; Digikey Part Number OR520-ND

Super glue

Very small Phillips screwdriver

Hot glue gun

Soldering iron with low wattage setting

Thin solder

INSTALLATION OF ENCODER

Observe the gear train on the lower (main) housing. The gear which is located at the bottom of the opposite end of the gear case from the output shaft has a flat shoulder on it about 0.2 inches wide. This is where the encoder will be installed. Reflective segments will be placed on the flat shoulder, and a detector will be attached to the inside surface of the housing at the side of the upper housing immediately adjacent to the shoulder. You should decide which side of the housing you want the encoder to be installed. As its pins and wiring protrude from the housing, the resulting bump prevents the servo from being mounted flat on that side. If you intend to mount two such servos on their sides to drive wheels on opposite sides of your robot, you probably want to put the encoder on one side of one servo and the opposite side of the other servo. This way, they can both lie flat while the drive shafts are both pointing either out or in.

12. Remove the gears from the lower half of the case (remembering where they go. They only work one way, but why have to figure that out again.)

13. Take the gear with the flat shoulder and clean it to remove all traces of lubricant from the shoulder area so that glue will stick to this area. We used warm soapy water and a toothbrush.

14. Cut a piece of aluminum foil, as wide as the shoulder and a couple inches long.

15. Use super glue to attach the tip of the foil to the shoulder in such a way that can easily and evenly pull the foil the rest of the way around the circular shoulder during the next step.

16. After waiting for the first spot of glue to dry, brush more super glue around the rest of the shoulder and pull the foil smoothly around and hold in place until the glue sets. Let it dry well.

image23.gif (213476 bytes)

17. Trim the extra length of foil, and any excess foil that may extend above the shoulder. Be careful not to tear any of the foil on the shoulder.

image24.gif (337512 bytes)

18. Reassemble the gears and reinstall the top housing (without putting the four screws in). Lay the servo on its side with the side on which the encoder is to be installed pointing up. Lay the detector chip on the side of the servo such that it is centered on the axis of the shouldered gear and is located between the gears above and below the shoulder.

19. Use your own favorite method to put marks on the servo housing where the four leads of the detector should pass through the housing. We used a piece of paper, and put four small dots at the correct spacing at the bottom of the reflector. Then we carefully cut out the center of the four dots so we could place the paper on the case side and mark the four spots.

20. Drill .040 inch holes (#60 drill) for each of the leads.

image25.gif (190508 bytes)

21. Insert the detector chip into the four holes from the inside of the housing. Bend pins a little on the outside to hold the chip in place. Note: In order to remember which pin is which on the chip after the housing is closed, we chose to always mount the chip with the bevelled corner facing toward the output gear. This will work on either side of the servo and facilitate wiring later. If you mess up or forget which way they are installed, no problem. One side is a phototransistor and the other an LED (diode) so reading and reversing your ohmmeter on all combinations will yield a low-one-way and high-the-other-way reading. When you have the positive (RED) meter lead on a pin where you got the low reading, the positive (RED) lead is now on the LED anode, and the other lead the LED cathode. From the spec sheet that comes with the sensor, the orientation of the phototransistor can be properly determined.

22. Reassemble the gears and upper and lower housings (without screws) and see if the chip is properly centered on the shoulder. It should be close to the centerline of the gear and not touching either of the two gears above and below it.

23. If it looks OK, apply a little glue down the holes from the outside to hold the chip in place.

Next, the foil on the shouldered gear must be modified to provide dark and reflective segments for the photocell to detect.

24. We divided the shoulder into 8 segments, 4 dark, 4 reflective. One method of doing this is to stretch a piece of paper around the shoulder, marking the length of the circumference on the paper. Then taking the paper, flattening it out, measuring the length of the circumference, dividing that by 8 and placing marks on the paper showing the divisions. The paper can then be rewrapped around the shoulder and the marks transferred to the shoulder.

25. You have several choices as to how to do the division. You can just cut out alternating segments of foil; leaving 4 foil segments alternating with 4 plastic segments. Or you can paint black paint over the foil for four alternating segments. Or, you can cut the foil off as before, and then paint the plastic segments black. We installed the foil, then painted alternate 45 degree segments flat black.

26. Reassemble the housing, install the mounting screws and the mechanical changes are complete.

The photo below shows the completed, painted 45 degree segments on the gear. Focus on the upper, left portion of the servo photo. You should see four vertical bands of color in the order black, silver, white, black. The white is actually a reflection from the camera flash in the silver section. The silver and white areas together form one of the four 45 degree silver segments. The black bands on the left and right are part of the 45 degree black painted segments on the flat side of the gear.

image26.gif (180358 bytes)

 

PREPARING THE ENCODER WIRING

Once the servo is reassembled, it is time to prepare the encoder sensor wiring.

27. Soldering the sensor pins are the most delicate part of this task. The pins are very thin, and they protrude very little from the case, so you have very little to work with. It is best if you use a low wattage soldering iron, or if yours has several settings, to go to the lowest heat setting, around 15-20 watts. Normal solder is usually much too thick, so get some of the thinner solder that usually comes in little plastic tube dispensers. Solder the four pins to four different colored wires. 24 to 30 gauge wire is best.

28. Once the wires are soldered, gently run the four wires down the side of the case in the direction of the main servo wire ribbon cable. We ran the wires in an S shape (see photo) to provide a little strain relief in the event the wires get pulled. Use a small piece of tape (electricianís tape in the photo) to hold the wires in place temporarily.

image27.gif (130021 bytes)

29. Where the sensor wires meet the servo ribbon cable, use a small tie wrap to secure all wires in a bundle.

image28.gif (193441 bytes) image29.gif (194588 bytes)

30. Next, remove the temporary tape, and use your hot glue gun to lay a covering trail of hot glue over the sensor wires. This does several things. It helps to physically protect the sensor solder connections, and it keeps the sensor wires running along the servo laying flat and out of the way.

image30.gif (214548 bytes)

31. You are now ready to wire and test your new encoded servo!

Text by Alex Brown and Richard T. Vannoy II

Photos by Richard T. Vannoy II, richardv2@home.com

Members, San Diego Robotics Society