Precision Clock

©Brooke Clarke, N6GCE

28 Oct 2002 first prototype
6 LEDs working & 1 PPS out working

6 digit precision clock to be driven from a precision osc based on a 28 pin PIC 16F870 (later a 16F873A) muxed LED display (photo at top of page)
MM5369A Replacement that is driven from a unit oscillator and outputs either 50 or 60 Hz (jumper select) and 1 PPS this is working
Using Odd frequency Oscillators
Precision Time Standard - Experimental Observations
Stability Table
Temperature Stability
Bresenham's algorithm

Seperate Web pages:
Disiplined Oscillators and Time & Frequency related Patents
Crystal Temperature Compensation Patents
Sundial Patents
Stellar Timekeeping -
Ideas for measuring the Earth's rotation

6 Digit Precision Clock

6 Digit LED precision clock (HH:MM:SS) where the uC clock source comes from a precision oscillator at 1, 5, 10 or 20 MHz.  Because the frequency division is in software it's possible to divide non standard frequencies down to 1 PPS (see below) allowing the use of lower cost yet very high quality oscillators as time bases.

Altough I have the TAC32 software and a GPS receiver with it's serial port connected to my computer, I don't normally run the software. I would like to have a hardware clock driven by my precsion oscillators as a check of their health.


It may be possible to offer an optional version that would display Sidereal time for astronomical use by swapping the uC for one with a different program.

By arranging the digits side by side and using the decimal point as the separator between hours an minutes and a blinking decimal point between minutes and seconds the display might also be used as a frequency or time counter with a different microcontroller installed.


Developing the software routines for the three projects below using the PIC 16F870.  This chip has the same modules needed for the MM5369A products below and has a number of extra I/O pins that can be used for development.  It also is more cost effective than using a smaller PIC for the 6 Digit Precision Clock than using a smaller PIC and then adding extra chips to get the needed I/O pins.
7 Oct 2002 - have interrupt routine working
10 Oct 2002 - have single 7-segment digit that will display a 16 bit value as 4 sequential hex digits for development
12 Oct 2002 - have 10 bit A/D working to be used with thermister for temperature sensing
28 Oct 2002 - received prototype PCB and after fixing the errors have the 1 PPS output and 6 digits turning on.
7 Nov 2002 - trying to get the Microchip ICD2 In Circuit Debugger version 2 working
19 Nov 2002 - Investigating the idea of using a 12F675 8 pin PIC 6 digit clock (maybe more) that would be able to drive any size of LED digits.
                        Starting prototype to try out the idea.  No RS-232, only runs from 10 MHz unit oscillator.

MM5369A Replacement

Many years ago National Semiconductor made an IC that contained an oscillator that worked with the common color burst crystal (3.579545 MHz) and divided down to a 60 Hz output.  This part is now obsolete.  To make a replacement today it costs less to use a unit oscillator than it does to use a separate crystal and loading caps.  Also using a microcontroller allows either 50 or 60 Hz outputs as well as a 1 Pulse Per Second output.

14 Oct 2002 - Prototype is working with the following features:

15 October 2002 - 12 MHz was chosen because it's evenly divisible by both 100 and 120 allowing the generation of either 50 or 60 Hz, but a better choice would be 20 MHz because it's the highest rated frequency for most of the modern PIC chips.  Most low cost unit oscillators have a frequency tolerance of 100 ppm (Parts Per Million) including voltage and temperature and 30 days of aging which translates to 2,000 Hz in 20 MHz.  On the 20.0 MHz unit oscillator I have the frequency was fast by about 100 Hz.  So the correction for starting frequency would also correct for the 120 and 100 division.  The higher frequency translates into finer corrections.

Enhanced MM5369A Replacement

The inexpensive unit oscillators behave about like a plain crystal in terms of frequency errors due to temperature and aging.  It may be possible to greatly reduce these errors not be trying to control the frequency but rather by controlling the 50/60 Hz output and the 1 PPS output.  This requires both temperature sensing and characterization of the oscillator being used for not only it's current frequency but also how the frequency changes with time (aging rate).  Since crystal oscillators are many orders of magnitude poorer than atomic frequency standards the crystal aging can be characterized in a relatively short time when an atomic standard is used as the reference.

Idea: 14 Oct 2002 - use a pot on AN1 as a switch that's only read at power up (that way it can not change) that would allow selection of:

The 1 PPS LED can be used to indicate which mode was selected during the power up sequence then it changes to the 1 PPS heartbeat.
An alternate use of AN1 might be to use a pot that has no stops and allow continuos frequency correction similar to a variable cap on a crystal but with way more range and resolution.

Using Odd frequency Oscillators

There are a number of oscillators on the market (eBay) that have output frequencies that are not the classical precision oscillator frequencies (1, 5 and 10 MHz).  For example the FEI model FE-2163A is a very high quality double oven unit with extremely good specs but it's frequency is 10,054,347.8 Hz..  I think this frequency can be divided down to exactly 1 PPS using a uC allowing it's use as a precision time standard.

Table of common crystal and unit oscillator frequencies and their factors, typically 2, 3 and 5.  Up to 30 MHz which is the highest I have seen a 16F870 or 16F873A run.

Precision Time Standard

Experimental Observations

Stability Table

This table will give you some idea of how the quality of the oscillator impacts time keeping.  For many months the FTS4060 Cesium standard has a measured stability in the area of a few parts in E-13.  An oscillator at 1E-8 would make a clock that's good to much better than 1 second per year if you correct for the aging.


For a few decades the second has been defined based on the atomic physics of Cesium.  For all the centuries prior the second was defined based on the rotation of the earth.  The switch was made because there are a number of irregularities in the earth's rotation and so it's not that good of a time keeper.

All precision oscillators have a means of adjusting their frequency, none of them turn on and run at exactly their nominal rate.  But the newer Cesium standards do come very close.  First and second generation Cesium standards have a manual "C Field" adjustment to adjust their frequency.  But even when not adjusted the frequency of a Cesium standard stays at a constant frequency, i.e. it does not have aging.

All other oscillators like lab grade crystal or Rubidium oscillators change frequency with time, i.e. they age.  A good oscillator, like a good wine, ages well.  That's to say that as the running time increases the rate of aging decreases.  For a good crystal oscillator after say 6 months of operation the aging rate might get down to parts in E-9 or E-10.  The aging at this point is predictable and can be accounted for either by changing the fine tuning or be predicting the frequency and changing the divisor to get to one second.

Note that precision crystal oscillators need to be calibrated at some time interval (6 months, a year, etc.).  At the time of calibration the frequency is not set to be spot on, but rather is set to be off by the maximum allowable amount that's within spec, but so that spot on is in the direction of the again.  This way at one half of the calibration interval the frequency will be spot on and at the end of the cal interval it will be right at the spec limit.  This way you get the maximum length cal interval for a given spec.

Temperature Stability


Patents related to Disciplined  Oscillators -

Bresenham's algorithm

These links are about a method where a fixed Timer count is used and so results in a jitter on the 1 PPS output as large as the size of the Timer count.  A much better way is to accumulate the fractional timer count error and add one count to the last count of the second and subtract 1 from the fractional error counter.  This way the jitter is limited to one timer count = 1 instruction count = 4/Fosc.

Of course this requires using a different value for the Timer count at different times in one second.  For the FEI FE-2163 double oven 10,054,347.8 Hz oscillator this would translate to 99 rollovers at a Timer1 count of 25,058 and a nominal last count of 32,844, but because of the fractional part overflow for 19 seconds in a row the last count would be 32,845 and once every twenty seconds the last count would be 32,844 resulting in zero error and jitter less than 397.8378 nanoseconds.

Zero-error One Second Timer! - I'm not using this method, but it could be applied differently for much better results
NIST -Dictionary of Algorithms and Data Structures - Bresenham's algorithm - the basis of the Zero-error timer
Bresenham Line-Drawing Algorithm -
Wiki - Bresenham's line algorithm -

Back to Brooke's Products for Sale, Time & Frequency, Military Information, Home page

This is the  time this page has been accessed since since 13 June 2002.