PDA

View Full Version : Trouble with DS1307 battery backup



Amoque
- 29th August 2014, 18:14
I am currently working with a DS1307 RTC ('877A and I2C). All is well reading, writing, and displaying result to a typical LCD. The difficulty comes when using a battery (2032 Lithium coin) to backup the clock. Insert the battery, the display flashes: 04:04:04; remove it, time returns to accurate display and advance. Re-insert battery, display reads: 04:04:04... Its quite a fun game, but not very efficient way to keep the time. I've checked the voltage of the battery, wiring, and everything else I can think of - as well as tried some basic filtering. I've searched Google for any known issues and found nothing... Anyone can advise?

SUNFLOWER
- 30th August 2014, 01:40
A schematic showing DS1307, never had trouble except once when a circuit mistake overheated the voltage supply and the clock with battery gave similar data.

http://www.harbornet.com/sunflower/PCB.jpg

aratti
- 30th August 2014, 06:37
Very likely a wiring problem. Did you place two diodes to isolate the battery from power?

You can have more help if you post the schematic.

Cheers

Al.

aerostar
- 30th August 2014, 07:17
Very likely a wiring problem. Did you place two diodes to isolate the battery from power?


Al.

You do not need your suggested diodes - if you look at the data sheet the backup battery has its own pin, and the battery should be connected to that and ground.

Amoque
- 30th August 2014, 11:54
I was thinking more like stray capacitance issues, or I2C resisters of wrong value (3K3)- something of that nature; maybe battery back-up voltage (3.32V) issue. Wiring the battery could hardly be easier and I've looked, until my eyes crossed, at the holder to be sure there was nothing wrong with it. I think I'll try a different battery, but I've already tried a different 1307 and a different 12.5 pF crystal, verified wiring- exact same result. Circuit is rock solid, just goes "404" on me when the battery is inserted.

mackrackit
- 30th August 2014, 13:52
What happens if you leave the battery inserted? Can you then reprogram the time?

Amoque
- 30th August 2014, 16:09
No... The LCD initializes, then displays "TEST" on startup or reset (both work fine, even with battery inserted), then clears the LCD and displays the time in a simple loop. Function is consistent regardless of battery, except the display remains fixed at 04:04:04 with the battery in place.

Reprogramming sets the time registers to the startup value, but 04:04:04 continues to be displayed until the battery is removed.

In exercising your suggestion, Dave, it appears that the clock continues to function correctly (and accurately) while the display is erroneous; rather it is some anomaly in the I2C that affects the output or display! What is the likelihood that different (lower? Higher?) I2C pull-ups would resolve this?

EDIT: Appending or propending text before or after the time displays as expected as well.

Amoque
- 30th August 2014, 16:26
Ok, mystery solved.

It appears that noise, capacitance, or competing residual signal on the breadboard was causing issue. Running the voltage supply directly to the circuit board resolves all issues. Thanks all - and you particularly you Dave, for putting me on the right track.

Amoque
- 2nd September 2014, 12:32
Ok, after further research, it appears related to battery voltage. The "new" battery I purchased reads over 4 volts. Just a head-up to others: something to look at if you're getting wonky readings from your DS RTC. I clipped a high draw LED to it for a bit - works flawlessly now. Sorry for the "Much ado about nothing."

Archangel
- 2nd September 2014, 19:24
Sorry for the "Much ado about nothing."
NOTHING, Really?
If it gave you pain, it was not NOTHING. Someone WILL encounter this situation again, AND see this thread, AND it will help them. Keep posting!

SUNFLOWER
- 3rd September 2014, 01:38
Very interesting. I did not know about DS1370 battery voltage sensitivity. I used long-life CR 1620 for 10 year clock service and never checked battery voltages with a meter. Something to consider in the future.

Jerson
- 3rd September 2014, 05:20
I've seen this problem before. The resolution is in the data sheet section regarding Vbat. This is what it says


From http://datasheets.maximintegrated.com/en/ds/DS1307.pdf page 6

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

Hope that helps

Amoque
- 3rd September 2014, 14:20
Yes, I read the warning and it eventually came back to me as a possibility - it just took too long for me to question that a brand new, off the shelf part would be the problem. FAR more often it is some errant wire or lack of understanding... in my case anyway.

If I've learned anything it is that those weird intermittent problems that come and go are most often related to power supply. Wires don't move and semiconductors don't magically heal - only to fail again - in a random pattern. Well, here's to posterity and "Good Luck" to the next guy.


Cheers,

andybarrett1
- 4th September 2014, 07:53
NOTHING, Really?
If it gave you pain, it was not NOTHING. Someone WILL encounter this situation again, AND see this thread, AND it will help them. Keep posting!

If this was Facebook …. Deserves a like:wink::wink:


I have had a wealth of help and advice from here…. By asking Questions

Thank you all of you !!!!