Shop OBEX P1 Docs P2 Docs Learn Events
Infrared wireless communication — Parallax Forums

Infrared wireless communication

ArnoNLArnoNL Posts: 15
edited 2009-02-14 15:53 in BASIC Stamp
Dear BS2 users,

I'm lookig into a solution were I want to use a wireless connection.
I'm looking into infra red as this is cheaper and should be easier than zigbee, appbee, xbee, etc. However I can't find any info on connecting it to a BS2. What I want is I have·2 pushbuttons who give a signal about a maximium of twice a second. Each time a button is touched I want to send info wireless via infrared to the BS2. Are there any application notes available regarding this?

Thank you in advance.

·

Comments

  • UghaUgha Posts: 543
    edited 2009-02-10 12:43
    What kind of info are you wanting to send?

    Serial will be very hard and very slow, as an LED actually takes a long time (compared to other forms of communication... faster than we can see to humans) to turn on and off.

    If its just maybe one byte you may be able to come up with an IR communication protocol that can transmit the data in 1 second or less.
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-02-10 13:05
    arnoNL

    Chapter 11 of the Basic Stamp 1 application notes.

    http://www.parallax.com/Portals/0/Downloads/appnt/stamps/bs1Appnotes.pdf

    You should be able to apply this to the BS2. You can use the parallax IR receiver for this application.

    I hope this helps.



    SJW
  • ZootZoot Posts: 2,227
    edited 2009-02-10 13:48
    There are lots of ways to send lots of info via infrared. One of the simplest is to hook the IR emitter and detector up to two pins and just use SERIN/SEROUT at 2400 baud to send bytes. This works over shorter distances with good line of sight and when there is not much interference (read: other IR).

    The way remotes work is more stable -- send a long start bit, followed by some data bits. In my own 'bots, I use a protocol (copied from Andy Lindsay at Parallax) where a start bit is a 3ms IR pulse, followed by a 1ms "rest", followed by 12 data bits -- a 1 bit is a 2ms pulse, a 0 bit is a 1ms pulse. I leave a 70ms pause between messages to allow other 'bots to "talk", so the max time between messages is about 100ms. This can be cut to less than 20ms if you have fewer bits and aren't allowing for other platforms to IR comm. too.

    In any case, see the document below which details using IR remotes (and sending and decoding the codes) with a Stamp. Given that you only need to send two bits (the states of your buttons) it shouldn't be too hard.

    www.parallax.com/Portals/0/Downloads/docs/prod/sic/WebIR-%20v1.1.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ArnoNLArnoNL Posts: 15
    edited 2009-02-10 13:58
    Wow, thanks for the fast responses. I've just ordered the components and already started with the code. Can't wait to connect them to my stamp en test the program.
    However it looks like IR is no more less expensive then RF communication, howcome? Is RF more difficult? Why not use RF and forget whole IR part?

    Kind regards
  • ZootZoot Posts: 2,227
    edited 2009-02-10 14:46
    IR is wayyyyyy cheaper than RF (and led and a detector might cost < $2). But IR is relatively slow, will only work over short distances, is subject to vicious interference (esp. from other IR devices) and depends on line-of-sight. Plus you can't really "network" it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • jjanesjjanes Posts: 24
    edited 2009-02-10 22:14
    Zoot said...
    IR is wayyyyyy cheaper than RF (and led and a detector might cost < $2). But IR is relatively slow, will only work over short distances, is subject to vicious interference (esp. from other IR devices) and depends on line-of-sight. Plus you can't really "network" it.
    What about laser?· Are components readily available?

    JJ

    ·
  • ZootZoot Posts: 2,227
    edited 2009-02-10 22:20
    My comments also addressed some theoretical concerns. What are you actually trying to do? Send the button pushes across a tabletop? Or halfway across a room? Use IR. Cheap, easy to customize, easy to test for interference. If you need something more robust, then I *would* use Xbee's -- they are relatively inexpensive, and code and documentation are widely available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • UghaUgha Posts: 543
    edited 2009-02-10 22:25
    I've had some success with the cheap ($14-$20 USD) wireless RF transmitter/receiver pairs sold at various places... they take some getting used to but I've had a nice 200-300 foot range with them.
  • ArnoNLArnoNL Posts: 15
    edited 2009-02-11 16:06
    Zoot said...
    My comments also addressed some theoretical concerns. What are you actually trying to do? Send the button pushes across a tabletop? Or halfway across a room? Use IR. Cheap, easy to customize, easy to test for interference. If you need something more robust, then I *would* use Xbee's -- they are relatively inexpensive, and code and documentation are widely available.

    Thanks Zoot, I only have to cross·2 meters or so. Also I only want to know (in a split second) when a pushbutton is touched (about twice a second max). However I find it difficult to determine what components to use and how the communication works. Studieing the hereforementioned application notes it looks like serin and serout (serial communication). I also want to order some components to start working with, any suggestions about the mentioned $2 sets?
    Also as much as Xbee appeals to me $19 is way to expensive and I think (not sure therefore I am lokking for shelp over here) overdone.

    The specs of my application are:

    -communication over 2 meters is oke
    -there is line of sight
    -of 2 pushbuttons I want the microcontroller to know (via wireless communication) when they are pushed. They are pushed only a few times per second at the max, they also can be pushed at the same time but not always

    Any recommendations of components to start with?

    Thanks for all the help, again.
  • ZootZoot Posts: 2,227
    edited 2009-02-11 16:33
    Use an IR emitter (LED) and an IR detector. Cost you less than $5.

    Then make your communication protocol SIMPLE. See the IR "how-tos" from Parallax as mentioned. I would do it like this:


    "Buttons" Stamp:

    1. Read buttons
    2. send "start bit" -- 3ms IR FREQOUT followed by a 1 ms "rest" (led off)
    3. send two data bits -- one for each button -- 2ms is "high" or one, 1ms is "low" or zero. Follow each with a 1ms pause.
    4. pause 10ms to let the other stamp deal w/the results
    5. go to step 1.

    If both buttons are pressed then your maximum time to transmit the data will be:

    3ms start + 1ms rest + 2ms "one" bit + 1ms rest + 2ms "one" bit = 9ms

    + 10ms pause = 19ms or about the time of servo pulse. That's 50 times a second, plenty fast. If neither button is pressed, or only 1, the transmission time will be slightly faster as the "zeros" are shorter.

    "Receiver" Stamp: (see Parallax IR notes regarding using of RCTIME rather than pulsin so as not to miss repeating pulse edges)

    1. PULSIN on the detector
    2. pulse ~ 3ms? yes -- go to step 3; no -- go to step 1
    3. two data bits received yet? yes -- go to step 8; no -- go to step 4
    4. RCTIME next pulse. pulse > 1.8ms and < 2.2 ms ? yes, bit = 1
    5. pulse < 1.2 and > .8 ? yes, bit = 0; no, bad pulse, clear data and back to step 1
    6. number of pulses = number of pulses + 1
    7. go to step 4
    8. button data received; do something with it
    9. go to step 1

    Last, there IS AN ACTIVITY like this (desktop communication between two Stamps) in the IR book (available as a download) from Parallax. Same protocol (3ms start, 2ms = 1, 1ms = 0).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ArnoNLArnoNL Posts: 15
    edited 2009-02-13 19:08
    Thanks, you're a great help!

    I've just ordered the parts at farnell. as soon as I get the parts I will write the code and keep you informed.



    Thanks again.
  • bdbbdb Posts: 30
    edited 2009-02-13 22:48
    First, thanks for the links to the App notes - looks like I can have many hours of fun there.

    Also, for the original poster, Parallax has a book and/or set on "IR Control for the Boe-Bot" that has a lot of projects of IR signals, including 2 Stamps talking to each other.·

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/infrared/List/1/ProductID/149/Default.aspx?SortField=ProductName%2cProductName
  • ArnoNLArnoNL Posts: 15
    edited 2009-02-14 10:08
    Thanks this is a very good book about starting with IR remote control!
Sign In or Register to comment.