Go Down

Topic: [Troubleshooting] Infrared interference with 38KHz IR sensor (Read 6195 times) previous topic - next topic

TomS240

Mar 23, 2014, 05:14 pm Last Edit: Mar 23, 2014, 05:17 pm by TomS240 Reason: 1
Hi! It's my first time posting on the forums, I'm sorry if this is in the wrong place.
Any help would be much appreciated :)

What I'm trying to do
I'm trying to detect a break in an infrared beam. For that I have a 38KHz IR sensor (right), and a simple IR LED (left).
I have both components set up on a breadboard, directly facing each other.


Schematic
This is actually the first time I'm trying to draw one of these.


The Code
I'm using the IRremote Library to modulate(?) the IR LED at 38KHz on digital pin 3.
Code: [Select]

#include <IRremote.h>

int RECV_PIN = 8;
IRsend irsend;

void setup()
{
 Serial.begin(9600);
 pinMode(RECV_PIN, INPUT);
 irsend.enableIROut(38); //38KHz
 irsend.mark(0); //Send
}

void loop()
{
 Serial.println((int)digitalRead(RECV_PIN));
}


The Problem
If I face both components at a small distance (5cm) everything works OK. I get a reading of 0 when light is detected, and 1 when I block the LED.
When I increase the distance (15cm+) I stop getting readings, as somewhat expected.

The problem is: the IR sensor I'm using is capable of detecting my TV remote from far grater distances (3m+) with no problem whatsoever. This made me think my IR LED isn't strong enough.
I then tried to detect my TV remote while leaving the IR LED on, at a distance of 15cm-20cm (because why not).
With this setup I did not detect the IR LED (as expected) but the sensor would only detect the TV Remote at very close distances (5cm - 10cm).

So this is where I'm at: the IR LED is strong enough to somehow interfere with other sources (TV Remote), while not being detected by the sensor.
If it's interfering, why Isn't the sensor picking the signal up? Am I doing something wrong here?

Thanks in advance! :)

knut_ny

IR led may need more current than the arduino pin can supply. use a transistor so LED current can  increase to maybe 100mA (se its datasheet to find working current)


Ny

AnalysIR

#2
Mar 24, 2014, 04:52 pm Last Edit: Mar 24, 2014, 04:55 pm by AnalysIR Reason: 1
Many of these IR receivers are designed to treat continuous signal as noise - so it is shut off /disabled.

It can work at close range because the internals are overloaded by the strong/close signal.

One option would be to try pulsing the signal on/off at say 600uSec intervals ( ie 600 on 600 off) or even 1000uSecs and increase the timing until you get it working.

This increases the complexity of the code as your receiving needs to account for it to detect spaces of more than 600uSecs ( or 1000uSecs etc) = beam broken

The correct IR receiver to use would be one designed as a light barrier (via google).


Also, if outdoors - sunlight would interfere a lot unless physically shielded.

TomS240


IR led may need more current than the arduino pin can supply. use a transistor so LED current can  increase to maybe 100mA (se its datasheet to find working current)


From what I've read I need a bipolar transistor. Is this right? Or any kind of transistor will do?
Never used a transistor before, I'm still trying to understand how to correctly manipulate the current...
Thanks for the tip!

TomS240


Many of these IR receivers are designed to treat continuous signal as noise - so it is shut off /disabled.
It can work at close range because the internals are overloaded by the strong/close signal.


Thanks, didn't know about that :)
I've learned about AGC and I think this must really be what's happening.


The correct IR receiver to use would be one designed as a light barrier (via google).

Great! I guess I'll buy one of these two:
http://www.vishay.com/docs/82458/tssp4038.pdf
http://www.vishay.com/docs/82479/tssp58038.pdf

Both datasheets states that "It can receive continuous 38 kHz signals or 38 kHz bursts.", so I guess I won't have any extra work with the code  :)

Should I also be looking for any specific kind of IR LED?
I've found this directional LED: http://www.vishay.com/docs/81090/tsff5210.pdf
Will this kind of LED work better in this type of application?

Thanks!

Chagrin

How much distance (how long of a beam) do you need? Any non-exotic, 20ma, IR LED will be able to do ~3 meters easily. Heck, even a white, 20ma LED can do ~3 meters with TSSP4038.

TomS240


How much distance (how long of a beam) do you need? Any non-exotic, 20ma, IR LED will be able to do ~3 meters easily. Heck, even a white, 20ma LED can do ~3 meters with TSSP4038.


Don't need that much distance, I think about 3 meters would be a good deal :)
Still, would a directional led (like http://www.vishay.com/docs/81090/tsff5210.pdf) behave better?
I'm a bit worried about the light bouncing off the walls and not being able to detect the break with precision.

Chagrin

You should enclose the IR receiver in a tube no matter what LED you choose. That's the best way to protect it from reflected light and direct sunlight (which will oversaturate the receiver). If you are having problems with reflected light just dim the LED a little.

The ideal LED would be similar to TSFF5210 but at the 940nm wavelength that the TSSP4038 is most sensitive to. But I'd stick with my earlier recommendation not to overthink the LED requirement; just look for whatever is inexpensive so you don't go crazy worried about burning out $1 parts. While you're testing you should also stick with visible LEDs (white / red) so you're not stuck looking at everything through your camera to see if the IR LED is actually on or not.

AnalysIR

Yes those receivers are the right ones.
TSAL6100 LEDs are good as they have a norrow angle.

+1 on the comment  on tube.
Place the receiver facing the least sunlight/ambient light and also at the end of a dark tube - for best results (also helps eliminating reflections.

If you want to go OTT, you could add some cheap optics to focus the IR beam directly on to the receiver, thus avoiding most issues!


TomS240

#9
Mar 27, 2014, 12:10 am Last Edit: Mar 27, 2014, 12:15 am by TomS240 Reason: 1

One option would be to try pulsing the signal on/off at say 600uSec intervals ( ie 600 on 600 off) or even 1000uSecs and increase the timing until you get it working.


Tried this while waiting for new components, it worked!
I only developed the part that deals with the IR LED, as detection will (hopefully) be straightforward with the new phototransistor.
Here's the code, as it might be handy for someone  :)
(It uses the IRremote library)

Code: [Select]

#include <IRremote.h>
#define PULSE_TIME 1000

int RECV_PIN = 2;
IRsend irsend;
unsigned long time;
boolean send = true;

void setup()
{
 Serial.begin(9600);
 pinMode(RECV_PIN, INPUT);
 irsend.enableIROut(38);
 time = 0;
}

void loop()
{
 if(millis() - time >= (PULSE_TIME/1000))
 {
   if(send)
   {
     irsend.mark(PULSE_TIME);
   }
   else
   {
     irsend.space(PULSE_TIME);
   }
   
   time = millis();
   send = !send;
 }
 
 Serial.println((int)digitalRead(RECV_PIN));
}


Thanks everyone for the tips, will try them out soon!

Go Up