NOTE: This is an archive of my old blog. Go to http://gonium.net for my current website.

Arduino DCF77 v0.2 released 14

Posted by md on January 06, 2007

4:57 nixietube clock

The sketch for decoding the time radio signal DCF77 is greatly improved: I use interrupts for handling the signal and a backup timer has been added.

Note that there is no interface at the moment, the time is simply put to the serial line. But it should be easy to add a display to show the time. The sketch eats roughly 6000 bytes of memory – if you want to add a user interface, you should consider buying a 16 kb Arduino ;-)

Of course, you also need the DCF77 receiver module and a pullup-resistor, as described in my old post.

You can download the code here:

BTW: The picture above shows a Nixie tube clock. I ripped the picture shamelessly from flickr, there’s a photostream showing the creation of the clock. Cool project.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Erik VdB Thu, 25 Jan 2007 01:12:21 UTC

    i cannot open the arduino-dcf77-clock-0.2.0.tar.bz file, after chang ing .bz to .gz winzip replys that it contains 0 files

  2. md Thu, 25 Jan 2007 10:37:56 UTC

    Hi Erik,

    I just downloaded the file to my linux box and it extracted smoothly:

    $ tar xvjf arduino-dcf77-clock-0.2.0.tar.bz

    Note that the archive is a BZip2 archive – I don’t have Windows around, maybe Winzip doesn’t understand this.

    I uploaded a ZIP archive for you:

    http://gonium.net/media/arduino-dcf77-clock-0.2.0.zip

    Tell me if it works for you.

    -Mathias

  3. Erik VdB Thu, 25 Jan 2007 12:23:37 UTC

    got the pde now, i still do not understand why i cannot the v2 file, the v1 file did work after removing the .bz extention.

    thanks i will try v2 now

  4. aslary Wed, 14 Jan 2009 19:54:02 UTC

    Hi Erik
    what do you mean –> .bz extention.
    And md! I have read the datasheet of Atmega168 and didn’t find timer2 (just find timer0/1)

  5. Richard Sat, 06 Jun 2009 19:39:03 UTC

    Hi Mathias,
    thanks for your very nice job.

    I have an Arduino Duemilanove ATMEGA 328 and no idea on the diff with 168…

    Pb whith TCCR2 at compile…

    Thanks.

  6. Sascha Sat, 10 Oct 2009 22:17:42 UTC

    Hallo Mathias,

    versuche mich auch gerade darin, Deine DCF77 Software auf meinen Arduino zu übertragen.
    Leider habe auch ich einen Fehler beim Compilieren, weil TCCR2 nicht definiert ist.
    Liegt das an V017 der Arduino Software?

  7. Stefan Tue, 20 Oct 2009 23:06:23 UTC

    Hi md

    I just found your latest code on the project. but sadly I still can’t make it work with my diecimila >

    In function ‘void DCF77Init()’:
    error: ‘TCCR2′ was not declared in this scope

    I use the latest enviroment 0017 – is this a problem?

    Thanks a lot,
    Stefan

  8. nomike Fri, 27 Nov 2009 21:31:41 UTC

    Has anyone solved the TCCR2 problem yet? I’m using environment version 0017 too, and a duemilanove with an “ATMEGA328″.

  9. Rory Mon, 04 Jan 2010 12:03:07 UTC

    I got it compiling properly by declaring the integer but also theres 2 others that need to be declared, so just add this near the top somewhere

    int TIMSK;
    int TCCR2;
    int OCIE2;

    So far with my reciever that i got today i have not got it working but its most likely my fault.
    Rory

  10. Jan Willem Fri, 08 Jan 2010 16:42:03 UTC

    I have the same error and I am using a Freeduino V1.6 wtih the Conrad DCF77 and environment 015.

  11. hiac Wed, 20 Jan 2010 10:58:37 UTC

    It’s the same form me!
    error: ‘TCCR2′ was not declared in this scope
    Are there any solutions until now?

    I’m using Nano-Board and also Arduino-Software version 0017.

  12. Willy Sun, 24 Jan 2010 16:57:57 UTC

    Hi Stefan
    I have just the same problem with my Arduino Pro ATmega 328

    In function ‘void DCF77Init()’:
    error: ‘TCCR2′ was not declared in this scope

    I use also the latest enviroment 0017
    What have you done so that it runs the program?

    Thanks a lot for your help,

    Willy

  13. elektro_wolle Sat, 13 Feb 2010 23:10:29 UTC

    Hallo Mathias,

    Thanks for sharing the code, but I had nearly no chance to retrieve a clean signal from the conrad DCF77 receiver. Every 3 to 4 seconds the debug information shows several short signals before the 100ms and 200ms signals. I’ve modified the interrupthandler to ignore the jitter:

    /**
    * Interrupthandler for INT0 – called when the signal on Pin 2 changes.
    */
    void int0handler() {
    int length = millis() – previousFlankTime;
    if (length < 10) {
    // ignore jitter
    return;
    }
    // check the value again – since it takes some time to
    // activate the interrupt routine, we get a clear signal.
    DCFSignalState = digitalRead(DCF77PIN);
    }

    and removed the DCFSignalState assignment in the main loop.

    The problem concerning TCCR2 can be easily solved via the MsTimer2 Library. Changing the interrupt initialisation to:

    /**
    * Initialize the DCF77 routines: initialize the variables,
    * configure the interrupt behaviour.
    */
    void DCF77Init() {
    previousSignalState=0;
    previousFlankTime=0;
    bufferPosition=0;
    dcf_rx_buffer=0;
    ss=mm=hh=day=mon=year=0;
    #ifdef DCF_DEBUG
    Serial.println("Initializing DCF77 routines");
    Serial.print("Using DCF77 pin #");
    Serial.println(DCF77PIN);
    #endif
    pinMode(BLINKPIN, OUTPUT);
    pinMode(DCF77PIN, INPUT);

    #ifdef DCF_DEBUG
    Serial.println("Initializing timerinterrupt");
    #endif
    MsTimer2::set(1000, advanceClock); // 500ms period

    #ifdef DCF_DEBUG
    Serial.println("Initializing DCF77 signal listener interrupt");
    #endif
    attachInterrupt(0, int0handler, CHANGE);
    }

    removing the old interrupthandler and added the advanceClock function:

    /**
    * The interrupt routine for counting seconds – increment hh:mm:ss.
    */
    void advanceClock() {
    ss++;
    if (ss==60) {
    ss=0;
    mm++;
    if (mm==60) {
    mm=0;
    hh++;
    if (hh==24)
    hh=0;
    }
    }
    }

    The timer is started in "Parity check OK – updating time" branch via MsTimer2::start(). The sideeffect of placing the MsTimer2::start after a positive parity check is that the time is only printed after successful decoding of the DCF77 Data.

    I'll mail you the complete sketch for integrating the changes in a version 0.0.3

    Best regards

  14. Elektrowolle > DCF77 Empfang mit Arduino Sun, 18 Apr 2010 12:28:09 UTC

    [...] mein DCF-77 Empfänger ab und zu Aussetzer zeigte, funktionierte der Code von http://gonium.net/md/2007/01/06/arduino-dcf77-v02-released/ leider nicht auf [...]

Comments