hex705

the first creature to discover water was likely not a fish

Xbee – configuring the radios

with 6 comments

Once your Xbee is wired up, you need to configure it for your application.  For basic use we are only interested in 3 settings in the radios.  Advanced users will want to look at online docs / manuals to get a sense of what else is possible.


Most of the info in this post is discussed in depth by Tom Igoe in Making Things Talk, pages 193 – 206.

Configuring a radio for a simple network involves three steps: (1) assigning the radio a network (ID), (2) assigning the radio individual (MY) address, (3) assigning the radio a destination (DL,DH) or receiver.

Assign a Network Identity (ID)

The network ID identifies, or determines which radios can speak to each other.  Only radios with the same ID can communicate.  In most cases all of the radios in a single project will have the same ID.

Given that our radios are shared – you should always set the ID parameter for your project.

Assign an Individual identity (MY)

The MY address is the address of an individual radio. MY addresses are unique and each radio in your project should be assigned its own MY.

If two radios have the same MY then they will both receive all of the messages directed to that MY address.

Assign a Destination (DL, DH)

The destination parameter defines which radios will receive your message.  The destination is defined by 2 numbers DL – destination low, and DH- destination high.  For the most part you should set DH to 0.

You then set the DL value to match another radios MY.  All radios with DL // MY pairings will have a directional link (from DL to MY).

In their simplest mode xBee radios are a lot like telephones.  You have to tell your device which radio you want to call.  When configured manually each radio is only able to send messages to other radios on the same network (ID) with matching DL // MY parameters.

If you want to send and receive messages between two radios, set their MY and DL identically.  That way they will be able to talk to and hear each other.

Broadcasting Messages

When you set a radio’s DL parameter to ‘ffff’ (it is a hex number) it is in broadcast mode. When put into this mode, radios can send messages to all other devices on the network (ID) regardless of MY // DL pairings.

Settings for our Games

For the exercises we did these last two weeks the radios were configured as follows:

ID 3332
MY 0
DL  0
DH 0

It is worth considering how the rules of the various games would be relaxed or constrained by different settings.

xbeenet

Configuring the Radios

There are several methods for configuring the xBee radio.  If you own a PC or have a dual-boot Mac then you can use the manufacturer’s X-CTU software.  (All the Mac laptops are dual boot.  Some do not yet have the software – but we will correct that.)  On any machine you can use Tom Igoe’s Processing terminal program.  You can do this through terminal or any serial interface (including the Arduino environment).  You can even do it through Arduino code and reset a radio on the fly – useful if you need to send messages to different devices but don’t want to broadcast.  This last stage can be considered an advanced topic for this class – there are examples in the text – I won’t go too far into them.

Using X-CTU

This is the easiest way to configure the radios.  It is also the only way to upgrade their firmware.  You will not usually need to do firmware upgrades on school equipment – so I will return to that matter elsewhere.

RESTART one of the hybrid computing laptops and boot it up at a PC.  Connect a radio following any of the methods described in wiring an xBee.  Note you must connect before you launch the software on a Mac.  Don’t have a PC to test.  Launch the X-CTU software – icon should be on the Desktop.

The default screen is the PC settings tab.  There is a large menu for COM port setup.  Select the visible port (on a PC COM is for communication – it is a term carried over from the olden days.  COM ports are often aliased USB ports on current machines).  Confirm that serial settings are: Baud – 9600, Flow Control – none, DataBits – 8, Parity – none, stop bits – 1 (these are all defined in my serial notes on blackboard).

Next, click the Modem Configuration Tab.  Under model parameters and firmware on the left click Read.  A huge number of Settings appear – these were read from the radio itself.  You need to set the ID, MY, and DL, DH options under the first menu – Networking and Security.

To edit any value click on it and form box appears.  Reset to the value of choice.

Write this data to memory after you have changed all of your parameters by clicking Write.  It is beside Read in the menu near the top.

Repeat this for all of your radios.

Using Processing

Download and launch Tom Igoes xBee-terminal for Processing.  This system is less verbose than the X-CTU system above but it is more than functional.  As it is effectively a hack – you need to do a little more legwork. As I only have single boot Mac machine this is my usual process.

When you run this code the first time, you will need to set the serial port – just as we have been doing all term.  Check the serial.list() array and select your port.

When you run this code you will get a simple terminal screen.  It lists the port, what you are typing, and what you Receive from the radio.  Check the text pages 198 – 206 for numerous variations and many more details.

These radios follow historic modem commands.  Modems used to be programmed with a series of commands that were prefixed with AT.  All settings and actions below have AT as a prefix.

To begin, you must put the radio in Command Mode (default mode is communcate).  In the following, type the characters between <> not the <> themselves.  The ‘\r’ means return.  The radio will default back to communication mode within 10 sec of no input.  So you may have to type +++ a few times during you session with this method.

<+++>

the Radio should send OK – if it doesn’t, check your wiring.   Don’t TYPE return!!  just +++ and then wait.

Type:

<ATID\r>

xBee will return the current ID setting, small case works too — <atid\r> will give same response.

Similarly you can check and other setting MY, DL, DH by prefacing with AT.

<ATMY\r>
<ATDL\r>
<ATDH\r>

To change a setting type AT then the setting ID then the value of the attribute.  So to change the network we need to reset ID.  We would set the ID to 1111 with the following:

<ATID1111\r>

typed without spaces.  Confirm that you entered the value with

<ATID\r>

now save your changes by writing (WR) to the xBee.

<ATWR\r>

Always save after you make a change!  You can double check by disconnecting and then reconnecting the radio and querying its values as above.

Using a generic Serial InterFace

The biggest challenge to using a generic serial interface is the fact that xBees do not send new-line commands at ends of statements.  This means everything from the radio will appear to overwrite itself on screen (we saw this during our games).

If you get comfortable with the patterns with the Processing interface then this isn’t an issue.  I would not use this method until you have configured a few radios with the above methods – it can be confusing.

The process is the same as above – but with really garbled feedback – hence Tom’s decision to write the terminal software.

Advertisements

Written by hex705

November 7, 2008 at 9:42 am

6 Responses

Subscribe to comments with RSS.

  1. This is a fantastic tutorial! Thank you!

    raf

    February 7, 2009 at 2:09 pm

  2. The diagram is really helpful and so easy to understand.

    raf

    February 7, 2009 at 2:12 pm

  3. We stumbled over here from a different page and thought I may as well check things out.

    I like what I see so now i’m following you. Look forward to looking at your web page yet again.

    Katja

    May 9, 2013 at 3:00 pm

  4. Every weekend i used to go to see this website, as i want enjoyment, for
    the reason that this this website conations
    in fact fastidious funny stuff too.

  5. I can’t get it to work….

    hesham

    August 21, 2014 at 11:18 pm

  6. Great information is shared.Thanks.The diagram above is cool.

    Dj

    October 9, 2014 at 10:00 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: