Accurate time keeping with Pic uC

MrChips

Joined Oct 2, 2009
34,842
:D

I'm used to that guy being referred as the OP.
TS and OP mean the same thing here. We understand both.
Also since this isn't actually a real project, and just a thought exercise, there are no requirements.
In that case all recommendations are up in the air.
Though exercise or not, it would help if you told us your objectives rather that have us all make hypothetical recommendations.
 

MrChips

Joined Oct 2, 2009
34,842
In order to help you along, here are some possible scenarios:

1) I want an alarm clock to wake me up in the morning. I don't want to have to set the time for at least 5 years.

2) I want my little gizmo to keep track of the time and date. I don't mind if it is off by 1 minute after a year of running on battery backup.

3) I have this neat project and I want to build a clock that will keep time for 10,000 years without any external electrical connection or power.
 

Thread Starter

Travm

Joined Aug 16, 2016
363
TS and OP mean the same thing here. We understand both.

In that case all recommendations are up in the air.
Though exercise or not, it would help if you told us your objectives rather that have us all make hypothetical recommendations.
The objective is to improve my understanding of microcontrollers and time circuits, touch on programming where appropriate, but for the moment focus on hardware.

Basically i'm wanting to integrate accurate time measurement with uC's to do things. Not sure which things, but something someday for sure. Looking at the moment for wall clock accuracy. As good or slightly better than your average microwave.

I think most of this has been satisfied, and its just friendly discussion at this point.

with respect to your most recent post, somewhere between 1 and 2 is where i'm going.
 

WBahn

Joined Mar 31, 2012
32,895
I might try to integrate something like this into a project in the future. Persistent through power outages is a neat feature. Interesting that bed side alarm clocks don't have a feature like this. I get that they often have a 9v battery installed, but why not a little RTC so that they can keep time forever.
Simple -- they are cheap, cheap, cheap. When you making something that you wholesale for a couple dollars but you sell millions and millions of, each additional penny in BOM cost is tens or hundreds of thousands of dollars off the bottom line. Most people simply don't care about accurate time keeping. When they set the alarm clock next to their bed they are more than satisfied if it is within a minute or so of the actual time -- they don't even check, they just set it to what their watch says or whatever the person on the radio just said. The feature they are looking for in a battery backup is just so that they don't have to set the clock when the power comes back on. If the time looks anything close to what it is supposed to be when the power does come on, they are happy and don't give it a second thought. Since most power outages are pretty short, some clocks just use a capacitor to keep the circuit from losing time and don't even try to keep time during the outage. If they can go just ten or twenty seconds then they will make it through most outages in many areas and people can unplug the clock and plug it back in and not lose the time and they don't care about whether it lost ten or twenty seconds in the process.

The first clock that I had that had a battery backup was wretched. I put in a fresh battery before I moved and the unit was unplugged for about an hour. When I plugged it back in it was more than twenty minutes off. As near as I could tell it used an RC oscillator that made no pretense of any kind of accuracy at all.
 

Thread Starter

Travm

Joined Aug 16, 2016
363
Simple -- they are cheap, cheap, cheap. When you making something that you wholesale for a couple dollars but you sell millions and millions of, each additional penny in BOM cost is tens or hundreds of thousands of dollars off the bottom line. Most people simply don't care about accurate time keeping. When they set the alarm clock next to their bed they are more than satisfied if it is within a minute or so of the actual time -- they don't even check, they just set it to what their watch says or whatever the person on the radio just said. The feature they are looking for in a battery backup is just so that they don't have to set the clock when the power comes back on. If the time looks anything close to what it is supposed to be when the power does come on, they are happy and don't give it a second thought. Since most power outages are pretty short, some clocks just use a capacitor to keep the circuit from losing time and don't even try to keep time during the outage. If they can go just ten or twenty seconds then they will make it through most outages in many areas and people can unplug the clock and plug it back in and not lose the time and they don't care about whether it lost ten or twenty seconds in the process.

The first clock that I had that had a battery backup was wretched. I put in a fresh battery before I moved and the unit was unplugged for about an hour. When I plugged it back in it was more than twenty minutes off. As near as I could tell it used an RC oscillator that made no pretense of any kind of accuracy at all.
yet the fill them with stupid gimmicks and charge $100 each.
Consumers are funny.
I cant wait for Capitalism 2.0 I hope i get to see it.
 

MrChips

Joined Oct 2, 2009
34,842
Even though you didn't ask, I will give you the answer any way.
The AC mains frequency is lousy for short term accuracy but over the long term is better than a clock crystal.

As one comic said, his watch is dead on time twice a day, since it stopped working.

AC mains frequency could be off by as much as ±1% at any instant in time but over the course of a day, the power plant will supply the exact number of cycles. Hence your clock radio driven by line frequency will be accurate to the second in the long term.

If you want the best of both worlds, you want a clock to run from line frequency and have a battery powered RTC to take over when the power goes.

Take a look at this application note:
http://www.intersil.com/content/dam/Intersil/documents/an13/an1342.pdf
http://www.intersil.com/content/dam/Intersil/documents/an13/an1342.pdf
 

Thread Starter

Travm

Joined Aug 16, 2016
363
Even though you didn't ask, I will give you the answer any way.
The AC mains frequency is lousy for short term accuracy but over the long term is better than a clock crystal.

As one comic said, his watch is dead on time twice a day, since it stopped working.

AC mains frequency could be off by as much as ±1% at any instant in time but over the course of a day, the power plant will supply the exact number of cycles. Hence your clock radio driven by line frequency will be accurate to the second in the long term.

If you want the best of both worlds, you want a clock to run from line frequency and have a battery powered RTC to take over when the power goes.

Take a look at this application note:
http://www.intersil.com/content/dam/Intersil/documents/an13/an1342.pdf
Very cool. Will tuck that into my toolbox.
Thanks
 
Top