Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing Xbee wireless modules with BS2 — Parallax Forums

Interfacing Xbee wireless modules with BS2

DileepDileep Posts: 4
edited 2007-05-16 14:42 in Learn with BlocklyProp
Hii all,

· As part of our project, we have to interface Xbee· wireless modules with BS2...
But we couldnot able to communicate successfully through these Xbee modules..(may be the problem lies in source codes)
Iam attaching the source code files for BS2. Please check it out and Could anyone please help·us out with proper basic stamp codes so that we can accomplish BS2 to BS2 wireless communication. Waiting in anticipation

with Thanks,

Dileep Kumar,
Grad Student,
Univ of Kansas
dilk@ku.edu

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-11-29 17:50
    The code looks good, I can test it at home tonight. Can you take a picture of your hardware setups?
    Or describe how it is connected?

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • aerodudeaerodude Posts: 22
    edited 2006-11-29 18:05
    Hi Martin,

    Dilip and I are doing this project. Want to mention that in the sat_xbee_compass_tx.bs2, we are trying to send the Electronic compass data to another BS2 using XBee. We will try to send the hardware setup by tonite.

    satish
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-11-29 23:44
    I tested this out, and besides mine not having the compass module causing it hang in the DO-LOOP (which I bypassed), it seems to work fine. What indications are you seeing on the boards and the DEBUG windows?

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • aerodudeaerodude Posts: 22
    edited 2006-12-07 05:03
    Hi Martin,

    Today I received AppBee modules. I am working on it right now. I was running the Config_XBee_Example.bs2 program to see if i can receive "Hello Node!".

    DO
    SEROUT TX,Baud,[noparse][[/noparse]"Hello Node!",CR]
    PAUSE 1000
    LOOP

    On the other end i am receiving HloNd!.......means its skipping every 2nd character. why is that? I tried with Baud 396, 188 for which I dont even see those alternative characters...its showing some garbage at constant rate. Plz help!!!

    --satish
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-12-07 05:32
    Hi Satish,
    Glad you received them.

    On the receiving end I assume you are using flow control and a loop to grab each character one at a time?· What happens is when RTS goes high to request a byte, it gets it, but the second one is on the way before the BASIC Stamp brings RTS low again, so every other byte is missed.

    When you say you changed Baud rates, did you change the XBee's baud rates too?

    String manipulation is never real smooth with BASIC Stamps, it's easier to send decimal values and such, but you can use the STR modifier to catch a series of characters into an array.

    Sounds like you are getting there though.

    -Martin


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • aerodudeaerodude Posts: 22
    edited 2006-12-07 07:21
    Hi Martin,

    Though one day shipping for AppBee costed some money..its worth it. I will try with STR later as I dont need to use any strings now. I tried sending compass data wirelessly and its working perfectly [noparse]:)[/noparse] now trying to send GPS data wirelessly.

    Do you have any sample codes for simultaneous communiation between two appbee's ?? Means lets say one module is constantly sending some data as the other module listening to that and sending some commands/data back? It will be great help to our project and I guess we can do some fun stuff (serious stuff) with tht.

    --satish
  • aerodudeaerodude Posts: 22
    edited 2006-12-07 07:34
    Martin,

    This is the code at the receiving end....

    RFin VAR Byte
    DO
    SERIN RX\RTS,Baud,[noparse][[/noparse]RFin]
    DEBUG RFin
    LOOP

    And in your reply you asked if I changed the XBee's Baud rate....what exactly do you mean by that? I changed the Baud value in both the codes as 84/188/396 . I guess this is the XBee baud rate !!!

    Have a general question....what difference it makes in sending a byte variable and word variable wirelessly? How much buffer that an AppMod can store before processed by BS?

    --satish
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-12-07 13:50
    No, the XBee is not like the 433MHz units, it has to talk to the controller, so it has an AT command to be configured for Baud rate (ATDB). The Xbee's actually communicate with each other at 250Kbps.

    Am I correct this is a college project? You need to start reading documentation a little deeper and researching. Parallax has a program for bringing data into Excel, StampDAQ. I'm sure a google search would have turned it up.


    The Xbee holds around 200 bytes in the buffer I think, so between a byte and word it is neglible. The XBee uses a real protocol, so what little data you send is emcompassed around many other bytes.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-12-07 13:59
    aerodude said...
    Hi Martin,

    Though one day shipping for AppBee costed some money..its worth it. I will try with STR later as I dont need to use any strings now. I tried sending compass data wirelessly and its working perfectly [noparse]:)[/noparse] now trying to send GPS data wirelessly.

    Do you have any sample codes for simultaneous communiation between two appbee's ?? Means lets say one module is constantly sending some data as the other module listening to that and sending some commands/data back? It will be great help to our project and I guess we can do some fun stuff (serious stuff) with tht.

    --satish

    Satish,
    Since the Xbee's (AppBee's are just the board they plug into) use a full protocol, clear channel assessment, etc etc, their is no special code needed for 2 to talk back and forth. The units check before sending, do error checking and retries for high reliability of comms.

    A project I am currenty involved with is montioring 5 units and collecting data from the real time. When told to, they all start sending data back to unit 0, 5-10 times a second. At any time I can tell them all to stop from the base unit (0). Each has their own address so I can wake up any or all. And all the data gets dumped directly into Excel.

    Read the docs,
    Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • aerodudeaerodude Posts: 22
    edited 2006-12-08 00:23
    Thanks Martin. I didn't really search the web for data logging...i just posted it. Will do now and get back if have any doubts.

    --satish
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-10 16:37
    Help I just got my xbee and it works great with the software that came with it. I can't get it to work with the stamp. I can't even get the loop back from the stamp editor to come back yes and it does with the X-CTU software. Why isn't the stamp editor seeing the port and loop back?

    I hope I've put this in the right place, I'm new to using forums.

    dennis@htshvac.com
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-05-10 16:51
    Hi Dennis,
    How are you connecting that you would expect to see loopback using the Stamp Editor?

    I have some documentation on this page at the bottom that may help:
    http://www.selmaware.com/appbee/

    -Martin


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-13 14:30
    I'm connecting it up so that I can program it. I use the stamp identify button and if its connected to the stamp I get loop back and echo, but if its connected to the Xbee I don't get that and I can't see anything from the debug either. If I run the X-CTU in term mod I can see the debug sent back to the computer. It seems like the stamp editor doesn't see the connection from the Xbee, but it does see it as a com port.

    What am I missing here?



    Thanks

    Dennis
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-13 14:41
    The Stamp Editor won't work if you try to use it with a packetized wireless link. It depends on exact timing of exchanges between the Editor and the Stamp and, with the packetization of data and transmit/receive delays, the Editor can't maintain the connection with the Stamp.

    You can use the xBee (and other wireless links) for data transfers using SEROUT/SERIN (works nicely), but you can't use it for programming.
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-13 15:56
    OK, thanks. I didn't know this. So I can send the debug back with the xbee?

    I really wanted to be able to program and make changes to the stamp with the xbee, that would have been nice.

    I thought I saw something for sending the debug back to the stamp on here, but not really sure where it was.

    Is that easy or there many timing problems?

    I wanted to be able to put the stamp in a plane to get info back from the stamp or propeller chip.

    Also is the anything that could be used to program the stamp wirelessly?

    And I really wish the stamp tech people told me this last week, I would have thought they knew about this. What I called they were no help at all. Just said it was the xbee problem and they couldn't help me at all.

    Also there is a problem with the stamp being 5 volts· and the xbee at 3.3volts, any easy quick fixes for this that you know of that I can do with out buying more things right now?

    Thanks

    Dennis
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-13 16:14
    This might sound really dumb, but can I talk to a stamp and send the program to one to program the other one? That is will one stamp able to program another?

    Am I just asking for too much here?

    I guess you can talk 2 way with the xbee too, right?

    I'm new to the basic stamp and just not too sure what I can really do with it yet.

    I'm getting the propeller to work with too. That would control the servos better. I got the BS2 controlling 2 servos now and that is working good. It can't do more than 2 without causing problems as far as the servos moving smoothly.

    I want to end up with gps in a air plane and an internet thermostat using ds1620 or ds1820. Now to find the time to learn this and to do it. LOL

    Thanks

    Dennis
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-13 16:42
    What about a wireless usb to use? Is there anything that might work for programing the stamp and getting debug info without problems?





    Thanks

    Dennis
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-14 03:18
    Dennis,
    Selmaware's AppMod xBee adapter takes care of regulating the 5V down to 3.3V and buffering the Stamp signals so they're compatible with the xBee. They also have another adapter that does the same, but has a slightly different form-factor. If you haven't, look at their website (www.selmaware.com).

    Wireless USB should work, but it depends so much on the timing of the wireless link. You'd just have to try it and be prepared for it not to work or not work reliably.

    I'm not aware of any attempts to program a Stamp using another Stamp. I don't think it's possible (because of timing and speed requirements). You could use an SX or a Propeller. There's a commercial device (the Stache) used for field updating of Stamps, but it's not wireless. You could use a Propeller since it has enough memory to store several "slots" of Stamp program. You could use the Propeller with a wireless link like an xBee, send the compiled Stamp program, and then program the Stamp from the Propeller once the whole Stamp program has been received.

    A Stamp ought to be able to handle 4 servos without problems as long as you're not trying to do a lot of other stuff between servo pulses. You'd have to post your code to see why it doesn't work better. With a servo pulse taking up to 2.5ms, 4 takes only 10ms. You've got another 10ms to read a sensor or two and do a little bit of computation before you run out of the 20ms between servo pulses.

    xBee provides a full duplex channel. That means it can send and receive.
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-14 18:42
    Yes thanks for the info. The stamp I have now is the old bs2, its· the slower one and after 2 servos it starts to show problems. I've ordered a faster stamp and that should take care of it. I tried many times to get 4 servos to work and the program was only reading then sending out the pules out with nothing else being done. 3 worked ok but you could see the delay to the servos and 4 was bad.
    So the BS2p should be good to even to may be 6 servos I think.
    As far as the 5 to 3.3 volt problem it looks like I can use a 74ls244 to fix this or save time and get something from selmaware.
    I would like to find more drawings for stamps that have been used to control things to get ideals from. I've ordered book and kits from parallax to look at and learn more on how to do what I want to.
    I've had this old stamp sitting around for years and played with it a few times, now they have them that will read the 1-wire parts easier so I may be able to do more things with Building automation or home control. And even the gps air plane.
    I wanted to make a plane fly from my house to a friends and drop off something and come back or evn fly over and take some pictures and come back. I'm sure I'll have a lot of testing to try and make sure that nothings wrong will happen bad and even thinking of it, it may be a bad ideal in case something went wrong, but its a start.
    I guess in the longrun I'll need wireless link that will go 2 or 3 mile with a good connection and send video back.
    But its going to take some learning, time·and playing to make all this work.
    Again thanks for your help.
    Can I ask what you do with the stamps?

    Dennis

    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-14 18:54
    I've mostly used them in sculptures (my wife is an artist). They've done things as simple as pulsing an LED (to look like a heartbeat) to an interactive piece that plays a sort of game. There are game pieces that have 1-wire buttons attached to them. When the "right" pieces are inserted into holes in a board, a servo opens a flap and a little sound recorder (from Quadravox) plays a little song while lights (LEDs) flash in patterns. It was this last one that I got a Stache in case an update had to be loaded into the Stamp when I wasn't around.
  • HTSystemsHTSystems Posts: 7
    edited 2007-05-16 08:29
    OK, here it the program I used. I got the faster bs2p ( old bs2) and it seems to be running the same. May be the PULSIN takes the same time to read even in a faster stamp. If I use slow servos I don't see the problem as much, so may be that can be part of the fix or use a servo controller for the servos. I want the transmitter to be able to control the servos as if nothing was there and the stamp to take over controlling them if needed. What am I missing here or did I get it with the PULSIN reading taking the same time?





    ' PULSIN.bs2

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    Pulse1·········· PIN···· 0 ' pulse input pin
    Pulse2·········· PIN···· 1
    Pulse3·········· PIN···· 2
    Pulse4·········· PIN···· 3



    PIN4············ PIN···· 4
    PIN5············ PIN···· 5
    PIN6············ PIN···· 6
    PIN7············ PIN···· 7
    PIN8············ PIN···· 8
    PIN9············ PIN···· 9

    time1··········· VAR···· Word
    time2··········· VAR···· Word
    time3··········· VAR···· Word
    time4··········· VAR···· Word



    Main:

    · PULSIN Pulse1, 1, time1···· ' measure positive pulse
    · PULSIN pulse2, 1, time2
    · PULSIN pulse3, 1, time3
    · PULSIN pulse4, 1, time4


    ········· HIGH 10········ 'LED test
    ········· LOW 10
    ········· PULSOUT 4, time1
    ········· PULSOUT 5, time2
    ········· PULSOUT 6, time3
    ········· PULSOUT 7, time4

    · GOTO Main
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-16 14:42
    One thing to remember is that regardless of the speed of the BASIC Stamp Module each PULSIN still has to wait for the complete pulse before the next one can be read. I wonder if part your latency issues are in the reading of the pulses themselves. Digital servos would certainly help as they don’t require as frequent of refreshing as standard analog servos.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.