I just realized that I didn’t fully understand a feature of the DW hardware. Although they talk about responding after a fixed delay, they don’t exactly do that.
The ranging process involves sending a packet on a round trip to a peer, which holds the packet for a fixed, and known period before sending it back to the sender.
The hardware will transmit the packet when a system counter reaches a specified value Ttx The counter is 40 bits long, and wraps every 17 seconds, so it increments a bit every ~16 picoseconds. The same kind of system counter is used to notice the arrival time, Trx, of the packet demanding the response. So you would think that Ttx =Trx + fixedDelay.
In fact they use Ttx = (Trx + fixedDelay) & 0xFFFFFFFE00 which potentially lops about 8ns off the arrival time. i.e. 2+ meters! Why do they do this, and why doesn’t it matter?
Here’s my theory. The actual time we want the packet to leave the antenna is going to be a little after the radio streams out the signals, because they have to crawl down to the antenna. So there is an antenna delay. So the radio needs to send the bits out a little early so they leave the antenna at the desired instant.
Now perhaps the chip can’t do carry-arithmetic, so they just make it easy to OR in the antenna delay. In any case the don’t bother unduly about getting the transmit time correct. All they need to ensure is that they have delayed long enough for the receiver to wake up and start listening.
Ttx = antennaDelayTime + (Trx + fixedDelay) & 0xFFFFFFFE00
Now I’m not sure if the actual transmit time stamp is simply computed and taken as fact, or if some analog magic causes the system counter to get copied at the critical moment. I suspect the former.
Adding in the antenna delay could produce a value that’s larger than 40 bits. But the system counter wraps at 40 bits, so the start time is masked at 40 bits too.
Ttx = (antennaDelayTime + (Trx + fixedDelay) & 0xFFFFFFFE00) & 0xFFFFFFFFFF
A potential snag with this mechanism is that something could slow up the host microprocessor from calculating the transmit time. If that takes so long that the transmit time passes then the game is over, and everything has to start over.