Read an Excerpt
  The Hands-on XBee Lab Manual 
 Experiments that Teach you XBee Wireless Communications 
 By Jonathan A. Titus 
 Newnes 
 Copyright © 2012   Elsevier Inc. 
All right reserved.
 ISBN: 978-0-12-391416-3 
    Chapter One 
  Experiment | 1    
  Introduction to the  X-CTU Software  
  
  REQUIREMENTS  
  1 XBee module  1 USB-to-XBee adapter (see text)  1 USB cable—type-A to mini-B  Digi X-CTU software running on a Windows PC, with an open USB port  
  
  INTRODUCTION  
  In this short experiment you will learn how to use the Digi International  X-CTU software to program and control XBee modules. These modules  use a simple serial communication protocol that connects them to external  devices, such as a PC and microcontroller integrated circuits, through a built-in  Universal Asynchronous Receiver Transmitter (UART). The UART in the  XBee modules operates by default at 9600 bits/second, which makes it compatible  with UARTs in other equipment, thus simplifying communications.  
  Many XBee commands use standard alphanumeric characters in the  American Standard Code for Information Interchange (ASCII), which means  you can simply type on a PC keyboard to perform XBee-module operations  without having to write programs for a computer. Thus early experiments in  this book will not require a microcontroller (MCU), although readers familiar  with MCUs will quickly understand how to apply them, if they choose. For a  table of ASCII characters and values, see Appendix G.  
  The X-CTU software "connects" with an XBee module via a USB connection  that acts like a "virtual" serial port. The software handles the USB drivers  needed to make possible these serial communications from a Windows PC.  At the XBee end of the USB cable you need an XBee-to-USB adapter such  as the XBee USB Adapter Board (part no. 32400) from Parallax or the XBee  Explorer USB (part no. WRL-08687) from SparkFun Electronics. Both adapters  provide several small LEDs that indicate operating conditions. Refer to  the respective adapter data sheets for more information. You must have one of  these adapters to perform the experiments in this book.  
  Step 1. Digi International provides free X-CTU software that you can  download from the Digi Web site at: www.digi.com. Search for XCTU (no  hyphen) and find the entry, "Knowledge Base Article – X-CTU (XCTU) software"  and click on it. On this page, click on the link at the bottom of the page,  "Click here to go to the X-CTU download page." Then download the latest  version of the X-CTU software and install it. Do not start the X-CTU software.  
  Step 2. Attach the XBee-to-USB adapter to the USB cable and then attach  the USB cable to your PC. If possible, use a USB port on your PC. Extension  USB ports on monitors or USB hubs sometimes cause problems. Do not insert  an XBee module in the adapter now. You will do so shortly. Follow the adapter  manufacturer's instructions (if any) that describe how to load drivers that configure  the USB port to act like a serial port. If you plug in the XBee-to-USB adapter  after you start the X-CTU software, the software might not detect the adapter.  
  Step 3. Start the X-CTU software as you would start any other program.  The opening display should appear as shown in Figure 1.1. If not already  selected, click on the PC Settings tab. In the Serial Com Port window, you  should see text similar to:  
  Communications Port (COM1)  USB Serial Port (COMxx)  
  where the xx represents a 1- or 2-digit number. Use your mouse to select this  line of text, which should highlight it to tell X-CTU to use the COMxx port to  connect to the XBee-to-USB adapter. Windows assigns COM-port numbers in  sequence and on my lab PC the adapter appeared as COM19. Many late-model  PCs lack a serial port, so you might not see the first line shown above for COM1.  
  The X-CTU software uses the following settings to communicate with an  XBee module:  
  Baud          = 9600 (Equivalent to 9600 bits/second)  Flow Control  = NONE  Data Bits     = 8  Parity        = NONE  Stop Bits     = 1  
  
  The X-CTU software should start up with these settings, but if not, use  your mouse to change them to the settings shown above.  
  Step 4. Disconnect the USB-XBee adapter board from the end of the  USB cable and insert an XBee module into the socket strips on the adapter  board. Ensure you have matched the placement of the XBee module with that  specified by legends on the adapter, or diagrams in the adapter instructions.  Figure 1.2 illustrates possible hardware problems.  
  After you have properly inserted the XBee module into the USB-to-XBee  adapter, reconnect the adapter to your USB cable. Depending on the adapter  you use, you might see LEDs turn on or flash. (On the Parallax adapter, a  yellow and a green LED turned on and a red LED flashed.)  
  Step 5. In the X-CTU window again look at the PC Settings section. Click  on the PC Settings tab at the top of the X-CTU window if you have clicked on  other tabs.  
  In the PC Settings area, find the button on the right side marked Test/  Query. Click on it to test the electrical communication connection to the XBee  module. A "Com test/Query Modem" window will open and it should appear  as shown in Figure 1.3.  
  If you see the error message, "Unable to communicate with modem,"  shown in Figure 1.4, the X-CTU program cannot "find" the XBee module.  Click on Retry to try communications again, or click on OK to go back to the  PC Settings window. You also can close the X-CTU program and restart it after  you confirm you have the XBee-to-USB adapter properly connected to your  PC. The X-CTU program usually does not recognize an adapter board plugged  in after you start the software. Also recheck the settings given in Step 3.  
  Step 6. The information shown earlier in Figure 1.3 indicates this experiment  used an XB24 XBee module with firmware version 10E6. Depending on  the module you have, model and firmware information might vary from that  shown here. The version information uses hexadecimal, or base-16, values.  
  Step 7. After you have seen the Modem type and Modem firmware version  information in the Com test/Query Modem window, click on OK and then  select the Terminal tab to open the X-CTU terminal window (Figure 1.5). This  window lets you type a message to control the attached XBee module and to  see responses from the module. The cursor should already flash in the white  message area.  
  The XBee modules rely on a set of "AT" commands to set operating conditions  and request actions. Years ago engineers created dial-up modems that  used similar AT commands to set up modem conditions, initiate communications,  dial phone numbers, and so on. Digi International lists the set of XBee  AT commands for the XBee24 modules in the document "XBee/XBee-PRO  RF Modules" available on the company's web site: http://ftp1.digi.com/  support/documentation/90000982_D.pdf as revision D, dated 25 July 2011.  Digi might have posted a newer version, though.  
  An AT command begins with three plus signs, +++, sent from your PC.  Type +++ in the terminal window. DO NOT press Enter or any other key  after you type +++.  
  You should see the +++ printed in blue and after a few seconds, the letters  OK should appear in red at the end of the plus signs (Figure 1.6). The "OK"  message lets you know the XBee module can accept AT commands. An XB24  module remains in this "AT-command" mode for about a minute. If you don't  type in a command within that time, you must type  again and wait for  the XB24 module to again display "OK" in the terminal window.  
  Step 8. In this step you will put the XBee module into the AT-command  mode and then send it a command. Review the command sequence below  before you do anything more:  
  +++  ATVR [Enter]  
  Now, type the three plus signs and wait for the "OK" response: +++ OK  
  Then, type ATVR and press Enter. Note what you see in the terminal  window. In my lab, I saw:  
  +++ OK  ATVR  10E6  
  The ATVR command sends the AT prefix that lets an XBee module know a  command will follow. In this case, the VR – Firmware Version command asked  the module to reply with the version number for its firmware.  
  Do not put an XBee module in AT-command mode and type random letters  just to see what happens. Doing so could alter internal settings that affect an  XBee module's operations.  
  If you type an invalid AT command or a valid AT command the XBee module  cannot perform, it responds with ERROR in red letters below the latest AT  command.  
  Step 9. If you plan to go on to Experiment 2 now, leave your XBee module  connected to the USB-XBee adapter, leave the USB cable connected to the  adapter and your PC, and do not close the X-CTU window.  
  Note: For more information about the origin and use of the AT modem  commands, visit: en.wikipedia.org/wiki/Hayes_command_set.  
  
  
 Chapter Two 
  Experiment | 2    
  How to Change XBee  Module Configurations  
  
  REQUIREMENTS  
  1 XBee module  1 USB-to-XBee adapter  1 USB cable—type-A to mini-B  Digi X-CTU software running on a Windows PC, with an open USB port  
  
  INTRODUCTION  
  In this experiment you will learn how to use the X-CTU software to program  an XBee module for specific actions. You will make changes in experiments  that will follow, so please do not go on to the next experiment until you understand  how to change settings and confirm them.  
  Step 1. You must have an XBee module plugged into a USB-XBee adapter  and the adapter must connect to a Windows PC USB port. You also must run  the X-CTU software. If you do not have this equipment set up and the X-CTU  software running, please complete Experiment 1 before you proceed.  
  Step 2. Check the connection between your PC and the XBee module:  Within the X-CTU window, click on the PC Settings tab and ensure you have  the communications set for Baud: 9600, Flow Control: NONE, Data Bits: 8,  Parity: NONE, and Stop Bits: 1. Click on the Test/Query button and the Com  test/Query Modem window should open and display "Communication with  modem..OK" and other information. (If you do not see this message, go back  and repeat Experiment 1 and see the Troubleshooting section in Appendix H.)  
  Click on OK in the message window.  
  Step 3. Click on the Modem Configuration tab. This window lets you  observe and change all of the operating information internal to an XBee  module. At this point the configuration window could be blank (white) or  it might contain information as shown in Figure 2.1. It does not matter.  (Digi International often uses "modem" to describe its XBee modules. To me,  modem sounds archaic, so I will avoid using it as much as possible.)  
  Step 4. Before you proceed, uncheck the small box "Always update  firmware" on the left side of the Modem Configuration window as shown in  Figure 2.2. If you check this box, or leave it checked, the X-CTU software  will attempt to update the firmware in an attached XBee module. If that update  fails, you could end up with a non-functional module. Do not update firmware.  
  Step 5. Before you use the X-CTU software to change configuration information,  you must ensure the software knows the type of module and the function  set you plan to use. When you work with a module, the Modem: XBee  should show XB24 and the Function Set should show XBee 802.15.4, as  shown in Figure 2.3.  
  (Continues...)  
  
     
 
 Excerpted from The Hands-on XBee Lab Manual by Jonathan A. Titus  Copyright © 2012   by Elsevier Inc..   Excerpted by permission of Newnes. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.