Shop OBEX P1 Docs P2 Docs Learn Events
RTC with compensated oscillator running fast, what would cause this? — Parallax Forums

RTC with compensated oscillator running fast, what would cause this?

rwgast_logicdesignrwgast_logicdesign Posts: 1,464
edited 2013-04-09 11:11 in General Discussion
So im running a ds1307 with a temperature compensated DS32Khz oscillator. Every time I check the clock it has gained a few seconds, the amount it is gaining actually seems arbitrary I need to do further monitoring to figure out just how off it is.

The reason Im really confused as to why the clock seems to gain up to a second a second a day. vs my time in windows, is because the oscillator is suppose to be accurate up to +/- 2 seconds a year. When I hooked up the oscillator the DS1307 data sheet said to run its output directly to the RTC's xtal input and float the RTC xtal output. The data sheet for the oscillator showed a few resistors/caps on the connection between it and the RTC chip, it said these were to keep current draw down and would need to be adjusted for accuracy depending on the RTC. Not caring much about the current I went ahead and just connected the out pin of the oscillator to the in pin on the RTC (as the ds1307 data sheet directed), figuring this would give the most accuracy.

Secondly I built this clock on a "shield" type module for my board and have unplugged it and plugged it back in many times while working on the board, Im wondering if somehow this could cause the problem? I really need to figure this out, because I am doing another project, which is a clock as a present and I can't have it gaining up to a second a day, thats a bit ridiculous.

If more information is needed I can certainly give it, but I am hoping this is just a problem with me plugging and unplugging the board or something, since it seems to be a bit of an unpredictable time gain.

Comments

  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2013-04-08 14:49
    Hi rwgast;

    What oscillator are you using?

    BTW, the coupling technique can't cause error per say, I mean a frequency is a frequency.
    It would be hard to add an extra cycle once in a while except due to noise.
    2 seconds per day would be about 64K added cycles/day out of the 2,831,155,200 cycles in a day.

    The method of coupling may cause the oscillator to "Work Harder" causing an error in the temperature compensator.

    What are you using as a time reference. Your PC may have much of the error.
    The PC could be pretty good if before you look at the clock you set it using the internet NTP, Network Time Protocol.
    I would usually recommend one of the NIST time keepers. (OK, I use the University of Minnesota time keeper because it's pretty close and needs less time delay compensation.)
    The NTP method should be accurate to a few mS of error.

    Duane J
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2013-04-08 15:37
    I am using a ds23khz in dip format http://www.datasheetcatalog.org/datasheet/maxim/DS32kHz.pdf

    As far as a time reference Ive just been opening the clock in win xp and setting the time to the second that way, I figured a computer would keep time via NTP just like a cell phone ETC. I will check out a better time reference and see if the PC is the problem, hopefully that is the issue. I dont mind some drift it is going to happen, but a second a day sometime is a bit much, that would be a full minute every two months.

    Hopefully there is not a problem with the way I wired the oscillator becuase there is just no room to go in and add the schematic for reduced current, I doubt this is the issue though as I followed the DS1307 data sheet instructions for using an oscillator , instead of crystal, and the DS32khz data sheet does not say anything about the reduced current schematic being more "accurate". When I finish the board today I will use NTP to set the clock and leave the module plugged in, and check for drift in a few days. I was thinking maybe the plugging and unplugging could cause error because it causes the oscillator to switch from back up power to VCC power every time, but this would also happen whenever the board is turned off..
  • jonesjones Posts: 281
    edited 2013-04-08 15:50
    Before you pull your hair out over the oscillator, be sure that the PC time is actually doing what you think it is. My computer is using the XP defaults for syncing with NIST time, which is once per week, and if it doesn't happen to be on when the resync is scheduled it doesn't get updated. For example, I just checked my pc clock against NIST and it was over 20 seconds off. I suggest you use http://nist.time.gov/ and select whatever time zone your RTC is set to. It's not perfect, but generally is within half a second or so.
  • User NameUser Name Posts: 1,451
    edited 2013-04-08 15:58
    Where did you get the information that the DS32KHz was accurate to +/- 2 sec per year? The data sheet you link indicates +/- 1 min per year.

    Edit: If you had the power budget, I'd steer you to a fabulous used SC-cut OCXO (made by Isotemp Research) that is currently available on eBay for only $20. There are also a variety of ways you can roll your own OCXO and get considerably better stability than the DS32KHz.
  • KyeKye Posts: 2,200
    edited 2013-04-08 16:11
    Note sure that the DS1307 is meant to be driven by an oscillator...
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-04-08 16:20
    I was using a DS3231 and checking it against the clock in one of my PCs. After a several days I noticed the DS3231 was running slow - by many seconds. In trying to figure out what the problem might be, I realized the Windows clock was set to synchronize only once a week. I had apparently set the RTC just one day after the previous synch. I let it run without changing anything and checked it again the morning after the next synchronization and the PC's clock was back to within a second of the RTC. The problem was inaccuracy in the PC clock not the DS3231.
  • jmgjmg Posts: 15,173
    edited 2013-04-08 16:25
    Every time I check the clock it has gained a few seconds, the amount it is gaining actually seems arbitrary I need to do further monitoring to figure out just how off it is.

    One second a day is ~ 11.574ppm, so you need to be sure you have a reference better than that.

    A PC Clock, will not be super stable, use it as a ball park only.

    OCXO are nice, but you can also get TCXO (FOX924B) from Digikey for under $4, good to < 1ppm/day, or you can get GPS modules that give 1pps with even better long term stability.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2013-04-08 16:27
    Use the Official NIST Time Widget
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2013-04-08 17:21
    Im not sure where I got +/-2 seconds a year from either, I guess I had just had the wrong information stored in my head :). -/+1 minute a year is totally fine with me, the reason I am using these DS32khz oscillators is becuase I have them on hand.

    I just checked the NIST site above and my PC is most likely the culprit here, it is almost a full minute off from that time. I never realized how inaccurate a PC clock was..
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-09 04:48
    The crystals within a PC are pretty much the same as the one's used by the Propeller and can vary as much as 3%. The 3% variation in accuracy is not related to frequency, but mostly thermal stability. To get a really accurate oscillator, one need to buy a crystal that comes with its own thermal oven that keeps it at a precise constant temperature. This are NOT cheap, a few hundred dollars for the cheapest.

    If you want accurate time, it is easier to just check with the internet everyday or every few hours.
  • RS_JimRS_Jim Posts: 1,764
    edited 2013-04-09 07:08
    Ron,
    Thanks for the time widget.
    Jim
  • User NameUser Name Posts: 1,451
    edited 2013-04-09 07:26
    jmg wrote: »
    OCXO are nice, but you can also get TCXO (FOX924B) from Digikey for under $4, good to < 1ppm/day, or you can get GPS modules that give 1pps with even better long term stability.

    I appreciate the low power and low cost of TCXOs, but simply touching my FOX TCXO for several seconds (I have hot hands) causes a detectable frequency shift on even an inexpensive frequency counter. Probably fine for many things. Distressingly unacceptable to me.

    @Loopy: Please see post #5.
  • RDL2004RDL2004 Posts: 2,554
    edited 2013-04-09 08:54
    The DS3231 and others in that series have internal TXCOs and are accurate to within a minute or so per year. They're not cheap as far as RTCs go, but with no need to fool with an external crystal, and their very high accuracy, I think they're well worth the extra cost (under$10) if you need a really accurate clock.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-09 11:11
    Touching a hot hand to a TCXO like the DS32KHZ, to look at frequency stability, is not a fair test. The DS32KHZ only samples temperature once every 64 seconds, and expects to be used in a temperature-stable environment relative to that time span. It is best to mount it away from heat sources such a power electronics that might cause frequent rapid temperature changes.

    I use the ISL12020M TCXO RTC with embedded crystal. It by default measures temperature at 10 minute intervals, but that can be configured to 1 minute. Same consideration for a stable environment. The temperature compensation itself is done by a combination of digital trimming, which adds or removes pulses from the 32kHz stream, and analog trimming that pulls the crystal frequency by means of capacitors in the oscillator circuit. There are registers (factory or user programmable) that compensate for the parabolic curve of the nominally 32768 Hz xtal, while operating at 1µA supply current for timekeeping.
  • I know this is a really old post, but I just read in rwgast_logicdesign's post how he was using Win XP's clock to check the system time:
    As far as a time reference Ive just been opening the clock in win xp and setting the time to the second that way
    The clock app in Win XP had a huge gotcha - every time you closed the app, it would write the currently displayed time to the system time, but would truncate any fractional seconds. You could set your system clock seconds behind true time just by repeatedly opening and closing the clock app.

    So, without realizing it, every time you checked your clock reference you would actually be changing the reference!

  • For my projects I use the MCP 3234 RTC chip. It has built in TCXO crystal oscillator, and bunch of extra features, alarm clock, extra memory, full calendar. Super accurate and easy (SPI) protocol to use. It costs about $10. but for the time you just spent on this forum... Just sayin'
Sign In or Register to comment.