Encoder Front Page
SRS Home | Front Page | Monthly Issue | Index
Search WWW Search seattlerobotics.org

Bill Harrison on IR detectors

[Editors note: Bill sent this email to our list server in the last couple of weeks. Bill has done a great job in pointing out some important information about using Infrared detection circuits. Its very much worth reading!]

From: bill harrison <bill@sinerobotics.com>
Date: Thursday, November 05, 1998 1:17 PM
Subject: Re: Sharp GP1U5 Based IR Sensors.

        I've run into many of the problems of the Sharp GP1U5 family of IR detectors.  They were originally designed as data receivers and as such are excellently designed. But they have been used successfully as object detector sensors.   In using them for object detect we have to keep a couple of things in mind:

        First, and I think you have this one covered (but others have not done this), is that you have to have a second modulation for the detector to work.  The detector sorta "re-zeroes" its self (probably via caps and resistors).  If it sees a steady state 40 kHz signal (assuming a 40 kHz module,  there are other frequencies available), it'll do fine for a short while and then start having a lot of "glitches".  If the signal has a second modulation (833 Hz works well) then the state is changed often enough to maintain a good signal.
        A sort of trick, is that if you do the software/hardare filtering technique of turning the IR LED on, check detector, turn the IR LED off, check the detector, and repeat, this does as well as a second modulation (it's actually a second modulation if you think about it).  Then you just check if you see enough "offs" with the IR LED off and enough "ons" with the IR LED on.   This is pretty, easy if you use a loop, and has worked pretty successfully in some of my robots.  I just go into a loop in which I get one "off" reading and one "on" reading.  I count good readings (if off, a good reading is off, if on, a good reading is on).  Then I allow it to have a few bad (as this will inevitably happen), of something like 5% of the total count ("good" count must be within 5% of the maximum count).  You can play with the allowable bad count for your situation (keep it
big if you prefer to see, and keep it small if you prefer to not see).

        The second problem that occurs is that it takes the Sharp detector some discrete time to stabilize a good output signal.  I seem to remember that it was something like 300 uSec.  (I haven't figured this out in a while as I just patch in the software that works now).
        So what you do is to change the state of the IR LED, go into a delay of 300 uSec (that's micro), then take a reading.  You would do the same every time you need a reading.
        You can play with the delay time, too short and the data gets unreliable due to not stabilizing fully, and too long you'll start seeing "glitches" (just as bad) (and your routine could start taking too long, Karl Lunt recommended using 80 cycles of readings).  Note that "too long" is *way* longer than 300 uSec.

        Another problem most face is that this type of sensor has a practical range limit of 2 to 6 inches (depending on a lot of things, though I have gotten one to operate at well over 20 feet),  so most see it as not too sensitive and try to boost up the IR LED power.  This is what I did when I started.   Actually the detector is *so* sensitive that it almost won't work as an object detector and boosting the IR power only complicates things.  (in fact Radio Shack now sells a non-Sharp module under their same part number that they used to sell the Sharp modules, but the new ones are so sensitive they are almost impossible to get to work).
        I've found that the low output old-fasioned IR LEDs running at only about 3 mAmp (that's mili) works pretty well.  Build a breadboard setup with a couple of 555 timers to run it (dual modulation) and just play with it (put a pot on the IR power).
        If the IR LED is too bright you'll run into problems of it bouncing off of everything and the Sharp detector has about a 135 degree field of view, as well as some sensitivity in pretty much all directions (problem with such high sensitivity level).  So you'll "see" something all the time.   I use those foil stickers that write-protect floppy disks to cover the holes and slits on the detector.  I also put some shrink tubing over the back of the IR LEDs.

        Another problem is that things that look opaque can actually be transparent to IR.  I was surprised to find that IR can pass through typical black electrical tape for example (though it makes it dimmer).  IR is also pretty good at going through paper.  Some pretty solid looking white plastics can be totally clear to IR.  I did find several things that were pretty good at blocking IR, but the best was any sort of metal, even a very thin coating on plastic works great (try using aluminum foil, just don't touch it to other electronics (besides grounding it)).

        Yet another consideration is that the detector acts as a sort of "integrator of area",  therefore you can get the same detect with a very bright small spot of IR reflection, *or* a large area of dim IR.   So this type of detector has trouble with things like table legs unless it's right in front of the detector (taking up a large portion of it's field of view).  But this works pretty well for flat surfaces such as maze walls.
        So when you point the IR LEDs down a tube you are limiting the area that the light will shine on, which greatly effects the detectors sensitivity.  Due to other considerations, I haven't seen this used very successfully yet (except one setup in which I used lenses).  You are probably better off just letting the IR LED shine on everything in front of it.  There is still enough resolution for such things as right or left.  The detector works better in this mode.

        A consideration on those cards that glow when IR is shined on them, the only real use I have for them is telling if the IR LED is on or not by putting directly in front of it.  Otherwise they are too insensitive to be useful (I have been in situations in which I absolutely could not tell if the IR LED was on using one of those cards due to the low power level needed for the design).
        An alternative that works pretty well is to use one of those hand held video cameras.  They see "near" IR (what we use for this type of detector) just like regular light, so you can actually see the IR through the view finder.  You can just look at the LED with the camera to see if it's on or if you want to know something like the beam angle (you just get in front of the IR LED and move around to see the edge of the disk in which  you can still see it lit).

        As a last note, be sure to ground the case on   those Sharp detectors.  They can generate interference by being an antenna for any electromagnetic waves around the detector.  Also you can put developed exposed color negative film in front of the detector to help filter optical noise.
        Sharp also sells a module that is just the same, but with added resistance to optical and electromagnetic noise (GP1U78Q for example).
        I've found many of my robots work fine in my shop only to have them behave very strangely at remote competitions.  This was due to interference at the competition that wasn't in my shop (some types of fluorescent lights can play havoc).

                Hope this was of help, and that you don't have to go though all that I did :-)

                Thanx to Eastside Robotics (which I belong) for the information.

                                Cheers,         Bill Harrison