Thanks to Lasse Lambrecht, I can release a new version of the DCF77 code – now you can run it on the ATMega168-based Arduinos.
The ATMega8 differs slightly from the ATMega48/88/168-series: The latter chips have an extended Timer2-hardware and therefore need different initializations. Lasse send me a nice adjustment of the code, basically he uses preprocessor flags to figure out which initialization commands to use: #ifdef ATMEGA168 TCCR2B |= (1<Tweaking the code 12
Posted by md
on April 18, 2007
Trackbacks
Use this link to trackback from your own site.
hi,
thanks for the code!
works perfectly on my ATMega168
kurt
Hi..
sorry i am a beginner. How to change the path of your librarys ?
/Applications/arduino-0010/hardware/libraries/DCF77/DCF77.o: In function `DCF77::serialDumpTime()’:
/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:76: undefined reference to `HardwareSerial::print(char*)’
/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:78: undefined reference to `HardwareSerial::print(char*)’
/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:80: undefined reference to `HardwareSerial::print(char*)’
/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:82: undefined reference to `HardwareSerial::print(char*)’
/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:84: undefined reference to `HardwareSerial::print(char*)’
/Applications/arduino-0010/hardware/libraries/DCF77/DCF77.o:/Applications/arduino-0005/lib/targets/libraries/DCF77/DCF77.cpp:86: more undefined references to `HardwareSerial::print(char*)’ follow
Couldn’t determine program size: hardware/tools/avr/bin/avr-size: ‘/tmp/build3840.tmp/Serial_DCF77_Signal.hex’: No such file
Thanks
jul
Hi Jul,
are you sure we’re talking about my code above (v0.2.1)? There is no DCF77.cpp in this archive, and the serialDumpTime function starts at line 225. Nevertheless, there is no HardwareSerial.print(..) in Arduino, but a Serial.print(…), AFAIK.
Sorry, but try to use this sketch unmodified first. I don’t have an Arduino 10 environment here, but since the interfaces weren’t changed, the code *should* work.
HTH,
-Mathias
Hallo Mathias,
sorry my fault. My error is:
In function ‘void DCF77Init()’:
error: ‘TCCR2′ was not declared in this scope
I have an arduiono diecimile an the atmega168.
Jul
Hi Jul,
aparently, you don’t have the ATMEGA168 flag defined, so the Compiler tries to compile the definitions for the ATMega8 (and the initialization registers have slightly different names…)
Try adding the line
#define ATMEGA168
to your code.
-Mathias
Hi Mathias,
thanks for your DCF-77 code! I’ve got a question: I’ve been running version 0.2.1 for about a day on a Diecimila board, and found that it loses about half an hour over a day. Every now and then, it seems to miss a few seconds, and then goes back to the start of the same minute. Here’s an example from the serial log with two such hiccups:
Time: 19:54:57 Date: 27.1.2009
Time: 19:54:58 Date: 27.1.2009
Time: 19:54:0 Date: 27.1.2009
Time: 19:54:1 Date: 27.1.2009
Time: 19:54:2 Date: 27.1.2009
Time: 19:54:3 Date: 27.1.2009
Time: 19:54:0 Date: 27.1.2009
Time: 19:54:1 Date: 27.1.2009
Time: 19:54:2 Date: 27.1.2009
Time: 19:54:3 Date: 27.1.2009
I’ll try to find the bug myself, but any ideas what might cause this?
Thanks!
- jan
Hi Jan,
I am sorry to hear that the code has these hiccups. I don’t have an Arduino any more (I gave it to my brother) so I can’t reproduce it now. If I remember the code correctly it simply measures the time between two signals as received by the DCF77 module. Depending on the time between two signals it determines if a “0″ or a “1″ bit was received. Each second a bit is transmitted.
The 59th second does not contain a bit and is used to synchronize the beginning of a new minute. I think here lies the problem: there is no signal for longer than a second, so the code resets the second count.
I would guess that you have an electrical problem: either the DCF signal is to weak where you are or the connection between the Arduino and the receiver is not solid. Try a different location and different pullup resistors (e.g. 10k vs 4k7).
HTH,
-Mathias
BTW: In another (unpublished) project I use the DCF77 receiver only to synchronize time periodically. I rely on a RTC to keep the time, in my case the DS1307. It also allows you to have a backup battery that keeps your time even if the power goes down. Reminds me that I could blog about this project ;-)
hallo,
I hope you still check this thread.
I tried your code, it seems work fine.
but it starts always from 0, such as;
Time: 0:0:1 Date: 0.0.0
Time: 0:0:2 Date: 0.0.0
i waited for start up for 5minutes.
but start it still from 0..
any idea?
thanks
ahon
Hello Mathias,
Firstly, thank you for publishing this nice piece of code !
Due to a faulty DCF board, as I found out later, I needed to take a closer look at it. I discovered a small bug that causes the backup stand-alone clock to lag a few milliseconds/second behind. Furthermore I needed to optimise the code in order to include the clock in other program. Amongst others, the timer interrupt now occurs once per second using the TimerOne library.
If you would like I can mail the modified sketch to you to publish a new version.
groeten, koos
I have some issues with keeping the time as well but got a rtc clock flying around here, can you drop me a line with the code for this one so I can see how you solved the periodical syncs?
Cheers
Passi
hi,
Atmega328 this code
I am findi
hi,
on ATMega328-based Arduinos, this code is not running.
Any idea if the changes for ATMega168 is also valid for ATMega328 ?
Thanks a lot for this nice work !
Best regards.