Looking for advice on real time clock

Hi All...

I am considering adding a real time clock chip to my application. The application will run from external 12VDC when it is in use, but have no power when it is not. I have two things I am grappleing with.

First, is it better to use a small coin battery to keep the RTC chip up when the power is off, or a big capacitor?

Second, is it better to hang it on the SPI or I2C bus.

For the first consideration, the benefit of a cap is that it would never need to be changed. As long as the device is used/powered every few weeks the clock should stay set. But, to my amazement, I see a 1F cap costs at least $4.10 quantity 1! A 3V battery can cost from $0.28 to $1.50 depending. It removes the issue of the clock loosing its time in a few weeks but will need to be changed some day.

A PCF2123 uses about 100 nA while a PCF8563 uses .25 uA. They use more when being accessed, but at that time its under external power.

As for the SPI/I2C issue, the onl;y thing is that I'll be using the SPI bus to talk to a SD card and don't know how complex it is to hang multiple things ont eh SPI bus. I realize it should be easy, but nothing ever really is.

Any thoughts? Thanks!

First, is it better to use a small coin battery to keep the RTC chip up when the power is off, or a big capacitor?

coin battery is most mentioned in the datasheets.

Second, is it better to hang it on the SPI or I2C bus.

Both are good, so it might depend on the rest of your sketch,

As for the SPI/I2C issue, the onl;y thing is that I'll be using the SPI bus to talk to a SD card and don't know how complex it is to hang multiple things on the SPI bus. I realize it should be easy, but nothing ever really is.

Then use the I2C bus -- there are libraries out there. Keep it simple. Let the SPI bus deal with the SD and the Ethernet cards etc...

For 5V Arduino the DS1307 RTC is ‘standard’ - several vendors have breakout boards with coin cell holder and crystal. Life of cell about 10 years, its a no-brainer really. For a 3V3 arduino mini pro, there’s the DS1338Z-33 which is a 3V3 version of the 1307. Both chips are available as 8pin DIP or surface mount.

Thanks everyone, I'll check all this out.

Personally I think its simpler to stick to a single bus. I'd use the spi in that situation. Controlling multiple devices is trivial. Also the wire library is a bit of a memory hog, which could be an issue if you have a lot of other libraries linked in.

yet another difference:
I2C uses 2 wires for any amount of devices. Handshake for device selection in software, (takes time)
SPI needs a Select line for every next device. device selection in HW => faster

Actually I was favoring the SPI bus for this purpose for a few reasons. First, I didn't want to add another library to the sketch, as someone mentioned. Also, the SPI version of the ultra low power chip is cheaper than the I2C version by about $0.70, and it uses 100 nA vs .25 uA. Not that the power issue exists any longer, the super cap is much more expensive than a battery.

My only hesitation on using the SPI bus was that I didn't know how much time the SD card software was going to be using it, but upon reflection, I won't be reading the RTC in any ISRs, so there should not be any contention for the SPI bus. For the most part, I'll take in a bunch of data, read the clock, write the data to the SD card, repeat.

Thanks for your thoughts everyone.

and it uses 100 nA vs .25 uA

What's a150nA between friends?

DISCLAIMER: Self-serving suggestion!

But, this is a quick off-the-shelf solution with DS1307:
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=48

DS1307 is an I2C device (SCL/SDA)
http://datasheets.maxim-ic.com/en/ds/DS1307.pdf
67 cents in larger qtys
http://www.dipmicro.com/store/DS1307N
Needs a crystal too
Standard 32.768kHz Quartz Crystal
http://www.dipmicro.com/store/XC4-32768
15 cents at same qtys

uses <500nA in battery backup mode.
A 25 cent 3V Coin cell battery would last a long time:
http://www.dipmicro.com/store/BAT-CR2032
holders:
http://www.dipmicro.com/store/BH120591-1
Coin Battery Holder ø 20mm (CR2025, CR2032) Top Load - dipmicro electronics - could end up paying more for these than for the battery!

“Backup Supply Input for Any Standard 3V Lithium Cell or Other Energy Source. Battery voltage must be held between the minimum and maximum limits for proper operation. Diodes in series between the battery and the VBAT pin may prevent proper operation. If a backup supply is not required, VBAT must be grounded. The nominal power-fail trip point (VPF) voltage at which access to the RTC and user RAM is denied is set by the internal circuitry as 1.25 x VBAT nominal. A lithium battery with 48mAh or greater will back up the DS1307 for more than 10 years in the absence of power at +25°C.”

@crossroads, you're a maniac!

Can I steal this whole post for my site documentation??

Maybe I can just arrange a Brain Backup??

Help yourself Terry, its all public domain as far as I'm concerned.
I start a new job Monday, with a 40 minute drive each way, so I'll probably be a lot less active after this weekend. PM me if you need help on anything.

I have been using the DS1337 on a number of my boards.
I like having the two interrupt lines (or one interrupt line and square wave output).

I diode-or (low Vf Schotky) the Vcc with a CR1220 coin-cell. Should last for apx 10years.

One thing to be careful of is the crystal selection. Some of the DS chips require 6pF and others 12pF.
Make sure you get the appropriate crystal.

The schematic and BOM for my PICO1TRC which uses a '328 and DS1337 is at
http://wiblocks.luciani.org/PICO/index.html

(* jcl *)