PDA

View Full Version : Simple beam break sensor



The Master
- 23rd July 2009, 20:09
Hi, I want to make a simple beam break sensor. Ive got some IR emiters and photo transisters (http://www.rapidonline.com/Electronic-Components/Optoelectronics/Infrared-Devices/5mm-Infrared-source-and-sensor/72945/kw/58-0320).

I connected the photo transister to an NPN transister which is connected to an LED. When i aim a remote at it the LED starts flashing (all good so far). When i connect the emitter up and aim it at the PT i can get the LED to light up but only at very close range (about 10CM). I tested again with my remote and managed to get about 30CM out of that.

How can i make a beam break sensor that works over about 2 meters? For a start do i need different emitters and PTs? Eventually i want a PIC chip to check the beam but for now im just doing quick tests with a transistor and an LED. Do i need any special circuit to make it more sensitive? I messed with the grounding resistors and got it so it was as sensitive as possible without being triggered by normal light but i still cant get more than a few CM range

mackrackit
- 24th July 2009, 02:07
http://www.rentron.com/Infrared_Communication.htm

Set up to receive the modulated frequency and you can in effect increase your range.
Sometimes a focusing lens is needed for very long range. 6 meters.

The Master
- 24th July 2009, 10:49
Isnt there a simpler way to do it? The emitters and PTs will all be connected to the same PIC. That PIC needs to do PWM on a few sets of LEDs and needs both its UART pins for talking to a PC. I dont have a spare IO pin to control the emitters either. I was hoping to just connect them to VSS/VCC through a resistor.

I dont need to send data. I just need a simple beam break system (on/off)

Melanie
- 24th July 2009, 12:19
1. Emitters and Sensors prefereably should be matched in the same IR range... One Emitter may not work well with a Detector best suited for a different range.

2. You may be being swamped by ambient light (which contains IR, UV, cats, dogs and the neighbours barbie smoke as well). To see if this is the case, try your experiment in a darkened room and you'll discover you have a much improved range over a room in broad daylight. Use an IR filter (wrench one out of your neighbours TV's facia as an experiment). Modulating the emitter at something like 32kHz and decoding similarly by the detector is what separates the signal from ambient noise (this nothing to do with actually sending Data).

3. The TSOP range of Detectors (eg TSOP17xx & TSOP18xx) contain integral filters and decoders which means you don't have to worry about that part of it. Even then when you look at the Datasheets you'll see they are optomised for certain frequencies).

4. You may notice (from Datasheets) that the junk IR Emitter/Receiver pairs are really specified for only a few cm operation.

The Master
- 24th July 2009, 16:06
The ones i got are matched (according to rapid). They are most likely a "junk pair" though.

When i was testing the room was fairly dark. The LED did light up when i shon a lamp into the PT but without a bright light it stayed off until i shon the emitter into it.

Rapid dont sell the ones you mentioned but they do have some that say "Demodulated output signal can directly be decoded by a microprocessor". Is there such thing as an emitter that modulates itself or will i need to find another IO pin for that.

This is my first time dealing with IR and it seems i dont know much about it. When i was at school a teacher said i could use it in the same way as an LED and an LDR. Nobody said anything about modulating it.

Lets just make sure i understand how this works. The emitter is modulated at a set frequency. For a 3 pin PT that has a demodulated output does that mean that even though the beam is modulated i will see a steady output?

Would this emitter (http://www.rapidonline.com/Electronic-Components/Optoelectronics/Infrared-Devices/High-power-infrared-source-and-sensor/29398) be suitable with this PT (55-0902) (http://www.rapidonline.com/Electronic-Components/Optoelectronics/Infrared-Devices/Infrared-photo-modules-38kHz/71292)? The emitter looks relatively powerfull and the PT has a demodulated output, IR filter, "High immunity against ambient light" and is highly sensitive etc.

Both sides will be set about 7cm into holes which should stop any external light getting into the sensor. They will be just over a meter apart but i want this to work over 2M to make sure its reliable.

Jumper
- 24th July 2009, 16:44
To start with I must say that the data sheets for these products are not that detailed.

It seems to be a good match between the LED and the Receiver and that is a good start. Around 940 nm so this will not be a problem.

Your big problem here is that you MUST modulate the LED with a 38kHz carrier frequency for the receiver to work. To make things even more difficult you can not just modulate it with 38k always, it has do be done in bursts. Please keep in mind that the PIC can only provide 25 mA current and that will not be enough for this to work well. You will need a mosfet or ULN 2001 or anything faster than a relay.

Let me explain some more...
In a better datasheet for a TSOP it will say the minimum number of carrier cycles for the receiver to decode the signal. 6-10 is a quite normal number. It will also say that a gap (off time) must be usually around 10-15 cycles between bursts.... and if any burst is longer than 70 cycles you will need a gap at least as long as the burst. VISHAY is a great place to find good datasheets.

This is for the gismos and gadgets inside the TSOP to work.. if the carrier is always on the AGC will adjust the sensitivy lower and then you will not get any result. There are some new TSOP by Vishay (TSOP4038, TSOP58038 are specially made for light barrier systems)that can be modulated continously but I hardly think this one has that based on the date 2007 and the poor datasheet.


If you want to use this one you must find a way to send bursts of 38kHz square wave to the LED and each of these bursts should probably be 10-70 cycles and followed by a gap where the LED is off for a time period similar to 15-20 cycles.

The easiest way would require 2 pins on your PIC. One HPWM set up to 38k (manually) and the other pin connected to the receiver to check if the output pin goes low. Pros: Since you have modulated the LED and it is only turned on in short bursts you can drive it really hard. 300-500 mA would probably work depending of how often you send a burst. More current=more light= longer distance!

If you only have one pin I would recommend you to use a AD or comparator input and read a LDR or PIN diode. In this case you can leave the LED on and check for a drop in the AD voltage when the beam is broken. Cons: The background light in the room can really influence the result. Indoor with a proper optical filter the ambient light should not be a problem when using IR. In this application a cheap laser pointer could probably work better than the LED since you will get a much higger mW/mm2 on the receiving end. But that would be harder to aim :-)

As mentioned before... use lens, a normal magnifying lens in front of the LED and one more in front of the receiver helps alot if they are properly focused. This you can easily see if you try with a RED led, then you will see what happens when you move the lens in front of the LED.

And if you go for a IR led solution get a optical filter. It sais that the TSOP has a built in filter but adding the dark piece of plastic Melanie suggested to "borrow" from a neighbour will help alot.

The Master
- 24th July 2009, 18:56
How picky are these things about the frequency? I should be able to get a PIC to output close to 38KHz but it wont be exact and the chip will be doing PWM on other outputs aswell as sending and receiving serial data so it might change a lot.

When you say "cycle" i assume you mean the emitter turning off and back on again (not an instruction cycle on the PIC).

Ive got some transistors i can use to drive the emitters so that bits ok.

Would i be able to do this without the lenses? I might be able to find some of those IR filters somewhere but i cant think of anywhere i could get magnifying lenses from

Ill add a few of the ones i mentioned before to my next order so i can do some more tests

mackrackit
- 25th July 2009, 06:47
You can rig a 555 to for the 38.5KHz. then all you have to do is trigger it when needed.

Cheap lens = cheap loupe. 10x might be a good start.

The Master
- 26th July 2009, 01:48
Good idea. I never thought of using a 555. Do you know what value resistors and capacitor i would need to get the right frequency? Ive been using a 555 calculator (http://freespace.virgin.net/matt.waite/resource/handy/pinouts/555/index.htm) and ive got 0.820K, 1.5K and 0.01uF. They give about 37.6MHz. Does it have to be exactly 38.5KHz?

Is there a way to calculate what resistors and capacitors to use? It would be better if there was a calculator where you can enter the Hz and it will calculate those for you.

Archangel
- 27th July 2009, 07:11
Is there a way to calculate what resistors and capacitors to use? .
http://www.national.com/ds/LM/LM555.pdf
The formula is in this data sheet near the end, page 10 between figure 13 & figure 14.

The Master
- 27th July 2009, 14:54
Sorry, i dont understand that formula. Its a bit more complicated than i thought.

Ive been reading a few webpages (and re-reading this thread) and i think im starting to understand how it works. I like the 555 idea but if i need to send it in bursts then ill need 2 555s (1 for the 38.5khz frequency and 1 to control the bursts). Other sites also recommend a variable resistor for fine tuning.

I think its best if i do use the PIC chip. I do still have the MCLR pin which can be used as an input only (for a sensor). Hopefully one of the pins on this chip has hardware PWM and hopefully that works how i think it does. That way i can adjust the frequency to suit and have the burst thing without having to make the PCB bigger and use extra components... and i wouldnt have to figure that equation out ;)

Im going to put an order in soon and get some new emitters/PTs and ill see how it goes. No doubt ill be back for more help when it doesnt work :P

mackrackit
- 27th July 2009, 15:13
Any of the PICs output pins can control the 555, look at the trigger pin of the 555. It is basically an on and off pin. The basic stamp folks did it this way before they had a freqout command.

The Master
- 27th July 2009, 22:22
Thats a good idea. Ill add some 555s and the related components to my next order

Archangel
- 29th July 2009, 08:44
A simple beam break sensor, what about a $5.00 US laser module and a simple CdS cell ?
http://www.doctronics.co.uk/555.htm#transducer
easier formula here http://www.doctronics.co.uk/pdf_files/555an.pdf

The Master
- 29th July 2009, 10:40
I dont want people to be able to see the beam but if i cant get IR working then that might be the only option.

Thanks for the links. Ill have a read through them

The Master
- 31st July 2009, 21:36
Im trying to get this 555 circuit working but nothing is happening. Ive been following a few different diagrams on the internet and none of them seem to work

I found this calculator (http://www.daycounter.com/Calculators/NE555-Calculator.phtml) on google. I entered 38.5KHz, 50% duty cycle and 0.001uF (1nF) capacitor. It said to use an 18.7K resistor for RB and 0K for RA. Ive been using a 15K resistor with a 5K variable resistor as another website said. It doesnt really matter if its at the right frequency for now though. the LED just wont light up at all (im using an LED for now so i can see it working).

Ive tried putting the output through a transistor. Ive tested the transistor by itself and it works fine.

My circuit currently looks like the one on that calculator site. Does anyone know what ive done wrong or what to check next?

mackrackit
- 31st July 2009, 22:35
http://www.uoguelph.ca/~antoon/gadgets/555/555.html
The above tells a lot about the 555. Try the metronome sample and step it up.

The Master
- 31st July 2009, 23:14
Ive had a read of that page and i tried the metronome example but its still not working. I didnt have a 250K variable resistor so i use a 220K normal resistor and i connected and LED to the output (and tried through a transistor).

Ive tried 4 different 555s now so im sure its not the chips that are at fault

mackrackit
- 31st July 2009, 23:36
Been awhile since I have played with a 555, but I seem to remember something about different types.

What are the numbers on you 555s?

The Master
- 31st July 2009, 23:43
I swapped to a different breadboard and its starting to look a little better. The metranome circuit worked. Ive put it back how i had it to start with and it seems to be oscillating but not properly.

The circuit ive been copying is the Infrared Emitter 555 Schematic (http://www.robotroom.com/Infrared555.html).

The chips i have are NE555N. Aparently the ones that start with NE are good for driving LEDs etc directly

mackrackit
- 31st July 2009, 23:53
Mold...Mold on the bread board. :D

You may be picking up some stray capacitance someplace.

The Master
- 1st August 2009, 00:50
I think its just got a few bad connections on it.

The circuit still isnt working. Ive had a look at the output on my picoscope and its not a 50% duty cycle. I dont really know how to read the results properly but im pretty sure its the wrong frequency too.

Im gonna go sleep on it. My head hurt a little after reading that link you posted. I think ill go back to the metranome and mess with some values tomorrow.

Archangel
- 1st August 2009, 06:20
I don't want people to be able to see the beam, but if I cant get IR working then that might be the only option.

Thanks for the links. Ill have a read through themred laser / infrared filter might work . . .

The Master
- 5th August 2009, 09:58
This seems to be working now. The calculators ive used say that RA (or R1) should be 0K. The circuit doesnt work unless i put a 1K resistor in. Ive tried a few lower values but the LED will go off after a set amount of time then not come back on. 1K doesnt give me a 50% duty cycle but it seems to be alright.

Once it was flashing correctly i changed the other values to what the calculator said and the LED came on but dimmer than usual so i assume its flashing really fast. I replaced with an IR LED and it now works over 2M

I hope it keeps working once its all soldered into a PCB :P