Dick Cappels' project pages http://www.projects.cappels.org

HOME (more projects)

Minimum Mass Wireless Coupler
Bidirectional RF communications works like very short range (10 to 15 cm) radio but is as easy as IR.  This material formed the basis of an article that was first published in the February, 2005 issue of Circuit Cellar magazine. A more recent term for this kind of RF link is "Near Field Communications".

Downloads -Down load the driver code.
Download the driver for the AMega8 (easily modified for any AVR with RAM) vlfcwm8.inc
Download the driver for the AT90S2313 (easily modified for any AVR with RAM) vlfcw2313.inc

Scroll to the bottom of the page to see a list of related projects.

Photo 1. A battery operated frequency meter (front), needs only to be placed near the base (rear) in order for them to communicate via the bidirectional Minimum Mass Link (as indicated by the illuminated Activity LEDs). A terminal emulation program allow control of display of results from the frequency meter without the need of physically connecting the two of them.

Here's a way to get a short range bidirectional RF (Radio Frequency) channel on a microcontroller, using the controller's tristatable I/O pins and on-chip comparator with a few passive components. The range with the firmware and simple I came up with for Atmel AVR controllers allows for low error rate communications over 10 to 15 cm using a 5.5 cm diameter loop antenna on each device. This is the answer to my search for the simplest and lowest cost way to connect instruments on my bench top to my computer and to each other without wires. Its an alternative to short-range infrared; except no need to make sure there is a good optical path between the units. I presently use this system for communications among a wireless alphanumeric 2 line X 16 character LCD (Liquid Crystal Display), a battery operated frequency meter, a four channel 10 bit voltmeter, and a base unit that connects my computer's RS-232 port to the RF channel. These projects are described on other pages on this site. This RF Link also adheres to the "Minimum Mass" product design concept - not using any thing that is not absolutely essential to obtaining the needed function.

The Minimum Mass RF Link makes use on a microcontroller's on-chip analog comparator connected to a loop antenna and a pair of bias resistors as a receiver and uses a tristateable output on one of the comparator pins to drive the same loop antenna as a transmitter. I have written code modules for the AT90S2131 and the ATMega 8. The code is fairly small - only 131 bytes for the ATMega8 version, and for hardware resources, it only uses an 8 bit time and the comparator.  Though I have only tried this on AVR controllers, I suspect this technique would work well on other controllers, such as the PIC family, equipped with comparitors.

The Basic Method
To get the signal from one place to another, place two coils facing each other within 10 to 15 cm of one-another (See Figure 1) . Drive one with a square wave signal and a voltage will show up across the other because of the magnetic coupling between the two of them. Now make them tuned circuits and the signal changes to a sine wave, and it grows in amplitude in the transmitter, and the receiver becomes more sensitive.

Figure 1. Drive a resonant loop antenna with a signal at the resonant frequency, and an AC voltage at the same frequency will be induced in a second, nearby resonant loop antenna.

Since these coils, which are actually resonant loop antennas, rely on magnetic coupling, they can be shielded. This is useful for reducing electrically coupled interference in the receiving mode and is also useful to prevent the microcontroller's clock from "leaking out"  if you have to meet regulatory requirements for incidental radiation.

The signal is serial data modulated onto a 181.818 kHz carrier with on-off keying. The frequency is in the 160 to 190 kHz band, where legal and technical requirements are relaxed, at least in the U.S. and Canada. The number, 181.818181 KHz results from dividing the microcontroller's 4 Mhz clock by 22 -something that's done is firmware. The baud rate is 1200 baud, and its set by a timer interrupt.

The circuit

Figure 2. Conceptual illustration of the use of the tristateable I/O pin and the transmit/receiver circuit. Pin 12 switches between input and output states. Pin numbers relate to the AT90S2313 DIP package.

A pair of resistors biases the resonant antenna at 1/2 the supply voltage (See Figure 2). This is the sweet spot of the comparator's common mode input range, where the input offset voltage is likely to be minimum, which result in the greatest receiver sensitivity. This is also nice for the transmit mode, when sending the 181.818 Khz carrier because the 0 to VCC swing on the output pin results in pleasingly symmetrical drive to the coil. The values of the resistors have little effect on receiver performance, but set the maximum drive current in the transmit mode.

In the base unit, which is AC powered and battery life is not an issue, the resistors are 220 Ohms each, which permits up to 23 milliamps peak current from pin 12, to give a little extra "kick" to the transmitter.  In the frequency meter, which is battery powered, the divider is made from 1K resistors and gets its power from an output port so it can be switched off to save power when the controller goes to sleep after a period of not being used.


Figure 3. The transmitter sends on-off keyed serial data on a 181.818 Khz carrier.

The transmit firmware routine shifts the byte to be transmitted a bit at a time, similar to the way a firmware UART works, shift one bit every 833 microseconds (1/1200 baud). If the bit being sent is a zero, the tristatable pin connected to the resonant loop antenna (pin 12 in Figure 2) remains as an input and the microcontroller set an 8 bit time to time out in one bit period, at which time the controller returns to shifting out bits without sending the carrier.

  If the bit being sent is a one, the tristatable pin connected to the resonant loop (pin 12 in Figure 2) is set to an output, the controller sets an interrupt timer to interrupt it after one bit period has passed, and enters a firmware timing loop that generates 181.818 Khz square waves on the tristatable pin, thus transmitting a carrier for one bit time. This is shown conceptually in Figure 3.

When sending a byte, a logic one start bit is sent (an 833 microsecond burst of carrier) first, followed by 8 data bits least significant bit first, and two stop bits which are logic zero (no carrier).

Getting a clean carrier out of the microcontroller while timing one bit period requires that the 8 bit timer and its interrupt be used so processor only spends time generating the carrier.

In pseudo code, here is the routine that generates the 181.818 kHz carrier:

forever:            ;Make 181.818 kHz square waves on output pin.
set output bit high
set output bit low
jump to forever

The 181.818 kHz carrier routine above is called as a subroutine after setting the 8 bit timer to interrupt it after one bit time. The corresponding interrupt  routine that is executed after the carrier is sent for one bit time is a very short one.

pop    r18        ;Pop interrupt return address
pop    r18       
reti              ;Return from interrupt

The pop instructions reposition the stack pointer so that when the return from interrupt instruction is executed, it returns to the routine that called the 181.818 kHz carrier generation routine. A similar method is used when sending a logic 0, except then no signal is generated on the output pin.


Figure 4. The receiver counts the number of times the waveform across the resonant loop exceeds the comparator threshold within a 1/4 bit period in order to determine whether a carrier is present or not.

The receiver is a lot like a sensitive frequency meter connected to a resonant loop antenna.  While the receive routine is checking for a logic 1 (the presence of a carrier), comparator interrupts are enabled, and an 8 bit timer is set to interrupt the routine that checks for the presence of a carrier 1/4 bit time later. Thus, after the 1/4 bit time interrupt, the register containing the bit count is a measure of the frequency of the signal received by the resonant loop antenna. If the corresponds to 181.818 kHz within preset limits, then the firmware considers the carrier to be present, and that the transmitter is send a logic 1. If the comparator interrupt count is too low, the assumption is that there is no carrier present. If the count is too high the assumption is that the interrupt source is noise or an interfering signal. 

This is a very rudimentary means of determining the presence of the carrier, and leaves the receiver open to treating noise as a signal. In my applications, I am involved in the process of interpreting the data, for example on an alphanumeric LCD display, so if the characters are garbage, its pretty obvious. If I were to use this for some sort of automatic control, for example, opening a door lock, a complex code of several bytes and either redundant transmission or a CRC (Cyclic Redundancy Check) would be needed to reduce mistakes. But for reading a frequency meter simply sending the ASCII codes is fine.

Decoding the string of carrier bursts, converted to ones and zeros by the carrier detection routines is done in a manner similar to a firmware UART - the firmware looks for a start bit, and if one is detected, it waits until the center of the following bit, and then samples each bit and shifts it into a byte wide register.

About Antennas

Half the external components in the minimum configuration are part of the resonant loop antenna, and the antenna's design dominates the transmitter strength and the receiver sensitivity.

The antenna is fundamentally a parallel resonant LC circuit tuned to the carrier frequency. Usually, I pick a capacitor with a practical impedance at the carrier frequency and then calculate the inductance needed to resonate with it.  The formula for finding the target inductance is , where L is the target inductance in henries, is the constant 3.14..., F is the carrier freqeuency in Hz, and C is the resonating capaacitor in farads.

I’ve used .033 uf capacitors in all the unitls I have built, and this resonates witih 23 microhenries.
here are several formuale availble for calculating the number of turns to use in a coil once you decide how much space you have for it, but I haven’t found one that seems to get real close. What I do, is wind a coil of about the number of turns I expect to need,  and then measure it. Since inductance is proportional to the square of the number of turns in a coil, I calculate an inductance factor for that size coil, and then I use that inductance factor to calculate the number of turns I will need. If I am careful, this goes pretty simply.

Inductance factor,  where K is the inductance factor, L is the inductance in Henries, and N is the number of turns in the coil. To find the the number of turns for a target inductance find N, where .  For the 5.5 cm loop, the constant came out as 1.11e-7 and the number of turns to get 23 microhenries came out to be 14.3 turns, so I just wount 14 turns and the measured inductance is 21.8 microhenries.

The antenna's operation in transmit mode is analogous to its operation in the receive mode, so let's take the receive mode first. The better the receiving antenna, the larger the signal appearing across it, and a lot of factors affect the amplitude. Looking at how these factors relate to one another (See Formula 1) can be useful in understanding how to optimize the design for a particular application. At first glance the formula may look a little intimidating, but all it really means is that the higher the carrier frequency, the more turns on the antenna, the higher the antenna's Q, the larger the antenna's diameter, and the stronger the RF magnetic field received by the antenna, the larger the signal at its output - larger signals on the output correspond to greater sensitivity.

Besides the received signal strength, sensitivity increases as linear function of the carrier frequency, the number of turns and the physical size of the loop and the Q (Quality factor) of the antenna.

V = K F N Q A B cos(alpha), where

V is the voltage across teh antenna coil in volts,
K is a constant for the antenna,
F is the carrier frequency in Hertz,
N is the number of turns in the loop,
Q is the quality factor fo the tuned circuit (the ratio of XL to R),
A is the effective area of the antenna in meters,
B is teh strength of the magnetic field fluctions at the antenna, and
alpha is the angle fo the receiving antenna with repect to that of the transmitter.

Formula 1. This is simplified expression that shows the major factors that affect signal amplitude at the input to the receiver.

In the case of this application, the upper frequency limit is set by the response of the controllers' on-chip comparator and the speed at which controller can process the incoming interrupts. The presence of the 160 kHz to 190 kHz license free band in the U.S. made 181.818 kHz very attractive since it is within the controller's range.

Antenna size, or effective area is one of the easier factors to control. The initial prototype and some of the battery operated devices I've built use 5.5 cm diameter circular air core loops because this is a convenient size and they are easy to make. In the RS-232 base unit, where space was not such an issue, I used a larger square air core loop that took up most of the available space to extend the range a little bit.

Photo 2. The antenna for the base unit is the largest I could neatly fit around the outer edge of the circuit board.

In another application, where space is a premium, I retrofitted an RS-232 LCD display board (See Photo 3) with the receiver circuit (only a coil, capacitor and two resistors + the firmware modifications). To get by with a small antenna footprint on the circuit board,  I wound the coil on a 30 cm ferrite rod. This particular coil is made of 29 turns of #30 wire on a 3 cm ferrite rod. The main advantage of the ferrite rod is that its effective area is much larger than its physical size (A in formula 1 is larger for a given circuit board footprint).

Photo 3. The wireless 2 line x 16 character display uses a small ferrite rod antenna, on the top edge of the circuit board, just above the TO-220 voltage regulator, to make it compact. Smaller sizes are possible, but as the antenna gets smaller, positioning with respect to the transmitter becomes more critical.

Another thing ferrite rods can do is raise the Q of the circuit, provided you use a ferrite with suitably low losses at the carrier frequency. A resonant circuit’s Q, which means “Quality factor” is the ratio of its reactance of its coil and capacitor to circuit resistance and is a fundamental measure of how well the circuit reuses energy stored in the
reactive components from cycle-to-cycle. For the Minimum Mass RF Link receiver, increasing a circuit’s Q increase the sensitivity, but at the expense of bandwidth. For the transmitter, increasing Q increases the amount of current in the antenna, and thus the strength of the  radiation.

Although calculating Q is straightforward if the circuit resistances are known, high frequency losses including skin effect, and the loading effects of associated circuitry,  calculating Q can give results that are off by a factor of two or more.

For the prototype coil design, 14 turns of #30 enameled copper wire were wound on a 5.5 centimeter air core, which gives 21.8 micro henries.

Based on this data, Q was calculated with the formula: Q =  XL/R (Formula 2) , where XL is the reactance of the coil, XL = 2 pi f L, (pi is the constant 3.14..., f is the resonant frequency, and L is the coil inductance in micro henries. The calculated Q was 32. But in real life, Q is much lower because of such circuit losses as skin effect, and eddy currents induced in adjacent windings.

To test a physical antenna, I measured the Q of a 5.5 cm prototype coils and its resonating capacitor by pulsing a low voltage across it with a field effect transistor and then time constant of the decay of the envelope, then calculated the effective  Q.

The Q of the circuit is found by the formula: Q = pi f t (Formula 3)

Where pi and f are the same as in Formula 2, and t is the time it takes the envelope of the ringing to decay  by 38%.  See Photo 4.

Photo 4. It took 6 half-cycles, or about 16.2 microseconds for the envelope to decay 38%.

Plugging the time constant into formula 3 gives a Q of only 9 at 182 kHz. About a third of what I estimated based on resistance. This is not bad news. The 3 db bandwidth of a resonant circuit can be found by BW = Q/f (Formula 4), so in this case, the 3 db bandwidth would then be 182 kHz/9 = 20 kHz. Good - it means that the antennas can sloppy and still work.

As an example of what you can get away with, the 5.5 cm loop antenna in the frequency meter lays over the battery pack (See Photo 5). I'm sure it lowers the Q of the antenna, but range to the base unit antenna or to that of the alphanumeric LCD is more than adequate.

Photo 5. A look at the guts of the battery operated frequency meter. The antenna is merely 14 turns of #30 wire held in place with clear plastic tape.

Firmware Usage

The firmware specific to the Minimum Mass Wireless Coupler is contained in an assembler include file. The incude file contains detailed instructions for its use and an application example. I have written include files for the Atmel AT90S2313 and the ATmega8, both operating at 4 Mhz. The include files only references one register by name, RFChar, the register by which the incoming and outgoing byte are transferrer, and the rest are referenced directly by register name, so that during assembly, there won't be any "Register Already Defined" warning messages resulting from use of some registers by both the main program and the include file. The Minimum Mass Wireless Coupler routines save the status register and the contents of all working registers they use except RFChar. When returning to the calling program, the status register and all working registers except RFChar are restored.

The main program needs to take care of some housekeeping, such as assigning the variable RFChar,  assigning I/O for the transmit pin (which could be separate from the receive pin if you want to use separate antennas or a more complicated circuit with, for example, a high power output stage or receive pre amp), the Activity LED, the pins associated with analog comparator input 0, and a pin to switch power to the bias resistors.

There are four callable subroutines in the include file.

SendRFByte  is a subroutine that sends the contents of RFChar via the Minimum Mass Wireless Coupler.

The subroutine, ReceiveRFByte, waits for start bit on RF channel for 63.75 bit times. If a start bit is found, the entire incoming byte is received and placed in RFChar and the carry bit is set. If a start bit is not found. the routine returns with the carry bit clear. This allows polling for incoming data without the receiver getting hung up.

As an example,

   rcall    ReceiveRFByte  ;Wait for character to be received
   brcc     getchar        ;If carry bit is clear, go back and wait some more.

Since switching from transmitting to receiving requires a little time for the analog components to settle, some delays routines are necessary. The subroutines that these delays are PostXmitDelay and PostRCVDelay. PostXmitDelay  is called when switching from transmitting data to receiving data and PostRCVDelay is called when switching from receiving data to transmitting, and its purpose is to wait for the unit on the other end to become ready to receive.

Here is a short program that uses all of the callable routines correctly. I have used this program many times while testing pieces of the Minimum Mass Wireless Coupler. It receives a character over the Coupler and echoes it back to the sender.

    rcall ReceiveRFByte    ;Wait for a character to be received.
    brcc  EchoTest         ;If nothing received, go back and check again.
    rcall PostRCVDelay     ;Wait for far end transceiver to recover.
    rcall SendRFByte       ;Echo character to far end.
    rcall PostXmitDelay    ;Wait local transceiver to recover.   
    rjmp  EchoTest         ;Go back to top and get another character.

While a character is being transmitter or received, the pin associated with the activity LED goes high.

Here are links to some projects on this site that use the Minimum Mass Wireless Coupler.

Terminal Interface with Minimum Mass Wireless Coupler

Scanning Voltmeter with Minimum Mass Wireless Coupler

Frequency Meter with Minimum Mass Wireless Coupler

LCD Display with Minimum Mass Wireless Coupler

Tiny Tuned Loop Antennas for the Minimum Mass Wireless Coupler

External link:
Two students at Cornell University incorporated some of these concepts in their school project. The project as posted at the university website is very complete and very well written.
A Remote Controlled DMM With Minimum Mass Wireless Coupler

HOME (more projects)

Contents ©2004, 2005, 2012 Richard Cappels All Rights Reserved. http://www.projects.cappels.org/
First posted in March, 2005.

You can send  email to me at projects(at)cappels.org. Replace "(at)" with "@" before mailing.

 Use of information presented on this page is for personal, nonprofit educational and noncommercial use only. This material (including object files) is copyrighted by Richard Cappels and may not be republished or used directly for commercial purposes. For commercial license, click here.

  Liability Disclaimer and intellectual property notice
(Summary: No warranties, use these pages at your own risk. You may use the information provided here for personal and educational purposes but you may not republish or use this information for any commercial purpose without explicit permission.) I neither express nor imply any warranty for the quality, fitness for any particular purpose or  user, or freedom from patents or other restrictions on the rights of use of any software, firmware, hardware, design, service,information, or advice provided, mentioned,or made reference to in these pages. By utilizing or relying on software, firmware, hardware, design, service,information, or advice provided, mentioned, or made reference to in these pages, the user takes responsibility to assume all risk and associated with said activity and hold Richard Cappels harmless in the event of any loss or expense associated with said activity. The contents of this web site, unless otherwise noted, is copyrighted by Richard Cappels. Use of information presented on this site for personal, nonprofit educational and noncommercial use is encouraged, but unless explicitly stated with respect to particular material, the material itself may not be republished or used directly for commercial purposes. For the purposes of this notice, copying binary data resulting from program files, including assembly source code and object (hex) files into semiconductor memories for personal, nonprofit educational or other noncommercial use is not considered republishing. Entities desiring to use any material published in this pages for commercial purposes should contact the respective copyright holder(s).