Interface IR Detector through comparator - help

Hi All,

I'm very new to the forums and the Arduino, but so far I've been having a lot of fun with it. I haven't touched electronics for many, many years, so this is great.

I'm trying to interface an IR detector to the Arduino to count RPM for my son's science project. I followed the directions and circuit here

but could not get the IR detector I have access to, to reliably trigger the Arduino interrupt.

I then built a circuit using a comparator (LM311) and it sort of works, however I appear to get way too many interrupts for one break of the IR beam, especially when moving slowly through the beam.

This is the circuit that I am using - and it is connected to pin 2 of the Arduino

I can post the code but it is pretty much the same as the one in the Instructables article.

Does anyone have any suggestions as to why I am getting so many interrupts and more importantly, how can I fix it?

Thanks

Martin

You need some sort of Schmitt trigger with hysteresis.

The other thing you could try is a capacitor across the photo detector to slow down any edge.

Thanks I will try and put together the Schmitt trigger.

What will the capacitor on the input do - I tried to do that and it did not detect the changes - maybe a wrong value for the cap?

An easier answer which will give you a much better result in several ways is to use the not-very-expensive (about $5 if you do it the hard way!... less, if you look around just a little) already-invented-wheel for just this part of the project....

(You can replace the IR control handset with the IR LED you already have, driven by a stream of pulses from a 555 timer.)

The sensor descibed there has the Schmidt (or an equivalent) as part of the sensor, takes care of giving you nice clean swings from 0 to 1 and back. Also more immune to IR "noise" in the environment, and (I think) makes sensing over a longer range easier/ more reliable.

You WON'T (for the project you describe) need any of the stuff about the library for decoding signals from an IR controller. But the hardware used with the controllers will give you easy access to a nice "on or off" (if beam is present) sensor, with digital output.

===
Are you really using exactly what you show as the source of the IR illumination? If so, check that the 5v supply is "clean", steady. A resistor and capacitor in parallel with the LED and its resistor might be an idea, too... just in case there's any "wobble" there. (People who know more than I about these things, please comment "good idea/ bad idea", and suggest values for the components?)

If you are using an IR remote control to do the IR illuminating, it would explain lots. They (IR controllers) pulse a beam which is itself pulsed (at a higher frequency).