Time synchronization with mains frequency (or: most accurate way to measure time)?

Go To Last Post
25 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey freaks!

 

I found a nice-looking "eternity calendar" in my local supermarket, it's made from metal and you're manually supposed to move around some magnets to show the current weekday and date...

As soon as I saw it, I thought it would be a great idea to stuff some LED's behind the cut out numbers in the metal to light up the weekday and date. With different colors I can even make it show the month too (green = month, red = day, for example).

Maybe somehow I can make it show the time too without modifying it too much.

 

Now the thing is, I want the clock to be as accurate as possible but without it costing a fortune. What I would like to do is set the time once, and not need to adjust it ever again or as seldom as possible.

 

What I'm thinking about is either using a 32kHz crystal or synchronize it with the frequency of the mains voltage (50Hz).

I've heard that, over time, the mains frequency is pretty much the most accurate timing source you can find here in Europe, although in periods it may drift in one direction or the other. I'm not sure if it's true, but it sounds plausible.

 

What would be the best way to sync my µC to the mains? 230V to 5V AC transformer, a single diode and resistor to ground, connect it to an input pin set up as digital input? Maybe with a zener to prevent over voltage on the input?

 

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will use a photo coupler.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This may not entirely answer your question, but it's quite interesting. Or at least, I thought so.

https://www.bbc.co.uk/news/scien...

 

Quebracho seems to be the hardest wood.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kabasan wrote:
I will use a photo coupler.

 

Not a bad idea, I might go with that instead of diode/resistor/zener.

 

John_A_Brown wrote:
This may not entirely answer your question, but it's quite interesting. Or at least, I thought so. https://www.bbc.co.uk/news/scien...

 

Very interesting indeed! :)

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Geronimo wrote:
Now the thing is, I want the clock to be as accurate as possible but without it costing a fortune. What I would like to do is set the time once, and not need to adjust it ever again or as seldom as possible.
Is Wi-Fi available?

If yes then NTP.

An inexpensive Wi-Fi and Bluetooth 4.2 module that's a new arrival at Mouser :

https://www.mouser.com/new/espressif/espressif-esp32-solo-1-module/

Geronimo wrote:
What I'm thinking about is either using a 32kHz crystal ...
drifts with temperature.

A 32KHz TCXO that's 13s/month at 25C :

https://www.mouser.com/new/cts/cts-tt32-hcmos-tcxo/

The operator can walk an accurate clock to your clock then adjust its time.

The following is for EU (DCF) and UK (MSF) :

https://store.oregonscientific.com/us/rm511a-radio-controlled-alarm-clock-black.html

There's an IC for DCF DCF77, MSF, WWV WWVB (and ...? JJY and HGB

 


http://www.npl.co.uk/science-technology/time-frequency/products-and-services/time/msf-radio-time-signal

C-MAX

CME8000

Radio Clock Receiver IC

Data Sheet

https://www.avrfreaks.net/sites/default/files/CME8000.pdf

http://www.c-max-time.com/products/showProduct.php?id=2 (C-MAX, CME8000)

 

Edits: strikethrus, CME8000 datasheet and product URLs

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Sat. Sep 15, 2018 - 12:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Geronimo wrote:
Now the thing is, I want the clock to be as accurate as possible but without it costing a fortune. What I would like to do is set the time once, and not need to adjust it ever again or as seldom as possible.   What I'm thinking about is either using a 32kHz crystal or synchronize it with the frequency of the mains voltage (50Hz).

 

You would want to do both, or even 3  (add support for a 1pps from a GPS module)

 

The TCXO linked above looks nifty, and I'd run all signal sources into their own totalizers, and then you can confirm which one is proven most stable.

 

Geronimo wrote:
What would be the best way to sync my µC to the mains? 230V to 5V AC transformer, a single diode and resistor to ground, connect it to an input pin set up as digital input?

Maybe with a zener to prevent over voltage on the input?

 

No. The hard part is going to be ensuring all the crap and lightning strikes etc do not affect your clock.  Ignore diodes/optocouplers  ....

Check if your MCU has schmitt pins, and then make an analog filtered mains copy, that is 0~Vcc.

 

That circuit is a good start, as D1/R1 becomes a R1/C1/R2/C2/R3 pathway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your Idea from post #1 looks pretty decent as an intial start.

I also agree with Who-me. Keeping the nasty stuff out is a big issue.

Replacing the diode with a resistor wil pull your signal actively to GND. No floating input / reliance on the pull down resistor, so you can use higher value resistors, which makes it easier to filter the crap out of it.

 

Also:

Do you have DCF77 reception in Denmark?

DCF77 modules are cheap and widely available (For example in of the shelf kitchen varietie radio controlled clocks).

This also solves the need to adjust the clock twice a year for summer / winter time.

 

For indoor use you can also pick up mains humm with a simple antenna.

When I touch my scope probe with my finger I usually measure a 60V+ humm @50Hz.

I use this often as a sanity check to see if a scope channel is enabled, the probe is connected to the right channel, etc.

 

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Geronimo wrote:
What I'm thinking about is either using a 32kHz crystal or synchronize it with the frequency of the mains voltage (50Hz).

I've heard that, over time, the mains frequency is pretty much the most accurate timing source you can find here in Europe, although in periods it may drift in one direction or the other.

This site gives the gives the current stability of the European grid, including its time deviation. At this very moment, the grid is 26.72s behind the real time. Earlier this year, it was six minutes because of a dispute in the Balkans.

- John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jfiresto wrote:

This site gives the gives the current stability of the European grid, including its time deviation. At this very moment, the grid is 26.72s behind the real time. Earlier this year, it was six minutes because of a dispute in the Balkans.

 

Nice link.

 

Seems it can 'wander' quite rapidly, and with no real long-term average discipline, so looks like not even worth bothering - but it might be cool to be able to show that  'dazed wandering' effect :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Geronimo wrote:
I found a nice-looking "eternity calendar" in my local supermarket, it's made from metal and you're manually supposed to move around some magnets to show the current weekday and date... As soon as I saw it, I thought it would be a great idea to stuff some LED's behind the cut out numbers in the metal to light up the weekday and date. With different colors I can even make it show the month too (green = month, red = day, for example). Maybe somehow I can make it show the time too without modifying it too much.

Any images ?

 

There is a common segmented LCD 4 Digit 0.17" that might peek thru any slot.

Last Edited: Wed. Sep 12, 2018 - 05:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

GPS was already mentioned above.

 

If you really want a long term, accurate, clock, then I use a crystal on the micro, (not the internal RC Osc), and once every now and then I'd update the software clock with the GPS data.

 

This is easier to do if the device sits by a window, so it can pick up the GPS signal.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would go for DCF reception.

in the past couple of months the 50Hz net has been found to not be as stable as it was in the past so you might get deviation from that. ( if 1 or 2 countries decide to stop the export of energy the rest has to compensate but that causes the grids frequency to drop)

also DFC will compensate for summer/winter time. Or not when it no longer is needed. in that way you never have to manually change the clock 2 times a year or ever set it back on time. take in account leap years.......

 

combine with a 32KHz crystal for when DCF signal should ever fail to be received for a short time you should be able to make a nice and highly accurate clock.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WiFi/NTP maybe is a bit overkill for what I want.

GPS too is probably a bit overkill and not really that suitable indoors I guess?

If I can, I will cram it all on an AtTiny11 (because I have some), if not it will go in a mega 8 or 16 for the same reason. wink

 

DCF77 actually is a great idea, reception around here should be fine (less than 1000km distance). I don't know why I didn't think about that in the first place!

 

Leap year and summer/winter time is something that can be handled in software without too much trouble.

 

Here's a picture of the thing in its box: