Shop OBEX P1 Docs P2 Docs Learn Events
Emitter and Detector?how to? — Parallax Forums

Emitter and Detector?how to?

bobsmithbobsmith Posts: 36
edited 2004-10-06 23:53 in BASIC Stamp
I want to make a beam break eye and I have a emitter and detector

basically all I want to say is:

emitter······ pin······ 5
detector···· pin······ 6
high 5

if in6 = 0 then
goto mode2········· 'i have it like this so when the detector is broken it
························· ' lets the stamp knows it is okay to run mode2

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-24 19:40
    What kind of emmitter? If it's IR, it will need to be modulated. You can use FREQOUT to do that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • bobsmithbobsmith Posts: 36
    edited 2004-09-24 19:55
    ya im pretty sure its IR... i don't have it infront of me now, but if it is will I write it like this then?

    IR_detect var btye
    low 6

    loop:
    pause 50
    freqout 7,1,38500
    ir_detect = in5
    if ir_detect = 1 then broken

    goto loop
    broken:
  • Tom WalkerTom Walker Posts: 509
    edited 2004-09-24 20:26
    The Stamp is a single-tasking beast, so you're detection line (which may or may not be valid depending on how you wire it up) won't execute until your freqout line is done.

    A better description of what you are trying to do might bring forth more suggestions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Many are cold...

    · but few are frozen...
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-24 20:33
    If you use the Panasonic IR detectors that we sell you can in fact do that. The Panasonic detector has a bit of hysterisis that keeps the detector output on long enough for the BASIC Stamp to load up the next instruction to look at it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ExilictExilict Posts: 31
    edited 2004-09-25 05:21
    I have a feeling bob and I are working on the same exact project....

    I believe we are both using emitters from radio shack
    http://www.radioshack.com/product.asp?catalog_name=CTLG&category_name=CTLG_011_002_017_000&product_id=276-142&hp=search

    Catalog #: 276-142

    Since we are both wet still maybe you could help us out?

    For starters we need to wire it into the board. I dont see a resistance so how do you know what resistor to use? (an explination would go alot farther then an answer)

    Second, basically what we need for code, and I am sure its very simple this.

    Immagine a button that operates a hammer that hits a nail.

    We do not want the button to work untill the nail is in place (break beam)

    however if the button is pressed 5 times while there is no nail, it works anyway.

    Once again, your help is greatly appricated! These tech forums are the #1 reason I went with Parallax over the competators.

    =X
  • NewzedNewzed Posts: 2,503
    edited 2004-09-25 12:43
    I would be very surprised if you could make an IR beam that a nail would break.· In order to block the beam entirely, the IR emitter would have to be so close to the nail you'd probably hit it with the hammer.· If you want to see what would happen to an IR beam, substitute a white LED for the IR emitter and see what happens in a dark room.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Try the Stamp Tester

    http://hometown.aol.com/newzed/index.html
    ·
  • ExilictExilict Posts: 31
    edited 2004-09-25 15:01
    That was just an example. Not exactally what I am trying to do.

    The emitter and detector will be about an inch apart, and the thing breaking them is roughly .7" Round.

    THanks
    Chris
  • NewzedNewzed Posts: 2,503
    edited 2004-09-25 15:05
    Then in that case you should be OK.· The emitter should be sleeved with heatshrink to confine the IR beam as much as possible.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Try the Stamp Tester

    http://hometown.aol.com/newzed/index.html
    ·
  • ExilictExilict Posts: 31
    edited 2004-09-25 15:11
    I just need the code and schematic to do it :-(

    -X
  • jmyeakleyjmyeakley Posts: 1
    edited 2004-09-26 13:39
    I'm also not sure what you are trying but why have the stamp turn on the emitter? Leave the emitter on all the time and just break the beam. The suggestion about heat shrink to block out ambien light is very important. As far as the resistance, try the formula : resistance in ohms = ( voltage supplied - voltage required ) / current in amps. I've used the formula to turn on a LED from a 12 v supply although the LED required 3.5V at 30 ma. Therefore Ohms = (12 - 3.5 ) / .030 which yields 283 ohms. Actually the power is from a 12V battery and I had used 13.5 as the voltage supplied.

    Good Luck,
    John
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-26 18:34
    If you're not using a detector with hysterisis (like the Panasonic that Parallax sells), then jmyeakley has a good idea: You can use a 555 or similar oscillator circuit to modulate the IR LED, then use the BASIC Stamp to check the detector.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
    247 x 284 - 4K
  • ExilictExilict Posts: 31
    edited 2004-09-29 01:45
    Ok, help me out a little more, becuase they just arent working quite right... I think I have the code down, but not the electronics part....

    I should be using a 185ohm resister? Brown - Grey - Green......???

    Thanks

    T-1¾. 20mA, 1.3VDC, 940nm. wavelength. For optoelectronic projects

    ohms = (5-1.3)/.020 = 185
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-29 02:04
    You're not going to find (easily) a 185-ohm resistor, so going with 220 (Red-Red-Brown) as it is the closest standard value.

    FWIW, I keep a little five-compartment container of resistors with these values:

    220
    470
    1k
    4.7k
    10k

    ... and I rarely use anything that is NOT from this container.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ExilictExilict Posts: 31
    edited 2004-09-29 02:25
    Ok, I tried it... and now the first 6 slots of my project board no longer work.... any ideas?

    Chris
  • ExilictExilict Posts: 31
    edited 2004-09-29 02:35
    I am also using

    PAUSE 50
    FREQOUT 15, 1, 38500
    IR_detect = IN14
    IF IR_detect = 0 THEN unbroken

    how do you know what freq to use?

    Thanks
    Chris
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-29 04:46
    Set it to the demodulation frequency of your detector. If your detector does not demodulate then the code you are using will do you no good. Just to make sure you have a part that does what you want, you should probably order a couple detectors from us or get them elsewhere (Panasonic IR detectors).

    http://www.parallax.com/detail.asp?product_id=350-00014

    This detector holds its output on long enough for the BASIC Stamp to move from the FREQOUT instruction to the bit sampling on the input pin. The code you have above will work with this detector.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ExilictExilict Posts: 31
    edited 2004-10-02 16:56
    I would be more then willing to buy new pieces if I knew I could get them to work..· However the holes that I must adapt to are round and cut for LED's.· I do not think that panasonic part would work.· Any other ideas?

    -X
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-03 15:11
    If I'm out today I'll pop by RadioShack (they care BOE-Bots now, did you know that?) and pick up that emitter/detector pair. It may be as simple as:

    Check_Interrupter:
    HIGH LedPin
    active = INS.LOWBIT(IrPin)
    LOW LedPin
    RETURN

    Now, be aware that using IR without modulation means it could be triggered by IR in the environment -- that's why we use modulation (to get rid of evironmental IR noise).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • SmithySmithy Posts: 1
    edited 2004-10-04 19:43
    hello

    I have the same thing from radioshack and it works well with the code in this text.· Chapter 6

    http://www.parallax.com/dl/docs/books/edu/toddler.pdf
  • jediakojediako Posts: 4
    edited 2004-10-05 02:45
    With great respect for Jon, Exilict, you can get a 1% , 187 ohms metal film resistors from www.mouser.com/xicon, and very cheap. But at present
    resistors are not your problem.
  • BSBob24BSBob24 Posts: 3
    edited 2004-10-06 23:53
    ╔══╗
    ║ 1 ║
    ╠══╝
    ║ If you put an array of IR emitters on the other side of the beam facing a single detector you get much more accuracy but
    ║ takes power.
    ║ Code:

    ║ UNBROKE:
    ║ FREQOUT 3,38500
    ║ INS = ~IN5

    ║ IF INS = 0 THEN BROKEN
    ║ GOTO UNBROKE
    ╙────────────────────────────╜
Sign In or Register to comment.