Path: Home => AVR-EN => Applications => DCF77 alarm clock
DCF77 Weckuhr Applications of
AVR single chip controllers AT90S, ATtiny, ATmega and ATxmega
DCF77 alarm clock with LCD

DCF77 alarm clock with LCD

This application of an ATmega16 provides an alarm clock with the following properties:

0 Content

  1. Hardware
    1. Schematic of the hardware
    2. Self-made high-performance DCF77 receiver
  2. Mounting and operation
    1. Mounting
    2. Hardware testing
    3. Operation
  3. Software
    1. Source code, assembling, binary transfer
    2. Test- and debugging assistence
    3. DCF77 signal decoding and diagnose
The complete project description, including all subpages and source listings, can be downloaded in one single PDF document here (111 pages, 3.7 MB).

1 Hardware

The hardware consist of the alarm clock and the DCF77 receiver.

1.1 Alarm clock

Schematic alarm clock m16 The alarm clock consists of the controller ATmega16 and some peripherals.

The controller clock is sourced from an xtal of 3.2768 Mhz on the XTAL1 and XTAL2 pins. See here for other clock options. From this clock source the device controls date and time.

The in-system-programming adapter ISP6 on the pins RESET, MOSI, MISO and SCK allows to program the chip.

The four-line LCD is attached to port C with the data bus and controlled by two portpins on port B. The 10k trim potentiometer controls the contrast of the LCD.

The backlight on pins 15 and 16 of the LCD is driven by the operating voltage and PWM-switched by OC2 of the controller.

To pins ADC0, ADC1 und ADC2 are attached:
  1. a potentiometer for adjusting input numbers,
  2. a photo transistor for measuring ambient light,
  3. the field strength voltage from the DCF77 receiver.
The supply voltage for the AD converter on AVCC is filtered with a 22µH coil and a ceramic capacitor of 100nF. The analog reference voltage on AREF is blocked with a capacitor of 100nF.

The signal output of the DCF77 receiver is connected to INT0. The polarity of the signal is irrelevant, the software works with both (see the signal analysis section for details of the decoding process).

The three keys for operation are connected to portpins PB0, PB1 and PB2.

The OC1A output from timer TC1 drives via an electrolytic capacitor the speaker, which plays melodies.

The power supply is built with a 9V transformer, two power diodes, an electrolytic capacitor and a 5V regulator with two Tantal capacitors. The 5V supply is fed via a Schottky diode to allow to add a combination of four rechargeable batteries as second supply. The rechargeable batteries are via a resistor of 3k3 loaded with a small current (3 mA when completely unloaded, 1 mA with completely loaded batteries) from the 9V source.

1.2 The DCF77 receiver

The DCF77 signal can be supplied by a commercial module or via the self-made receiver here. This receiver was used in developing the software.

2 Mounting, initial operation, operation

2.1 Mounting

DCF77 m16 controller The controller part was mounted on a double-sided breadboard. The 16-pin connector for the LCD is mounted towards the soldering-side and the connections are made with solderable enameled copper wire.

The six-pin ISP connection and the sixteen-pin connector can be seen in the lower part of the picture. To the left side the supply connector is located.

DCF77 mounting the controller in a box Here the mounting of the components in a plastic box can be seen. To the right the power supply, to the left the speaker on the side wall, below the board with the controller and a small board with the keys and the photo transistor.

On the bottom of the box the DCF77 superhet and the four rechargeable batteries are mounted. Because the superhet is mounted very near to the speaker the receiver is plugged with strong stray signals in case that music is played on the loudspeaker. When the music finalizes it lasts a few seconds until the influence of those stray signals diminishes and the reception of DCF77 signals is free of errors.

2.2 Initial operation

DCF77 m16 fuses When putting the device into operation the fuses of the ATmega16 have to be programmed to work with the external xtal of 3.2768 MHz.

To ease debugging of the hardware, the source code has several test modes included. Those test modes can be invoked by setting the debug switches in the source code to 1, reassembling and burning the generated hex code into the controller chip's flash. All debug options are in detail described here. Setting at least one of the debug switches to 1 invokes the include source file, which normally is not producing executable code.

DCF77 LCD debugging First the LCD shall be tested because all further test steps depend from the LCD and its correct functioning. The LCD test issues the text shown here and does nothing else than that.

Further test modes are:
  1. dbgAdc: displays the result of AD conversions,
  2. dbgKey: displays the state of key inputs,
  3. dbgSpk: sounds a 1,000 Hz tone on the speaker,
  4. dbgDcfDur: displays the duration of signals on the DCF77 input in milliseconds (high and low),
  5. dbgDcfSig: displays signal errors on the DCF77 input with longer text messages,
  6. dbgDcfBits: displays the last eight bits received via DCF77,

    Debug DCF bits

  7. dbgMusic: displays diverse parameters when playing music.
With those debug switches all external hardware can be tested.

2.3 Operation

Key operation Operating the alarm clock is rather simple. The attribution of keys to actions is simple and adjusting, e. g. the alarm time, is rather quick.

All key functions appear in line 4. A comprehensive description of key functions is given here.

3 Software

3.1 Software in HTML-Format

The complete source code can be viewed in html format here in your webbrowser.

3.2 Download of the assembler source code

To assemble the source code the following files have to be downloaded and stored in the same directory:
  1. dcf77_clock_m16_v5_en.asm (Main source file),
  2. (the LCD routines),
  3. (Musical notes, melodys and routines),
  4. (Debug routines).
Consult the debug switches (all have to be zero for the final version) and the adjustable constants in the main source code file to adjust the code to your needs. Then assemble the code (either with ATMEL's assembler 2, with gavrasm or with the assembler simulator avr_sim. If you do not know how to assemble, consult the how-to for Linux or Windows.

Do not forget to change the fuses of the ATmega16 and, if your xtal frequency is different from 3.2768 MHz, to adjust the constant clock in the main source code, otherwise your time and date will not be correct.

3.3 Description of the software, documentation

The functioning of the software is comprehensively described here, all functions are in theory and practice listed there.

Praise, error reports, scolding and spam please via the comment page to me.

To the top of that page

©2018 by