Battery Backup Circuit?

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

I'm making an alarm clock with an ATMega32 (it's a "special" alarm clock). I'd like to add a battery backup circuit, like all the commercially available clocks have. Presumably, I'd use a 9 volt battery as the power source.

I'd like to detect that my +5v line driven supply has failed, switch to battery power, and shut off my power hungry peripherals with my software. I'm mainly interested in keeping the 32khz timer running and keeping track of time. Of course, when line voltage came back, I'd go back to normal operation.

I have a plain old fashioned transformer/rectifier/filter cap linear power supply and 7805 regulator supplying my 5 volts.

Anybody have any good ideas for a cheap, easy way to do this?

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

I'm not going to comment on your question directly. But a couple of things come to mind with your approach.

First, kind of a trivia thing, 9V batteries have poor power density compared to other packages. For a 1-off that doesn't need to run for n years, it doesn't really matter. For a production app I'd dig deeper into that.

Second, with a Mega32 you will fight every step of the way to make a true low power (few uA, less than 100uA say) design. Again, for a 1-off it may not matter. But I'd start with Mega169 family or Mega48/88/168.

Now, on to timekeeping. For quick dev of a 1-off, I'd ditch the US$4.75/qty. 100 Mega32 and use a US$1.50/100 Mega48 and a suitable RTC chip (which I would pull from my bin of assorted samples obtained free from MAxim over the years). Now I've just eliminated almost all the problems/questions you are posing, if you don't need to "run" off the battery, just keep time when the mains are off.

Lee

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

A couple of general comments on "clocks".

An accurate crystal isn't. It's good for maybe a few days, but almost always the power mains give the best long term stability.
As Lee mentioned, 9V has bad power density. If you use instead 3xAA (3.6V) for backup, you can easily get 2000 mAH (NiMH). If your "High power" peripherals draw 10 mA, you'll have to turn them off after about a week on battery.
If you expect to be off the mains for a long time, and if you also want to be accurate when you come back, consider a radio-adjusted clock. There's probably no use trying to get WWVB in Singapore, but maybe there's a local reference.

-Mike

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

Quote:

An accurate crystal isn't.

A recent mailing from Maxim/Dallas sent me to
www.maxim-ic.com/DS3232RTC
and claims +/- 1 min/year accuracy:

Quote:

The DS3232 provides extremely accurate timekeeping in a 20-lead SO package—plus a whole lot more! This device is a highly stable, temperature-compensated oscillator (TCXO) combined with a real-time clock (RTC). The DS3232 provides 236 Bytes of SRAM, a digital temperature sensor, and an integrated crystal at a low cost. User calibration is NOT required to achieve accuracies of better than ±1.8 minutes/year (< ±3.5 ppm) over the industrial temperature range (-40°C to +85°C), and better than ±1 minute/year (< ±2.0 ppm) in the 0°C to +40°C temperature range.

Now whether this is yet another of Maxim's phantom parts... :)

Lee

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

Hi guys,
Thanks for the comments. A few comments to your questions...

I need the codespace of the Mega32. I'm slightly over 16K now and I still have a bit more code to add. My clock has a Winbond Chipcorder sound IC and does a bit more than a typical clock. I'm writing the code using Forth (yes...I'm an oddball).

I like the idea of keeping time in the Mega chip to minimize cost. The RTC chips seem to cost $1.50 or more in qty. I have fantasies of being able to sell this as a high-end alarm clock someday.

The comment about using the line power frequency for timekeeping is interesting. Is that more accurate than a 32Khz crystal? Digital watches seem to work well with their crystals.

And yes, here in Singapore we don't have atomic clock broadcasts. We also have 50hz power to make things more messy.

I'd only use the battery to keep my Mega running, to keep the 32khz clock running. It would wake up and monitor power and sleep until power was restored.

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

The simplest idea would be to put a diode between your filter cap and regulator, and one between your battery and regulator. Then you could use resistor dividers, make them really big resisters like 10Meg or so, to divide that voltage to less than 5 and a comparator to tell you if your're running on line or battery. The battery might not run it very long as your regulator will be using a lot of its power.

---
Formerly Torby. Stitch626 just seemed a more descriptive nicname.