90 lines
3.9 KiB
Markdown
90 lines
3.9 KiB
Markdown
# Timing Instrumentation
|
|
|
|
All values measured on the DUT with `esp_timer_get_time()` (monotonic
|
|
microseconds), from `captures/2026-09-01T10-34-24-hil` (1200 s run, 72
|
|
repeats, 214 RX candidates, repeat delay set to 200 ms).
|
|
|
|
## Measured
|
|
|
|
| Quantity | min | median | max | n |
|
|
|---|---|---|---|---|
|
|
| RxDone -> reconstructed end of frame ("deaf tail") | 9 360 us | 12 240 us | 17 120 us | 214 |
|
|
| TX airtime (SetTx to TxDone) | 10 421 us | 13 422 us | 14 560 us | 72 |
|
|
| Programmed repeat delay (frame end -> TX start) | 200 001 us | 200 001 us | 200 008 us | 72 |
|
|
| Repeated frame length (over-the-air bytes) | 63 | 100 | 113 | 72 |
|
|
|
|
Independent confirmation from the SDR side (raw IQ, same run): observed
|
|
burst duration differs from the computed airtime by 0.2-1.5 ms
|
|
(median 1.2 ms), and firmware TX events align to observed RF within
|
|
0-3.1 ms (median 2.4 ms).
|
|
|
|
## Derived
|
|
|
|
```
|
|
repeat delay accuracy : +1 us to +8 us against a 200 ms setting
|
|
(jitter well under 10 us)
|
|
RX deaf time per repeat : ~225.7 ms median
|
|
= 12.2 ms deaf tail
|
|
+ 200.0 ms programmed delay
|
|
+ 13.4 ms TX airtime
|
|
```
|
|
|
|
The programmed delay dominates by design; it exists to make SDR
|
|
correlation possible during development.
|
|
|
|
## The 12 ms deaf tail
|
|
|
|
The SX1262's GFSK packet engine cannot express Wireless M-Bus length
|
|
semantics (format A carries per-block CRCs that the L-field excludes), so
|
|
RX uses a fixed 255-byte capture and the firmware truncates in software
|
|
using the L-field formulas. Consequences:
|
|
|
|
- RxDone fires `(255 - frame_bytes) * 80 us` after the frame really ended;
|
|
the firmware subtracts this to recover the true end-of-frame timestamp,
|
|
which is what the repeat delay is measured from.
|
|
- During that tail the receiver is not re-armed for sync search, costing
|
|
9.4-17.1 ms of receive availability per detected frame -- including for
|
|
false syncs from the deliberately short 8-bit preamble detector.
|
|
|
|
Optimisation candidate (not implemented): poll `GetRxBufferStatus` after
|
|
`SyncWordValid`, read the L-field as soon as it lands, then stop RX early
|
|
once the computed frame length has been received. That would cut the tail
|
|
to roughly the frame's own airtime and materially raise the duty cycle of
|
|
a production repeater.
|
|
|
|
## Relevance to the production gateway
|
|
|
|
- A production repeater using randomized 5-25 s delays will have a very
|
|
different deaf-time profile; the 200 ms figure here is a development
|
|
artefact, not a design target (see docs/STANDARDS_GAPS.md).
|
|
- The fixed-255 tail is an SX1262 packet-engine limitation, so it applies
|
|
to any SX126x-based design. Budget for it, or implement early-stop RX.
|
|
- Repeat-delay accuracy of a few microseconds shows the ESP32-S3 side has
|
|
ample timing margin; timing precision will not be the constraint.
|
|
|
|
## Airtime measurement vs true channel occupancy
|
|
|
|
`tx_airtime_us` and the duty-cycle ledger both use wall time from `SetTx`
|
|
to the moment `TxDone` is observed. That interval includes SPI round-trips
|
|
and up to ~1 ms of polling granularity, so it over-states true channel
|
|
occupancy:
|
|
|
|
```
|
|
computed airtime, 102-byte payload : (102 * 80 us) + 640 us = 8.8 ms
|
|
measured SetTx -> TxDone observed : 13.4 ms median
|
|
```
|
|
|
|
Consequences, both deliberate:
|
|
|
|
- The reported duty cycle is conservative (over-counted by roughly 50 %),
|
|
so the 0.1 % guard suppresses slightly earlier than strictly required.
|
|
For a compliance guard, erring high is the safe direction.
|
|
- Independent confirmation that the real occupancy matches the computed
|
|
airtime comes from the SDR side, not the firmware: observed burst
|
|
durations in raw IQ differ from the computed airtime by 0.2-1.5 ms
|
|
(median 1.2 ms), i.e. the transmission itself is ~9-10 ms for a 100-byte
|
|
frame as expected.
|
|
|
|
A production implementation should budget on computed airtime and use the
|
|
measured value only for latency diagnostics.
|