Internal clock calibration


+ Reply to Thread
Results 1 to 14 of 14

Thread: Internal clock calibration539 days old

  1. #1
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,369
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Internal clock calibration

    I like to use devices with accurate internal clocks and I was thinking about how to calibrate or even better auto-calibrate. An obvious source of accurate timing is cheap GPS modules 1Hz output. I figure you could sit in a tight loop counting up till an interupt from 1Hz or have the 1Hz trigger a timer. Either way the number generated is compared to a compile time constant or maybe lookup table.

    Even more accurate would be to have the 1Hz counted in hardware to some know value, like 60. That should reduce any jitter.

    Before I play with this, am I reinventing the wheel or is there some better way to do it?
    George.

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,452
    Thumbs Up
    Received: 49
    Given: 44
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    Even if you got the clock exactly in step with GPS, I would guess that subsequenty, as the temperature changed, the clock would drift.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,369
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    @Charliecoultas and of course with Vdd (especially if battery powered)

    GPS modules are so cheap I could include it in the project, on eBay they start at 3 (with an antenna). I wonder if any will work indoors? Probably not.
    George.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,452
    Thumbs Up
    Received: 49
    Given: 44
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    I have used a few of these on "clocks" and yes, they work indoors. But I'm not sure they would be work in multi-story buildings. Some of these cheap GPS, with antenna, give the time a few seconds out until they get a certain update, which happens within the first twelve minutes of power-up. They tend to favour a 3.3V supply so watch this.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,670
    Thumbs Up
    Received: 352
    Given: 168
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    I don't quite understand your logic George.

    If an external unit is going to be used for timing, why not simply use a crystal, or better, a crystal oscillator? Both give a very stable clock for the device, and the faster you run the device, the less a fluctuation will matter, because it is then fluctuating in pico seconds, so even a 1 cycle delay will have very little difference.

    A ceramic resonator is not as good as a crystal, but crystals are now, literally pennies to buy.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,374
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    Hi Lester,
    I believe he wants to use a precise clock to calibrate the internal osc and then run the device on its own.

    Bob

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member david's Avatar
    Join Date
    Jan 2019
    Posts
    100
    Thumbs Up
    Received: 4
    Given: 1
    Total Downloaded
    174.52 MB

    0 Not allowed!

    Default Re: Internal clock calibration

    Hi,
    The ultimate DIY frequency source is probably a frequency locked loop (FLL) where the long term stability of a GPS timing signal is combined with the short term stability (phase jitter) of an OCXO (oven controlled xtal osc).
    The typical 1pps GPS timing signal will have something like 30-70nS of edge jitter due to atmospheric aberrations and micro timing granularity. This can be largely eliminated by integrating over a longer period so that the same jitter is spread across many seconds.
    The FLL is quite simple - the micro counts the output from say a 10MHz OCXO over a period of say 16 seconds using the CCP in capture mode. If the OCXO is exactly on frequency you would expect 160,000,000 pulses. You don't need to count all the pulses, just look at the register overflow and determine if it's less or more than the perfect clock count. The difference can then modulate a high resolution PWM (only some PICs) or drive a DAC which then fine tunes the OCXO. A key feature of the approach is to never stop or start a clock and just take a snapshot of the value and let it keep running such that fractional counts are accumulated rather than truncated.
    With relatively simple hardware it's possible to get down below 0.1ppb error however it will take a few hours to get there as the closer you get the longer it takes to accumulate an error pulse. I'm sure you could also discipline a (voltage controlled) TCXO if phase jitter was not a concern.
    GPS modules are very cheap and I've had no problems working inside a single story dwelling. If you need to you can always use an external antenna.

    Regards to all,
    David

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Member david's Avatar
    Join Date
    Jan 2019
    Posts
    100
    Thumbs Up
    Received: 4
    Given: 1
    Total Downloaded
    174.52 MB

    1 Not allowed!

    Default Re: Internal clock calibration

    Hi,
    Well that last post was one extreme and really only intended to be used as a good, stand-alone reference rather than be used in some other project as a clock source.
    You may want to check what some of the little u-blox M8x modules can do as they offer configurable 1pps outputs covering 0.25Hz up to 10MHz. This won't integrate out the timing jitter but should allow you to obtain a stable 10MHz clock and if you can live with 30nS RMS jitter then it involves no other hardware. I've not directly measured this re-configured 1pps out but the specifications look quite reasonable.

    Regards,
    David

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,369
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    Kindda stupid of me too take this long but whenever you get a lock you can reset the time/date. I doubt if this is practicable but I was just throwing in an idea. I thought the self-calibration was cool.
    George.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Member david's Avatar
    Join Date
    Jan 2019
    Posts
    100
    Thumbs Up
    Received: 4
    Given: 1
    Total Downloaded
    174.52 MB

    0 Not allowed!

    Default Re: Internal clock calibration

    Hi George,
    If you're only concerned about long term accuracy could you use the AC mains frequency to keep time? Digital clocks only ever need adjusting when there's a power cut and even this can be largely overcome by having a 50Hz clock generator take over when mains power fails. If the supply authorities hold the number of cycles error to 1/day (non accumulative) then you're already better off than a crystal over that period.

    Cheers,
    David

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,369
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    I'm sure your correct re. mains being more accurate but I was taken by the simplicity of GPS which of course will still work with battery power and I'm scared of mains.
    George.

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    549
    Thumbs Up
    Received: 33
    Given: 7
    Total Downloaded
    3.87 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    Quote Originally Posted by towlerg View Post
    I like to use devices with accurate internal clocks and I was thinking about how to calibrate or even better auto-calibrate.
    I noticed this post the other day but did not reply as I did not understand the question, are you taking about an internal time/date clock or the system clock?

    I may be wrong but from the brief look I have had at date/time clocks within PIC's I do not recall seeing any adjustment options to their internal clock source. If you are talking about the internal system clock while you can vary them by setting the OSCTUNE register values are then not shipped factory calibrated in which case they should be as accurate as they are going to be out of the box, usually +/-1%.

    Consequently, I would think that the only way to increase the accuracy of the system clock is to use a more accurate external clock. You could perhaps change the properties of the oscillator by heating/cooling the device but that would be a rather impracticable solution.
    As for a date/time clock I would think your method of deriving the amount of error, the subsequent adjustment value and when to apply the adjustment (weekly, monthly, yearly) would work. I had the impression that the reference clock source would be a permanent feature rather than a temporary calibration only hookup so that periodic calibration checks could be performed, if so then would it not make more sense to just use that (if possible) as your clock source rather than the internal clock?

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #13
    Senior Member SimonJA's Avatar
    Join Date
    Mar 2006
    Posts
    844
    Thumbs Up
    Received: 14
    Given: 16
    Total Downloaded
    1.03 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    I think there are some calibration registers for the rtc, at least for 24 series pics: RCFGCAL, I was thinking about adjusting these relative to gps time on my project on another thread.

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #14
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,369
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: Internal clock calibration

    I'm only thinking of system clock but I don't see any reason why not.

    In fact the two go rather well together, the RTC gets updated and calibrated when the GPS has a fix and the RTS holds time when GPS has no fix.
    George.

  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. [SOLVED !] Bootloader pic16F1788 internal clock 32Mhz
    By bcans in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 6th July 2016, 17:53
  2. No internal counter/clock?
    By bcans in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 8th April 2009, 06:39
  3. Internal Clock/Oscillator
    By Oloff in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 14th January 2007, 12:25
  4. Internal oscillator calibration value
    By Eriond in forum Proton Plus Compiler v3
    Replies: 12
    Last Post: 19th May 2006, 17:15
  5. [SOLVED !] Setting the Internal clock on 16F676
    By bruceanderson in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 22nd August 2005, 18:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts