APS013 DW1000 and two way ranging
APS013 DW1000 and two way ranging
Version 2.4
TABLE OF CONTENTS
LIST OF TABLES ................................................................................................................................................2
LIST OF FIGURES...............................................................................................................................................2
1 INTRODUCTION ........................................................................................................................................3
1.1 DW1000 BASED TWR ................................................................................................................................ 3
2 IMPLEMENTATION OF RANGING ..............................................................................................................5
2.1 DISCOVERY PHASE ........................................................................................................................................ 5
2.2 RANGING PHASE .......................................................................................................................................... 5
2.3 MESSAGES USED IN RANGING ......................................................................................................................... 6
2.3.1 General ranging frame format ........................................................................................................ 6
2.3.2 Blink frame format .......................................................................................................................... 8
2.3.3 Poll message ................................................................................................................................... 8
2.3.4 Response message .......................................................................................................................... 8
2.3.5 Final message ................................................................................................................................. 8
2.3.6 Ranging Initiation message ............................................................................................................ 9
2.4 TWR OPTIMISATION FOR POWER CONSUMPTION ............................................................................................... 9
2.4.1 Discovery phase .............................................................................................................................. 9
2.4.2 Ranging phase .............................................................................................................................. 11
3 CONCLUSION .......................................................................................................................................... 13
4 REFERENCES ........................................................................................................................................... 13
5 DOCUMENT HISTORY ............................................................................................................................. 13
6 MAJOR CHANGES ................................................................................................................................... 13
7 FURTHER INFORMATION ........................................................................................................................ 15
LIST OF TABLES
LIST OF FIGURES
1 INTRODUCTION
In this application note two-way ranging (TWR) scheme as used by Decawave’s example application
(DecaRanging) is described. TWR is a basic concept to calculate the distance between two objects by
determining the time of flight (TOF) of signals travelling between them.
The distance between the objects may be calculated using the formula,
The DW1000 uses mathematical and electronic techniques to implement a very precise clock. By
recording the state of this clock when certain events occur during DW1000 transmission and
reception of the radio wave signals, the DW1000 has the ability to ‘timestamp’ those events.
TWR has advantages over other distance measurement and locating systems in that it can be used
by stand-alone devices which only have relative distances to measure. There is no requirement for an
infrastructure of fixed communicating devices to determine separation distances.
The initiator transmits a radio message to the responder and records its time of transmission (transmit
timestamp) t1. The responder receives the message and transmits a response (a radio message)
back to the initiator after a particular delay treply. The initiator then receives this response and records
a receive timestamp t2. This process is depicted in Figure 1.
Now using the timestamps t1 and t2, the initiator can calculate the round trip time troundtrip and knowing
the reply time in the tag, treply, the TOF can be determined by,
𝑡2 − 𝑡1 − 𝑡𝑟𝑒𝑝𝑙𝑦
𝑇𝑂𝐹 =
2
If we assume the speed of radio waves through air is the same as the speed of light c, then the
𝑡2 − 𝑡1 − 𝑡𝑟𝑒𝑝𝑙𝑦
𝐷𝑖𝑠𝑡𝑎𝑛𝑐𝑒 = 𝑐 ×
2
In the case of tag-to-anchor two-way ranging, there are a number of sources of error due to clock drift
and frequency drift [4]. Asymmetric double sided TWR method is used in Decawave’s implementation.
It reduces the error due to clock and frequency drift. Figure 2 shows a Poll-Response-Final method of
doing TWR and it also shows the formula used for calculation of TOF.
Tround1 Treply2
Initiator time
Poll Resp Final
TX RX TX
RMARKER
Tprop Tprop Tprop
Responder
Poll Resp Final
RX TX RX
Treply1 Tround2
The Final message communicates the initiator’s Tround and Treply
times to the responder, which calculates the range to the
initiator as follows:
2 IMPLEMENTATION OF RANGING
In Decawave’s two-way ranging demo, two units operate as a pair. One unit acts as a “Tag” initiating
the ranging exchange and the other unit acts as an “Anchor” listening for the tag messages and
performing two-way ranging exchanges with it. This is shown in Figure 3 below.
Idle
Idle
For clarity, this optional message is not shown in the remainder of this document.
The general message format, shown at the top of Figure 4, is the IEEE 802.15.4 standard encoding
for a data frame. The two byte Frame Control octets vary between the messages as some use 8-octet
(64-bit) addresses and others 2-octet (16-bit) addresses. A single 16-bit PAN ID (value 0xDECA) is
used for all the messages. The only exception is the Blink message which is described in 2.3.2 below.
In a real deployment, the PAN ID might be negotiated as part of associating with the network or it
might be an installation configured constant. The blink message follows the format defined in clause
5.2.2.7 Multipurpose blink frame of the IEEE Std 802.15.4e™-2012 (Amendment to IEEE Std
802.15.4™-2011).
The sequence number octet is incremented modulo-256 for every frame sent, as per IEEE rules. The
source and destination addresses are either 64-bit numbers programmed uniquely into each unit
(during manufacture) or 16-bit addresses temporarily assigned. The 2-octet FCS is a CRC frame
check sequence following the IEEE standard, (this can be generated automatically by the DW1000 IC
and appended to the transmitted message).
The content of the ranging message portion of the frame, (the “Variable # octets” part of the Poll,
Response, Final and Report message shown above in Figure 4), defines which of the four ranging
messages it is. We will also refer to this section of the message as the "application level payload ".
These are shown in Figure 5 and described in sections 2.3.3 to 2.3.6 below. In these, only the
ranging message portion of the frame is shown and discussed. This data is encapsulated in the
general ranging frame format of Figure 4 to form the complete ranging message in each case.
0x20 - -
0x61 0x50 -
0x69 - -
The Blink message frame format is used for sending of the tag Blink messages. The Blink frame is
sent without any additional application level payload, i.e. the application data field of the blink frame is
zero length. The result is a 12-octet blink frame. The encoding of this minimal blink is as shown in
Figure 4.
The Poll message is sent by the tag to initiate a single range measurement. For the poll message,
the ranging message portion of the frame is a single octet, with the value: 0x61.
The Response message is sent by the anchor in response to a poll message from the tag. The
Response message is 5 octets in length. Table 1 lists and describes the individual fields within the
Response message.
The Final message is sent by the tag after receiving the anchor’s response message. The Final
message is 9 octets in length.
Table 2 lists and describes the individual fields within the Final message.
Note 1: The time units used are those defined in the IEEE standard and native to the DW1000, where
the LSB represents 1/128 of the fundamental UWB frequency (499.2 MHz), or approximately 15.65
picoseconds.
Upon receiving the Blink message the unpaired anchor will send the Ranging Init message to the tag
that has sent the Blink message.
The Ranging Initiation message is 5 octets in length. Table 3 lists and describes the individual fields
within the Ranging Initiation message.
To optimise power usage, while in this phase, the receiver on-time needs to be minimised. As the
Ranging Init message is sent after a particular delay (shown in Figure 6), the tag should only turn on
its receiver after this delay, and employ a receive timeout, to turn off the receiver if the ranging
initiation frame does not arrive.
Figure 6 shows the time the tag spends in each of the states for the case when the anchor is using an
800 µs response time for the Ranging Init message.
Note: The absolute minimum response time that can be achieved would be around 200 µs, this is
microprocessor dependent, it depends how quickly the microprocessor can see the completion of
reception and start the transmission. However in the example in Figure 6, an 800 µs delayed
response time is used. This is because when the “Smart Tx Power” option is enabled for the 6.81
Mbps data rate, only 1 frame can be transmitted in 1 ms in order comply with ETSI and FCC
regulations on TX power.
Receiver
timeout
1s
Tx Rx Tx
Tx preamble Tx preamble
data data data
Prepare &
schedule
delayed Turn on
Process “Range Init” Rx and Process
Listen for
received
Anchor “Blink” received frame listen for
“Poll”
“Blink” transmission “Poll”
Rx Tx
Rx preamble Tx preamble
data data
Blink
Range Init
Poll
To save power, in this phase, the tag needs to complete these operations as quickly as possible, and
then return to low power mode (Sleep state).
In this example, to reduce the transmission, and reception times, a preamble length of 128 is used
together with shortened ranging messages (section 2.3 describes the message formats), and the
highest data rate of 6.81 Mbps. As a result of using this configuration the total frame transmission
time is about 180 µs, and the reception time is about 215 µs. The reception time is longer because of
a 16 µs receiver start-up delay, and due to the execution time of the leading edge detection search
that is part of our receive time-stamping and takes up to 60 µs after SFD detection.
To reduce the time spent in the idle state, the duration of SPI transactions also need to be minimised.
This is limited by the microcontroller’s SPI peripheral abilities. As DW1000 supports SPI speeds of up
to 20 MHz the microcontroller should be configured to run at 20 MHz if possible (We have used an
STM32 device which is limited to 18 MHz). Measures should be taken to send all the bytes of an
individual SPI transaction back-to-back without any dead time between them (e.g. by employing DMA
on the host processor if possible). As well as the physical speed of SPI operations the application also
needs to make sure that the number of SPI read and write operations are minimised (i.e. only read /
write the necessary registers for the required operation).
The short response times mean that 32-bit timestamp arithmetic can be used, i.e. since 232 divided by
the LSB of timestamps (128 x 499.2 MHz) is 67.2 ms. This further minimises the processor execution
time and saves power.
Note: The absolute minimum response time that can be achieved would be around 200 µs, this is
microprocessor dependent, it depends how quickly the microprocessor can see the completion of
reception and start the transmission. The anchor will respond immediately, but the tag will only send
the Final 1 ms after the transmission of the Poll. This is because when the smart tx power option is
enabled for a 6.81 Mbps data rate, only 1 frame can be transmitted in 1 ms to meet the ETSI / FCC
regulations on transmitted power.
All times shown in Figure 7 are in microseconds (µs) unless otherwise stated.
Tx Rx Tx Tx
Tx preamble Tx preamble Tx preamble
data data data data
delayed response time = 580 us
Prepare &
schedule
Turn on delayed Turn on
Rx and Process “Response” Rx and Process received Process
Anchor listen for received frame listen for “Final” and received
“Poll” “Poll” transmission “Final” calculate ToF “Poll”
Rx Tx
Rx preamble
data
Tx preamble
data Poll
Final
3 CONCLUSION
This application note has given an overview of two way ranging as it is implemented by Decawave in
its DecaRanging application. We have also outlined optimisations that can be applied to minimise
power consumption for a battery powered device.
4 REFERENCES
Reference is made to the following documents in the course of this application note: -
5 DOCUMENT HISTORY
Table 5: Document History
6 MAJOR CHANGES
Revision 1.0
Revision 1.1
Revision 2.0
Revision 2.1
Revision 2.2
Revision 2.3
Revision 2.4
7 FURTHER INFORMATION
Decawave develops semiconductors solutions, software, modules, reference designs - that enable
real-time, ultra-accurate, ultra-reliable local area micro-location services. Decawave’s technology
enables an entirely new class of easy to implement, highly secure, intelligent location functionality and
services for IoT and smart consumer products and applications.
For further information on this or any other Decawave product, please refer to our website
www.decawave.com.