Simple beam break sensor


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Well

    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.
    Last edited by Jumper; - 24th July 2009 at 16:50.

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    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 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.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post

    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.
    Last edited by Archangel; - 27th July 2009 at 07:14.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Need a cheap touch sensor idea.. here it is
    By mister_e in forum Code Examples
    Replies: 20
    Last Post: - 16th April 2016, 22:42
  2. Ultrasonic distance sensor with PIC16F84A
    By MrRoboto in forum mel PIC BASIC
    Replies: 3
    Last Post: - 29th June 2009, 09:01
  3. PICBASIC PRO-coding for wireless sensor node
    By syazila in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2009, 00:05
  4. Replies: 0
    Last Post: - 2nd February 2009, 23:23
  5. Replies: 6
    Last Post: - 18th January 2008, 08:17

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts