An optical encoder has some advantages over a mechanical encoder. One advantage is no bouncy or noisy electrical contacts that create false or extra pulses. Also, an optical encoder can operate at a higher rotation rate than a mechanical encoder.
I created a simple optical encoder from commonly available materials.
ENCODER HOUSING: I made the encoder housing from a 3/4 inch PVC pipe cap with a short length of 3/4 inch PVC pipe glued inside. The axle that supports the encoder disk was made from an inexpensive motor that I removed the magnets and the motor brushes from in order to allow the motor armature to spin freely.
The motor is then installed inside the PVC pipe. Since the fit was a little loose, I wrapped a couple of turns of tape around the body of the motor to make a tight fit. I also had to drill a small hole in the bottom end of the pipe cap to provide clearance for the rear motor bearing.
I sanded a flat spot on the outside of the pipe cap and drilled a small hole to accept a 4-40 flat head screw pointing out from the inside of the cap. This provides a threaded stud where the support for the encoder PCB is attached. The hole must be carefully located so that the opening in the photo-interrupters are at the correct level in relation to the encoder disk.
Finally I installed, with a press fit, a 1.5 inch diameter by 0.375 inch thick nylon disk to the motor shaft to which the encoder disk will be attached.
ENCODER CIRCUIT BOARD: I was able to fit the electronic components on a section of fiberglass circuit board that measured 1.375 inches by 1.625 inches. The photo-interrupters were located side by side and near the top edge of the PCB. The PCB also had a small hole drilled in it to allow mounting to the encoder support.
I installed two 0.1 inch spaced two position terminal blocks to facilitate the wire connections.
The encoder circuit uses two off-board 74HC14 Schmitt trigger inverters to clean up the pulses from the photo-interrupters and to drive two hi-efficiency blue indicator LEDs, one from each channel. This is not necessary for all applications.
The support for the encoder PCB was made from an approximately 1.25 inch long section of 0.375 diameter round nylon rod which was drilled and tapped at each end with a 4-40 thread.
ENCODER DISK: I designed the encoder disk by making a pattern using the spread sheet program Excel and then creating a pie chart with alternating black and white segments. The encoder pattern can be made with a variety of different diameters and with a different number of segments. It is important that the total number of segments used divide evenly into 360.
The artwork was printed out and then glued to a piece of thin cardboard with rubber cement. I used a compass to define the diameter of the disk and then cut it out with scissors. The notches at the edge of the disk were made with a 0.281 inch punch with the center of the hole located at the junction of the black and white segments.
This provides a total of 18 evenly spaced openings. The notches could also be cut out with a sharp x-acto knife instead of using a punch and cutting out the edge of either the white or black segment – but not both!
The finished disk was then glued to the nylon disk attached to the motor shaft.
The disk shown in the photos below had a diameter of 3.375 inches with a total of 36 segments – 18 black and 18 white.
More information on the encoder disk here: http://saroselectronics.com/create-encoder-pattern-using-excel/
PVC CAP WITH MOTOR AND MOUNTING STUD INSTALLED
ENCODER CIRCUIT BOARD
COMPLETED OPTICAL ENCODER WITHOUT DISK
COMPLETED OPTICAL ENCODER WITH DISK
CLOCKWISE PULSE OUTPUT FROM ENCODERS
COUNTER-CLOCKWISE PULSE OUTPUT FROM ENCODERS