Xbee Tips And Tricks ( Help)
chris jones
Posts: 391
Hello
i am working on a cool project and will rely on my xbee modules a lot, i have had a lot of issues getting my xbees off the ground but was a hardware issue all along. So i would like to start this forum thread to see if i can get some help from the community on my ideal’s and questions i have about my xbees.
Current Setup
2 prop demo boards
2 xbee S1
2 LCD
2 Adapter boards ( http://www.parallax.com/Store/Access...2/Default.aspx )
1 USB Adapter board
i am working on a cool project and will rely on my xbee modules a lot, i have had a lot of issues getting my xbees off the ground but was a hardware issue all along. So i would like to start this forum thread to see if i can get some help from the community on my ideal’s and questions i have about my xbees.
Current Setup
2 prop demo boards
2 xbee S1
2 LCD
2 Adapter boards ( http://www.parallax.com/Store/Access...2/Default.aspx )
1 USB Adapter board
Comments
You should get at least one of these:
http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/SortField/0/catpageindex/2/Level/a/ProductID/643/Default.aspx
When you put an XBee on that board and connect it through a USB cable to your computer, you can use the free XCTU software (available at Digi.com, links on the Parallax site) to read whatever information you want to from the XBee, and also to change the various settings. That's the easiest way to do those things.
If you remove the USB cable from that board, and you've installed headers, it can also be used to mount the XBee on a breadboard. Otherwise you'll want another adapter to mount your second XBee on, so you can connect it to your Prop demo boards. Since the Prop is 3.3V (which matches the XBee), you can simply use one of these:
http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/SortField/0/catpageindex/2/Level/a/ProductID/642/Default.aspx
I'm not sure what you mean by "my xbees Mac address" - are you talking about its hardware serial number? The ATSL and ATSH commands will get you the high and low words of the serial number, but normally you use other means of addressing an XBee, notably the "MY" source address, in combination with the PANID (network ID number). Alternatively, you can set and use a unique Node Identifier label for each of your XBee modules. Your other XBees can use those addresses/PANIDs/NIs to address a specific XBee.
And one i set the ID how do i access it from my propeller chip?
1 - You can mount the module on your USB board and use XCTU to read the current settings, make the changes you need, and then write the new settings to the module. They will stay set that way then until you explicitly change them.
2 - You can read and change the settings through your Propeller software. Of course you can write the changes you make that way to nonvolatile memory as well, but it's fine to just set up your software so that when the program runs, it makes the changes, so that it doesn't matter what the settings are before that point.
Reading and setting the settings through the Prop chip is a matter of using the XBee object in the OBEX (or of just sending the serial data yourself through your own code, if you prefer). Here's a snippet of Spin code I'm using:
You should read through the XBee object to get a sense of what can be done, and how to do it.
I would try declaring a string, then using AT_Config with ATMY and a pointer to your string to get the MY address into that string.
ID := XB.AT_Config(string("ATMY"))
PUB AT_Config(stringptr)
{{
Send a configuration string for AT Mode
XB.AT_Config(string("ATMY 2"))
May also be used to query
XB.AT_Config(string("ATMY")) ' request value
addr := XB.RxHEX ' accept value
FOR Transparent (Non-API) MODE USE
Be sure to issue .AT_Init once at startup
}}
You can use
AT_Config(string("ATMY"))
to request the value, but you need another line of code accept the data returned by the XBee:
ID := XB.RxHex
-Martin
i seem to have something messed up can you glance at my code and see if everything is correct.
XB.AT_init
XB.AT_Config(String("ATMY 0")) ' Config to receive as Module 0 to match XBee-MAWD telemetry output DL setting.
_________________________________
its using pin 0 to get the setings P0 DOUT
LCD.Dec(value)
or
LCD.Hex(value)
since the ID is stored as a value and not a string.
Also, your repeat loop has this being done continuously with no delay in it - probably not a good idea. Read and display once and end with a repeat for testing.
You also have ID defines as an array, where it only needs to be a word value - again, not a string that is returned.
Some untested revisions... Ok, I've not used the new forums much yet, and how to insert code in a post escapes me right now, so attached.
XBee_LCD.spin
Good luck!
-Martin
You don't need to set your XBee's MY before reading it. Every XBee has a MY address, whether you've ever changed it or not. I believe they're shipped with their MY set to 0, but I'm not certain about that. Regardless, you should be able to read the MY address even if you've never set it.
It's good code for reading the XBee. Did you get any other errors?
Start slow, be sure you can read the XBee and send to the PST instead, then add in your LCD stuff and test that.
I tested the code I sent without the LCD. It read it.
-Martin