Programming multiple AVR/Arduino boards with XBee

Multi AVR programming using XBee

One of the major issues we have with the project is that we’re working with many robots (our goal is to make about 50 of them). Planning ahead, we thought it would be nice to be able to program them all at once to accelerate the development, especially towards the end of the project. We thus decided to experiment with multi-board wireless programming using XBees.

Step 1 : One-to-one wifi programming

There’s not much information on the web on how to program many AVR/Arduino using XBees but there is information on how to program one board. The first set of instructions we found are from LadyAda but we had better results with the instructions for the Arduino FIO.

The tutorial gives a detailed account of the different parameters that need to be set for the master (transmitter) and the slave (receiver). If you follow it step-by-step it should work fine. You can also check the extra tips they give if you run into trouble. We even tried with a very big program (50k!) and it works great.

The only thing we had trouble with is that the data transmission quality was bad and dropped quickly as we increased the distance between the XBees. This was likely caused by interferences with other wifi networks in the area. We solved this by changing to a different channel (the XBee CH parameter).

Step 2 : One-to-many wifi programming

In the Arduino FIO guide they mention: “Note: If you set the programmer’s destination address (DL) to FFFF, it will re-program all Fios in its PAN ID. To program one Fio at a time wirelessly while others are on, set the programmer’s DL to that Fio’s MY address.”

Basically, you have two choices: sequential or parallel programming. In the case of sequential programming, what you would do is more or less something like:

  1. Assign a unique MY address to each slave
  2. For each address do the following:
    1. Change the master’s DL to the slave’s address
    2. Upload the program

The advantage of this is that you get a chance to check that each board was programmed successfully before moving on. The disadvantage is that it takes as much time as there are boards: it just automates the switching from one board to the next for you.

(Notice that at this step we’re working with only two slaves.) We didn’t try that technique (yet). Instead we used the parallel programming trick. For this, you set the master/programmer’s DL address to FFFF. At first it didn’t work because all the slaves were sending data back to the master which seemed to overflood it. We tried to have only one slave return data back by setting it’s DL to the master’s MY address and by setting the other slave’s DL to an unexisting MY address, but this didn’t work well either.

We finally got it working by cutting the physical connection between the AVR first UART TX pin and the XBee’s TX. This worked great and seems stable, even for large programs and high baud rates (57600). We yet have to test it with more boards than two.

The files:

Leave a Reply

Your email address will not be published. Required fields are marked *