[time-nuts] Timestamping counter techniques : phase computation question
Erik Kaashoek
erik at kaashoek.com
Sun Jan 30 11:46:19 UTC 2022
In a timestamping counter I'm trying to calculate phase and frequency
using statistical techniques.
The counter has two counters, one for the input events and one for an
internal clock.
The capturing of these counters happens synchronized with an event.
The counter takes the timestamps at more or less regular, but not
identical, intervals
An example of 20 captures is:
Events      Clock
280707207Â Â Â 1693452332
280708207Â Â Â 1693473665
280709207Â Â Â 1693494999
280710207Â Â Â 1693516332
280711207Â Â Â 1693537665
280712207Â Â Â 1693558999
280713207Â Â Â 1693580332
280714206Â Â Â 1693601644
280715207Â Â Â 1693622999
280716206Â Â Â 1693644310
280717206Â Â Â 1693665644
280718206Â Â Â 1693686977
280719206Â Â Â 1693708311
280720206Â Â Â 1693729644
280721206Â Â Â 1693750977
280722206Â Â Â 1693772311
280723206Â Â Â 1693793644
280724206Â Â Â 1693814977
280725206Â Â Â 1693836310
280726206Â Â Â 1693857644
By subtracting the counts at the first capture one gets:
Events Clock
0 Â Â Â Â 0
1000Â Â Â 21333
2000Â Â Â 42667
3000Â Â Â 64000
4000Â Â Â 85333
5000Â Â Â 106667
6000Â Â Â 128000
6999Â Â Â 149312
8000Â Â Â 170667
8999Â Â Â 191978
9999Â Â Â 213312
10999Â Â Â 234645
11999Â Â Â 255979
12999Â Â Â 277312
13999Â Â Â 298645
14999Â Â Â 319979
15999Â Â Â 341312
16999Â Â Â 362645
17999Â Â Â 383978
18999Â Â Â 405312
It is visible the clock count interval is not completely constant and
the mathematical method used should be able to deal with these interval
variations.
To calculate the ratio between the frequency of the events and the
frequency of the clock a linear regression is calculated where the event
capture is the X and the clock capture is the Y.
The slope of the linear regression is the ratio between the frequency of
the events and the frequency of the clock.
To calculate the phase between the clock and the events it is assumed
that the regression also provides the Y intersect for X is zero as the
fractional correction of the clock count at event count zero as the
capture happened synchronized with the event (and NOT with the clock)
This leads me to my questions:
1: Is using linear regression as described above a good method to
calculate the phase relation between events and clock? If not, what
method to use?
2: For highest accuracy of the calculation output, is it best the
captures are at (almost) regular intervals (as above) or is some form of
dithering of the interval better? And what form of dithering is best?
3: Assuming it is possible to have a large amount (1e+5) of captures per
measurement interval, are there other or additional methods to further
improve the accuracy?
More information about the Time-nuts_lists.febo.com
mailing list