Add $PMTXTS PPS timestamping (opt-in host timing telemetry)#5
Draft
peterlewis wants to merge 1 commit into
Draft
Add $PMTXTS PPS timestamping (opt-in host timing telemetry)#5peterlewis wants to merge 1 commit into
peterlewis wants to merge 1 commit into
Conversation
With `pps = on` in config.txt, emit one proprietary NMEA sentence per PPS edge over the existing CDC stream, carrying the sub-second phase captured at the edge plus calibration / holdover / die-temperature telemetry. Time-critical fields are snapshotted in the PPS ISR; formatting and CDC submission happen in the main loop, serialised against the NMEA passthrough. With no enumerated host the record is dropped before any formatting. mk4-time/Core/Src/main.c: capturePPS(), emitPPSTimestamp(), measure_temp(), a `pps` config key and one main-loop hook. qspi/config.txt documents the key. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4f901ab to
02671b2
Compare
This was referenced Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. One feature for the Mk IV: opt-in per-PPS host timestamping, found while building a host companion. Source-only —
mk4-time/Core/Src/main.cand one documentedconfig.txtkey. Built and flashed on an STM32L476 time board and left running; it stays a draft because theqspi/output/*.binrelease images still need rebuilding from the diff (see To do).The two unrelated firmware fixes this branch used to carry — the charger-power hard-fault and the date-board text OOB — have moved to the hardening PR (#7), so this one is just the feature.
$PMTXTSper-PPS host timestamping (opt-in)The clock disciplines to the PPS edge to sub-µs, but a host over CDC only ever sees NMEA, which arrives a few hundred ms after the second and is smeared by USB framing — so there is no host-visible timing-stability metric. (The stale
cdc-ppsbranch approached this by toggling the CDC DCD line, which is capped at the ~1 ms USB framing floor.)With
pps = oninconfig.txt, one proprietary sentence per PPS edge over the existing CDC stream:seqepochcurrentTimeat the edge (Unix s, UTC)subms/systick/loadcalerrcalibrateRTC()already computes → ppmsincecaltempflagsdata_valid/had_pps/rtc_goodTime-critical fields are snapshotted in the PPS ISR (a handful of register reads); the sentence is
snprintf-formatted and submitted to CDC from the main loop, never the ISR, serialised against the existing NMEA passthrough. With no enumerated host the record is dropped before any formatting, so the feature costs nothing when nobody is listening. The host's arrival time is USB-jittery, but the measurement is captured in firmware at the edge and carried in the payload, so transport jitter does not corrupt it. Absolute offset to UTC is not recoverable over USB — a host derives jitter, stability and drift, not absolute offset.mk4-time/Core/Src/main.c:capturePPS(),emitPPSTimestamp(),measure_temp(), theppskey, one main-loop hook.Temperature
The die-temperature field made it cheap to characterise the oscillators against temperature on the unit. The 10 MHz HSE — which holds time through a running GPS-loss holdover — measured flat, ≈ 0.011 ppm/°C (R² ≈ 0.37) over a ~6 °C sweep, i.e. running-holdover drift from temperature is sub-millisecond over any realistic outage, so no compensation is included. The 32 kHz LSE has a real tempco but it only bites across power-loss recovery, where the MCU is off and cannot compensate. The die-temp telemetry is kept because it is useful and proven; the steering code is not. (The sweep is narrow — see To do.)
Data (STM32L476 time board, GPS-locked)
$PMTXTSstreams at 1 Hz interleaved with NMEA; checksums valid;seqcontiguoussystick85 ± 2 counts)flags = 7)To do
Before this leaves draft:
qspi/output/*.binrelease images from the source diff. The diff is source-only; the committed binaries are unchanged and would need regenerating to match.calerrandsincecalgive a live time-uncertainty, so the display can show only the digits it can still stand behind, degrading like an analogue needle.