Fair warning: the following details on what led me to experiment with AVR-based AM radio transmission are rather long and convoluted. Feel free to skip to the good stuff.
Well just a couple of months ago I was in Toronto presenting a paper at this year’s IEEE CASE conference. While there I happened to speak with one gentlemen about his work in agricultural automation. He was looking for ways to autonomously and uniquely identify plants growing in the rows of a field. Now although each plant could be easily identified by the base of its stalk, the leaves of several plants often grew together. So if you wanted to take samples of a certain plant’s leaves, you might have trouble tracing base to leaf (particularly if you were a robot). Well this got me to thinking: what if we measured the electrical resistance between stalk base and leaf while sampling? Then perhaps we could determine which leaves belong to which stalk, thereby uniquely identifying our samples.
To test this idea, I popped outside with my multimeter and started sampling. Sadly, my initial resistance measurements, made by poking sewing needles into leaves and stems, proved unfruitful. Each pair of points I tested showed an impedance in the megaohm range, regardless of whether or not the points were located on the same plant. In other words, I couldn’t find a way to distinguish measurements taken on the same plant from measurements taken between plants. Well eventually I got to thinking that perhaps this was due to capacitance within the plant, and that I should instead try an AC impedance measurement. This technique has actually proven much more interesting. I’m still in the process of performing frequency response tests, but I’ll likely post my results next week.
So how does the electrical impedance of plants relate to AM radio transmission? Well, as I was injecting different high-frequency (10-100kHz) signals into my philodendron, I noticed that even with my second electrode disconnected, I still picked up a small but measurable radiated signal. This got me to thinking – can plants act as decent antennae? Or rather, plantennae? To find out, I decided to build a simple radio transmitter. And the simplest technique for radio transmission, as far as I know, is amplitude modulation.
Faced with the task of constructing an AM transmitter, most people would probably build themselves a purely analog circuit based on one of the thousands of schematics available online. However, I don’t have much of a selection of analog parts and oscillators. Plus, I wanted to build something I’ve yet to see online: a microcontroller-based AM transmitter.
First, a little background is in order. According to the US Office of Spectrum Management, the AM broadcast band runs from 535 to 1605kHz; it’s the largest blue strip shown in the frequency allocation chart below (an equivalent chart for the UK can be found here):
So the first thing I needed was a carrier wave oscillating somewhere within this frequency range. I then needed a way of modulating the amplitude of said carrier wave at any given audio frequency. This is the basic principle of amplitude modulation: your low-frequency audio signal essentially “rides” on top of a high-frequency carrier wave.
To accomplish this task, I used one of the timer/counter modules provided on my ATMega324, an 8-bit AVR microcontroller. With the chip internally clocked at 8Mhz, I configured counter TC1 to generate a PWM signal at approximately 540kHz. This output was then modulated via changes to its duty cycle (scroll to the end for source code):
At the top of the above image, in blue, is the PWM output generated by the ATMega324. You can see that its duty cycle is being modulated between about 5% and 50%. The rate of this modulation is controlled by a second MCU counter (TC0). Now this square-wave output isn’t quite ready for transmission. While it could be fed straight into an antenna, it should first be filtered to eliminate the harmonics inherent in any square-wave. This filtering actually converts the square-wave into a sine wave, producing the modulated output shown in yellow above. This signal can now be picked up by any AM radio, which will then convert this modulated transmission into an audio signal (the red line above).
In order to filter the AVR’s square-wave output into a sinusoidal AM signal, I designed a simple resonant RLC circuit. Not only does this clip off most of the square-wave’s harmonics, it actually provides a slight voltage amplification through resonance between C1 and L1. The resistance R3 in this circuit was needed to prevent excessive current draw from the AVR, and R2 is included to model the series resistance of the inductor L1:
Now unfortunately, the components I had available yielded a resonant frequency of about 563kHz – slightly higher than my 540kHz target. However, the PSpice bode plot above still predicts a significant gain from the RLC circuit at 540kHz. Computing the resonant frequency of any RLC circuit can also be accomplished by using this simple formula:
In addition, I ran simulations of this circuit’s transient response using a pulse input:
The ringing you see in the transient response above is not intentional, but has to do with the input frequency being slightly different from the resonant frequency. This is a phenomenon called beating. Fortunately, the beat frequency above is about 20kHz, which is well outside of the audio range, so this won’t impact the transmission of any signals.
So with the components selected, I proceeded to build and program my transmitter. An antenna was connected between the inductor and capacitor shown in the schematics above. Initially I used a piece of wire about 40.6″ in length (an even fraction of the transmitted wavelength). As planned, I also tested the system using a shorter length of wire (about 36″) connected to a houseplant via a small sewing pin. Interestingly, the plant actually did function slightly better than the wire whip antenna:
The receiver I used was a simple Timex clock radio, positioned on the other side of the plant, approximately three feet from my electronics and wire antenna:
As I mentioned, the “plantenna” did slightly improve reception. However, the effect was admittedly quite small. My fingers actually had a greater impact on the signal’s strength than did the plantenna. Whenever I touched the leads of the resistor in my RLC filter, the volume and clarity of the received signal were noticably improved. Perhaps I need to try a few other varieties of plants?
Of course, what this circuit really needs is an active amplifier. However, increasing my transmission radius much beyond three feet would probably fracture a law or two. As it stands, I imagine my radiated power is somewhere in the microwatt range, so I doubt the FCC will be banging down my door any time soon. But you never know…
One final thing I found interesting: high-power AM signals actually transmit significantly farther at night than during the day. I’d read about this, but had never experienced the effect until the other night. During the daytime, AM540 had been almost completely clear of broadcasts. But at night, I was pulling in one station very clearly. In fact, it was almost overpowering my teeny transmitter. According to this website, “distant AM radio stations are better received at night because the ionosphere that reflects AM stations is protected from ionizing radiation and ionized particles from the Sun.” Pretty nifty, eh?
So having successfully tested this AM transmitter, my next logical step was to program it to play music. And the first thing that came to mind? The Tetris theme! I’ve played so much of that game it’s practically burned into my memory. So creating the following video wasn’t too tough, it just took a bit of trial and error getting the timing right. (And sadly, something weird seems to have happened to the audio during upload compression…)
- The complete AVR Studio project can be found here
- Or, if you just want a peek at the source code, try: am_test.c