Arduino Forum

Development => Other Software Development => Topic started by: mrTee on Apr 19, 2012, 11:22 am

Title: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Apr 19, 2012, 11:22 am
I wrote yet another DCF77 library for Arduino.
It is based on the sketch by Matthias Dahlheimer, but with some differences
- Plays nice with the Time Library (http://arduino.cc/playground/Code/Time) and setSyncProvider callback
- Uses a single interrupt for signal-changed based triggering
- More robust against noise: rejects the majority of incorrect spikes
- More sanity checking on decoded time.
- Can return UTC time, useful for timezone conversion

You can find the library here:
http://thijs.elenbaas.net/downloads/?did=1 (http://thijs.elenbaas.net/downloads/?did=1)
and additional information here
http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-library/ (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-library/)

Below is an example of how to use it using setSyncProvider
Code: [Select]
#include "DCF77.h"
#include "Time.h"
using namespace Utils;
#define DCF_PIN 2   // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0      // Interrupt number associated with pin
time_t prevDisplay = 0; // when the digital clock was displayed
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
void setup() {
Serial.begin(9600);
DCF.Start();
setSyncInterval(30);
setSyncProvider(getDCFTime);
// It is also possible to directly use DCF.getTime, but this function gives a bit of feedback
//setSyncProvider(DCF.getTime);
Serial.println("Waiting for DCF77 time ... ");
Serial.println("It will take at least 2 minutes until a first update can be processed.");
while(timeStatus()== timeNotSet) {
// wait until the time is set by the sync provider
Serial.print(".");
delay(2000);
}
}
void loop()
{
if( now() != prevDisplay) //update the display only if the time has changed
{
prevDisplay = now();
digitalClockDisplay();
}
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.println("");
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
unsigned long getDCFTime()
{
time_t DCFtime = DCF.getTime();
// Indicator that a time check is done
if (DCFtime!=0) {
Serial.print("X");
}
return DCFtime;
}


I would appreciate it if anybody would give it a testdrive. Let me know what you find.
Thijs



Title: Re: DCF77 library for Arduino
Post by: ninja2 on Apr 19, 2012, 12:32 pm
excuse my cruiosity, but what does a dcf77 do and where do you buy them?
Title: Re: DCF77 library for Arduino
Post by: mrTee on Apr 19, 2012, 03:42 pm
Hi,
You're excused  ;) DCF77 is officially the name of a radio station in Germany. This radio tower sends out an atomic clock synchronized signal modulated on a 77kHz longwave that can be received in most of Europe (see this post (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-signal/) for more information). The hardware that you need to receive this signal is quite cheap and simple to connect to your Arduino (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-hardware-2/) ).

However, you profile says that you reside in Australia, and I'm not aware of any existing Australian equivalent of DCF77, so this might not be an option for you. A GPS module could be a good alternative and isn't that expensive either.

Thijs
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: ninja2 on Apr 19, 2012, 10:12 pm
thanks for explanation. I'm already up to speed on GPS, I use a LS20031 that gives me time just fine (using time library). However although I have been able to get setsyncprovider to work with a DS1307 RTC I can't get GPS to respond... hence my interest in your thread.
I ran a thread on it here: http://arduino.cc/forum/index.php/topic,81175.msg612786.html#msg612786 (http://arduino.cc/forum/index.php/topic,81175.msg612786.html#msg612786)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Apr 20, 2012, 09:25 pm
I don't have a GPS so I cannot reproduce this, but I would use a stub for the callback. Below is a sketch that I used for testing the DCF77 library.
Code: [Select]
#include "DCF77.h"
#include "Time.h"

time_t time;
DCF77 DCF = DCF77(2,0);
int count = 0;

void setup() {
 Serial.begin(9600);
 DCF.Start();
 setSyncInterval(30);
 setSyncProvider(getDCFTime);
}
void loop()
{    
 count++;
 delay(3000);
 if  (timeStatus()== timeNotSet) {          
    Serial.print("-");
 } else {
   time = now();
   Serial.print("+");
 }
 if (count==20) {
     count=0;
     Serial.println("");      
 }
}

// Stub for GetTime function
unsigned long getDCFTime()
{
 time_t DCFtime = DCF.getTime();
 if (DCFtime==0) {
   Serial.print("n");  
 } else {
   Serial.print("u");  
 }
 return DCFtime;
}


The setSyncProvider is set to query the time provider every 30 sec, the main loop asks for a new time every 30s.
The output is the following:
n  = time provider is queried but did not return update      
u  = time provider is queried and returned update
-  =  3s have past, internal clock is not set
+  =  3s have past, internal clock is set

The results I found where:
Code: [Select]
n--------------------
-----n---------------
-----nnnn---------------
-----nnnnu++++++++++nnnn+n+n+n+n+
n+n+n+n+n+nnnnnu++++++++++n+n+n+n+n+
n+n+n+n+n+nnnnnu++++++++++n+n+n+n+n+
n+n+n+n+n+nnnnnu++++++++++n+n+n+n+n+
n+n+n+n+n+nnnnnu++++++++++n+n+n+n+n+


What I learned from this:
- timeStatus() and now() together somehow trigger a time provider query 4 times, which can be seen by the "nnnn" sequences
- When the time between updates has past (30s) the setSyncProvider will query the timeprovider every call to now() or timeStatus(), which can be seen by the "n+n+n+n+"sequence

I imagine that you can learn a bit about the GPS time update in this manner without diving into the library itself. Hope this helps.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: ninja2 on Apr 20, 2012, 11:51 pm
that's a very neat and clever testing technique!
I will steal your idea and give it a try on my GPS, but it will be a while before I get to it because I'm focused on getting code working for my new accelerometer code at present - too many toys to choose from  :) but I'll let you know what I find
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Apr 24, 2012, 09:41 pm
I'm interested to hear what you find! Good luck with your accelerometer code.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Apr 24, 2012, 09:53 pm
Library update:
After finding the TimeZone library by Jack Christensen (see this thread (http://arduino.cc/forum/index.php/topic,96891.0.html)), I added an example to convert DCF time (which is in CET) to another timezone. However, since the local time to UTC time conversion is sometimes ambiguous, I included a function that returns UTC time, taking into account the daylight saving time bits

Code: [Select]
#include <DCF77.h>       //https://github.com/thijse/Arduino-Libraries/downloads
#include <Time.h>        //http://www.arduino.cc/playground/Code/Time
#include <Timezone.h>    //https://github.com/JChristensen/Timezone

#define DCF_PIN 2          // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0 // Interrupt number associated with pin

//United Kingdom (London, Belfast)
TimeChangeRule rBST = {"BST", Last, Sun, Mar, 1, 60};        //British Summer Time
TimeChangeRule rGMT = {"GMT", Last, Sun, Oct, 2, 0};         //Standard Time
Timezone UK(rBST, rGMT);

time_t prevDisplay = 0;          // when the digital clock was displayed
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);

void setup() {
  Serial.begin(9600);
  DCF.Start();
  setSyncInterval(30);
  setSyncProvider(getDCFTime);
  // It is also possible to directly use DCF.getTime, but this function gives a bit of feedback
  //setSyncProvider(DCF.getTime);

  Serial.println("Waiting for DCF77 UK local time ... ");
  Serial.println("It will take at least 2 minutes until a first update can be processed.");
  while(timeStatus()== timeNotSet) {
     // wait until the time is set by the sync provider     
     Serial.print(".");
     delay(2000);
  }
}

void loop()

  if( now() != prevDisplay) //update the display only if the time has changed
  {
    prevDisplay = now();
    digitalClockDisplay(); 
  }
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.println("");
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year());
  Serial.println();
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

unsigned long getDCFTime()
{
  time_t DCFtime = DCF.getUTCTime(); // Get  UTC time
 
  if (DCFtime!=0) {
    time_t LocalTime = UK.toLocal(DCFtime);  Convert to UK time
    return LocalTime;
  }
  return 0;
}
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on May 22, 2012, 10:34 pm
Since no big issues have arisen, I have added the library to the playground: http://arduino.cc/playground/Code/DCF77 (http://arduino.cc/playground/Code/DCF77)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Schueler on Jun 22, 2012, 02:35 pm
Hi,

I am building a Nixie clock ( who isn't...  ;) ) and I use the DCF77 of Conrad. Not the most stable and best buy but at least it is cheap.

At first I was not able to get the time with your example. Even some tweaks didn't do the trick.
However, the tracer showed me a lot of distortion so I went looking in your code and found a missing filter in the DCF77::int0handler function of the file DCF77.cpp.
You do filter out distortion after the pulse ( for 700ms ) but not at the beginning of the pulse.

I added 1 if-statement at the beginning of the function and now it works perfectly now within my system!!!!

Code: [Select]
void DCF77::int0handler() {
int flankTime = millis();
int sensorValue = digitalRead(2);

// If flank is detected quickly after previous flank up
// this will be an incorrect pulse that we shall reject
if ((flankTime-PreviousLeadingEdge)<DCFRejectionTime) {
return;
}

// ********
// If the detected pulse is to short it will be an
// incorrect pulse that we shall reject
if ((flankTime-leadingEdge)<50) {
return;
}
// ********

if(sensorValue==HIGH) {
if (!Up) {
// Flank up
leadingEdge=flankTime;
Up = true;                
}
....


Great yob by the way... saves me a lot of worries to design it myself     ;)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Jul 03, 2012, 09:17 pm
Hi,

Thanks for the suggestion! Indeed, the Conrad receiver really is not all that stable. But then again, many receivers seem to have that problem.
Nevertheless, my Conrad receiver has not given me that many false flanks during a pulse, so I never saw the need to implement this kind of rejection.

It seems like a good idea, though! I've added it to the library, together with some minor fixes. It can still be downloaded here:
http://thijs.elenbaas.net/downloads/?did=1 (http://thijs.elenbaas.net/downloads/?did=1)

Let me know what if it works for you!

Ps. I'm part of the other 50%: I'm building a Word-Clock instead of a Nixie Clock.   :)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: sarzillabruno on Jul 20, 2012, 06:59 pm
I can change the pin and therefore the interrupt?
because I would use 2 pins for other purposes and to "read" the signal DCF77 use pin 18 with interrupt 5.
but I think it does not work.
I have to change something?

thanks

P.S. I use arduino mega 2560
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Jul 25, 2012, 10:26 am
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 (http://arduino.cc/en/Main/ArduinoBoardMega/), you can use the following pin/interrupt combinations on the Arduino Mega:

Pin 2 - interrupt 0
Pin 3 - interrupt 1
Pin 18 - interrupt 5
Pin 19 - interrupt 4
Pin 20 - interrupt 3
Pin 21 - interrupt 2

When using, for example, pin 18, you can start your code with

Code: [Select]
#define DCF_PIN 18         // Connection pin to DCF 77 device
#define DCF_INTERRUPT 5 // Interrupt number associated with pin

DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: dreyfus on Aug 09, 2012, 11:12 pm
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 ).



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:
Code: [Select]
        int sensorValue = digitalRead(dCF77Pin);

to
Code: [Select]
        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.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Aug 22, 2012, 10:25 pm
Hi,

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.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: mrTee on Sep 20, 2012, 09:17 pm
A little later than expected, the library now supports inverted pulses as input.

The constructor now has an optional parameter OnRisingFlank:
Code: [Select]
DCF77(DCF77Pin, DCFinterrupt, OnRisingFlank)
If OnRisingFlank set to false, the algorithm will trigger on falling edge.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: franzs on Oct 31, 2012, 09:39 pm
Hi!

I wired a cheap DCF77 receiver from Pollin to an Arduino Uno: http://www.pollin.de/shop/dt/NTQ5OTgxOTk-/

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.

Please find the output of InternalClockSync at http://pastebin.com/ZbtzWtqZ (http://pastebin.com/ZbtzWtqZ)

The output of SyncProvider is here: http://pastebin.com/5DSfAkjZ (http://pastebin.com/5DSfAkjZ)
In line 4 of the output of SyncProvider it's 12:01:00 actually. After the next sync the time is corrected (line 126).

Another output is here: http://pastebin.com/SWJBXFSy (http://pastebin.com/SWJBXFSy)

I enabled VERBOSE_DEBUG and recorded a video of the output:
http://dl.dropbox.com/u/87685034/SyncProvider_3_converted.avi (http://dl.dropbox.com/u/87685034/SyncProvider_3_converted.avi)

I tried both examples a couple of times. The DCF77 signal is quite clear.

Any idea what's going wrong?

Best regards
Franz
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 01, 2012, 07:37 pm
I implemented a DCF77 clock with an additional exponential filter in order to improve noise tolerance. You can find the experiment here: http://blog.blinkenlight.net/binary-clock/ (http://blog.blinkenlight.net/binary-clock/). This is actually part of a larger project where I intend to push the noise tolerance quite a lot further: http://blog.blinkenlight.net/2012/12/01/dcf77-project/ (http://blog.blinkenlight.net/2012/12/01/dcf77-project/).
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 02:17 pm
I am trying this module (http://www.reichelt.de/Bausaetze/DCF77-MODUL/3/index.html?;ACTION=3;LA=444;GROUP=CE2;GROUPID=5727;ARTICLE=57772;START=0;SORT=user;OFFSET=100;SID=11T82zlX8AAAIAAEZIe-U2530e31e3c2f7c716839e901e8b4a463) 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?
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 02, 2012, 05:09 pm
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.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 05:26 pm
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 (http://www.reichelt.de/index.html?;ACTION=7;LA=3;OPEN=0;INDEX=0;FILENAME=X200%252FDCF77.pdf;SID=11T82zlX8AAAIAAEZIe-U2530e31e3c2f7c716839e901e8b4a463) 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?
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 02, 2012, 05:37 pm
The datasheet says maximum current 5uA. With a 10k pullup you draw 500uA. You are overloading it. You should try a 1M resistor.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 05:48 pm
Actually the datasheets states an output current > 5µA, but i will try a 1M resistor. Maybe it works. It won't hurt anyway :D
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 02, 2012, 05:58 pm
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.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 06:01 pm
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 :(
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 02, 2012, 06:08 pm
Maybe you already killed the module. I am using this one: http://www.voelkner.de/products/162756/Dcf-Empfaengerplatine.html (http://www.voelkner.de/products/162756/Dcf-Empfaengerplatine.html)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 06:13 pm
Seems to be the same as this one (http://www.conrad.de/ce/de/product/641138/C-Control-DCF-Empfaengerplatine/SHOP_AREA_17348&promotionareaSearchDetail=005). Maybe i drop by at the big blue C tomorrow to get it.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: udoklein on Dec 02, 2012, 06:18 pm
Conrad and Völkner are different brands of the same company. They just address different market segments. See here: http://de.wikipedia.org/wiki/Conrad_Electronic (http://de.wikipedia.org/wiki/Conrad_Electronic)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Nachtfalke on Dec 02, 2012, 07:21 pm
Didn't know that. Anyway the price is the same.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: Enam on Sep 18, 2013, 11:37 am

A little later than expected, the library now supports inverted pulses as input.

The constructor now has an optional parameter OnRisingFlank:
Code: [Select]
DCF77(DCF77Pin, DCFinterrupt, OnRisingFlank)
If OnRisingFlank set to false, the algorithm will trigger on falling edge.


Hello,

I think I have the same problem with the inverted signal, thank you for your hint.

But I don't know where in the code I put "false" in and which Version of the code did you use?

Thank you for help.

Kind Regards
Enam
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: babutian on Jun 03, 2019, 05:49 pm
Hello after downloading the DCF77 lib (including Time and TimeZone) I keep getting the following errors:

Code: [Select]


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:

Code: [Select]
#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() {

}
 


Any suggestions would be greatly appreciated!
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: 6v6gt on Jun 04, 2019, 08:03 am
Try:
#include <TimeLib.h>
Instead of:
#include "Time.h"
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: babutian on Jun 04, 2019, 04:51 pm
Hi, unfortunately I don't have the timeLib.h file, there is only time.h in the appropriate Time lib folder... Where do I get it?

regards
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: babutian on Jun 04, 2019, 04:58 pm
found it, thanks!
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: ProLaser2846 on Aug 01, 2019, 12:02 pm
Hi, my name is Mateusz and I'm from west part of Poland, so distortions in signal I received is not bad. Thank you for your library! ;)

My question is, How can I print on lcd or maybe just serial monitor parity bits of DCF77 signal? I have got built a prototype of DCF77 clock and I want to add some gadgets to it. ;P

Thanks and regards! :)
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: 6v6gt on Aug 01, 2019, 08:01 pm
The format of the signal is described here and includes the parity bits:
https://en.wikipedia.org/wiki/DCF77 (https://en.wikipedia.org/wiki/DCF77)

I guess when you say you want to print the parity bits, you mean you want to print if the parity bit check passed or failed.

CEST/CET timezones (bit 17 and 18) can also be used as a check. These bits cannot be equal.
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: ProLaser2846 on Aug 01, 2019, 09:51 pm
I guess when you say you want to print the parity bits, you mean you want to print if the parity bit check passed or failed.

Exactly!
I want to checks every parity bit in signal (P1, P2, P3 and maybe "S" bit too [yes I know S bit is not a parity bit]) and display it on lcd by

if (parityBitP1 == 1) {
   lcd.print("1");
   }

if (parityBitP2 == 1) ...

But I can't write program that will do this because I don't know how. :/
Can someone help me with that? I don't even know how to start writing this code... :(
Title: Re: DCF77 library for Arduino - synchronize with atomic clock
Post by: 6v6gt on Aug 02, 2019, 10:30 am
You have got the code linked in the OP http://thijs.elenbaas.net/downloads/?did=1 (http://thijs.elenbaas.net/downloads/?did=1) installed and working ?

The parity checking is done here:

Code: [Select]


// Check parities
    if (flags.parityMin == rx_buffer->P1  &&
        flags.parityHour == rx_buffer->P2 &&
        flags.parityDate == rx_buffer->P3 &&
rx_buffer->CEST != rx_buffer->CET)
    { 
    . . .
   // parity ok
    }
    else {
    . . .
       // parity check failed
    }



So, for example, flags.parityMin is the parity pit for Minutes calculated from this bits received in the data stream from the DCF transmitter.
rx_buffer->P1 is the actual parity bit received in the data stream from the DCF transmitter.
Clearly, if the calculated and actual parity bits don't match, there is a parity error.
From that, you should be able to find something to print to the LCD screen.