Sensing optical tape
Reflectivity differences can be sensed using optoelectronic components. An Emitter and a Receiver are arranged so that more of the Emitter's light is seen by the Receiver when the target is white, than when it is black.
Emitters provide a cone of illumination, and receivers have a cone of sensitivity, sometimes called a receiving angle. They are available with narrow (e.g. 10 degrees) through wide (e.g. 130 degrees) full-width cones. You can aim the Receiver and the Emitter so that their cones overlap at the desired detection distance.
Infrared (IR) opto devices are popular, as are visible light (usually red.) Infrared has the advantage that Receivers are somewhat more sensitive in IR, and daylight and indoor illumination are low in IR thus avoiding that confounding factor. IR Receivers are often encapsulated in black or dark blue plastic that is transparent to IR, thus blocking ambient visible light. 900nm is a typical IR wavelentgh.
Visible light opto devices have the advantage that you can better see what you are doing, and they are pretty. 660nm is a typical red wavelength.
Infrared emitters are sometimes called IREDs. Visible light emitters are called LEDs.
Receivers may be phototransistors or photodiodes. Phototransistors have more gain: more current for a given amount of light. The have the disadvantage of being slow, typically 5uS rise time for phototransistors vs. 5nS for photodiodes. They also have more variability in gain, part-to-part, and more dependence of gain upon temperature.
Each LED or IRED has a maximum forward current, If(max), typically 30mA. It also has a forward voltage drop (Vf) like any diode, which depends weakly upon forward current. 0.6v is a typical forward voltage for a silicon diode. A typical AlGaAs IRED may have a forward voltage of 1.9v at 20mA forward current.
Some LEDs and IREDs are much brighter than others. There are many figures of brightness. Some are intensity per unit area in the brightest part of the cone of illumination, while others integrate the total light output over all angles. You have to be careful about this if you are comparing narrow-cone to wide-cone emitters.
To operate an LED or IRED you usually need a limiting resistor in series with it. Choose the limiting resistor so that when the supply voltage minus the emitter's forward voltage, is across the limiting resistor, it will pass the current you want, not to exceed If(max). For instance with a 5v supply, and anticipating a forward voltage across the IRED of 1.9v, we will have 3.1v across the limiting resistor. If the value of that resistor is 100 ohms, the limiting resistor (and the IRED) will have 31mA through them.
The longer lead is the anode. In the first circuit diagram it is anode top, cathode bottom.
Photodiodes will conduct like ordinary diodes in the forward direction, so we don't use them that way. The trick is, they conduct backwards when exposed to light: one electron sneaks through for each photon, more or less. So we use them biased in reverse as shown in the second diagram.
Refering to the second circuit, the photocurrent passes through the sensing resistor, here 1 megohm, so each 1uA of photocurrent results in an output voltage of 1v, up to 5v but no more. If you use a larger sensing resistor, you will get a greater sensitivity. 1M is a lot however: think about the input impedance of whatever you are going to test with or connect this to. Digital voltmeters (DVM) and oscilloscopes usually have an input impedance of 10M, so that's OK. What is the impedance of an input line on a PIC chip or Basic Stamp?
If you need to amplify your light signal, or compare it to an adjustable threshold, consider a photodiode amplifier or a comparator such as LM311.
The longer lead is the anode. In the second circuit it is cathode up, anode down.
Phototransistors will operate like ordinary transistors (here, an NPN transistor) but most do not give you access to the Base. You can see it but you can't touch it. Light falling on the Base acts like a current into the Base. The phototransistor conducts, from Collector to Emitter, a current which is the transistor gain (hfe) times the Base (photo)current. Anyway, it conducts.
Refering to the third circuit, the Collector-Emitter current passes through the sensing resistor, here 10Kohm, so each 0.1mA of current results in an output voltage of 1v, up to almost 5v but no more.
The light sensitivity of this phototransistor circuit is probably similar to the photodiode circuit, but its output impedance is 100x less.
The longer lead is the Emitter. In the third circuit it is Collector up, Emitter down.
Some favorite Emitters and Receivers
In visible light (red), I have used the SLI-580UT3F LED (clear package)at 30mA, which throws a bright and narrow cone of illumination (~15 degrees). The PDB-C134 (clear package) photodiode passed about 1.5uA photocurrent at a range of about 3cm with a white paper reflector. It is also narrow-cone (~30 degrees).
In infrared (IR), I have used the QED123 IRED (clear pink package) at 30mA, which throws a bright and narrow cone of illumination (~15 degrees). The LTR-4206E (IR transparent black package) phototransistor passed about 300uA at a range of about 3cm with a white paper reflector. It is also narrow-cone (~30 degrees).
The QRB1114 optoreflector is popular and is dicussed on the Optoreflector wiki page. It consists of an IRED and an IR phototransistor, exactly as dicsussed here, but together in one package, thus, conveniently pre-aimed. The Emitter and Receiver cones overlap best when a target is at a distance of 0.15 inches. Its sensitivity falls sharply beyond that distance. If you can make do with that distance (or somewhat more) it is very convenient. If you want to specify your own optical geometry, use discrete components.
Using a digital input line to tune up your sensing resistor value will be frustrating. Instead, monitor the voltage across your sensing resistor with a digital voltmeter (DVM) or oscilloscope, as you adjust your optical geometry and sensing resistor vale.
(add circuits for comparator/trimpot, schmidt trigger, and photodiode amplifier)