Serial Link Transceiver

This project aims to provide RS232 level serial link interfaces between two communicating devices by means of an RF link. The interface units use the Atmel AVR ATMega48 series to control the communications between the RS232 interface and the radio interface, with HOPE RF RFM12 transceivers driving the RF link. The remote power switch receiver board provides the hardware support for the interface unit, and the AVR C library rfm12lib by Hansinator, Tixiv and Soeren provides the software support for the RF units. An interrupt driven UART library developed by Peter Fleury and updated by Andy Gock and others has also been used to ensure that the volume of serial line traffic can be handled.

The software for the board to provide serial communications is given on GitHub in the firmware-transceiver directory.

The Fleury/Gock UART library provides a macro for computing baud rate settings. The computation however can result in significant baudrate errors when the baudrates are high. A set of macros based on avr-libc setbaud.h are provided in the header file baud.h that will compute the most accurate setting. This can take into account the double bit rate configuration bit in the ATMega48 series of AVRs, but is more generally applicable to other AVR families.

The software does not have automatic baudrate detection nor any means to change the baudrate other than by recompilation.

The transceiver accepts serial data via 256 byte transmit and receive buffers, which will comfortably handle a burst of this length, and most likely longer bursts if the baudrates of the serial and RF interfaces are the same. The RF transmit and receive buffers are 30 bytes (the rfm12lib default). If the serial and RF baudrates are different then all buffer sizes will need to be changed, but it is unlikely that any gains can be achieved by doing this. The protocol overhead of the RF transmissions will result in the overall data rate of the RF link being slightly less than that of the serial link, so without flow control there will always be a maximum burst length limit.

Collision prevention (normally known as carrier sense) as provided by rfm12lib is used to reduce the chance that a transmission starts while a reception is in progress. There will still be a small but important probability of an actual collision occurring that could result in data loss. To avoid this a more complex CSMA protocol needs to be developed, or additional hardware provided with two parallel unidirectional links on different frequencies.

The hardware configuration for the board requires software SPI to be enabled and the following settings:

#define DDR_SS DDRD
#define BIT_SS 4
#define DDR_SCK DDRD
#define BIT_MOSI 7
#define BIT_MISO 6
#define BIT_SCK  5
#define BIT_SPI_SS 4

#define RFM12_BASEBAND RFM12_BAND_433
#define FREQ 433175000UL

#define RFM12_INT_VECT (INT1_vect)
#define RFM12_INT_BIT (INT1)
#define RFM12_FLAG_BIT (INTF1)
#define RFM12_INT_SETUP()   EICRA |= (1<<ISC11)

#define RFM12_SPI_SOFTWARE 1

The program works with both RFM12 and RFM12B interchangeably. The RFM12B works at 5V power although not recommended in the datasheet (reason is not given).

First created
10 October 2014
Last Modified 4 January 2015
© Ken Sarkies 2014