Optointerrupter
Overview
An infrared slotted optical switch is a device similar to the photo-reflector except that the emitter is pointed directly into the phototransistor. The slotted optical switch can be used to build shaft encoders. Shaft encoders can give the robot feedback on how far its wheels have turned or on synchronizing two wheels' velocity. A shaft encoder usually consists of a slotted optical switch and a striped wheel with a palette of radically alternating holes or slots on it. The palette of stripes will alternately reflect or not reflect light to the phototransistor, yielding a pulse-train output. The robot can then tell how far its wheels have rotated by counting the pulses.
Circuitry
An example circuit (that should work with the PC104 stack's digital input) for the QVB 11134 slotted optical switch is shown below. When nothing obstructs the infrared beam, the phototransistor conducts and holds the voltage low. When the beam is broken, the phototransistor no longer conducts, and the voltage goes high. Because the effect of the phototransistor is not very large, we use a large resistor (R2), and an opamp voltage follower as a buffer. Also note that we have a resistor (R1) to protect the IR LED in the switch.
File:Optointerruptor ex schematic.jpg
File:Optointerruptor ex photo.jpg
(Note: the mounting tabs on the QVB 11134 optical switch have been snipped off for clarity)
Connecting to the PC/104 Stack
The files below contain an example XPC Target program that will count the number of times the IR beam has been broken, and display them on the Seetron BPI-216 LCD display (on the COM1 serial port). Connect the output of the circuit above to channel 2 of the PC104 stack's digital input port. Depressing the Bit1 button (which sets channel 1 high) on the stack's break-out board will reset the counter to 0. Of course, you can edit the Simulink model to tweak the settings or route the data elsewhere if you do not wish to use the LCD.