IR beam break counter

Hi All,

I know this has been done to death, but I have searched all over, and have not found a solution for my issue in the forums, or anywhere else for that matter.

My project is an infrared beam break counter. There is a bit more to my project, but for simplicities sake, I will focus on the part which is giving me trouble.

I am having some trouble with an infrared receiver. I am not sure the exact model, but they are something like the PNA4602.

When I illuminate the receiver with the 38khz IR signal, it goes high for about 3 or 4 seconds, after which it seems to go unstable and flicker. If I break the beam the receiver goes low. As soon as I unobstruct the beam, the receiver goes high for a few seconds then unstable again. Process repeats.

This was havoc on my counter, as when it went unstable, it would count 2 or 3 breaks per second, when no breaks were occurring.

At first I tried to put a capacitor between +5 and ground at the receiver pins, but this just seemed to slow the flicker somewhat.

The hoped for and expected outcome, was I would shine the IR light on the receiver, and it would stay high until the beam was broken. Any ideas on why it is not doing this?

Essentially, I have reworked the code below (thanks to Ken Shirriff), and for the purpose of trouble shooting, I have used this exact code to isolate my problem.

#include <IRremote.h>

#define PIN_IR 3
#define PIN_DETECT 2
#define PIN_STATUS 13

IRsend irsend;
void setup()
{
  pinMode(PIN_DETECT, INPUT);
  pinMode(PIN_STATUS, OUTPUT);
  irsend.enableIROut(38);
  irsend.mark(0);
}

void loop() {
  digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
}

I have followed his exact hardware setup (http://arcfn.com/images/ir-schematic.png) to begin with, then I added a 47uF cap to the input pins of the receiver. (Does it matter if the cap is polarized in this DC application???)

Many thanks in advance to anyone who can point the way!

Mike

When I illuminate the receiver with the 38khz IR signal, it goes high for about 3 or 4 seconds

Right away I'm a bit confused because the PNA4602 receiver makes its output go LOW when it is illuminated by IR light. Or do you mean that your status LED goes high?

How close is your receiver to your transmitter? I've found it is possible to be too close and you end up saturating the receiver (which kinda leads to behavior similar to what you describe).

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

Thanks for the quick reply!

Sorry, I was reversing things. The LED is lighting, indicating the receiver has gone LOW.

The separation is meant to be about 40mm, but I get the same results whether the separation is 10mm or 250mm.

I also thought the issue might be a faulty part, so I have switched out both the emitter and receiver, and I get the same result.

I appreciate the help.

bamboo-cowboy:
I am not sure the exact model, but they are something like the PNA4602.

Are you sure it is 38kHz and not 36 or 40 for example?
Depending on how precise the Arduino output and the filter on the input is this could possibly explain the problems you are describing.

Just a thought...

These receivers are designed for receiving a 38KHz beam that is pulse modulated with data. You are giving it a continuous beam and so the AC coupling inside the chip is giving up when it does not see a change in the light level.
The trick is to pulse the beam on and off to bias the receiver properly.
You will have to experiment with the timing but I should start with 1mS pulses. I experienced the same problem on one of my projects using this sort of setup and pulsing was the cure. Although I did use a different sensor to you.

Thanks, I will give this a try!

has anyone used the arduino for the timing of drag racing / sprinting

I am pretty sure Grumpy Mike is right. Do you think you might have that code still floating around on your computer, Mike? I am not a very proficient coder, and I can't figure out how I can create a pulsed 38 khz signal and simultaneously read the receiver output. I know it must be possible, cuz a pwm signal can be transmitted and I can read the receiver output. When I try to pulse the 38 khz signal at 10ms off, 10ms on, it seems like during the time the device is listening for IR receiver output, it is not transmitting the 38 khz signal.

I looked at a datasheet for the receiver which I think I have. It says the following.

Some examples for such disturbance signals which
are suppressed by the TSOP18.. are:
• DC light (e.g. from tungsten bulb or sunlight),
• Continuous signal at 38kHz or at any other
frequency,
• Signals from fluorescent lamps (see Figure B).
• Continuous IR signal (e.g. 1ms burst, 2ms pause)

So I need to transmit a 38 khz signal that avoids being filtered for a moment and at the same moment listen for the IR receiver output.

Is there an easier way to do this? Are there IR receivers that filter non 38 khz but does not suppress continuous signals?

Thanks guys.

Easiest way: generate a 38 kHz signal on one pin and another 500 Hz signal at another pin. Put the IR emitter between those pins. Thus the signal is generated by the counters and the CPU is ready to anything else you want.

Of course you could also use the mstimer2 library for switching the 38kHz PWM on and off every 1ms. If you have enough pins though the two timer approach would be more "CPU friendly".

it seems like during the time the device is listening for IR receiver output, it is not transmitting the 38 khz signal.

Yes that is fine, it is the electronics in the receiver that will hold the signal for 2mS after the 38KHz IR signal stops, or keeps going.

Are there IR receivers that filter non 38 khz but does not suppress continuous signals?

Not that I know of. These things are designed for IR remote controllers, these do not transmit a DC component to the signal and so it makes sens to reject them. There are lots of modulation schemes about and the main reason of having one is to avoid DC components in the signals.
Another approach is to use two NE555 timers to generate the 38KHz signal modulated at 1mS.

Thanks to everyone for the informative suggestions.

I have finally opted to just use a phototransistor without any built in analysis circuitry.

I got frustrated trying to fool the sensor, and decided to go for something simpler. (I find myself doing this all the time!)

Right now, everything seems to be working without any additional circuitry, I have just connected the phototransistors output to my input line and done my best to optically isolate the sensor from external interference by putting it in a tube and lining up my emitter to shine down the tube.

If I really try hard, I can get the thing to perform incorrectly by shining fluorescent lamp light down the tube, so I think this will likely be sufficient for my project.

I have a backup plan if the interference causes problems in its operating environment. I have seen someone using a 741 op-amp to filter out inappropriate frequencies of light.

Again, thanks for the help guys.