Wireless Robot Control
From JopWiki
Contents |
[edit] Introduction
The task of this project is to attach the XBee module to the JOP powered LEGO robot and implement a simple example protocol.
The purchased XBee Starter Kit contains two XBee Modules, one serial interface board, one USB interface board, one installation CD, and other necessary accessories such as cables, adapters, etc.
As shown above, the remote XBee Module shall be directly wired to the LEGO robot which requires a bit soldering and hardware adaption in VHDL. The base XBee module can be connected straightly e.g. to a PC through the USB interface.
The CD includes X-CTU software for windows which allows convenient configuration of the XBee Modules. Without the software, the Modules also can be configured through a terminal program in AT Command Mode.
[edit] XBee Configuration
The default XBee RF Module configurations are listed as following:
| Baud | 9600 |
| Flow Control | none |
| Data bits | 8 |
| Parity | none |
| Stop bits | 1 |
| Addressing | (Unicast) MY=0, DL=0, DH=0 |
Parameters can be configured by X-CTU Software or in AT Command Mode.
Example: changing the baudrate to 115200
1. By X-CTU Software
- Choose the "Modem Configuration" tab
- Press the "Read" button
- Choose "Serial Interfacing -> BD - Interface Data Rate -> 7 - 115200"
- Press the "Write" button
2. AT Command Mode using terminal
- Send +++ to enter into AT Command Mode. If the Baudrate of the PC and the Module match, the system will response OK.
- Send ATBD<CR> to read the current speed. The system will response e.g. 3 which stands for baudrate 9600.
- Send ATBD7<CR> to set the baudrate to 115200. The system will response OK.
- Send ATWR<CR> to write data to non-volatile memory. The system will response OK.
- Send ATCN<CR> to exit command mode. The system will response OK.
See decumentation of XBee 802.15.4 OEM RF Modules for more information.
[edit] Connecting XBee Module to JOP
The minimum connections of the XBee Module are Pins 1, 2, 3 and 10. Pins L2 SDO and L3 SDI on JOP connect the XBee radio signals to a second inbuilt UART.
| XBee Module | JOP |
|---|---|
| Pin 1 VCC | |
| Pin 2 DOUT | L3 SDI |
| Pin 3 DIN | L2 SDO |
| Pin 10 GND |
[edit] Hardware Adaption
On the LEGO robot, one UART is served to communication with the outside world through the serial interface. Thus a second UART is built to receive the remote control signals. Its VHDL definition is to simply create a second instance of the UART component. Its pin assignments are shown below. Pin l(2) on the JOP Module is SDO, l(3) is SDI.
cmp_ua2: entity work.sc_uart generic map (
addr_bits => SLAVE_ADDR_BITS,
clk_freq => clk_freq,
baud_rate => 115200,
txf_depth => 2,
txf_thres => 1,
rxf_depth => 2,
rxf_thres => 1
)
port map(
clk => clk,
reset => reset,
address => sc_io_out.address(SLAVE_ADDR_BITS-1 downto 0),
wr_data => sc_io_out.wr_data,
rd => sc_rd(4),
wr => sc_wr(4),
rd_data => sc_dout(4),
rdy_cnt => sc_rdy_cnt(4),
txd => l(2),
rxd => l(3),
ncts => '0',
nrts => nrts_ignored
);
The byte to be transmitted or received is save in address IO_BASE+0x41, and the UART status saved in IO_BASE+0x40. The addresses are correspondingly defined with Register names IO_STATUS_WL and IO_UART_WL.
[edit] Java Code Example
[edit] Related Readings
Not prerequisite to use XBee
- ZigBee Overview (online course)
- ZigBee Tutorial by Pete Cross Part1 Part2
- Home networking with Zigbee
- ZigBee Articles from RF Design Magazine


