Overview RFSv4.3 is a RF module providing easy and flexible wireless data transmission between devices. It is based on AVR Atmega8 with serial output which can be interfaced directly to PC. Features 2.4 GHz Carrier Frequency RS232 UART interface with variable baud rate Input supply voltage: 5V to 12V 255 possible Channels frequencies (0 to 255) Programmable Device Address (255 per channel) Default mode is 0 and baudrate is 9600. Easy-to-Use AT command: Set working mode, Serial Baud Rate, etc. Compact Size, Out of Box: Plug and Play Supported Baud Rate 9600,19200, 38400. Two easily configurable modes: Data mode and Command node. Page 1
Pin Configuration Page 2
[RF Communication Release] 2012 Connecting the RF Module Step 1 Step 3 Page 3 Step 2 Step 4
Note [RF Communication Release] 2012 Configuring the RF Module Version The firmware version can be check by issuing ATFV command. Out of the box When powered on, RF module will send ok through serial port at 9600 baud. The default operation mode is Transceiver and the default sender and receiver address is 0. If you have two RF module, any data sent to RF_A from serial port the same data will be received by RF_B and displayed on the serial port. AT Commands The configuration of the RF module can be modified using AT commands. At startup the RF module is in data mode. To submit AT commands, the RF module must be switched to command mode by sending three plus signs ( +++ ) on serial port software. When the RF module receives the ( +++ ) on the serial port it will respond with: ok, starting command mode. The RFBee is now in command mode until switched back to data mode (using ATO0 see below) or power reset. AT Format: AT + Comand(ASCII) + parameters (optional, character)+<cr> Where <CR> is Carriage Return which has binary value 13 (0x0D in Hex). Page 4
[RF Communication Release] 2012 Example: +++ - Go to command mode, the RF module will return ok, starting cmd mode ATBD1<CR> - Set Uart Baudrate of the RF module to 19200, returns ok on success and otherwise error. ATBD<CR> - Get UART Baudrate of the RF module, returns 1 and ok on success and otherwise error. ATO0<CR> - Switch to data mode from command mode, the RFBee will return ok and any data send afterwards will be transmitted again. For ex: In flash magic go to Tools Terminal select com port option -set new lines to CR ( carriage return) Command Parameter AC 0-2 MA 0-255 DA 0-255 Adressing Page 5 Specification Address Check: determines whether the RF module checks the incoming packet address against its own address or not. If broadcast is enabled both its own address and the broadcast 0 address will be considered valid. 0:No address check 1:Address check, no broadcast 2:Address check and broadcast My Address: set the RF module s own Destination Address: set address of the receiver Default Typ e 0 r/w 0 r/w 0 r/w
Config: select wireless transmission data rate 0: 500kbaud RF CF 0-3 1: 250kbaud 2: 10kbaud 0 r/w BD 0-2 3: 2.4kbaud Baud Rate: Set Uart Baud rate of the RF. 0: 9600bps 1: 19200bps 2: 38400bps 0 r/w TH 0-32 Threshold: Set threshold in bytes that will trigger RF to start transmission. 1 r/w Serial 0: Payload only. OF 0-3 1: source, dest, payload 2: payload len, source, dest, payload, rssi, lqi 0 r/w 3: same as 2, but all except for payload as decimal and separated by comma's Page 6
MD 0-2 Mode: Set working mode of the RF. 0:transceive 1:transmit only 0 r/w Mode 2:receive only O 0 Online: return to data mode w CI 0-255 Miscellaneous RS - To select device channel ID. Restore: restore the configuration to default settings. 0 r/w - w Output format : Using ATOF it is possible to change the output format of data packets received. ATOF set to 0: Payload ATOF set to 1: Source address (1 byte) Destination address (1 byte) Payload Page 7
ATOF set to 2: Payload length (1 byte) Source Address (1 byte) Destination address (1byte) Payload RSSI (1 byte) LQI (1 byte) ATOF set to 3: As ATOF2, but now all byte values (except Payload) displayed as decimal and all fields separated by comma s. RSSI: Received Signal Strength Indicator. One byte signed data, unit dbm. LQI: Link quality indicator. One byte data, see CC2500 datasheet for details. Broadcasting : When every RF module has it s a unique address assigned (e.g. 1,2,3 and 4 if you have 4 RF module) there are two ways to let all RF modules receive the same packets: 1. Set ATAC to 0: this will disable address checking and all RF modules will receive all packets sent. Downside of this is that any private communication between e.g. 2 and 3 will always show up at 1 and 4. 2. Set ATAC to 2: this will enable address checking including broadcasts. This will enable private communication between RF modules (e.g. packets between 2 and 3 will not show up at 1 and 4). The RF module sending the broadcast must set the destination address to 0. Packets with destination address 0 will be received by all four RF modules. Page 8
Receive window of RF Module No. 1 Transmit window of RF Module No. 1 Fig 1(a )RF Module No. 1 Receive window of RF Module No. 2 Transmit window of RF Module No. 2 Test Case 1: PC to PC Wireless communication using CC2500 based RF modules. Configure the modules using AT commands: By default address check is disabled and data transmitted by one module will be received by all other modules. Once the 2 modules have been connected to 2 different PC s and are powered on with the terminal initialized on both of them, the connection may be tested. Any data transmitted from one PC will appear on the other PC, character by character. Check fig.1 (a) and 1(b) for input and output on two different PCs. Fig 1(b ) RF Module No. 2 Page 9
Test Case 2: BOT to BOT Wireless communication using CC2500 based RF modules The example shows the implementation of data transfer using the modules. The following code will allow LED1 of BOT1 to be synchronized with LED1 of BOT2. Initial Settings for Test Case 2: With default settings, address check is disabled. so, data transmitted by one RF will be received by all. For communication between 2 specific modules enable address check using AT commands : For ex: with ATAC =1 Configure the source and destination address using AT commands: ATMA = my address, ATDA = destination address, ATCI = channel ID. RF Module No. 1: RF Module No. 2: 1) ATMA 1, 2) ATDA 2 3) Channel id 0, 3) baud rate 9600(ATBD=0) 1) ATMA 2, 2) ATDA 1 3) Channel id 0, 3) baud rate 9600(ATBD=0) Below is the code required to be programmed in both the bots: The code part labeled as bot1 will be the master. For the master the bot2 code must be commented. The code part labeled as bot2 is for slave. For the slave the bot1 code must be commented. In the below code, the Bot2 section (slave bot) is shown as commented. Make sure to use proper commenting for each case, in order for the code to work correctly. Page 10
#include <avr/io.h> // header file defining I/o operation #define F_CPU 8000000 // CPU @ 8MHZ #define USART_BAUDRATE 9600 // SERIAL Communication @ 9600 baud #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) // baud rate formula #include <util/delay.h> // header file defining delay int main (void) // main code begins { DDRB = 0xff; // PORT B as output DDRD = 0xfc; // PORT D PIN 3-7 as output. PIN 2 is input for switch UCSRB = (1 << RXEN) (1 << TXEN); // Enable Rx & Tx of USART UCSRC = (1 << URSEL) (1 << UCSZ0) (1 << UCSZ1); // 8bit, 1 Stop bit, no parity UBRRL = BAUD_PRESCALE; // setting baud rate @ 9600 baud UBRRH = (BAUD_PRESCALE >> 8); unsigned char a=1; unsigned char b; // Character Variable for Rx packet. while(1) // loop forever Page 11
{ /* //BOT1 code //Tx Code if (a == '0') a='1'; else a='0'; UDR = a; // Add next byte to be transmitted to the UDR buffer while ((UCSRA & (1 << UDRE)) == 0); // Loop until UDR buffer is ready to receive // next byte to be transmitted. while ((UCSRA & (1 << RXC)) == 0); // Loop until UDR buffer is receiving RECEIVE data. b = UDR; // Read byte by byte from the Received Data Packet into the variable if (b == '1') //check for Actual data from received Packet to be = (ASCII - '1') { PORTB = 0x01; // led1 on led2 off if true if a[2] == 0x52 } else PORTB = 0x00; Page 12
_delay_ms(1000); */ /* //BOT2 code. //Rx Code while ((UCSRA & (1 << RXC)) == 0); // Loop until UDR buffer is receiving RECEIVE data. b = UDR; // Read byte by byte from the Received Data Packet into the variable if (b == '1') //check for Actual data from received Packet to be = 0x52 (ASCII - R) { PORTB = 0x01; // led1 on led2 off if true if a[2] == 0x52 } else PORTB = 0x00; if (a == '0') a='1'; else a='0'; UDR = a; // Add next byte to be transmitted to the UDR buffer Page 13
while((ucsra & (1 << UDRE)) == 0); // Loop until UDR buffer is ready to receive // next byte to be transmitted. _delay_ms(1000); */ } // While loop closed. return(0); // syntax never reached } Note 1:- Mount the RF modules, one each on the mounting space provided on the two bots. Switch on the two bots. Note 2:- To trace the communication simultaneously on Terminal, open terminal on separate Computers one for each bot. Create a connection with following settings: 1) Port Com1, 2) Baud rate 9600, 3) Flow Control None, 4) Data 8bit, 5) Parity None, 6) Stop Bit 1bit Make use of the 3 wire serial interface provided on the board besides the MCU to watch the signals. You should get a stream of toggling 0 s and 1 s in terminal. Page 14