Radio Circuit DiagramsRemote Circuit DiagramsUSB Circuit Diagrams

USB Radio Terminal Schematic Circuit Diagram

In the January 2009 issue of Elektor we saw how straightforward it is to connect a lowcost RFM12 868 MHz ISM (licence-free) radio module to an ATmega microcontroller. Simple example listings in BASCOM demonstrated how to communicate data using the modules [1].

The ‘USB radio terminal’ circuit described here connects an RFM12 radio module to the R8C/13 microcontroller board used in the ‘Transistor Curve Tracer’ project described in the February 2009 issue [2].  The circuit can be used to transfer data (for example from a PC terminal emulator program) wirelessly to another microcontroller and vice versa. Of course, the remote microcontroller also needs to be equipped with a radio module. As ready-made and tested boards are available (even the radio module is available from Elektor [3]) building the circuit does not present any great difficulty. All that is necessary is to connect a total of six pins of K1 on the R8C/13 microcontroller board to pins on the radio module.

USB Radio Terminal Schematic Circuit Diagram

The 5 V and ground pins are connected directly to their namesakes so that the radio module draws its power from the microcontroller board. The SPI port on the radio module is driven from port pins P1.0 to P1.3 on the microcontroller: see the ‘circuit diagram’. The microcontroller module will receive its power over the USB cable when it is connected to a PC. The author has written R8C firmware in C, available for download in source or hex format from the Elektor website. The C source can be edited and compiled using the ‘High Performance Embedded Workshop’ IDE by Renesas [2], and further information is available from the R8C pages of the Elektor website [4]. The Motorola hex file can be downloaded over the USB port using the Flash Development Toolkit [2][4]. To enter programming mode jumper JP1 must be fitted on the microcontroller board and the reset button pressed briefly. After programming is complete, don’t forget to remove the jumper and press the reset button again. The firmware mostly consists of the BASCOM routines written by Burkhard Kainka [1], modified and converted into C. Extra functions have been added to handle the UART1 interface, which is connected to the USB interface chip.

On the transmit side, the program waits for characters to arrive over the USB port and stores them in an intermediate buffer. When the sequence <CR> <LF> is received the line of characters is sent to the radio module transmitter using a special protocol. On the receive side, the program waits for characters from the radio module receiver. When the <STX> control code (‘start of text’, 0x02) is received, the subsequent characters are buffered until the stop code <ETX> (‘end of text’, 0x03) is received. The transmitted message includes a trailing checksum, so the complete sequence of characters is <STX> <string> <checksum> <ETX>. If the checksum is correct, it, along with the <STX> and <ETX> characters, is discarded, <CR> <LF> is appended, and the resulting string sent out over the USB port to the PC. Of course, strings and commands can be sent over the radio link to other applications. In some cases the protocol will have to be adapted. In particular, because of the limited available RAM on the R8C/13 (1 kB) the intermediate buffer is only 200 bytes long. This should be adequate for most uses. As configured, the software uses a data transfer rate of 9600 baud with 8 data bits, 1 stop bit, no parity and no handshake. The terminal program (for example, Hyperterminal) must be configured to match these settings.

Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close