[time-nuts] Curve fitting

Tom Van Baak tvb at LeapSecond.com
Wed Dec 23 20:12:44 UTC 2009


> A disciplined oscillator can be modeled by an equation like:
> 
> OSC_FREQ = DRIFT_RATE*TIME + TEMPCO*TEMP + OSC_GAIN*DAC_VOLTAGE

Hi Mark,

I'm happy you're doing this. You're on the right track.
HP 58503/Z3801 have something sort of like this which
is where the predicted holdover time numbers come.

But be cautious thinking drift rate is always a constant.

Also be cautious about how you handle measurement
uncertainties. All GPSDO raw data has an implicit error
and finite resolution and this will bite you if you plan to
integrate, for example, reported DAC/EFC voltage over
a long time.

That aside, here's my recommendation.

1) To get a feel for modeling the GPSDO please start with
the easy case first. Disable TBolt disciplining and then
you will get a clean record of time (phase) error between
the OCXO and GPS. Record temperature but ignore it
for now. Or externally stabilize the temperature so you
don't have to worry about it. No need to record the DAC
settings since it is constant in this mode. 

You will now have a time series from which you can plot
phase error over time, frequency error over time, and
frequency drift rate as a function of time.

When unlocked, a long time error plot is often uninteresting
because it goes from zero to a large number, quadratically.
A frequency offset- or drift-removed residual time error plot
is much more revealing.

When unlocked, a frequency error plot directly gives you
a visual feel for the frequency stability of the OCXO. You
can immediately see how close to a straight line it is. The
slope of the line is the drift rate. And the more wiggles, the
more the variation in drift rate. You can try this with just a
few hours of data, but it might be more useful if you have
days of data available: frequency error is easy to measure

When you plot frequency or drift rate you have to choose
an averaging interval. Too small an interval exposes too
much noise; too large an interval and you get too few points.

Some people plot frequency drift as one point per day.
You can see this would require days or weeks of data.
If you don't have the patience perhaps once an hour will
work, although you may find the noise in this plot too high.

You can skip all the plots and just crunch on the raw data.
The code is simple for things like: mean, standard deviation,
min/max, rise over run, least squares fit, Allan deviation, etc.
A line fit of frequency, or a quadratic fit of the raw data, for
example, directly gives you drift rate.

I wrote C code for all this and can give it to you to play with.


2) DAC gain is easy to characterize. You can set the DAC
manually when disciplining is disabled. Also in this mode
the TBolt gives you time interval error measurements for
free every second. From these you get frequency error in
one line of code.

So programmatically set the DAC to its min and max and
perhaps every volt in between. In each case compute the
frequency error. Now you have a set of points (EFC voltage,
OCXO frequency). The slope of this line is your DAC gain.

For greater precision use longer measurement intervals
or make multiple measurements checking the mean and
standard deviation until it meets your desired threshold.
At the rails it might take only a few seconds.

You can get fancy -- compute frequency error to a higher
accuracy at each point and make a measurement at every
1/10th volt from min to max, etc.

Doing a least squares fit of this finer data set not only gives
you a more precise measure of DAC gain but the residuals
give you a measure of DAC non-linearity as well.

I played with all this a while ago. See this unfinished page:

http://www.leapsecond.com/pages/tcxo-efc/

A rough version of the C code is around too. See:
http://www.leapsecond.com/tools/efc1.c


3) I'll go on about your tempco question later.

/tvb




More information about the time-nuts mailing list