The AVR AM Radio Transmitter (and Plantenna)

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.

The Plantenna?

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.

The Technique

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):

US Frequency Allocation ChartSo 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):

AVR Amplitude Modulation Technique (not to scale)
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:

PSpice RLC Circuit Schematic - The antenna is connected at the voltage probe.

PSpice Bode Plot - Cursors are located at ~540kHz

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:

RLC Resonant FrequencyIn addition, I ran simulations of this circuit’s transient response using a pulse input:

PSpice RLC Circuit Transient Response Schematic - The antenna is connected at the voltage probe.

PSpice Transient Plot
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:

AVR AM Radio Circuitry

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:

Timex Clock Radio ReceiverAs 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?

The Video

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…)

Download

  • The complete AVR Studio project can be found here
  • Or, if you just want a peek at the source code, try: am_test.c
This entry was posted in Hobbies, Just For Fun, Test and tagged , , , , , , . Bookmark the permalink.

24 Responses to The AVR AM Radio Transmitter (and Plantenna)

  1. Pingback: Electronics-Lab.com Blog » Blog Archive » Simple AVR AM Radio Transmitter

  2. Pingback: Plantenna: the plant antenna - Hack a Day

  3. Pingback: Plantenna: the plant antenna | Group51.org

  4. Mike says:

    Just to clarify, based on some of the comments I’ve been reading on HaD…

    First, no, I’m clearly not an expert on radio transmission. Not even close. I can really only tell you what worked and what didn’t. I don’t have any RF instruments so I can’t quantify any of the results above. All I can say is that with that alligator clip connected to the plant, reception was improved qualitatively. With the clip disconnected (but the wire STILL attached to the circuit), reception was not quite as good. But again, it was a small difference. With regard to the RLC circuit, no, it doesn’t amplify the output power. However, it does amplify the voltage at the antenna. That’s the resonant nature of this RLC circuit. Granted, not all RLC circuits are resonant (underdamped), but this one was designed to be.

    Anyway, I hope you’ve still found something here interesting/useful! My apologies if I’m wasting your time. Thanks!

    -Mike

  5. Josh says:

    Awesome project! I’ve done a lot of looking around for projects using the ATMega series as a digital frequency synthesizer and as far as I can tell you’re the first to do it successfully. Just so you know, here are the basic FCC requirements for unlicensed intentionally radiating devices: http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;sid=8bff1cfa6c08b479de2ce647b7f5b897;rgn=div5;view=text;node=47%3A1.0.1.1.14;idno=47;cc=ecfr#47:1.0.1.1.14.3

    Basically, it can’t cause interference, and it has to be under 100mw. I’m curious to hear a little bit more about what inductor you used and whether it was homemade or store-bought. In my completely analog experiments I’ve had to rely on hand-rolled inductors that are far less than perfect to say the least. Thanks for posting this! I’m inspired to dig up my Arduino and try making some waves with it again.

    • Mike says:

      Thanks Josh, I really appreciate the comment! That’s a great link as well. I’d thought about searching for something like that but couldn’t figure out where to begin.

      So in this case I just used a pair of 1mH, commercially-made inductors (the two blue cans in the picture/video). They’re not great, but not terrible either. I can’t say I’ve ever tried making my own, although I did once wind a small transformer. At the moment I don’t have any proper wiring available…

      Thanks again!

  6. James says:

    Excellent project and good thought process, love it. Quite inspiring.

  7. Martin says:

    Hi Mike,

    Picked up this project on HAD, and wanted to say nice work. I’ve been wondering if this is possible with a microcontroller and it looks like it is!
    Thanks!

  8. Stephan says:

    Us ham radio operators are known to load up things like spruce trees. With a big spike into the tree.. or a few of them and some ground radials you can load up and transmit. Just keep the power low, you might just light the tree on fire. I think the biggest problem with your project tho is that you are using the AM band. The wavelength down there is from 180m to 520m, so your plantenna is way to short. Quarter wavelength is usually a good start for a radiating device. You could try the FM band if the regulations in your country permit you to do so. Up there at least the wavelength is near 3m, so you could easily use 2 plants to make a half wave dipole and get better results. Heck, you could feed it directly with a small tuner from coax and see how well it work.

    Just my two cents.. Cool project..

    • Mike says:

      Wow, that’s pretty cool Stephan! I guess spruce trees are quite a bit closer to AM wavelengths. I tried to at least hit an even multiple of the 540kHz wavelength, but I suppose such a small fraction of a wavelength doesn’t do much good. I’d love to try out FM, but I couldn’t do it with the AVR – not without some serious overclocking.

      Thanks!

      • Stephan says:

        You could play on the FM band by building a simple oscillator for the frequency of use and then figure out a way for your AVR to modulate the signal. Even if it was just a simple tone. Even with out the signal being modulated you would at least hear the carrier, same with the AM band. With AM detection you will hear the carrier as a ‘clean spot’ on the band, but if you can find a general coverage receiver that can do SSB (Single Side Band) you will be able to discriminate the carrier with a slight frequency offset with the SSB receiver and hear your carrier as a tone. Might give you better results to work with.

        Give it a shot, get a simple receiver that has SSB like the Grundig YB400. Radio Shack used to sell them and you can get them on the cheap via EBay. They are nice little receivers.

        As for the wavelength of your AM plantenna… Try a Pine tree or Spruce… or maybe a big vine? see what happens. If you like email me and I can send you some photos and plans on how I have done It before.

        • Mike says:

          Cool, thanks for the information! I’d love to learn more about radio communication – my school never offered much on the subject. I’ll see what I can dig up on FM modulators and receivers on EBay…

  9. Shah says:

    I very interested with this

    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.

    How do you know the beating frequency is 20kHz? any formula ?

    • Mike says:

      Hi Shah,

      I computed the 20kHz number just by looking at the graph above. I can see that the beating is happening with a period of about 50us, so taking the inverse of that you get 1/0.00005 = 20,000Hz.

      However, you’re likely looking for a more generic way of computing this. Well, I’m no expert, but I believe you can do this by simply taking the absolute value of the difference between your two frequencies. In other words, if my filter’s resonant frequency is 563kHz and I’m actually feeding it a 540Khz signal, I should see a 23kHz beat (abs(563 – 540) = 23), and that is about what I get (20 ~= 23). Also, this page may prove more useful to you: http://www.sasked.gov.sk.ca/docs/physics/u5c42phy.html

      Thanks for visiting!

  10. Nikolas says:

    Hi Mike,
    Very interesting experiment !

    This technique is much like “The forced oscillation technique” (FOT) which is also used to measure respiratory rate by measuring slightly changes of human body impedance..

  11. flz47655 says:

    Your article is very very interesting, do you have a version of code for Arduino (or an ATMega328 that run at 16Mhz?

    • Mike says:

      Thanks! I don’t have code specifically for the 328, but it’s got the same timers as my 324, so you should be able to use the exact same *.c file I posted above, just with modifications for 16Mhz instead of 8Mhz. So basically just cut the delay and timers in half by adjusting the TCCR registers (you’ll have to check the ATMega328 datasheet for details). I’m not sure if you can use this directly with the Arduino interface though or if you’ll have to compile it through AVR Studio…

  12. flz47655 says:

    Thank you Mike, I will try to adjust TCCR.
    I’ll keep you updated

  13. Valter Fukuoka says:

    Hi Mike, do you have a complete schematics picture or draft, or any closeup photo of the circuit (breadboard)?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>