Odd LED/transistor behavior

Hi all, I have something odd happening and I haven't been able to figure out a solution. It's driving me nuts.

I have an IR LED and IR sensor working well as a trigger. Break the beam between the two and the Arduino Mega sees the pin on the IR receiver go high. The pin goes high once per break, no matter how long you keep the beam broken.

My Arduino code initializes by setting D2 as output, D10 as input, then writes D10 high. In the main loop it turns the transistor on and off at 38khz, which turns on/off the IR LED, which triggers the IR sensor. When the beam is broken the pin on the IR receiver (D10) goes high.

All is well until I add 3 feet of wire between the IR LED and the circuit. The IR sensor then triggers intermittently when the beam is broken. Things are fine when the beam is not broken. I've eliminated IR leakage as the cause of the problem. The only thing I can think of is that the extra resistance from the wire is causing some weird interaction with the transistor, or is acting as an antenna and introducing noise into the circuit? I've tried both 22AWG and 14AWG wire with no improvement, so maybe it's not a problem with resistance? The board gets its power from the Arduino Mega, and I have the same results when it's powered via USB or an external 12v wall adapter. If I disconnect the LED from the circuit the IR sensor triggers once like it's supposed to, rather than intermittently.

Thank you for any advice you can offer, I appreciate it.

IR Sensor

IR LED

Transistor

Illumitune project (my project is based off this)
http://www.sparkfun.com/tutorials/282

emitter.png

detector.png

The pin goes high once per break, no matter how long you keep the beam broken.

Yes it will.

That sensor is a TSOP382, it is designed for remote controls. It is designed to transmit data over the beam, it is not designed to detect a beam break. This means that when it sees no more data it just shuts down and in effect you only get a pulse out of it. You could change your setup so you modulate data onto the IR beam but it is better if you get the right sensor for the job.

The sensor you need for your application is a TSOP4038.

Thanks Mike, I'll try one of those. While I'm waiting for it to show up in the mail, any idea why the extra wire causes things to stop working properly? Everything works fine, but as soon as I add the extra wire on the LED problems start. Ideally I'd like to fix the existing system rather than replacing the sensors, if possible.
-Bryan

My guess is either:-

is acting as an antenna and introducing noise into the circuit?

Like you said. Or it could be that the extra length of the wire into the LED is adding extra capacitance and so degrading the signal going into the LED. Try moving the transistor as well at a distance from the arduino as that can often reconstitute the signal. You might need to drop the series resistor value.

Mike, the sensors should be arriving soon. Reading over the basic descriptions in the data sheets I understand the conceptual difference between them, (the new ones report when the beam is broken and the old ones are designed to read the data sent on the beam) but looking in more detail at the output graphs they seem identical. Can you explain how they're different? I'm getting a bit lost in the data sheets.
Thanks,
Bryan

the new ones report when the beam is broken and the old ones are designed to read the data sent on the beam)

Yes that is exactly the point. The two are very similar devices.

but looking in more detail at the output graphs they seem identical

Well the both look the same but what is different in the TSOP382 is that the signal is being driven by the data in the IR beam and in the TSOP4038 is a result of a blocking obstacle in the beam.

The bit in the TSOP328 sheet is:-

• Burst length should be 6 cycles/burst or longer.
• After each burst which is between 6 cycles and 70 cycles a gap time of at least 10 cycles is necessary.
• For each burst which is longer than 1.8 ms a corre- sponding gap time is necessary at some time in the data stream. This gap time should have at least same length as the burst.

You won't find this in the TSOP4038 data sheet.

Lots of guys round here trying to use IR rcvrs for "beam-break".

I came up with something I thought not bad, but somebody came along with a link to guy who's done a lot more than I --
http://arduino.cc/forum/index.php/topic,75566.0.html

Take your pick (mine is closest to the door.)