IR beam break detection

Hello all. One of my ongoing projects is staircase lighting using an Arduino Uno and a TLC5940. The trigger at the top of the staircase will be a PIR sensor. At the staircase bottom the trigger will be an IR beam break; the receiver of the beam will be a TSOP1738. Originally I used the IR library for the IR sender but found that the TLC5940 library uses one of the timers that the IR library uses to output a 38khz signal to an IR led. I turned to a 555 timer to generate that frequency but couldn't maintain a steady 38khz. I think the tolerance of the 555's external components that I used was the reason for that. So I purchased a Wrobot Digital 38KHz IR Transmitter (image below). I couldn't find out very much about it's operation. I think it outputs a 38khw frequency as long as the data pin is held high; at least that's what the illuminated onboard led when the data pin is held high might indicate.

The Vishay TSOP1738, as I understand it, will not indicate seeing a 38khz light signal (output pin going low) if the signal is a continuous stream of pulses. What I read from the data sheet (below) "Burst length should be 10 cycles/burst or longer. After each burst which is between 10 cycles and 70 cycles a gap time of at least 14 cycles is necessary", in my mind, confirms that.

I think what might work is to turn the data pin of the sender high and low at a frequency of 1kz which would output bursts of 38 cycles, which is within the parameters of the receiver data sheet. Theoretically I should see a 1kz frequency on the TSOP1738 output pin. I think I could then use pulseIn(pin, value, timeout) to detect a beam break.

Do you think I'm on the right track here? Thanks - Scotty

http://www.emartee.com/Images/websites/emartee.com/42200.jpg

http://www.robokits.co.in/datasheets/tsop17xx.pdf

scottyjr: Do you think I'm on the right track here? Thanks - Scotty

Yes.

http://www.vishay.com/ir-receiver-modules/

TSSP4038, TSSP58038 et. al. don't require any gap time and will accept a continuous 38KHz signal.

Hi Scotty,

I use this IR pair: http://arduino-info.wikispaces.com/InfraredBeamPair

The transmitter just needs 5V and is packaged nicely. The receiver works well under most lighting conditions. In direct sunlight you need to put it in a blackened tube to get longer range.

This has worked well for people / animal detection and object detection across a 4 foot path on conveyer belts in a warehouse.

I've failed to get this circuit working.

#define PIN_IR_DETECT 4 //tied to output of IR detector
#define IR_TRANS_PULSE_PIN 5 //tied to DATA pin of transmitter
unsigned long PULSE_WIDTH; //pulsewidth of IR receiver output
boolean IR_REC_STATUS; //is IR receiver output active LOW or HIGH?


void setup()
{
  Serial.begin(9600);
  pinMode(IR_TRANS_PULSE_PIN, OUTPUT);
  pinMode(PIN_IR_DETECT, INPUT);
  analogWrite(IR_TRANS_PULSE_PIN,127);//turn IR emitter on 1msec, off 1 msec
  
}

void loop(){

  
  PULSE_WIDTH = pulseIn(PIN_IR_DETECT, LOW);
  IR_REC_STATUS = digitalRead(PIN_IR_DETECT);

  Serial.print ("Pulse Width =  ");
  Serial.print (PULSE_WIDTH);
  Serial.print ("      IR Receiver Status =  ");
  Serial.println (IR_REC_STATUS);

}

I tried two TSOP1738 receivers. Due to the opposite digital reads of their outputs, I suspect one is bad. I read the output to the DATA pin of the transmitter with a meter (has frequency/duty function)and verified that the frequency is 1khz with a duty cycle of 50%. The output of the serial monitor is below.

Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0
Pulse Width =  0      IR Receiver Status =  0


Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1
Pulse Width =  0      IR Receiver Status =  1 


Pulse Width =  6295      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  214      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  214      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  218      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1
Pulse Width =  220      IR Receiver Status =  1

The first two groups of text are the results of plugging in one receiver then the other. The last group is the result of no receiver installed leaving pin 4 of the Arduino floating. That last group indicates to me that pulseIn functions.

Something that I observed while viewing the serial monitor confuses me. When either receiver is installed the serial monitor updates about once every second. When not installed the data on the serial monitor scrolls very quickly as if it's updating as fast as the sketch allows.

Chagrin, I would rather have used those type of receivers. Wish I would have know about them.

terryking228, Those do look nice but, in this case, a bit pricey for me especially considering shipping costs when compared to a component that costs less than $2 and free shipping if you don't mind the wait. For a project that demanded reliability I would spend the money for peace of mind.

Thank you all for your replies. Got any ideas on what is going on here? - Scotty

Hmmmm. You are doing simultaneous transmit and receive, right?? Maybe the software/libraries interfere with each other???

IF you had another Arduino you could test separately…

terryking228, I'm not using any libraries right now. My immediate goal is to detect an IR beam break. Later that working hardware and code would be incorporated into a final project sketch. I suppose you could say I'm sending and receiving at the same time but not via the Arduino in that the 38khz functions are autonomous in the sending and receiving devices. The sketch enables the sender to send a stream of 38khz pulses for a brief time and checks the receiver's digital output. Perhaps I don't understand what you are asking. - Scotty

Hi Scotty,

OK, I'm not clear on your situation.. Do you have 2 arduinos.. 1 Transmit, 1 receive?? Sorry....

I'm only using one Arduino. The circuitry is as shown in a previous post of mine in this thread. - Scotty