Electronic – Calculating error between two clocks

clockdrift

I have a clock. It generates ticks. I want to know the error in PPM relative to another clock, so I count the ticks.

Let's say the oscillator is 1 MHz (for simplicity). I should count 1,000,000 ticks per second. I plot the (expected_tick_count – actual_tick_count) per other-clock-second. I get a nice line which represents the accumulating error, in microseconds. Linear regression results in R^2 = 0.9999 (i.e. a perfect line), and a slope of 27. To me, this implies 27 PPM error in the oscillator.

I assume this means I actually get 999,973 ticks per second instead of 1,000,000. So I tune the oscillator frequency so that it includes an extra 27 ticks per second.

I re-run my test. I expect to see negligible error. Instead, I find another line, with a slope of about 3. So it appears as if my initial regression analysis was off by 3 PPM, despite an R^2 that is the envy of statisticians everywhere.

Am I missing something?

Best Answer

What accuracy does the datasheet for your oscillator claim? Typically, a crystal oscillator will only guarantee to be within 25ppm.

Perhaps the act of measuring the frequency is having an effect also.