Yes, you can initialize the library with any pin and interrupt number. You need to use one of the latest versions, there used to be a bug in this part of the code. According to this page, you can use the following pin/interrupt combinations on the Arduino Mega:
I'm using the DCF-2 module from ELV, and the DCF77 library at first did not work for me.
The problem is solved now, but here are the symptoms I had, for others using the same hardware ( http://www.elv.de/dcf-empfangsmodul-dcf-2.html ).
The hardware seems to work; the sketch "DCFSignal" shows received data
in the expected 1000ms intervals.
The pulse length seems to be wrong: the "DCFPulseLength" sketch shows that a pulse is not around 100ms and 200ms long, but nearer 800ms or 900ms instead.
Since a pulse longer than 180ms is considered "1", the "DCFBinaryStream" sketch shows received "1"s exclusively. The buffer is filled with the "1", and afterwards the parity is wrong.
After much debugging the reason for this behaviour became clear: the ELV "DCF77-2" module (which only has one signal output) delivers an inverted signal.
The following code change solved the problem: DCF77.cpp 0.9.7, line 95:
int sensorValue = digitalRead(dCF77Pin);
to
int sensorValue = !digitalRead(dCF77Pin);
(Note the exclamation mark before digitalRead() used to convert each "0" to a "1" and vice versa).
If somebody pointed me to the right direction (mrTee?) I could provide (hopefully) more elegant changes which also fix all warnings that compilation using Arduino 1.0.1 currently cause.
That was thorough bug hunting! I had a look at the specs, and I could not find any mention on outputting an inverted signal. I've send you a test version of the library with a small change that should make it able to deal with inverted signals. If it works I will publish it (after my holiday).
Where there any warnings while compiling the library before making changes? I checked, but in Arduino 1.0.1 with verbose logging turned on, I do not see any warnings.
It works out of the box. No extra components were necessary.
Then I ran the examples bundled with the DCF77 library. It turns out that SyncProvider is one minute ahead at the first sync. InternalClockSync works as expected.
The output of SyncProvider is here: Output of SyncProvider - Pastebin.com
In line 4 of the output of SyncProvider it’s 12:01:00 actually. After the next sync the time is corrected (line 126).
I implemented a DCF77 clock with an additional exponential filter in order to improve noise tolerance. You can find the experiment here: Binary DCF77 Clock | Blinkenlight. This is actually part of a larger project where I intend to push the noise tolerance quite a lot further: DCF77 Project | Blinkenlight.
I am trying this module to get to work. According the example DCFSignal, the module seems to work, but the pulses seem to be to short so that the library cant interpret it (see attached screenshot). Does anyone have a clue how to fix that issue?
How did you connect this module to your Arduino? This is a 3.3V module with very limited driving capability. In doubt I would say you are overloading the module.
I connected the GND and the Vcc of the module with GND and the 5V-pin of the arduino. I tried connecting the signal pin with D2 of the arduino with and without a 10k pull up resistor. With the resistor, the signal on D2 stays at hi. Without the resistor the signal shows the behaviour seen in my attachment. The modules datasheet clearly states a supply voltage range from 1.2 V to 5 V, so there should be no overloading. The datasheet also states a maximum ripple of 10 mVeff. Maybe thats the problem. Does anyone know the ripple of the 5V supply voltage while arduino is connected to my PCs USB-port?
Yes, but it also says current consumption <100uA. Obviously the >5uA gives you a hint about the capabilities of the module. If it could drive 500uA they would have written it. This kind of module is designed to go into a clock --> low current consumption is a design goal, extended driving capability is not. --> I would be very suprised if it would be able to drive 500uA. This is the reason why I bought one with additional driver transistors.
The 1M resistor does part of the trick. The signal doesn't stay at high with the 1M resistor connected, but it shows the same signal sequence as without any resistor, so the signal peaks are still much shorter than stated in the spec
Hello after downloading the DCF77 lib (including Time and TimeZone) I keep getting the following errors:
Build options changed, rebuilding all
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static void DCF77::finalizeBuffer()':
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:160:25: error: 'now' was not declared in this scope
filledTimestamp = now();
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::receivedTimeUpdate()':
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:189:50: error: 'now' was not declared in this scope
time_t processedTime = latestupdatedTime + (now() - processingTimestamp);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:197:20: error: 'SECS_PER_MIN' was not declared in this scope
if(difference < 2*SECS_PER_MIN) {
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:209:25: error: 'SECS_PER_MIN' was not declared in this scope
if(shiftDifference < 2*SECS_PER_MIN) {
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::processBuffer()':
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:271:2: error: 'tmElements_t' was not declared in this scope
tmElements_t time;
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:284:12: error: request for member 'Second' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Second = 0;
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:285:9: error: request for member 'Minute' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Minute = rx_buffer->Min-((rx_buffer->Min/16)*6);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:286:12: error: request for member 'Hour' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Hour = rx_buffer->Hour-((rx_buffer->Hour/16)*6);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:287:12: error: request for member 'Day' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Day = rx_buffer->Day-((rx_buffer->Day/16)*6);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:288:12: error: request for member 'Month' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Month = rx_buffer->Month-((rx_buffer->Month/16)*6);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:289:12: error: request for member 'Year' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'
time.Year = 2000 + rx_buffer->Year-((rx_buffer->Year/16)*6) -1970;
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:290:37: error: 'makeTime' was not declared in this scope
latestupdatedTime = makeTime(time);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getTime()':
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:310:48: error: 'now' was not declared in this scope
time_t currentTime =latestupdatedTime + (now() - processingTimestamp);
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getUTCTime()':
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:325:42: error: 'SECS_PER_HOUR' was not declared in this scope
int UTCTimeDifference = (CEST ? 2 : 1)*SECS_PER_HOUR;
^
\\nas\Main\DOCUMENTS\Arduino\libraries\DCF77\DCF77.cpp:326:68: error: 'now' was not declared in this scope
time_t currentTime =latestupdatedTime - UTCTimeDifference + (now() - processingTimestamp);
^
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
for just this code:
#include "DCF77.h"
#include "Time.h"
char time_s[9];
char date_s[11];
#define DCF_PIN 2 // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0 // Interrupt number associated with pin
time_t t;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
void setup() {
Serial.begin(9600);
DCF.Start();
Serial.println("Warte auf Zeitsignal ... ");
Serial.println("Dies kann 2 oder mehr Minuten dauern.");
}
void loop() {
}