clock that should work in very Precisely

Discussion in 'Embedded Systems and Microcontrollers' started by micropad, Jan 29, 2012.

  1. micropad

    Thread Starter Member

    Dec 24, 2011
    38
    0
    Dear All
    Please Let me know that using pic16f877a's timer1, can we build a clock that should work in very Precisely
     
  2. hexreader

    Active Member

    Apr 16, 2011
    250
    82
    Your clock will be as accurate as the crystal that you use for timing, or less accurate if your code is poor.

    What is "very Precisely" ? one minute per day, or one PicoSecond in 10,000 years?
     
  3. micropad

    Thread Starter Member

    Dec 24, 2011
    38
    0
    Thanks hexreader for reply
    I mean at least one second for one year and I sow lot of web site says that it is impossible that is why reason RTC existing
    please help
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Timer one is well suited for such task. You can use a 32.768KHz crystal as an external oscillator. Timer1 with external oscillator at 32.768KHz generates overflow interrupt every two seconds. If we set timer1 to start at 0x8000 (32768), the TMR1 will overflow every one second. It is some programming tricks involved to start timer1 at 0x8000. But I leave it to you to crack down that code
     
  5. hexreader

    Active Member

    Apr 16, 2011
    250
    82
    One second per year is about 1 part in 30 million, if my maths is correct.

    You might just manage that with a very expensive crystal oscillator (where the crystal is contained within an oven), but no ordinary crystal will even come close. 10PPM is typical for a standard crystal.

    What about synchronising to a radio clock signal?

    Not sure that RTC will help much. They are designed for better stability, but still rely on a crystal.
     
  6. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Maybe using the 50/60hz mains frequency it is not completely stable, but the power companies are supposed to correct it so that the number of pulses in each day is constant?
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I agree. One second pr year. Is much harder to get. The week link here is not the PIC. But the crystal. The best crystals I have seen has has a accuracy around 5 PPM. But errors due to temperature drift is not accounted for in this number
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    Last edited: Jan 29, 2012
  9. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
  10. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    I think if you use the 32.768KHz crystal, you'd have something as accurate as a digital watch, which is normally considered pretty good, but not as good as a second per year. You can use a GPS receiver for super-accurate time though, and they're available in modular form. Would that be useful?

    GPSDO, I'm not familiar with that, but it ought to work about the same.
     
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Maxim IC makes a few real time clock chips with a built in crystal. They are a little pricy (near 10 bucks for 1 in distribution) but the best accuracy I've seen without crystals in temperature controlled ovens. Since these chips have the crystal built in they can measure their own temperature and perform corrections. They are rated 2 ppm, which is larger then your 1 sec/yr.

    Google DS3231 or DS3232.
     
    PaulEE likes this.
Loading...