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 7

Revert back to sending timestamp data to NTP on a 16 second interval
Ignore repeated NMEA data (happens ~5 times a day, causes the offset to spike to -1s)
Send STM32F4 clock data at 2HZ instead of 1HZ

Graphs

Histogram

This takes all samples within a 16 second window and graphs the number of samples within X µs of the mode and compares it with the count of offsets sent to NTP

There are significant peaks at -5µs, -10µs, -15µs, -20µs, as well as minor peaks at 5µs, 10µs, 15µs, and 20µs. I suspect the USB host only transfers data on a 200khz timer
Comparison between run 7 and run 8:
percentileRun 7Run 8
50%5 µs3 µs
90.0%20 µs19 µs
99.0%43 µs42 µs
99.9%53 µs51 µs
Run 8 and run 7 were very close

PC clock

Loopstats graph - local clock error (PPM, green) and USB/GPS offset (µs, red)

Overall conclusion

Doubling the timer transfer did not have a large impact, and more investigation is needed into the 5µs rounding

Future enhancements