This article shows how you can program a Firewing main board using a wireless XBee module. This is extremely useful if your Firewing board is located in a particularly inaccessible place. Even if it accessible, wireless programming can really help debugging. For example, if you have a little robot scuttling about, being able to quickly and easily upload new firmware without having to use cables is a real plus. For this article, a Sparkfun Explorer Board was used to act as the transmitter and a Firewing XBee Shield was used for the receiver.
The Firewing XBee shield has a number of very useful features. For example, it has a build in micro SD card slot and a large prototyping area. You can also switch the XBee RX and TX pins between pins D0 and D1 or D2 and D3 on the Firewing board. Both of these pin sets support hardware UART. Most importantly, it has all of the extra circuitry needed to support remote bootloading - that is, it can process a remote signal and force the Firewing main board to perform a software reset which will initiate the bootloader process.
The modules used for this project are what are known as 802.15.4 or Series 1. These are very easy to configure and come in different power options. The stated range for the low power versions is 100 ft (30 m) line of sight. For the high power versions, it is about 1 mile (1.6 km) line of sight. In reality, ranges will be much less in a urban environment. For this project, on chip antennae, low power XBee modules were used (XB24-API-001). Please note that at the time of writing, the "on chip" antennae versions have been superseded by the "PCB antennae" modules, but will work in exactly the same way.
You will need to configure your XBee modules to act as transmitter and receiver. By far the easiest way to do this is by using X-CTU. This is a program supplied by Digi (the people who make the XBee modules) and you can download from here. Click on the "General Diagnostics, Utilities and MIBs" option to reveal the X-CTU installations available for download.
You will also need a board that connects to your PC or laptop, like the Sparkfun Explorer Board. When plugged in, the board will enable the XBee module to communicate with the X-CTU configuration software. The board will also act as the transmitter when bootloading, which will be discussed later.
Configuring the XBee Modules
Assuming X-CTU is installed and you have a suitable XBee host board plugged into your PC or laptop, you can now configure each module to act as transmitter and receiver.
- Using X-CTU to configure for RX. When configured, this module should be plugged into the XBee Shield.
- Using X-CTU to configure for TX. When configured, this module should be plugged into the explorer board.
Configuring the Explorer Board
The Firewing bootloader uses DTR to perform a software reset, which we somehow need to send to the remote XBee shield. To support this, the explorer board needs a small wire soldered between "DTR" and "DI03". When the Firewing loader asserts DTR, the message is transmitted via the XBee's DI03 pin, which is received by the XBee shield and a software reset is performed. As previously stated, the Firewing XBee shield has all of the circuitry needed to support a remote software reset, so no hardware modifications are needed.
The explorer board uses a FTDI USB to serial chip which initiates a "Serial Enumerator" transaction when the board is plugged in. The XBee module on the receiver really does not like this and it can, in some circumstances, cause the receiver XBee module to become bricked. Don't panic though, the solution is easy. Just disable the serial enumerator option from the FTDI advanced panel and all we be well. Instructions on how to do this and also how to unbrick and XBee module can be found here.
Configuring the Bootloader
By default, the Firewing loader will try and find a "Firewing Communications Port" when bootloading. However, this process will fail because no Firewing main board is connected directly to the PC or laptop. To change the loader configuration, select the little drop down arrow next to the Firewing IDE "build" button, as shown below:
Then select this option again to invoke the change parameters dialog box, as shown below:
and change the -cCOM option to tell the loader which port the explorer board is attached to.
If you have followed all of the above instructions, you should now be good to go. Make sure that the Firewing XBee Shield switch is in the UART position and power is applied to the main Firewing board. All you now need to do is Press F10 in the Firewing IDE to compile and then program your remote Firewing main board. Have fun!