Tuesday, May 11, 2010

Arduino Reading Optical

Here is what is currently in production for the Arduino project. It is a draft and not finished work.

Reading Optical

Many optical devices are analog and not digital. The task is often to convert the response of the analog device into a more-or-less digital response. In the application of the analog devices in this segment, the analog pins on the Arduino chip will be used. Pins 0, 1 and 2 will be used. The analog pins on the Arduino read the input voltage from the device and convert into a numeric value.

The Arduino reference manual states, “This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit.”

Note that the voltages are still between 0 and 5 volts. Be careful not to fry your Arduino.

The numeric values from the analog pins may then be tested and branched using ranges of values and a case statement; an “if” structure will also work. Synthesizing digital action from an analog device merely means that the voltage has crossed a certain threshold; the number returned from the pin has passed a certain value and a test becomes true of false accordingly.

Goal

Instruct the student on input sensors- light (including optical encoder), switches and potentiometer. Optical encoders and switches are the “more binary” devices in the group; other items are “more analog”

Prerequisites

No prerequisites beyond the basic Breadboard Arduino class. These programs cover new material for this class and do not build on previous material.

Method

Cover analog versus digital input. Reiterate voltage capacities of the Arduino (0-5 volts). More information is available through the serial output than with LEDs in this segment.

Notes

There are multiple circuits on this board. Neither takes up much breadboard space or pins on the Arduino. If the infrared rangefinder is the Sharp brand, then a connector will most likely need to be built. In this case, a three pin, 0.10 inch pitch header pin was soldered to the end of the special pigtail for the sensing unit. After soldering, insulation and stability were needed, so a blob of hot-melt glue was added to the header pin.

The Parallax PIR unit, without a pigtail will only fit on the corner of the board due to I/O pin placement and jumper pin placement. A couple of ling wires are needed to connect to the Arduino. Other components are fairly straightforward.

The programs have some serial output to be displayed on the computer monitor. Power indicators may be left off.

The Class

Optical sensors are sensitive to light. Infrared (IR) has been grouped into this segment as it is looked at as both heat and light. It is light that cannot be seen with the naked eye, but certain electronic devices are sensitive to it. The remote control for your television is an IR device. For some reason, cameras on cell phones are sensitive to IR light. If you aim your TV remote at your cell phone camera, you will be able to see the light produced by the remote. There is more going on than just an IR flashlight, but at least you can verify that the batteries are not dead.

In this class, there are three devices- a simple photo resistor that passes power as a function of the amount of light striking it. This particular device is translucent and as such, is also sensitive to some of the light striking the back of the device. As more light strikes the surface, the resistance lowers. When the resistance lowers, more voltage appears on the Arduino analog pin and the Arduino returns a higher numerical value.

The infrared rangefinder uses reflected infrared light to determine range up to about 50 inches. Since it is using light, it is also susceptible to interference- things that would also get in the way of visible light. It is also sensitive to the color of the reflective surface. If sensing people, different colored clothing will yield different responses. It is not an exact science.

The Passive Infrared (PIR) device works the same way as the motion detector lights that light your driveway when someone walks by. It has a series of Fresnel lenses over an IR-sensitive device. When the device senses IR moving from one lens to another, a signal is produced. This device is also sensitive to distance. This particular PIR is a Parallax device designed for hobbyists.