DS_TWR: Can the initiator obtain distance information?

Hi everyone,
I followed the DW3XXX_API and implemented the ds twr example. I don’t see any code in the initiator that calculates distance. Can the initiator obtain distance information? Or maybe I misunderstood the meaning of double side. Does it refer to one more data transfer? Thanks.
Ken.

Single sided TWR is:

  1. A sends to B.
  2. B replies after a fixed time.
  3. A calculates distance as speed of light*(receive time - transmit time - fixed delay) / 2

So the initiator knows the distance but that fixed delay is based on device Bs clock and measured on device As clock. Which means device A needs to make an estimate of the difference between it’s clock and the other devices clock and correct for that.

Double sided TWR is:

  1. A sends to B.
  2. B replies to A after a fixed time.
  3. A replies to B after a fixed time.

At this point both sides have transmitted a packet and then received a reply that was sent a after a fixed delay. One of those delays was set on device B and measures on device A. The other was set on device A and measured on device B. This means that the errors due to clock difference in the two measurements will be equal and opposite, they cancel out. If we calculate the average of the two results we don’t need to worry about measuring clock errors.

However this requires that the device doing the calculation needs to know the results from both sets of range measurements. As part of step 3. Device A can include its results in the message sent to B so at the end of that stage B knows everything needed to calculate a range.
But the initiator (device A) can’t possibly know the full results at that point, the only way the initiator can gain all the information required to calculate a DS-TWR result is if device B sends its results back in some way.

Which is a long way of saying that for the initiator to know the range using DS-TWR you need 4 packets. With only 3 the responder can calculate the DS-TWR but the initiator only has enough information for a SS-TWR.

1 Like

Hi AndyA,
Thanks for your help. So I can’t let the initiator obtain the distance data with original source code of DS_TWR. Am I correct?
Regards,
Ken.

I’ve not checked that specific code but if it only uses 3 packets then you are correct. You need a second packet from the responder back to the initiator if you want to calculate the range there.

One thing you can do if you are measuring the range between the same devices multiple times is modify the second packet (responders initial response to the initiator) to include the results from the previous DS-TWR. This removes the need for a separate results only 4th packet but is only practical in certain situations.