Implementation of UWB indoor location and distance measurement based on TOF algorithm

. In order to achieve indoor positioning, based on the distance positioning algorithm is essential, it designs a company using DecaWave DW1000 chip and STM32 embedded control chip using the TOF algorithm and ranging system, indoor location in wireless sensor network. The whole system is divided into hardware and software. The hardware part includes anchor nodes and node labels, set up node using DW1000 chip and STM32 chip combination, the software using C language to write the STM32 location algorithm and control information controller, complete data acquisition, transmission and processing functions, in order to get the node label and the anchor node distance.


Introduction
At present, GPS (Global Positioning System) has become the necessary configuration of most hand-held intelligent devices such as mobile phones and tablet computers.The function of outdoor location using GPS or communication base station has been widely applied.The popularity of outdoor location technology makes people's travel and life more convenient.Even in a strange city, it is easy to find destinations without asking for directions.Now people are not satisfied to be able to enjoy the positioning service outside, and the demand for indoor positioning is more and more [1].However, due to the current mature positioning technology is mostly based on satellite or outdoor base station, once we enter the room, the signal is difficult to play a role after interference and diffraction.Therefore, indoor positioning research has broad space for development and application prospects.
At present, there are many indoor location technologies.The common location technologies are Wi-Fi positioning technology, Bluetooth positioning technology, Zig-Bee location technology, Ultra Wide Band, UWB location technology.In theory, the positioning accuracy of UWB positioning can be achieved in centimeter level or even higher [1].It has great potential in the application of accurate positioning.It is a hot spot in the research of wireless positioning technology.
This paper mainly discusses the location of indoor location using UWB signals.The location signal is based on ultra wide-band signal.It has the advantages of high location accuracy, low energy consumption, high reliability, anti-multipath capability and strong antijamming capability.It has been widely concerned in many fields such as wireless communication, location, radar imaging, and so on [2].

The overall structure of the system
With the continuous development of modern wireless technology, location information service has also been paid more and more attention.GPS can not play an outdoor effect in a closed environment, even inconveniences.Therefore, we need to design a set of location schemes suitable for indoor complex environment to overcome the typical problems such as multipath interference and non visual distance propagation, so as to achieve stable, delayed and low location performance system [9].
Wireless positioning system is a kind of software and hardware set that can provide information of objects, animals, personnel, or other things without the need of complex wired deployment.It can organize and transmit and process the location information organically, then locate the vast majority of things and instantly feed back their position coordinates [9].
The positioning system is composed of two parts: hardware system and software system.The hardware part is wireless sensor network based on UWB (IEEE802.15.4) protocol [5], including tag nodes (Tag) and anchor nodes (Anchor), as shown in Figure 1.The software part is STM32 embedded control program.The same hardware anchor nodes and node labels in the structural system, the difference lies in the software program is different from the anchor nodes according to a certain time interval transmit range frame tag node receives frame information will be calculated packet reception time ranging algorithm to estimate the tag node and the distance between the anchor node and display [3].Label node (Tag): the node to be measured; An anchor node (Anchor): a node with a known position.

Hardware design
Hardware is the running platform of software, and it is the basis of data communication.The upper limit of the system's [9] is determined by the performance of the designed hardware.The hardware part of the system includes the power module, the UWB radio frequency signal transceiver module, the crystal oscillator module and the STM32 control part, as shown in Figure 2.  The main parts of the normal operation and function of the system are usually composed of clock circuit, antenna circuit, reset circuit, power circuit and so on [9].Indoor distance measurement system is based on data acquisition and processing.The parameters related to location information are collected and transmitted on hardware, and the function is realized through software processing and display.Besides the pins and interfaces of the hardware layer, some devices also need to communicate with the computer through serial ports or network ports.Therefore, the correct hardware system is the premise to ensure the data to reach the host computer successfully.The lack of optimization of location algorithm only affects the effect of positioning, and the failure of hardware and software will lead to the failure of the system [9].

Ultra Wide-band Signal Transceiver Module
This system uses UWB signal to transmit, receive and handle the signal.In recent more than 10 years, due to the demand for precise positioning in many areas such as detection, navigation and tracking, target recognition, UWB positioning has become the forefront topic of concern.Now UWB positioning research is still developing [10].
The UWB RF transceiver module is the core module of the ranging function.The anchor nodes and tag nodes use the same hardware circuit to realize their respective functions by software [4].Between the anchor node and the label node, the distance between the nodes is calculated by the radio frequency signal and the TOF algorithm.
The wireless positioning chip DW1000 of the module is a radio frequency chip developed by DecaWave Company to use the UWB signal based on the IEEE.802.15.4 communication standard.The crystal frequency of DW1000 used in the module is 38.4 MHz, which can be directly supplied by the Temperature Compensated Crystal Oscillator (TCXO) directly through the XTAL1 pin.
The UWB technology based on integrated single chip wireless transceiver with IEEE802.15.4-2011 ultra wideband standard; 6 mm 6 mm 48 pin QFN package, small package and pin for rich with the implementation of cost-effective solutions and real-time positioning system in wireless sensor networks [9].It supports 6 frequency bands from 3.5GHz to 6.5GHz, supporting high data rate communication for 110 Kb/s, 850 Kb/s and 6.8 Mb/s.The chip uses coherent reception technology, which has good communication distance [9].The direct distance is up to 290 meters, and the non direct distance is 35 meters, which helps to reduce the system cost and the cost of deploying additional infrastructure.It is highly immune to multipath fading, and can be reliably communicated in high fading environment.In the indoor real-time location system, the location accuracy of mobile objects is 10 centimeters.Short packet communication can support the high density of the label, and can monitor up to 11000 targets within the range of 20m [4].
DW1000 normal working voltage is 3.3 V, part of the on-chip resources directly from the external 3.3 V power supply, part of the resources required by the on-chip LDO buck to 1.8 V power supply, the LDO required by the relevant pin external decoupling capacitors, such as VDDDIG, VDDREG, VDDIF, VDDMS, VDDVCO, VDDCLK, VDDSYN through the 0.1 capacitor decoupling F grounding [1].
DW1000 has 8 GPIO and can be configured as a second function.This system is not used for other purposes and is connected to the terminal, as a standby.SPICSn, SPICLK, SPIMOSI, SPIMISO are connected to the pins corresponding to the SPI module in the master chip Stm32f103rct6 as the communication interface between the DW1000 and Stm32f103rct6.

Main Control Chip
DW1000 chip is a chip developed by DecaWave for indoor positioning, which is designed according to the IEEE802.15.4-2011 ultra wideband standard.According to the chip data manual, the minimum error should be within 10 centimeters.The farthest distance of DW1000 is 450 meters (straight distance, non straight distance is 45 meters) [1].The chip has low power consumption and can be used for two-way ranging and positioning.It can be used as a supplement to the technology RFID and Wi-Fi for the current indoor positioning (and the underground positioning also can be used).
Comprehensive performance and cost considerations, selection of the STMicroelectronics production of a Cortex.M3 core 32 bit enhanced ARM microprocessor based on STM32F103RCT6 as the core processor in the wireless location system, the main frequency of the chip microprocessor 72MHz, with 48K SRAM and 256K FLASH storage space, three 16 bit timer 2 basic timer, respectively.4 and 2 senior general timer, universal IO port up to 51, the communication interface is rich, there are 3 SPI, 2 IIC, 1 SDIO, 5 serial interface, 1 USB and 1 CAN, other resources include 2 DMA controller, 3 12bit ADC and 1 12-bit DAC.The microprocessor has powerful functions, low price, and the working voltage is between 2 and 3.6V.It has various power saving modes, which ensures low power consumption.The working environment temperature is -40℃~+80℃, which shows that it can run steadily during the cold winter season.In addition, in the application of the chip for development test, the JINK debugger can be used to make the simulation experiment very convenient [11].
At present, the single-chip market price is very low, cheaper than many other similar ARM, DSP and other similar chip, but it is very powerful, and can fully meet the requirements of the work, even if they wanted to upgrade, from the current point of view, but also to meet the needs.Has rich peripheral interface, large storage space, which makes the MCU has powerful expansion and storage capabilities, in addition to the microcontroller using the Cortex.M3 kernel, the Cortex.M3 kernel microcontroller without using ARM code and Thumb code conversion problems, using the Thumb.2command.
The instruction set, the higher efficiency and better performance; due to the adoption of the Cortex.M3 kernel and Cortex.M3 kernel optimized power design, which makes the power consumption is relatively low; the single-chip is the mainstream product of STMicroelectronics, currently on the market there have been many developers using the MCU, so this microcontroller there are a lot of data available, which greatly saves the development cost.
The STM32 main control part configures and manages the DW1000 module through the SPI bus and data communication.The test point also needs to pack the distance data and then communicate with the location server.The location server determines the final location of the mobile node through the geometric algorithm [4].

Program framework and algorithm design
An indoor wireless positioning system not only has hardware, but also software, otherwise it is impossible to run.Both are equally important and indispensable.The hardware platform of indoor wireless positioning has been completed.In order to make the system function, we need to build the corresponding software platform.

Program framework
As shown in Figure 3, the software framework of the system is divided into 3 layers: the user application layer, the DWM API business layer, and the device driver layer.In which DecaWare implements the DWM API business layer and the driver layer code.The driver layer controls its operation through the SPI interface of DM1000.In the driver layer, the interface functions writetospi () and readfromspi () are used to access the hardware.These two functions need user's own realization according to different master chips and their configuration [6].

Ranging Algorithm
This paper adopts the TOF ranging algorithm, which is a two-way ranging technology.It mainly uses the time of flight between the two asynchronous transceivers (Transceiver) to measure the distance between nodes.TOF ranging technology is Time of Flight Measurement.The traditional ranging technology is divided into two way ranging technology (Two Way Ranging) and one way ranging technology (One Way Ranging) [8].This paper uses one-way ranging technology.This technology does not require synchronization between anchor nodes and tags, and is easy to implement.Figure 4 below is a detailed process of ranging.(1) The distance between the two points is:  =  × . (2)

Signal transmission and reception
UWB communication is mainly based on the transmission and reception of message frames.The IEEE 802.15.4 standard provides a general message format for data frames.Figure 5 shows the general structure of the ultra wideband communication frame.The first half of it is a synchronous head composed of the preamble code and the SFD, and then defines the physical head of the payload part length and the data rate of the communication frame data.The message frame sent by the base station includes a field that receives the timestamp [9].The microprocessor in the base station processes the data in advance and writes the data to the message buffer before the message frame is sent to the main base station.
In order to smooth the transmission signal, the main controller must be transfer data to the register file (0x09: send buffer), to a pre selected preamble length, data transmission rate and the pulse repetition frequency is to write to the register file (0x08: transmission frame control), transmitter configuration in the idle state, but the communication frame the configuration can be carried out in the process of sending [4].
If all the other related configurations have been completed, the master controller will start sending by setting the TXSTRT control bits in the register file (0x0D: system control register).When the send command arrives, DW1000 automatically sends the frame of the complete frame: preamble, SFD, PHR, and data.
FCS (CRC) will be automatically attached to the communication frame as a design of the physical layer.
The communication frame at the end of the transmission through the register file (0x0F: system event status register) send signal TXFRS event state orientation control, finally by DW1000 back to idle, waiting for a new command.
The reception of a signal frame is completed by an automatic reboot of the host request or the receiver.The receiving opportunity keeps the search for the preamble until the preamble is detected or obtained and then ready to start demodulation.When the receiver searches for the preamble timeout, or when the preamble is not detected in a certain time, the receiving opportunity stops receiving a period of time to work again.

Summary
Because of its great signal bandwidth and good time resolution, UWB technology has highlighted its advantages in positioning applications.This paper discuss the design of ranging in ideal indoor environment, introduces the hardware structure and software architecture of the system, and through the analysis of algorithms and formulas show that the ranging process of this system detailed.The system realizes the function of distance measurement.Because

Figure 1 .
Figure 1.Overall map of the positioning system

Figure 3 .
Figure 3. Software framework diagram The software used in the development of STM32 main control chip is the KEIL uVision5 development environment.KEIL uVision5 is launched by KEIL in October 2013, mainly for uVision5 IDE integrated development tools, mainly for ARM processors, especially ARM Cortex M as the core processor.KEIL uVision5 can be compatible with KeiluVision4, and on the basis of KEIL uVision4, it strengthens the support for the development of Cortex.M microcontroller, and divides the traditional development mode and interface into two parts: MDK Core and Software Packs.The MDK Core contains the microcontroller development of all components all have, editor, IDE (uVision5), u-Vision ARM C / C++ tracker, commissioning editor and Pack-Installer, Software Packs can complete support for the new chip and Middle Library without tool chain case upgrade.

Figure 4 .
Figure 4. Single side two-way ranging processDetailed explanation for tag sends a poll to the target anchor node, and marks the sending time Tsp, and then enters the state of response message starting to listen to anchor.If there is no news for a period of time, then tag will timeout and send poll message again.Anchor listens the address for its own poll message, if it gets the message, it marks the receiving time Trp, and sends response message to tag, at the same time, marks the sending time Tsr.Tag receives the respond message, marks the receiving time Trr, then packages Tsp, Trr and Tsf into a frame final message to send to anchor, where Tsf sends the time for the message, and Trf receives the time for the message (dw1000 special function).The single side flight time is: TOF = {(Trr − Tsp) − (Tsr − Trp)(Trf − Tsr) − (Tsf − Trr)} ÷ 4(1) The distance between the two points is:  =  × .(2)

Figure 5 .
Figure 5. Frame structure diagram of communication frame