DS3231 RTC running fast

Thread Starter

mcgyvr

Joined Oct 15, 2009
5,394
What could cause a DS3231 i2c real time clock to run fast?
And what can I do to troubleshoot it?
I'm talking a 1-2 minutes or so a day.. (the first board was consistent and the second board seems to be sporadic.. sometimes it runs fast..other times it doesn't)
Supply Noise?
Damaged internal xtal?
Maybe increase the decoupling cap.. Its .1uF and not as close to the IC as I would put it.. Its maybe 2" of trace length from the supply/ground pins.

The micro its attached to is also resetting multiple times a day. (Watchdog function turned on I believe) Which is the next problem to look at..

Schematic is identical to the datasheet "typical operating circuit" except for nothing connected to INT, RST, and 32khz which were left floating.. All other NC pins are tied to ground per the datasheet.
 

THE_RB

Joined Feb 11, 2008
5,438
I think the "sporadic" fault nature gives you a clue.

Maybe it is your controlling device, ie a bug in software that is somehow affecting the RTC, either writing to the RTC and changing its time or wrongly interpreting the time from the RTC?
 

ErnieM

Joined Apr 24, 2011
8,377
The RTC running "fast" is interesting. If you did not have the battery backup installed it may run fast or slow if the power is glitching. With the battery it should just chug along like nothing happened.

A watchdog timer timeout looks very bad for your software, could the stack be overflowing? Got room to add some more (assuming it's a C soft call stack).

Does the working board show any problems or is one board 100% good and the other bad?
 

Thread Starter

mcgyvr

Joined Oct 15, 2009
5,394
First its not my code or product (just trying to help a friend) so I haven't jumped into the software side yet.. Still looking at hardware/noise issues as the cause. I'm thinking it might be noise related too as they just used the minimum recommended caps on everything.. Nothing beyond straight up datasheet recommended circuit/minimum caps,etc... No ground plane,etc..

Maybe this will help now.
This micro basically controls multiple relays. The turning on/off of 2 specific relays seems to correlate with the micro resets. These relays are in a dedicated box linked to the main board via a 15 pin serial cable. Inside the relay box (input from the serial cable) is a ULN2803 that triggers each relay. On the other side of the serial cable is a 74HC540 buffer which is fed by a PCF8574 I2c to 8 bit I/O expander.
So its (micro i2c output---PCF8574---74HC540)---serial cable---(ULN2803--relays)
(brackets represent each "enclosure/pcb")

I just keep thinking its all related to "noise" or something on the I2c bus but aren't sure nor am I familiar with out I would go about testing that theory as the cause of the resetting and the fast clock.

Others are using the same firmware and aren't having these problems.

Here is the kicker IMO....
As of last night all I did was unplug the 120VAC items on the contact side of those 2 relays and the resetting "seems" to have stopped and the "clock" seems to be running correctly now. I'm just stumped on how something on the contact side of the relay is effecting something on the coil and back side.. I wasn't aware that issues could be caused by "whatever" crossing back over the contact to coil isolation gap.. Or maybe its just the close proximity of the AC cables and now that I have moved them a bit the problem seems to be gone.
 
Last edited:

tracecom

Joined Apr 16, 2010
3,944
Are the 120VAC devices that are controlled by the relays putting a "glitch" back onto the mains that is affecting the PS for the clock chip?
 

ErnieM

Joined Apr 24, 2011
8,377
Here is the kicker IMO....
As of last night all I did was unplug the 120VAC items on the contact side of those 2 relays and the resetting "seems" to have stopped and the "clock" seems to be running correctly now. I'm just stumped on how something on the contact side of the relay is effecting something on the coil and back side.. I wasn't aware that issues could be caused by "whatever" crossing back over the contact to coil isolation gap.. Or maybe its just the close proximity of the AC cables and now that I have moved them a bit the problem seems to be gone.
It's been a few decades since I saw something similar when someone turned off a power supply on the bench next to mine and the circuit I was working on (not my design nor build) reset itself.

It was a floating CMOS input, and even something several feet away induced a signal large enough to change the floating input's state.
 

THE_RB

Joined Feb 11, 2008
5,438
The RTC chip uses extremely low power for the 32kHz oscillator, it's likely that spikes on the wiring could cause the oscillator to experience extra clocks which would result in fast running.

I would put a good tantalum cap 47uF 10v etc on the power pins right at the RTC chip, and decouple the 1-wire comms with a series resistor of a couple hundred ohms. You may need to change the value of the 1-wire pullup resistor. Going further you could put the RTC in a small metal can for RF/EMI shielding.
 

Thread Starter

mcgyvr

Joined Oct 15, 2009
5,394
ok more info.. It seems that the i2c scl/sda lines were also extended through the serial cable to a connector on the relay board for future i2c expansion units. There are jumpers in the main board to disconnect those lines through the serial cable.. After pulling those jumpers the resetting "seems" to have stopped and the clock is running at the proper speed. so far..
The pull-up resistors to 5v on the scl/sda lines are 4.7k ohm.. maybe try something smaller.. 1.5k?

The RTC has a 100n cap on the vcc to gnd. In fact all the IC's each just have a 100n bypass cap. The main 5V and 12V supply is generated by a "Chinese mystery black box" ac/dc convertor on the relay board and passed back through the serial cable to the main board. Here is the datasheet for the 5/12v supply https://dl.dropbox.com/u/9726802/09 AC220SXXDCX X-5W 48.00 k.pdf
Its bought with the AC side components (cap/res/inductor) built into it.. Output caps are not. And the 100n caps on each IC supply are the only other caps.
 

ErnieM

Joined Apr 24, 2011
8,377
HenLv Power Shanghai Technology Co. said:
during use kindly notice main ground and load ground must be connected to the ground. So it is safe for human even if some problems happen. supportive circuit is isolation, so it is no need to connected with the ground.
Gee,with documentation as explicit as this why would you ever worry about that component?

The only omission on the power side is the large bulk cap where the manufacturer recommends 2200 uF, but the 0.1's are there so it's not too shabby. You might try to tack in a large cap to see if it improves things.

Smaller pull ups on the I2C may help... so may adding series resistors between the pull ups and the serial cable, I'd start with 100 ohms and see what happens.
 
Top