Tue 17 Jun 2008
RFM12 Tutorial - Part2
Posted by Stephen Eaton under Embedded, RF, Tutorials, rfm12
Part 2 - RFM12 Hardware Interface
In this next part of the RFM12 tutorials I’ll be covering the hardware interface, signal descriptions and how you go about hooking it up to the MCU of your choice.
Packages
The RFM12 RF module comes in a couple of different packages, DIP and SMD, I’ll mainly be covering the DIP throughout these series, but will touch on the SMD where necessary. There is also a long range version of the RFM12B, this is the RFM12BP and has a reported range of 3000m. The RFM12BP only comes in an extended SMD package, but I won’t be covering it here in the tutorials, although all of the commands will be the same. The only difference is the RFM12BP has an on board power amp, which requires 12V to power the PA portion and has associated control pins for Tx/RX control.
DIP
The DIP package uses a 6×2 2mm pitch header to connect the various signals to the MCU, The size of this header is a bit of a problem if you want to do prototyping as it doesn’t breadboard well, initially I didn’t have any 2mmm pitch female headers so I hand soldered on individual wires to the back of each pin, not really good in the long run as the wires kept on breaking off, so I designed a breakout board to bring out all the signals onto a standard 100mil pitch, much easier to breadboard.
SMD
There are two version of the SMD module, and from what I can gather the only difference is the crystal, one is the standard HCU form factor, while the other is a ceramic oscillator.
Antenna: The only real difference when using the SMD over the DIP package is there is no on-board antenna connection, the antenna comes out via one of the pins, so you need to design in an antenna connection if using the SMD version.
ARSSI: The SMD package allows access to another useful signal that is not available to the DIP version, this is the ARSSI - Analogue Relative Signal Strength Indicator, which is basically the strength of the signal being received by the module, however it’s not bought out on any of the pins, beats me why? There a digital version of this signal accessible though the software interface, from what I can gather there is a difference from the Digital and Analogue versions of this signal. Anyway what it boils down to if you want to access this analogue signal then you have to manually solder on a wire to access this pad (shown as red circle).

Antenna
The antenna mostly used will probably be a whip antenna, basically a piece of wire cut to the right length, I won’t be covering antenna theory here, as I don’t know it ;), but suffice to say the approx lengths involved are as follows (measured from factory supplied antennas):
433Mhz - 173mm
915Mhz - 87mm
With these lengths I’ve had no problem reaching 30m+ indoors through a number of walls and 120m+ outside, I’ve not yet trie different types of antennas such as SMA connected rubber duck type but they should work as I’ve spoken to tech support at HopeRF and they tell me that the antenna circuit on both modules is balanced to 50 Ohm, this means that most SMA rubber duck antennas in the right frequency range will also work. Make sure that the antenna is matched to the frequency range required to get the best range, i.e. don’t use a wifi antenna for 2.4GHZ on a 433Mhz module, it may work for short distances, but definately won’t be optimal for long distances, also you may damage your RF module (unconfirmed it this is is the case as these are low power devices), but usually antennas need to be SWR matched to stop reflectance back into the transmitter circuit.
There is also some technical documents on Hopes website for PCB based antennas, but I’ve not used these at all so your milage may vary with them.
As mentioned earlier the SMD has no direct antenna connection so you need to design in a connection, either a solder pad on your board or an SMA connector.
The DIP package on the other hand allows you to solder in the antenna right onto the module, usually you will solder in the wire directly, however you need to make sure that you get the right pad, as there are two very small solder pads right next to each other, one is the antenna, one is ground, both are not marked in anyway as to to their function, and the documentation does not show which one is which. You need to solder in the piece of wire to the one not connected to ground, best to check with a multimeter or continuity tester first.
It looks as though you can also uses these two pads on the DIP module to connect an external SMA connector with a pigtail to the module as well (both ground and antenna).
PIN Connections
The pin connections for the module is described below, I have indicated whether the connection is required or is optional when making connections. The basic connections as described will allow data rates of up to approx 12000bps on an 8Mhz PIC using a bit-bashed SPI, polled approach when handling sending and receiving data, higher data rates will require hardware SPI, higher MCU speed and the use of interrupts, these will be discussed in a later tutorial.
UPDATE: Please see this article for more detailed information regarding RFM12B bit rates and the different pin connections.
VDD (required) - The nominal working voltage is between 2.2v and 3.8v (NOT 5V), make sure that you have bypass filters in place on the supply rails.
nINT/VDI (optional) - This pin can be configured as either input or output, if configured as an input then it’s function is an active low interrupt request from the MCU, The MCU pulls this line low if it want to interrupt the RF module.
If configured as an output then its the VDI, Valid Data indicator, meaning valid data has been detected by the receiver and outputs a high. Factory Default is VDI
SDI (required) - SPI Data input, where the MCUs MOSI signal needs to be connected to.
SCK(required) - SPI clock input from MCU
nSEL (required) - Chip Select (active low). This signal must be pulled low before any signal is sent via SPI to the RF module,
SDO (required) - SPI Data out, where the MCU MISO signal needs to be connected to.
nIRQ (optional) - Interrupt Request output (active low), this is when the RF module wans to signal the MCU an event has occurred. This should be tied high with a pullup resistor.
FSK/DATA/nFFS (optional but requires 10K pullup when not used):
FSK - Transmit data input
DATA - Received Data output
nFFS - If pulled high then the FIFO is selected then data is transmited / received via the internal FIFO acessed via the SPI interface. If the FIFO is not being used then this is where the data is directly clocked into or out of the Tranceiver. Use this mode for high datarates.
DCLK/CFIL/FFIT (optional):
DCLK - is the data clock when no FIFO is used (used in conjunction with FSK/DATA/nFFS pin).
CFIL - is used to connect an external capacitor when using 256K datarates, this is for the analogue filter, normally the internal digital filter is used by default, only lower data rates are achieved with the digital filter.
FFIT - FIFO interrupt, interrupt signal is generated whenever the FIFO interrupt level is achieved (level is configured via SPI and is covered in the software interface tutorial), normally the interrupt level would be set to 8 if using the FIFO so that an interrupt is generated for every byte received. If using the FSK/DATA to clock in the data then the interrupt level should be set to 1, this way an interrupt is set for every bit sent/received.
CLK (optional) - Clock output, defaults to 1Mhz, but can be configured in increments up to 10Mhz, or switched off. This signal can be used to provide a clock signal to the MCU if it has no internal oscillator, i.e. cuts down on an additional crystal required for the MCU. This signal is also used in the calibration of the RF modules and will be explained later.
nRES (required) - this is reported in the Hope RF documentation as an output but is really an input (active low) and needs to be tied high at all times. If pulled low it will reset the module back to POR default (power on reset) settings.
GND (required) - Power Ground.
ANT (on SMD, required) - Where the antenna is connected.
Back - Part 1 | Next - Part 3
13 Responses to “ RFM12 Tutorial - Part2 ”
Comments:
Leave a Reply
You must be logged in to post a comment.



June 30th, 2008 at 4:54 pm
Hi,
second part is also gr8. It help to clear a lot of concepts. waiting for the next part.Hope the controller u will use is AVR and programming will be in C language.
June 30th, 2008 at 5:02 pm
Yes working on the C for my Arduino, which is AVR based
Was actually just wiring up the RFM12B to the prototype board/shield as your comment came in lol
July 3rd, 2008 at 1:50 pm
Hi,
Stephen. Finally i have transmitted the data sucessfully using RFM12BP. i am reciving the data on hyperterminal of my pC. but there is still a small problem that is if I send numbers in sequince i.e from 1-9 it recives the odd numbers first and then the even one. i donot know y is this hapening if u can help me out with this problem .I know u will have some gr8 ideas for solving this problem. Thanks a lot dear.
July 3rd, 2008 at 3:07 pm
Well done! Please send me your code if possible, I would love see it.
The only thing I can think of is the TX levels maybe causing problems. How are close are the two units? The RFM12BP is for ranges up to 3000m so you may have to drop the Tx power right down to minimum and the Rx sensitivity down during development.
Are you doing any error checking with your packets? Such as CRC or a checksum? That way you can be sure that the packet you sent is the packet you received.
Also you may have to look at some forward error correction such as a hamming code, but I would not have thought it was needed for such small data streams.
July 4th, 2008 at 1:36 pm
Hi,
Thanks for ur appreciation :)and useful tips too. My code is nearly same as the one given in the programming guide. if u still need give me ur mailing adress. the two modules are kept closer so,I think ur right I have to reduce the power. Also on some other website I have studied that these modules have no internal error correction and they say something about the SNAP protocol. Do you have any idea abt it? if any plz do share how to use this protocol with these modules. Thanks.
July 5th, 2008 at 7:57 am
None of the RFM12 modules have error correction, so you need to build that into you application. Just a basic CRC or checksum while testing should be ok, all depends on you application.
1) Build your packet
2) Do a checksum of everything, but not the sync or the preamble.
3) Add this calculated checksum to the end of the packet.
4) Transmit the complete
5) On the receiver you receive the packet containing the data and checksum
6) recalculate a new checksum on the received data using the same formula you used on the transmision side. Don’t include the received checksum in this calculation only the data.
7) if the calculated checksum and the received checksum are the same, then more than likely you have a good packet, if not then you have a corrupt packet and you either ignore the data or get it resent.
The snap protocol you are referring to, is S.N.A.P and is found here http://www.hth.com/snap/ this defines a simple network addressable protocol.
August 4th, 2008 at 7:30 pm
Just a note to thank you for these tutorials. After a couple of hours of coding and reading I have managed to get two of these devices communicating effectively.
Many thanks again.
Stephen (UK)
August 6th, 2008 at 9:50 am
Great to hear, thanks for the feedback
September 18th, 2008 at 1:22 am
Can you please tell me the difference between RFM12 and RFM12B ? (I noticed a VCC difference)
September 24th, 2008 at 12:41 pm
*reSpawn
Good question, I’ve only used the RFM12B variety, but from the looks of the data sheets you’re right, it only looks like a VCC difference. Even the chip programming guides looks the same.
Anyway I’ve asked just sent an email off to HOPE so “Hope”fully I’ll get a reply (lol sorry about that)
September 24th, 2008 at 1:42 pm
*respawn - you are half right
Response from Hope:
The differences between RFM12B and RFM12 are :
1.Sensitivity: RFM12 is -109dBm, RFM12B is -112dBm
2.Power supply: RFM12 is 2.2V-5.5V. RFM12B is 2.2V-3.6V
October 31st, 2008 at 2:31 pm
Hi
My name is nithin prakash, i recently started to work on RFM12BP, i have just established communication b/w RFM12BP modules. I have a doubt in the Power amplifier section. To the VCC-PA pin i have an input of 12V from a DC power supply. For the RF module that i am designing i want to give it a 5V supply, so know i am planning to introduce an voltage booster circuit i.e. 5v to 12v(say max1771). But if i connect a ammeter in series with the power supply the current drawn by the VCC-PA pin is at 0mA or 0A. I am doing continuous transmission for 10 seconds. The current consumption of the power amplifier is vital for the selection of voltage booster.
Thank you in Advance….
November 2nd, 2008 at 12:37 pm
Hi
My name is nithin prakash, i recently started to work on RFM12BP, i have just established communication b/w RFM12BP modules. I have a doubt in the Power amplifier section. To the VCC-PA pin i have an input of 12V from a DC power supply. For the RF module that i am designing i want to give it a 5V supply, so know i am planning to introduce an voltage booster circuit i.e. 5v to 12v(say max1771). But if i connect a ammeter in series with the power supply the current drawn by the VCC-PA pin is at 0mA or 0A. I am doing continuous transmission for 10 seconds. How can the current consumption be at 0A or 0mA?. The current consumption of the power amplifier is vital for the selection of voltage booster.
Thank you in Advance….