RTC update on power loss

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

Hi Freaks,

I am working on this clock project using M48.
How do I update my time when I have complete power loss?(i.e.no batteries, no supercaps)

Do I have to use a GPS module to sync up with the new time when power comes back on? EEPROM won't work because there is no way to predict how long the batteries/power will have gone before they are replaced.

I don't have a real time clock IC right now and I want to keep it that way. The M48 only is doing this job.

Thanks.

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

You have the answers
Choose one

Battery.

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

well then you will need some sort of external time reference. GPS is one, NTP servers are another (if you have network connectivity), and finally there is WWVB, which is likely your cheapest option.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Hm... If you can find out that your clock is wrong you can use any appropriate way to set it. It maybe a keyboard, the GPS modue, LAN and etc. What you want!)

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

Ok thanks for the feedback.

I looked at the CME8000 for WWVB.

Does anyone know about a DIP package for the CME8000? I would like to try it on a breadboard.

Also looks like the WWVB signal is generated in Colorado which is next door to me. So I should have good signal strength :)

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

Quote:

I don't have a real time clock IC right now and I want to keep it that way. The M48 only is doing this job.

Hey--the "M48 only" has nothing to do with it. You are creating an RTC, out of a general-purpose IC. That makes it an "RTC IC" no matter what you want to call it.

Anyway, here's what I'm getting at: When I buy a new DS1305 or other RTC IC, I have to set the time. When I totally remove the power from the DS1305, I have to set the time. If I change time zones, I have to set the time. ...

Thus, your situation is no different, as you have already turned your Mega48 general-purpose microcontroller into an "RTC IC".

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

npat_avr wrote:
Ok thanks for the feedback.

I looked at the CME8000 for WWVB.

Does anyone know about a DIP package for the CME8000? I would like to try it on a breadboard.

Also looks like the WWVB signal is generated in Colorado which is next door to me. So I should have good signal strength :)

Not a dip version, but a whole module with antenna:

http://search.digikey.com/script...

[edit changed link to digikey US from Canada]

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

Last Edited: Mon. Aug 24, 2009 - 01:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The cheapest way to do a WWBV prototype is go to Walmart and buy a cheap "atomic clock", which can be had for $10 or so. Then you get the receiver, antenna and all other components conveniently stuck down on a piece of brown paper - sorry, PCB - which you can break in half and pick off the CME8000 signals.

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

peret wrote:
The cheapest way to do a WWBV prototype is go to Walmart and buy a cheap "atomic clock", which can be had for $10 or so. Then you get the receiver, antenna and all other components conveniently stuck down on a piece of brown paper - sorry, PCB - which you can break in half and pick off the CME8000 signals.

Or for $10.70 USD you can have one from digikey [single piece pricing], and save yourself the waste ;)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Thanks for the ideas,guys.

Let's say I have a CME8000 and an AVR. I then use the AVR only to get the time from the CME8000 and display it on the LCD. Also assume that I am using an internal AVR clock. With this configuration, will I still be limited by the AVR internal RC oscillator error because the AVR still needs to use a timer to get the clock ticks every second and refresh the time on the LCD every second?

I would think if I could use the CME8000 output and give it straight to the LCD, I would be able to minimize the error due to internal RC. Of course I can use an external oscillator for my AVR.

I guess this would mean that I should have the ability to program the CME8000 to send data to the LCD? Sorry just thinking out loud.

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

I have a radio controlled kitchen clock. It has hands and everything. And I just have to replace one AA cell every two years.

Now my wristwatch has to be replaced every few years when the strap breaks. I have never replaced a watch battery in my life.

Your AVR would work the same if you buy a RTC chip, 32kHz crystal and a battery. The AVR could use RC clock. Or you could use a 32kHz crystal on TOSC with your AVR.

David.

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

Quote:
I would think if I could use the CME8000 output and give it straight to the LCD, I would be able to minimize the error due to internal RC. Of course I can use an external oscillator for my AVR.

Have you ever looked at the data sheet for the CME8000? It isn't any kind of a clock. All it does is demodulate the off-air signal and output it as a stream of serial pulses. You still need a micro to decode the pulse stream into a recognizable time format. Also, unless you live in the shadow of the WWVB transmitter, reception is intermittent, so you need a local clock to keep time between updates, and just use WWVB to synchronize it periodically. As David Prentice suggests, I would use a 32kHz crystal on TOSC for basic time keeping and run the AVR off its internal RC.

Attachment(s): 

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

The WWV and similar low frequency time transmissions are normally used to "discipline" a clock's accuracy. There are long (hours) periods when the signal is too weak to demodulate, due to propagation conditions. And seasonal variations.

What's wrong with an RTC chip + coin cell battery?

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

Well when the battery dies the RTC is lost. I wanted to check if there was an easier way to reset the time to current time.

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

The RTC chips choose their own voltage source. So you replace the coin cell while the chip is powered with its regular Vcc.

If the regular Vcc fails, the RTC powers itself from the Vbat.

You will have to do the maths but a CR2032 will keep your time for months on end.

Perhaps you should describe your intended application.

Incidentally, I think my kitchen clock only makes periodic checks with MSF (the English transmitter). So the radio receiver only uses battery power during the periodic check. Between these times it just works like a regular battery clock.

Mind you it is fun watching the clock adjust at the change of Daylight Savings Time.

David.

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

npat_avr wrote:
Well when the battery dies the RTC is lost. I wanted to check if there was an easier way to reset the time to current time.

Decent coin cell battery powers an RTC for a year or more. What is the need you have?

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

I could use an RTC chip + coin cell battery but I already have everything coded and working on a M48. I would like to keep the existing setup.

So I guess my options (with the M48) are:
1. rechargeable battery (solar or electrical)
2. battery voltage monitoring with RTC update from WWVB to synchronize clock after new battery has been replaced
3. battery voltage monitoring with RTC update from user (key entry)after battery has been replaced.

Option 2 seems more attractive than the other three.

Since I am also learning to use the bootloader, I guess I could keep all three versions of the code ready and load whichever one I want just to see if it works.

This project is just a hobby project and I am looking to learn and play with new stuff. Thanks for your patience.

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

Quote:

Since I am also learning to use the bootloader, I guess I could keep all three versions of the code ready and load whichever one I want

Judgng by this comment and the one in another thread about BLIPS you seem to have misunderstood what the benefit of a bootloader is. How is it really any different to what your ISP system already allows you to do (that is reprogram the app space when you choose?). Also it will "cost" you about 512 bytes of the 4096 in your chip.

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

I know it is not any different, Cliff.

I just want to learn how to do it which is the only reason I am trying to do it.

Also when I put the entire circuit(M48 + peripherals,etc.) in an enclosure, I won't be able to take the M48 out and program it with an ISP. It would be easier to use the two pin interface and use the bootloader to reprogram the M48 wouldn't it?

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

6 or 2 pin connector on the board does not make that much difference :) You do know you can reprogram an AVR without removing it from your board if you designed in an ISP header?

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

Yes jayjay..
I know this seems a roundabout(and tougher) way to do the same thing but I wanted to get my feet wet with bootloaders..:) Glutton for punishment..