DS1307 slowdown on vbat

Hi, Im having very odd issues with my RTC clock, so Id like some help if anyones got an idea as to whats going on.

I`ve setup an RTC, it behaves correctly when on 5V, but when I turn the power off it loses time, i.e. runs slowly.

A quick power off/on works as expected, just happens when left off for half an hour or so, it`ll lose ten minutes or some such.

I`ve got a cap on 5v-Gnd, and pull ups 4.7K on the two data lines, a CR2032 bat connected to the 3V and Gnd, and the crystal is soldered directly to the two legs.

Im assuming the crystal is good, as I dont lose time when powered up, and it`s getting vbat power, or it would lose time completely.

Not sure what`s going on, possibly bad transition from 5V to bat on power loss ?

cheers

al

Measure the voltage of your battery while it is the only thing powering the RTC.

I found mine would run slow if anything else was connected to the battery. In my case, I had connected the battery to an analog input so I could monitor the voltage. This caused the ATmega to be "back-powered" by the I/O, which caused enough drain on the battery that its voltage dropped out of spec for the RTC.

Also, the RTC's oscillator is much more sensitive to noise when powered by the battery. The assumption that the crystal is "fine" because it works while powered is incorrect. If you are on a prototype board, you probably won't be able to get a good clean ground plane around the crystal. If you are on a PCB, the datasheet shows excellent examples of how to layout the board to reduce noise.

I know from experience that it makes a difference.

I made this little DS1307 board (see picture) - How would I create a ground plane?

Would a piece of foil glued to the board and connected to ground suffice?

Thanks!

It would be better than nothing. If it works then it suffices. :wink:

Have you verified your battery's voltage while it is powering the RTC chip?

James,
"It would be better than nothing" I did some research on ground planes back when I made my board but I never could
find a clear definition of what a "proper" ground plane is.

I also have a board from Futurlec DS1307 Real Time Clock Mini Board - it looks like the ground plane may be layered but I can't tell for sure.

The voltage across Vbat and GND is 3.04. I have some Chronodot modules which use a DS3231 and they are much more accurate.

Ground Plane is just that: a plane connected to ground. Attaching a piece of foil to ground is very similar to what you would do with a PCB.

On the PCB I designed the bottom layer is ground and, like in the board you linked to, there is a ground plane on the top layer which the crystal physically (not soldered) sits on top of. (I then put a series of vias around the top plane, as suggested by the datasheet.)

The DS3231 is probably a better way to go, they are more accurate than the 1307 even under best case conditions.

James,
Thanks for the explanation! I saw the diagram in the spec sheet pertaining to the crystal and ground plane, but it wasn't clear to me.

The fundamental issue is that to get very low power dissipation (about 1 microwatt) when running off the battery the oscillator circuit is very weak. Also the crystal is low frequency (32.768kHz) to reduce dissipation but this means that the currents through it are much smaller than a MHz crystal. Thus induced signals picked by the crystal can or its wires will compete with the tiny oscillation of the quartz crystal for the attention of the oscillators input pin. A ground plane will mitigate any capacitive pick up by shielding the sensitive circuitry from changing electric fields.

There can still be induced signals from nearby large currents (magnetic/ electromagnetic pickup) so its good to mount the RTC away from any wires taking significant AC currents.

Normally though a battery-backup clock won't see any nearby currents when running off the battery as the power is off - but it could be important when the power is on since the same oscillator is running (albeit at higher power).

The disturbance on power going on or off is probably going to disturb the time keeping a little - switching the power on and off once a second will probably noticeable affect longterm timekeeping. Running any other load from the backup battery will also perturb the oscillator.