DCF77 Time Signal Decoding

DCF77 Time Signal Decoding

Description


This project shows how to receive and decode the DCF77 signal and extract the contained date and time information.

For more information regarding the DCF77 signal check the link section.

 

Hardware


DCF77 receiver module

For receiving the DCF77 signal a receiver module is required. This module receives the DCF77 radio signal and outputs it as serial stream.

DCF77 module

Connection to the Microcontroller


The module just needs to be connected to the power supply and the signal output of the module needs be be connected to an I/O pin of the microcontroller. The module which I use has an open collector output, hence a pull-up resistor is required.

Connecting DCF77 module to Microcontroller

Software


The driver which is getting described here is written in C language for the CCS C Compiler (Microchip C18 compiler support will follow).

To integrate the DCF77 driver, you just need to define the pin where the DFC77 module is connected to and include the driver header:

/* --- configure DCF77 driver --- */
#define DCF77_LED_PULSE     PIN_A0  /* pin shows DCF77 pulses */
#define DCF77_PIN_DATA      PIN_C1  /* pin to where the DCF77 signal is being received */
#include "dcf77.h"

The decoding of the DCF77 signal is getting done via a 1ms timer interrupt. So you need to configure a timer to overflow every 1ms and call the DFC77 task inside the interrupt service routine. In the below example, timer 1 is used to generate the 1ms interrupt:

#INT_TIMER1
void isr_timer1()
{
/* reload timer 1 registers to get 1ms timer interrupt */
set_timer1(TMR1_RELOAD_VAL);
/* call DCF77 task for decoding the DCF77 signal */
dcf77_1ms_task();
}

To get the decoded time and date signal you just need to check if new data has been received via the driver function dcf77_newdata(). If new data is available, you can get the current time and date via the correspoding driver functions:

/* if new DCF77 data is received and the data is valid */
if (dcf77_newdata() != FALSE)
{
min = dcf77_get_min();
hour  = dcf77_get_hrs();
day = dcf77_get_day();
month = dcf77_get_month();
year = dcf77_get_year();
/* output date and time to RS232 @ 19.2 kbaud */
printf("date: %02x.%02x.%04x time: %02x:%02x\n\r",
day,
month,
year,
hour,
min);
}

A full demo application can be found in the Download section below.

Download


Links