DS3231 RTC running fast

Discussion in 'General Electronics Chat' started by mcgyvr, Dec 13, 2012.

  1. mcgyvr

    Thread Starter AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    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.
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    ...perhaps check out the aging offset register on page 14 of the datasheet...
     
  3. mcgyvr

    Thread Starter AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    aging register is not being used..
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    perhaps it needs to be...

    from datasheet:
     
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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?
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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?
     
  7. mcgyvr

    Thread Starter AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    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: Dec 14, 2012
  8. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    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?
     
  9. mcgyvr

    Thread Starter AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    Maybe.. I'm hoping to be able to check stuff out this weekend on the o-scope.
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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.
     
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
    chuanxiaoli likes this.
  12. mcgyvr

    Thread Starter AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    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.
     
  13. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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.
     
Loading...