I want to use an IR sensor for object detection. An LED will be turned on if an object is detected. But because of sunlight, it's malfunctioning (i.e. always getting logic 1).
So, how do I omit the interference due to sunlight?
I want to use an IR sensor for object detection. An LED will be turned on if an object is detected. But because of sunlight, it's malfunctioning (i.e. always getting logic 1).
So, how do I omit the interference due to sunlight?
I'd like to expand on analogsystemsrf's answer a bit:
Thus pulses, or squarewaves, of photons may be your best bet.
Exactly.
Sunlight doesn't change quickly.
If your illuminating IR LED is pulsed on/off, e.g. at 25 kHz (easy with a microcontroller), then you can simply measure the photocurrent at every pulse:
Add all measurements when the LED is on, subtract all measurements where the LED is off.
When you write that down, you'll see that you're simply subtracting the background light, which stays constant.
WARNING --- if your circuit is just a photodiode and a resistor, then high amounts of DC_photon flux (the sunlight) will push the output voltage close to rail, and the circuit will become VERY UNRESPONSIVE to changes. Thus you need to find a way to AVOID pushing close to rail/VDD/GROUND.
Thus I offer this:
If you run the photodiode current thru a normal silicon diode, you can get a LOGARITHM of the current.
This --- the LOG --- greatly extends your dynamic range.
As the reflectance of your "object" changes with different objects, you may need to calibrate any thresholding or detecting activity in the circuits.
And there will be temperature effects.
Thus pulses, or squarewaves, of photons may be your best bet.
However, you need to bias the photodiode, despite the sunlight;
Or use a black_looking IR filter, taken from a discarded VCR.
To handle sunlight, I've very successfully used a parallel_load for the photodiode:
a transistor to pull DC (sunlight) current from the photodiode
a resistor, perhaps 10,000 Ohms, to convert small fast photocurrents into voltages; connect this resistor from the output node (photodiode, resistor, transistor_collector) to ground.
Operate the transistor base from a low_pass version of its collector.
You will need a filter. Sunlight doesn't vary rapidly. All you have to do is to use high-frequency pulse for driving the LED. And design a bandpass or high pass filter to receive the desired signal.
You can find an IR sensor with built-in bandpass filter in the market.
And if you are using a high-frequency microcontroller (STM32, ATSAM, etc.) then you can implement digital signal processing (FFT/ IIR/ FIR). You will find library function related to FFT/ IIR /FIR on the internet.
In addition to pulsing, you can also pick a wavelength where the sun is less bright. 1.5 um for example is often used for that purpose, although it does not work with cheap silicon diodes. 930nm is also sometimes used, since water absorption attenuates sunlight somewhat at that wavelength. Add a bandpass filter at one of these wavelengths and you will detect a lot less solar radiation.