Xbee module configuration from a µcontroller

Similar documents
By Ambuj Varshney & Akshat Logar

XBee-PRO PKG-R RS-232 RF Modem

Figure 3-1: XBee Loopback Testing

XBee /XBee-PRO OEM RF Modules

XBee-PRO PKG-U USB RF Modem

XBee-PRO PKG-U USB RF Modem

XBee Series 2 OEM RF Modules

XBee-PRO PKG-R RS-232 RF Modem

XBee-PRO XSC RF Module

XBee ZNet 2.5/XBee-PRO ZNet 2.5 OEM RF Modules

XStream OEM RF Module


Dual Serial Shield User Manual

XBee /XBee-PRO ZB RF Modules

XBee-PRO 900 DigiMesh RF Modules

XBee-PRO 868 RF Modules

User s Manual Closer to Real, Zigbee Module ZIG-100. Wireless Communication. ROBOTIS CO.,LTD

Z232. Technical Manual. Low cost wireless interface for TERN controllers th Street, Davis, CA 95616, USA Tel: Fax:

Bluetooth Embedded Module

USB Wireless Bridge USERS MANUAL R02

Sierra Radio Systems. Mesh Data Network. Reference Manual. Version 1.0

XStream-PKG-U USB RF Modem

Overview. Applications. Features. Pin assignment

XBee-PRO XSC RF Module

Innovati s Bluetooth 100M Universal Wireless Bluetooth Module

ES- JBM-141SPP Module. Application Note

XStream OEM RF Module

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

ZIGBEE PROTOCOL FOR SYSTEMATIC PARKING SYSTEM

1 of 4 1/23/ :17 AM

ARDUINO WIRELESS SD SHIELD Code: A000065

DFRobot BLE4.1 Module SKU: TEL0120

ELET114A Bluetooth Module DATASHEET. Website: / 7

Basics of UART Communication

8/11/11. Radio Communication Configurations Zigbee Configurations. Zigbee. XBee Wireless

Wireless-Tag WT51822-S4AT

USB ZigBee Adapter. User Manual. 1.0, Dec 2011

XBee Wireless. Michelle Shorter

Bluetooth Serial Adapter


XBee /XBee-PRO DigiMesh 2.4 RF Modules

L13. Communicating wireless by XBee modules

[WIR-1286]868MHz LORA Wireless Module. Page 1. LORA 868MHz Wireless serial link [WIR-1286]

MeshX [Firmware Version 801(x)] MaxStream Wireless Mesh Networking

Using UART in radio data transmission with the CDP-02 module By Tomihiko Uchikawa

Implementation of a New Wireless Module for the Cornell Ranger. By Andrew Mui

ZFSM-201-KIT-1 Wireless UART Application User Guide

BT-22 Product Specification

SNR610. Embedded network node module SNR610. Description. Feature. Application. SNR610 is highly integrated network module.

MIT Media Lab: XBee Workshop. Instructor: Rob Faludi

XStream-PKG-E Ethernet RF Modem

RF4431 wireless transceiver module

1 WATT/900 MHZ STAND-ALONE RADIO MODEMS

XStream-PKG-U USB RF Modem

Embedded Serial Web Server. User Manual

Wireless Sensor Networks. Introduction to the Laboratory

WIR-1386 / WIR-1186M Long Range 865MHz 867MHz RF Wireless Module with WIR-METERING Mesh Stack

March 21, BT22 Datasheet. Amp ed RF Technology, Co., Ltd.

AppNote-US2400-EVB Low Power 2.4GHz Transceiver

XStream-PKG-E Ethernet RF Modem

Digi 9XTend-PKG-R RS-232/422/485 RF Modem User s Guide

XBee Starter Kit Getting Started Guide

The Unofficial XBee FAQ (version 1.3)

IO Expansion Shield User Manual

Published in A R DIGITECH

Outline. TWR Module. Different Wireless Protocols. Section 7. Wireless Communication. Wireless Communication with

G3P-WiFi User Manual Release 1.2

XStream AT Commands. Advanced Manual v South 520 West, Suite 180 Lindon, UT Phone: (801) Fax: (801)

BLUETOOTH MODULE. Model BT-20

XBee ZigBee SMT RF Module Development Kit Getting Started Guide

FireBeetle Board 328P with BLE4.1 SKU: DFR0492

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

An Efficient Image Transmission Technique Using Wireless Multimedia Sensor Network

Ct-BT04 Specification Sheet

Hints and tips when using RC1xx0 RF Modules

LM072 Bluetooth Module Standalone (With Embedded Bluetooth v2.0/v2.1 Stack)

XCite Advanced Programming & Configuration

RF4432 wireless transceiver module

BLE Bluetooth Low Energy Modules SBC2112-B. Preliminary Specification. Version 1.0

MSI-P710 PC/104 ZigBee Wireless Card with Analog In & Digital I/O User Manual (Preliminary)

WiMOD LR Base Plus Host Controller Interface

Freescale Semiconductor, I

WiMOD LR Base Host Controller Interface

Product Brief. Model: TLM922S-P01A. Ver.1.4

Product Brief. Model: TLM922S-P01A. Ver.1.0

AppBee-Mod & AppBee-SIP Documentation for use with the BASIC Stamp

C:\Users\Jacob Christ\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

kcserial User Guide version 2006.FEB.20

UART/RS232/RS485/USB/Ethernet Over Powerline Communication Transceiver Module. User Manual

DEMO XTR-8LR100 DEMO XTR-8LR10 User Manual

Asynchronous Serial Communication Protocol (without Flow Control) using TLM 2.0 (Example of Non memory based protocol )

Contents. Architecture DWC18 Wireless Communication System for e maintenance Purpose, Function & Technical Specs

The BASIC Stamp and other 5 V controllers need an adapter that:

KW41Z IEEE and BLE Coexistence Performance

GETTING STARTED GUIDE

MSI-P700 PC/104 IEEE Wireless Card with Analog & Digital I/O User Manual

ECM-1240 User Manual

+ (5~27 VDC) GND. Bluetooth V4.2 BLE RS-422/485 Serial Adapter. Model: BLE-485C. 1. Package content: BLE RS-422/485 adapter

Product Specification

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Transcription:

APPLICATION NOTE AN_P12AB04_1 Xbee module configuration from a µcontroller Soulier Baptiste Polytech Clermont Ferrand 2012-2013 The purpose of this application note is to explain how to configure the main options of a Xbee RF module with a basic µcontroller.

Table of Contents Introduction... 2 I. The Xbee modules... 3 I.I. General Overview... 3 I.II. Main Configuration s Options... 4 I.III. Configuration s Stream... 5 II. Xbee configuration from a µcontroller... 7 II.I. Connection Xbee µcontroller... 7 II.II. Designing a Configuration function... 8 II.III. Peripheral functions needed... 9 II.IV. Example of a C Configuration function... 10 Conclusion... 13 Soulier Baptiste AN_P12AB04_1 Xbee Configuration 1

Introduction Nowadays, a lot of applications require wireless transmissions. Different technologies exist, and, according to the needs of the application (data rate, transmit range, transmit power, sensitivity, consumption ), some are more appropriate than others. You can find, for example, Wi-Fi, Infrared (IR), Bluetooth One of this wireless ways to transfer data is the Xbee modules. Using the Zigbee protocol, based on the IEEE 802.15.4 Standard for Wireless Personal Area Networks WPANs, these Xbee modules are low-power digital radios designed by DIGI. The purpose of this application note is to explain how, from a classic micro controller, to configure the main options of these Xbee modules in order to create a simple wireless communication. Soulier Baptiste AN_P12AB04_1 Xbee Configuration 2

I. The Xbee modules This part of the application note presents the module, and the general options to configure in order to established a basic wireless communication. I.I. General Overview The Xbee modules sold by DIGI (www.digi.com) are small radios operating within the ISM 2.4 GHz frequency band and meeting IEEE 802.15.4 standards. Figure 1: Xbee Module (S1 &S1 pro) Easily integrable with its reduced size, the Xbee modules offer the following properties (Xbee1 and Xbee1 pro): Transmit range: 30m up to 750m Transmit power: 1mW and 63mW Receiver sensitivity : -92dBm to -100dBm Transmit peak current (@3.3V): 45mA and 250mA Reception current (@3.3V): 50mA and 55mA Power down current: <10µA RF data rate 250 kbps Retries and Acknowledgements Source/Destination Addressing Unicast & Broadcast Communications Point-to-point, point-to-multipoint and peer-to-peer topologies supported Coordinator/End Device operations You can find more Xbee specifications at www.digi.com. For low data rate transmissions with a reasonable consumption, the Xbee seems to be a good compromise. Plus, it is rather simple to understand it way of functioning and to get it communicating. Soulier Baptiste AN_P12AB04_1 Xbee Configuration 3

I.II. Main Configuration s Options There is no particular need to configure the Xbee module to communicate, but, according to the application developed and the integration environment of the module, you might have to change some parameters (like the serial data rate for example). Here are the main parameters you might have to configure on a Xbee module: Serial communication parameters: o Data rate (1.2kbps to 250kbps) o Number of Stop bits o Parity o Data length Sleep mode o Enabled/Disabled o Cyclic/Pin o Time before sleep RF Power Level Get Serial Number (module address) Destination address Source address Channel used PAN ID MAC mode Packetization timeout Pull-up resistor options Pins configurations Find the complete datasheet at: http://ftp1.digi.com/support/documentation/90000982_j.pdf The classic way to configure a Xbee module is to use the Digi's X-CTU Software and a serial connection to a PC. Digi stocks RS-232 and USB boards to facilitate interfacing with a PC. X-CTU software: http://ftp1.digi.com/support/driver/40002636_a.zip Figure 2: Xbee development Kit Soulier Baptiste AN_P12AB04_1 Xbee Configuration 4

Figure 3: X-CTU, Configuration and Communication software With the X-CTU software, you re able to configure the serial connection (between the module and the PC) and you re able to communicate with the connected module (to configure some of its parameters for example) and with distant module via the connected module. I.III. Configuration s Stream In order to set up the module, the AT Command Mode is used. The AT Commands allow to turn the module into it configuration mode and to easily configure each parameter available. From the X-CTU terminal on a PC or from a µcontroller, the principle of this Command mode is the same, as described in the example below: Soulier Baptiste AN_P12AB04_1 Xbee Configuration 5

Figure 4: Example of Configuration s Stream This first example shows the command stream to, in this case, configure the serial baud rate at 9600. To enter in the command mode, the characters +++ must be sent to the module with a Carriage Return (CR). Once these characters have been sent, a guard time (GT, default 1s), while no characters should be sent, must be respect. The module answers to a correct command by sending back the word OK with a Carriage Return. In the previous example, the baud rate command is used: BD => ATBD with the parameter 03 which refers to the defined value of 9600 bauds (page 33/68 datasheet). The configuration is then saved to non-volatile memory using the command ATWR (Write) so that configuration persists through subsequent power-up or reset. Finally, to exit the Command Mode, the characters ATCN are sent to the module. The AT commands available must always be prefixed by the characters AT and formatted as defined: Figure 5: Syntax of AT commands Soulier Baptiste AN_P12AB04_1 Xbee Configuration 6

The various AT commands available are described in the datasheet: http://ftp1.digi.com/support/documentation/90000982_j.pdf NOTE: Failure to enter AT Command Mode is most commonly due to baud rate mismatch. To avoid this problem, ensure that the Baud setting on the PC Settings tab or on the µcontroller s UART matches with the interface data rate of the RF module. By default, the BD parameter = 3 (9600 bps). II. Xbee configuration from a µcontroller According to the application developed, and particularly when the Xbee modules are to be embedded into autonomous systems, the module s configuration cannot always be proceeded manually by connecting each module on a development kit and by configuring the parameters from the X-CTU software. In that case, one solution is to program the configuration of the module directly into the micro controller used to transmit the wireless data. II.I. Connection Xbee µcontroller Of course, a such micro controller must have a serial interface to be connected to the module. The minimum PINs required for the serial communication are DIN (Data In) and DOUT (Data Out). Obviously, the Xbee module needs to be alimented (3.3V) with the PINs VDD and GND. Figure 6: Basic connection µcontroller-xbee As shown in the Figure 6, the serial communication is asynchronous (no clock s signal shared). This means that the serial interface should be an UART (Universal Asynchronous Receiver Transmitter). Soulier Baptiste AN_P12AB04_1 Xbee Configuration 7

The pin UART_TX of the µcontroller should be connected to the pin DI and the UART_RX should be connected to the Xbee s pin DOUT. Considering that the Xbee module, now connected to the µcontroller, is supposed to be in it default state with it start parameters, the configuration program can be written. II.II. Designing a Configuration function With the X-CTU software and it graphical interface, the configuration is pretty easy, the commands are sent in the terminal and the module s response are posted and shown in this same terminal. But, from a µcontroller, the configuration must be operated blindly considering that we have no screen to print the data exchanged with the module. This is why one solution consists in developing a configuration function as a Finite State Machine (FSM). This FSM should first enter in the command mode, send the various commands successively, save the configuration to the non-volatile memory and finally, quit the command mode. If any step can t be proceeded (Fail), the FSM goes directly to the final state and quits the command mode. This first description is very basic, we ll see later that, in order to facilitate the debug of the program, the FSM should in fact be more complete. For example, a failure at one specific state of the FSM should be reported with the number of the missed state. Figure 7: Principle of the FSM Configuration Function Soulier Baptiste AN_P12AB04_1 Xbee Configuration 8

With this principle, the configuration is realized at the function s call and is completely autonomous. The user just has to schedule once the configuration, prepare the command lines to send, choose the right parameters and the order of the commands. II.III. Peripheral functions needed To use a such configuration function, we have to be able to communicate properly with the Xbee module. That means we need peripherals functions: Configure and Initialize the UART o Initial Serial baud rate : 9600 o Data length : 8 bits o Bit Stop : 1 bit o Parity : None o UART FIFO : enabled and reset o Enable UART transmit and reception o Pin Configuration Port used Pins used Pin s Function : UART (Tx & Rx) Pull-up resistor Send a buffer (command) to the Xbee o UART s port used o Pointer on the buffer to send o Size of the buffer o Transmit mode Receive a buffer (response) from the Xbee o UART s port used o Pointer on the reception buffer o Size expected o Reception mode (blocking/ none blocking) Wait a defined time (to avoid guard time violations) o Use a Timer which generates an Interruption each 1ms (for example) and increments a counter variable (SysTickCnt++) o Create a delay function Void delay (int tempo) //wait tempo ms Soulier Baptiste AN_P12AB04_1 Xbee Configuration 9

II.IV. Example of a C Configuration function This part presents an example of configuration function developed and used in a specific application which requires to change the serial data baud to 250kbps and to enable the sleep mode on Pin request. First, the UART is initialized with 9600 bps, 8bits data length, 1 bit stop, no parity. Then the configuration function (Xbee_config) is called. Finally, the return code of the function is analyzed to determine if the process succeeded or failed. o If the process succeeded, the UART configuration is changed (baud rate 250kbps) to keep the same serial configuration as the Xbee module (now at 250kbps). o If the process failed, an error code is generated and signaled to the user. At this moment, and if the configuration succeeded, the module is configured and can be used to communicate with another wireless system. The configuration FSM used in this application is pretty simple: Figure 8: Configuration FSM used in the example application Soulier Baptiste AN_P12AB04_1 Xbee Configuration 10

The C source of this configuration function is the following one: /*********************************************************************//** * @brief Xbee module configuration * @param[in] none * @return int : (1:succes) (0:fail) * @author : BAPTISTE SOULIER **********************************************************************/ int config_xbee(void) int etape_config=0; while(1) switch(etape_config) case 0 : //Initial step : Entering commande mode Delay(1500); UART_Send(TEST_UART, commande_0n, sizeof(commande_0n), BLOCKING); Delay(1500); //Ensure no Guard Time Violation UART_Receive(TEST_UART, commande_resp, 3, NONE_BLOCKING); if (commande_resp[0]==commande_ok[0] && commande_resp[1]==commande_ok[1] && commande_resp[2]==commande_ok[2]) etape_config = 1; else etape_config = 6; break; case 1 : //Serial Baud Rate Configuration UART_Send(TEST_UART, commande_bd, sizeof(commande_bd), BLOCKING); UART_Receive(TEST_UART, commande_resp, 3, BLOCKING); if (commande_resp[0]==commande_ok[0] && commande_resp[1]==commande_ok[1] && commande_resp[2]==commande_ok[2]) etape_config = 2; else etape_config = 6; break; case 2 : //Sleep Mode Configuration UART_Send(TEST_UART, commande_sm, sizeof(commande_sm), BLOCKING); UART_Receive(TEST_UART, commande_resp, 3, BLOCKING); if (commande_resp[0]==commande_ok[0] && commande_resp[1]==commande_ok[1] && commande_resp[2]==commande_ok[2]) etape_config = 3; else etape_config = 6; break; case 3 : //Saving full configuration UART_Send(TEST_UART, commande_wr, sizeof(commande_wr), BLOCKING); UART_Receive(TEST_UART, commande_resp, 3, BLOCKING); if (commande_resp[0]==commande_ok[0] && commande_resp[1]==commande_ok[1] && commande_resp[2]==commande_ok[2]) etape_config = 4; else etape_config = 6; break; case 4 : //exit commande mode UART_Send(TEST_UART, commande_cn, sizeof(commande_cn), BLOCKING); UART_Receive(TEST_UART, commande_resp, 3, BLOCKING); if (commande_resp[0]==commande_ok[0] && commande_resp[1]==commande_ok[1] && commande_resp[2]==commande_ok[2]) etape_config = 5; else etape_config = 6; break; case 5 : return 1; // Full configuration completed => return success case 6 : return 0; //configuration failed => return fail default : return 0; Figure 9: C source code of the example function Soulier Baptiste AN_P12AB04_1 Xbee Configuration 11

The prototypes of the sub functions used are: int config_xbee (void); void Delay (unsigned long tick); uint32_t UART_Send(UART_TypeDef *UARTx, uint8_t *txbuf,uint32_t buflen,transfer_block_type flag); uint32_t UART_Receive(UART_TypeDef *UARTx, uint8_t *rxbuf,uint32_t buflen,transfer_block_type flag); Figure 10: Function s prototypes The data used in this function are: //uint8_t = unsigned char uint8_t commande_0n[]='+','+','+'; //openning commande mode uint8_t commande_bd[]='a','t','b','d','3','d','0','9','0','\r'; //250kbps serial interface uint8_t commande_sm[]='a','t','s','m','1','\r'; //Sleep Mode (0:disable) (1:pin controled) uint8_t commande_wr[]='a','t','w','r','\r'; //write configuration (saving) uint8_t commande_cn[]='a','t','c','n','\r'; // exit commande mode uint8_t commande_ok[]='o','k','\r'; // /!\ Input : module response if commande well understood uint8_t commande_resp[3]; // buffer used to record the answer sent by the module to our commandes and used to compare with commande_ok Figure 11: Data declarations The function fills its role. This example illustrates a simple way to program the Xbee module configuration from a µcontroller. Soulier Baptiste AN_P12AB04_1 Xbee Configuration 12

Conclusion Using a Xbee module in an embedded application is a pretty simple way to manage a wireless communication. The most important step in the development of a such application is the configuration: the µcontroller configuration, but also the Xbee module configuration. To configure a Xbee module for an integrated utilization, it s hardly possible to use the development tools like the development kit and the X-CTU software. Then, it s not a big problem, now you ve seen, in this application note, how to manage an Xbee configuration from a µcontroller. Keep in mind that the configuration s way proposed in this document is only a solution among others and that the best solution will still be the one that you understand best. The solution proposed here is also very basic and according to your needs deserves to be improved. Contact: baptiste.soulier@gmail.com Sources: www.digi.com Complete datasheet: http://ftp1.digi.com/support/documentation/90000982_j.pdf Soulier Baptiste AN_P12AB04_1 Xbee Configuration 13