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 (0)

:} lol :D =) :o) :B 8-D :P :-)) :-< ;) :-/ :( :.( O.o ;o) :-* 8-| :-| 8)

Toplist