So I want to make a ATMEGA328P into a accurate clock. Yes I know I can use a RTC like DS3231 become according to the datasheet it becomes a paperweight in 2100. Yes I know that is a long time away, but I hope some one is still using my clock then.
So I know a Arduino UNO in it's current form is not a very accurate clock because the 16mhz crystal is not very accurate. Can I simply use a crystal that is much more accurate to get more accurate time? Can I replace it with a TCXO crystal like TYKTBLSANF-16.000000? According to the TYKTBLSANF-16.000000 datasheet it looks like it runs at 3.3v, and since ATMEGA328P runs at 5v, is that a problem?
Find a Duemilanove, the prior Arduino model that still used a crystal and 22pF caps.
Or use one of my boards, I use crystal & caps on all of them. http://www.crossroadsfencing.com/BobuinoRev17/
What do you mean by "clock"? The DS3231 has no issues with respect to keeping time, it is the date that starts to have issues after 2100.
i.e. if you don't need the date, then it doesn't matter
And how accurate does the clock need to be?
You could work around the RTC date issues by offsetting the year inside the RTC to a year that is similar to the current year.
(See this thread for some comments on that: How to use the RTC DS3231 after the year 2100? - Libraries - Arduino Forum)
And if you stored some state information inside AVR EEPROM, you could even "remember" the needed offset across power cycles.
Also, if you are just looking for a stable/accurate time base to do all the datetime calculations inside the AVR then why would you
not use the INT/SQW output of the DS3231?
The big question becomes if you are trying to do all the time keeping inside the AVR, what are you going to do about power failures?
Looking and being concerned about things that far out is very tough. Look at how connected the world has become in the past 20 years and the acceleration of things like IoT. It could be that in 30-50 years nearly everything is connected and everything clock related gets a network time from a time server rather than store or track the time locally.
Then things like leap second corrections might become common place.
The implications of this could be significant since there is already a mounting and expanding difference between UTC and TAI time. (like around 37 seconds). http://leapsecond.com/java/gpsclock.htm
But it comes back to just how accurate the datetime has to be and how are power failures/recoveries handled?
Also note many parts of the system may (will) fail until 2100. For example electrolytic caps, Arduino's flash where your program is stored, any mechanical moving part of your clock. The clock must be really valuable for someone to care about searching for those ancient parts to replace them...
doanerock:
So I want to make a ATMEGA328P into a accurate clock. Yes I know I can use a RTC like DS3231 become according to the datasheet it becomes a paperweight in 2100. Yes I know that is a long time away, but I hope some one is still using my clock then.
The flash (program) in the Arduino is only guaranteed for 20years.
It might hold the program for 20 more years if you're lucky, but 80+ years is pushing it.
You might want to make a clock with an ESP8266 module,
and let it get the time (including daylight saving) of the internet.
NTP example in this guide.
Leo..
Wawa:
The flash (program) in the Arduino is only guaranteed for 20years.
From the datasheet:
Reliability Qualification results show that the projected data retention failure
rate is much less than 1 PPM over 20 years at 85°C or 100 years at 25°C
So if it is not subjected to high heat, it would likely last much longer than 20 years.
Is this clock stationary or mobile
Used at home where you have control over the WiFi network, or used in a public place.
If at home, with your own router, then SSID and PW are just two fixed lines of code in the sketch.
Internet time might be easier inside than GPS time.
What sort of readout, and should it have a battery backup.
Leo..
doanerock:
How do you offsetting the year inside the RTC and still get accurate calendar?
You intentionally pick a year that makes all the days in the months land on the proper days and handle leap year as if it were the correct year.
As long as you know the offset from the real year, you then add/subtract the offset from the "fake" year inside the RTC to get the correct year.This was in the thread that I linked to.
For the leap second issue, I am just planing on letting the GPS resync the clock.
Wait.... What? If you have access to and are depending on GPS time, then you probably do not need an RTC.
All you need is a reasonably accurate time base to "tick" in between updates from the GPS time.
The DS3231 could easily provide that with the INT/SQW output.
@Wawa NTP on the clock is just too much to try and enter a ssid and password.
Not when using an esp8266. WifiManager makes it really easy as you can use any wireless device with a web browser.
It is cheaper than a m328 solution and MUCH faster with LOTS more flash and RAM, plus it has wifi builtin.
Even as short as 20-30 years from now which is a reasonable amount of time for a sentimental clock, will things like current wifi, GPS, or even things like NTP sill be in use?
I think if you really are concerned about longevity, then keeping things simple and as self contained as possible would be recommended.
i.e. if it is just a clock device used to display just the time of day,
keep it really simple and use something like a 3231 and have buttons that can be used to set the time, and don't worry about the date stuff as an incorrect date or day of week does not affect the time.
@Wawa sorry I am not looking for alternative ways to accomplish my goal. I know all about NTP. I know about WWV. I don't want to use them.
I want to use GPS to set the clock. I guess my ultimate goal to fix a way around DS3231 2100 problem.
So many there is a equally accurate RTC that has calendar data further in the future.
Mabey even have the arduino act as it's own RTC given it can be accurate enough, and shut down the GPS and screen during a power outage, and just switch to battery just for time keeping until power comes back.
This is interesting theoretical problem but you should state your goal more clearly. Why exactly are you so interested in the 2100 mark? I think it is very likely both you and all current GPS satellites will be dead in 2100. Who knows if GPS signal will be available in 2100? I guess GPS as we know it will be ancient technology no longer used.
For the clock you will probably use some crystal to keep time when GPS is unavailable. I wonder what is long term drift of crystal. For example DS3231 has 1ppm first year and 5ppm first 10 years. How much it will be in 80 years?
doanerock,
IMO, you need to take a big step back and describe to us what you are really trying to accomplish.
You started off wanting to have an accurate time source and were worrying about an issue with an RTC chip that doesn't happen until 80+ years from now.
But the 2100+ year problem can be worked around.
From more recent comments, it now appears that you are wanting to use GPS to "set the clock" but also want an RTC to run when the power is off.
But if you have access to GPS time why would you need to have an RTC at all?
There are many ways to keep track of time.
I'm lost about what you are trying to accomplish, and I'm probably not the only one.
I think at this point it would really help to have a clear understanding of what you are wanting to accomplish and any specific requirements so we can make reasonable suggestions.