Friday, March 26, 2010

light sensers




light sensers

The most commonly used light sensor in our robots is a light dependent resistor which,
as its name implies is a resistive sensor. The resistance of a typical LDR, such as the
ORP12, ranges from 1 MΩ or more in darkness to about 80 Ω in bright sunlight. Indoors,
with indirect daylight or artificial illumination, their resistance is a few kilohms.
LDRs respond to light of most colours, with a peak response in the yellow. Of all the light
sensors, the LDRs are the slowest and their response times are several tens or hundreds of
milliseconds. Although this is seems quite fast to humans, the PIC works much faster
than this. Programs may need a short delay to allow time for the LDR to catch up with it.
The potential divider (see drawing opposite) can have a fixed resistor, a variable resistor,
or both. The variable resistor allows for setting the output voltage for any given light
level. The total resistance should be in the same range as the average resistance of the
LDR under the expected operating conditions.

Another popular light sensor is the photodiode. The action of these depends on the fact
that the leakage current when the diode is reverse biased varies with light intensity. The
circuit is on p. 73. The leakage current is very small. In darkness it is only a few
nanoamps and rises to about 1 mA in bright light. The resistor has a resistance of a few
hundred thousand ohms, so the current generates a reasonable voltage across it. Often a
330 kΩ resistor provides suitable output voltage. The output must be connected to a high
impedance input so that the voltage is not pulled down. The PIC is a CMOS device so has
high-impedance inputs.
A photodiode is generally more responsive to light from the red end of the spectrum.
Some are specially sensitive to infrared. These are used with infrared LEDs for reading
optical encoders (p. 84). They are employed as sensors in line-following robots because
they are less subject to interference from external sources of visible light.
The response time of a photodiode is fast, generally a few hundred nanoseconds, so there
are no problems with this.
A phototransistor (overleaf) has properties similar to those of a photodiode, though their
response time is longer. They are connected in the same way as an npn transistor in a
common-emitter amplifier. Phototransistors often lack a base terminal and, if present, the
base is usually left unconnected.

BUILDING THE POWER SUPPLY



For safety reasons, you must enclose the power supply in a plastic or
metal chassis (plastic is better because there is less chance of a short circuit). Use a perforated
board to secure the components, and solder them together using 18- or 16-gauge
insulated wire. Alternatively, you can make your own circuit board using a home etching
kit. Before constructing the board, collect all the parts and design the board to fit the specific
parts you have. There is little size standardization when it comes to power supply
components and large value electrolytic capacitors, so presizing is a must.
HOW THE CIRCUIT WORKS
Here’s how the circuit works. The incoming AC is routed to the AC terminals of the transformer.
The “hot” side of the AC is connected through a 2-amp slow-blow fuse and a single-
pole, single-throw (SPST) toggle switch. With the switch in the off (open) position, the
transformer receives no power so the supply is off.
The 117 VAC is stepped down to the secondary voltage of the transformer (12 to 18
volts, depending on the exact voltage of the transformer you use). The transformer specified
here is rated at 2 amps, which is sufficient for the task at hand. Remember that the
power supply is limited to delivering the capacity of the transformer (and later the voltage
regulator), no more. A bridge rectifier, BR1 (shown schematically in the box in Fig. 15.18),
converts the AC to DC. You can also construct the rectifier using discrete diodes, and connect
them as shown within the dotted box.
When using the bridge rectifier, be sure to connect the leads to the proper terminals.
The two terminals marked with a “~” connect to the transformer. The “ ” and “ ” terminals
are the output and must connect as shown in the schematic in Fig. 15.18. Use a
5-volt, 1-amp regulator—a 7805—to maintain the voltage output at a steady
5 volts.