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 3

The microcontroller now sends one byte over usb as the timing signal, and the timing information is sent on the next usb poll (1ms later). A small program on the PC takes 16 seconds of timing information and sends the median offset to ntpd via the shm driver.

Graphs

USB offset compared to NTP's calculation of clock offset

This compares NTP's local clock offset (from loopstats) to the GPS peerstats. At 1:30 GMT, the internet stratum 2 servers were removed from the NTP server's configuration.

Conclusion: the internet stratum 2 servers were skewing the clock (due to the asymmetric delay). The time from the USB connected clock is staying within 50µs when measured on the PC side

USB time quality

Just the variance of the USB connected clock:

Conclusion: the only data above 50µs is the restart at 1:30 GMT.

Cable Modem upstream latency

Theory: my home connection has 5ms more latency on its upstream than its downstream, on average. This will show up in NTP as a 2.5ms offset.

Conclusion: average is closer to 2ms off, so it might be closer to a 4ms skew or the stratum 2 ntp servers could be 500µs off.

Overall conclusion

This change lowered the window between the actual time and the PC's reception of it from 500µs wide to under 50µs wide. This accomplishes the original goal of 1ms accuracy

Future enhancements