Download

... Mek's creations and more

AM morse code transmitter with AVR

I wanted to build a simple AM transmitter with only a few meters range, for one geocache where morse code would be transmitted. At first I thought about switching an external "constant-beep" transmitter via AVR but then I stumbled upon a simple schematic that did the whole thing with AVR and only single transistor.

The original source is on this page.

I copied the schematic into EAGLE to make it more visually appealing while making the component values more clear.

It's pretty simple.

AVR runs on internal oscillator at 8 MHz that is divided by 8, so the real frequency is 1 MHz. Clock pulses are output from AVR on PB4 (pin 3). This carrier signal of frequency 1 MHz is modulated by pulses from PB3 (pin 2), which is driven by code. The result is amplified using N-MOSFET and fed into the antenna.

The signal can be tuned on AM band of a regular radio around 1 MHz (not exactly because internal oscillator is not too precise).

Program is simple enough:

#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define _BV(bit) (1 << (bit)) // _BV macro is not defined so define it here

void beep()
{
    for (char i = 100; i; i--)
    {
        DDRB |= _BV(PB3);_delay_ms(1);
        DDRB &= ~_BV(PB3);_delay_ms(1);
    }
}

void rest()
{
    _delay_ms(200);
}

void dot()
{
    beep();
    rest();
}

void dash()
{
    beep();
    beep();
    beep();
    rest();
}

void space()
{
    rest();
    rest();
    rest();
    rest();
}

void spaceWord()
{
    space();
    space();
}

int main()
{
    DDRB |=_BV(PB3);
    for (;;)
    {
        dash(); dash(); space(); // M
        dot(); space(); // E
        dash(); dot(); dash(); space(); // K
        dot(); dash(); dash(); space(); // W
        dot(); space(); // E
        dash(); dot(); dot(); space(); // B
        _delay_ms(1500); // silence
    }

    return 0;
}

When programming, fuses need to be set like this:

  • Internal Oscillator 8 MHz
  • DIV8 enabled
  • CKOUT enabled

Range of the transmitter depends on antenna length. With 10cm wire it was only 1 meter, but with 1,5m wire it covered whole room (which is good enough for me so I didn't try any further). It worked best when I held the antenna in my hand.

The original author used AVR ATTiny44A, I used ATTiny85, which is smaller but still has plenty of usable pins. Also, the transistor should have been 2N7000, but that is an exotic one in Slovakia. I used a different enhancement mode N-MOSFET: FQPF8N60C, and I am pretty sure any other transistor of this type would work.

You can see the result in the following video. I am showing reception on an ordinary radio, also in SDR-Sharp in PC

ZIP file for download contains schematic in PNG and EAGLE format, and source code as an Atmel Studio solution.

Comments (3)

:} lol :D =) :o) :B 8-D :P :-)) :-< ;) :-/ :( :.( O.o ;o) :-* 8-| :-| 8)
GregK   1st January 2018 1:58 am
I was actually thinking it just transmits the last 4 digits of the lat and long and you just type that in to your GPS and that takes you to the real cache. But your idea is better :)
Mek   23rd December 2017 11:19 am
Hello! No worries, this idea is here for sharing so it will be cool if you use it.
Anyway, this was only an idea for a geocache, but I have yet to find an electronically-lockable box (that can be also opened with a key if necessary) so it is only in the planning stage. But I will surely update this article with link to the geocache, if it ever gets published :)
GregK   23rd December 2017 11:16 am
Hey! Cool idea I had the same one to make a geocache! :) I thought it was an original idea but I guess not :( I was looking for a way to make a simple CW transmitter for AM and I found this. Anyway I'm going to do this thanks for the great post! What is your cache's number ill be sure to take a look and maybe find it one day.

Toplist