[time-nuts] Time stamping with a PICPET

Tom Van Baak tvb at LeapSecond.com
Sat Oct 26 04:37:20 EDT 2013


> What kind of accuracy do the picket's have.   You can log pulses using the
> PPS system on bare PC hardware and get the time of the pulse logged to
> within about 2 uSec.  Simply connect the pulse to DCD line of a real serial
> port.
> 
> If you need better than 2 uSec then yes you need external hardware.

The current version of picPET is 400 ns resolution given a 10 MHz clock. It was designed for applications needing millisecond- to microsecond-level accuracy. Not bad for a $1 8-pin chip.

> If those pickets are much better than 2 uSec then they make a GREAT front
> end for a NTP server.  Question: how do you transfer accurate time into the
> PIC?

They are a form of T2D or TDC (time to digital converter) or TSC (continuous time-stamping counter) for making zero-dead time measurements, not real-time clocks for the purpose of maintaining time of day, or day or year.

If all you need is a 1PPS source use a GPS timing receiver, or a GPSDO with 1 PPS output, or a 10 MHz external clock and a picDIV divider. See http://leapsecond.com/pic/ for many different dividers.

----

As far as NTP is concerned, I wonder if you've ever considered turning the tables on how it works. AFAIK, NTP gets an external time reference (e.g., 1PPS) as an interrupt. With modern computers, this is horrible. There are far too may layers of h/w jitter (pipelines, multiple levels of cache, TLB misses, etc.) and s/w jitter (interrupt handling, spinlocks, interrupt masking, priority levels, etc.).

For best timing, perhaps a better solution is not to have NTP receive a 1PPS as *input* and try to pretend to measure it internally in s/w but for NTP to *output* a 1PPS and measure that externally with sub-microsecond h/w (like a picPET).

That bypasses all the jitter associated with asynchronous events; replacing it instead with a synchronous event. If NTP takes an internal s/w timestamp before and after the pulse is output, and you obtain (via serial port) the timestamp reading made by external h/w you can then correct the NTP paper clock, with far less h/w and s/w jitter.

The mental shift is to stop treating a PC+NTP as a precise clock and pulse measurement instrument and start treating a PC+NTP as a precise clock and pulse generation instrument.

/tvb



More information about the time-nuts mailing list