STM32F4 time experiments

other runs

Goal

1ms or better accuracy on a USB-connected GPS.

Hardware

stm32f4 discovery board using a 10.5mhz internal timer is measuring the PPS interval from a Fastrax UP501 GPS reciever (claims "+/- 50 ns (RMS) accuracy"). The stm32f4 is connected via full-speed usb to a pc

Software

See: usb gps

Changes from Run 4

GPS NMEA data changed to be go through the STM32, userland process switched to run as realtime SCHED_RR

Graphs

USB offset compared to NTP's calculation of clock offset

This compares NTP's local clock error (from loopstats) to the GPS peerstats.

You can see the effect of the daily AC schedule changing the temperature in the local clock error pattern repeating. There are four settings in the daily AC schedule.

STM32's timer

This shows the interval between PPS samples as measured by the 10.5mhz timer on the microcontroller

This shows the timer has an error of between 73ppm - 78ppm.
There is a daily repeating pattern, which is also probably driven by temperature.
The ~15hz ringing is probably due to the timer's source, a PLL driven by an 8mhz external crystal.

clock variance

NTP's measurement of variance of the GPS clock:

The vast majority of samples were under 30µs variance.

Time Min/Max

The pulse per second offsets compared to the PC's clock are collected over 16 seconds and the min and max values are graphed. Userland process was switched to realtime at 15:00

"HS SOF" - USB highspeed start of frame time is shown as a scale reference.
The min offset extending far below -100µs shows the process isn't always scheduled on time

Time offset range

This is the difference between max and min offsets is graphed to show the (in)stability of the clock data

"HS SOF" - USB highspeed start of frame time is shown as a scale reference
The average difference between min and max is under 100µs.

Histogram

This takes all samples within a 16 second window and graphs the number of samples within X µs of the mode

Some stats: 55.0% of samples +/- 10 µs of mean, 90.4% of samples +/- 40 µs of mean, 99.0% of samples +/- 153 µs of mean, 99.9% of samples +/- 922 µs of mean

Overall conclusion

This change lowered NTP's window between the actual time and the PC's reception of it from 50µs wide to under 30µs wide.

Future enhancements