Shop OBEX P1 Docs P2 Docs Learn Events
Multiple IR leds on Stamp BS2 — Parallax Forums

Multiple IR leds on Stamp BS2

Ferrit37Ferrit37 Posts: 2
edited 2008-09-19 21:43 in Robotics
Hey Guys,
New to the Forums so I hope this is the right place.
I have the Sumobot competition kit and have worked my way through the book.
I'd like to have 5 IR sensors and a ping(( on my 'bot but I need to free pins up.
Can I put IR leds in parallel on the BS2?, can it handle the load?

cheers,
ferrit37

Comments

  • SRLMSRLM Posts: 5,045
    edited 2008-09-18 05:43
    Depends. Are you planning on having them go all at once? If you do them sequencially ( a pin each) then you should not have a problem. If you want to use one pin for all the IRs then you'll need external circuitry to handle the load. There are several threads floating around here about powering multiple LEDs off of one pin.

    So, your setup: 5 pairs of IR LEDs and Recievers, Fire all the LEDs at once, read from one reciever, repeat 4x more. Correct?
  • Ferrit37Ferrit37 Posts: 2
    edited 2008-09-18 05:49
    Hey SRLM,
    Thanks for the reply, I've been using the search function digging through.
    Yep, that was the general idea or split them into left and right pairs maybe
    fire left, read LF, fire right, read RF, repeat for LS and RS.

    cheers,
    ferrit37
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-09-18 15:27
    Ferrit37,

    It shouldn’t be a problem…the BASIC Stamp2 can only do one thing at a time anyway so there would never be a need to light up multiple IR LEDs anyway. You would have to sequence through them. One thing you might want to do is trim your PAUSE in the main loop to account for additional code-overhead so that there is no lag in the sensors of servo refresh. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Steve in NMSteve in NM Posts: 54
    edited 2008-09-18 22:30
    Chris,

    I know it's possible to fire a bunch of IRLEDs simultaneously (like with a MOSFET), but I'll swear it's possible to grab the state of multiple pins with one command.

    No? Am I having another senior moment? blush.gif

    Edit: Ok. Maybe it was two commands?:

    DIRL=%00000000
    X = INL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not a complete idiot! Some of my parts are missing.

    Post Edited (Steve in NM) : 9/18/2008 10:46:42 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-09-18 23:21
    Yes, but what you're trying to read is the outputs of several IR-decoder modules. You've lit the IR-LED's with a "FREQOUT" command, which oscillates them at 38,700 Khz. That way, their reflection can trigger the IR-Decoder modules.

    If you do a read of an "INL", you'll only read the IR-decoders at that moment in time. This MIGHT work, but is a little iffy.
  • Steve in NMSteve in NM Posts: 54
    edited 2008-09-19 14:02
    allanlane5 said...
    Yes, but what you're trying to read is the outputs of several IR-decoder modules. You've lit the IR-LED's with a "FREQOUT" command, which oscillates them at 38,700 Khz. That way, their reflection can trigger the IR-Decoder modules.

    If you do a read of an "INL", you'll only read the IR-decoders at that moment in time. This MIGHT work, but is a little iffy.
    Understood and agreed. From Roboticsv2_2.pdf, Page 240:
    ...
    "The key to making each IR LED/detector pair work is to send 1 ms of 38.5 kHz FREQOUT
    harmonic, and then, immediately store the IR detector’s output in a variable."
    ...
    FREQOUT 8, 1, 38500
    irDetectLeft = IN9


    Since that works, it seems an "INL" should, too. Unfortunately, I only have one loose detector·so I can't verify whether· this is the case.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not a complete idiot! Some of my parts are missing.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-09-19 14:57
    Steve,

    Okay, so you want to FREQOUT to a MOSFET and generate the IR on multiple LEDs. Then you want to read the state of the pins connected to the detectors. Assuming that your arrangement is such that there is no IR interference from the other sensors, it could work. I guess you’ll have to try it and follow-up here with your results. Good luck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Steve in NMSteve in NM Posts: 54
    edited 2008-09-19 15:43
    Chris Savage (Parallax) said...
    Steve,

    Okay, so you want to FREQOUT to a MOSFET and generate the IR on multiple LEDs. Then you want to read the state of the pins connected to the detectors. Assuming that your arrangement is such that there is no IR interference from the other sensors, it could work. I guess you’ll have to try it and follow-up here with your results. Good luck.

    Exactly. I thought Ferrit37 might like to know if this can be done, too. It would be a much more efficient method than testing for the state of each detector one at a time between FREQOUTs.
    Since I only have one detector, here's what I currently have running:
    STATUS VAR INB
    start:
    FREQOUT 15, 10, 38000
    DEBUG HOME, "STATUS = ", BIN STATUS
    GOTO start
    What I see·in the debug window is -REALLY- erratic.·Does the code lack something? Since I only have the one detector, it can't be interference. Though I *did* note a hint of sage wisdom seeping through your comment. wink.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not a complete idiot! Some of my parts are missing.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-09-19 16:51
    Steve,

    If you have only one detector then the other lines are floating and their values could be anything at anytime including oscillating. You’re going to need 4 detectors to get a true 4-bit input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-09-19 17:03
    Or, install 10Kohm "pull-up" resistors from the I/O pin to Vdd on your other three lines...
  • Steve in NMSteve in NM Posts: 54
    edited 2008-09-19 21:43
    allanlane5 said...
    Or, install 10Kohm "pull-up" resistors from the I/O pin to Vdd on your other three lines...
    Well, duh. I knew I'd have to use pull-ups.·blush.gif

    Anyway, IT WORKS!·With INx, you can report the logic state of any bit, nibble, byte, or word.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not a complete idiot! Some of my parts are missing.
Sign In or Register to comment.