- Shopping Bag ( 0 items )
Get the practical knowledge you need to set up and deploy XBee modules with this hands-on, step-by-step series of experiments
Get the practical knowledge you need to set up and deploy XBee modules with this hands-on, step-by-step series of experiments
The Hands-on XBee Lab Manual takes the reader through a range of experiments, using a hands-on approach. Each section demonstrates module set up and configuration, explores module functions and capabilities, and, where applicable, introduces the necessary microcontrollers and software to control and communicate with the modules. Experiments cover simple setup of modules, establishing a network of modules, identifying modules in the network, and some sensor-interface designs.
This book explains, in practical terms, the basic capabilities and potential uses of XBee modules, and gives engineers the know-how that they need to apply the technology to their networks and embedded systems.
Jon Titus (KZ1G) is a Freelance technical writer, editor, and designer based in Herriman, Utah, USA and previously editorial director at Test & Measurement World magazine and EDN magazine. Titus is the inventor of the first personal-computer kit, the Mark-8, now in the collection at the Smithsonian Institution.
The only book to cover XBee in practical fashion; enables you to get up and running quickly with step-by-step tutorials.
• Provides insight into the product data sheets, saving you time and helping you get straight to the information you need.
• Includes troubleshooting and testing information, plus downloadable configuration files and fully-documented source code to illustrate and explain operations.
Introduction to the X-CTU Software
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
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.
How to Change XBee Module Configurations
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
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.
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.
Preface and Acknowledgments Experiment 1. Introduction to the X-CTU Software Experiment 2. How to Change XBee Module Configurations Experiment 3. One-Way Digital-Input Communications Experiment 4. Use an XBee Module for Remote Control Experiment 5. XBee Modules Transfer and Control Analog Signals Experiment 6. Remote Control of Digital and Analog Devices Experiment 7. How to Transmit Data on a Logic-Level Change Experiment 8. How to Handle Data from Several Analog Inputs Experiment 9. Investigate Sleep Modes and Sleep-Mode Timing Experiment 10. How to Use API Packets to Control a Local XBee Module Experiment 11. How to Use API Packets to Control Remote XBee Modules Experiment 12. How to Use API Packets to Control Remote I/O Lines Experiment 13. Remote Control of PWM Outputs Experiment 14. How to Parse Data from Digital and Analog Pins and Control Individual Digital Outputs Experiment 15. How to Control Several XBee Modules with Broadcast Commands Experiment 16. How to Communicate Between an MCU and an XBee Module Experiment 17. Two-Way Communications with XBee Modules Experiment 18. How to Discover Nearby XBee Modules Experiment 19. How to Set Up a Small XBee Network Experiment 20. Digital and Analog Measurements in a Network Experiment 21. How to Handle an Unknown Number of XBee Modules Experiment 22. Exploring Cyclic-Sleep Operations Appendices Glossary Index