• No results found

Evaluation of Bluetooth 5.1 as an Indoor Positioning System

N/A
N/A
Protected

Academic year: 2021

Share "Evaluation of Bluetooth 5.1 as an Indoor Positioning System"

Copied!
112
0
0

Loading.... (view fulltext now)

Full text

(1)

, STOCKHOLM SWEDEN 2020

Evaluation of Bluetooth 5.1

as an Indoor Positioning

System

PHILIP ANDERSSON

LINUS PERSSON

KTH ROYAL INSTITUTE OF TECHNOLOGY

(2)

Authors

Philip Andersson | phande@kth.se Linus Persson | linusper@kth.se Engineering Design

KTH Royal Institute of Technology

Place for Project

Knightec

Stockholm, Sweden

Examiner

Dejiu Chen

KTH Royal Institute of Technology

Supervisor

Masoumeh Parseh

KTH Royal Institute of Technology

Industrial Supervisor

Feras Faez Elias Rizwan Mahsud Knightec

(3)

Evaluation of Bluetooth 5.1 as an Indoor Positioning System

Philip Andersson Linus Persson Approved 2020-09-01 Examiner Dejiu Chen Supervisor Masoumeh Parseh Commissioner Knightec Contact person Lars Westling

Abstract

There is a high demand for Indoor Positioning Systems (IPS) due to the wide

application possibilities. The main issue for localization by wireless signals in an indoor environment is the multipath propagation problem. Multipath propagation occurs when signals reflects and refract from an object, changing the signals characteristics. Today there is no IPS that can balance the cost, accuracy, and complexity.

In January 2019 Bluetooth released a new standard, Bluetooth Low Energy (BLE) 5.1, which enables the ability to measure the Angle of Arrival (AoA) of an incoming signal. The purpose of this thesis is to mitigate the disturbances caused by multipath

propagation by conducting a case study. This was done by designing systems that

combine different positioning techniques with sensor fusion and evaluating them based on power efficiency, execution time and precision. Two wireless localization techniques were evaluated, trilateration and triangulation, which are based on Received Signal Strength Indication (RSSI) and AoA respectively, along with an Inertial Measurement Unit (IMU). An Extended Kalman Filter EKF was used to fuse the sensor data.

The system with the best overall performance uses the AoA signals and a multipath mitigation technique. The system with AoA and IMU had a similar performance but has an overall higher complexity due to the added IMU component. The RSSI system could not satisfy the requirement of precision.

Keywords:

Indoor Positioning System, AoA, RSSI, IMU, Sensor Fusion, Multipath Propagation

(4)
(5)

Examensarbete TRITA-ITM-EX 2020:529

Utvärdering av Bluetooth 5.1 som ett Inomhus Lokaliserings System

Philip Andersson Linus Persson Godkänt 2020-09-01 Examinator Dejiu Chen Handledare Masoumeh Parseh Uppdragsgivare Knightec Kontaktperson Lars Westling

Sammanfattning

Det finns en stor efterfrågan på inomhus positionssystem (IPS) tack vare de många möjliga tillämpningarna. Det största problemet för inomhuslokalisering med trådlösa signaler i inomhusmiljö är flervägsutbredningsproblemet. Felvägsutbredning inträffar när signaler reflekterar och bryts på ett objekt, och ändrar dess karaktär. Idag finns det inga IPS som kan balansera kostnaden, noggrannhet och komplexitet.

I januari 2019, släppte Bluetooth en ny standard, Bluetooth Low Energy (BLE) 5.1, som gör det möjligt att mäta ankomstvinkeln (AoA) för en inkommande signal.

Syftet med denna avhandling är att minska störningarna orsakade av

flervägsutbredning genom att utföra en fallstudie. Detta gjordes genom att designa system som kombinerar olika positioneringstekniker med sensor fusion och utvärdera dessa med avseende på energieffektivitet, exekveringstid och precision. Två trådlösa lokaliseringstekniker utvärderades, trilaterering och triangulering, som är baserade på mottagen signalstyrka indikation RSSI och AoA respektive, tillsammans med en

tröghetssensor (IMU). Ett Utökat Kalman-Filter (EKF) användes för att kombinera data.

Systemet med den överlag bästa prestandan använder AoA-signaler och en teknik för att dämpa flervägsutredningen. Systemet med AoA och IMU hade liknande prestanda men den totala komplexiteten ökade med att lägga till en IMU komponent. RSSI systemet var inte tillräckligt tillfredsställande med avseende på precisionskraven.

Nyckelord:

Inomhus positioneringssystem, AoA, RSSI, IMU, Sensor Fusion, Flervägsutbredning

(6)
(7)

We would like to thank Knightec for giving us the opportunity to write our thesis at their office and provided us with the equipment we needed, and especially our industrial supervisors Rizvan Mahsud for his inputs and Feras Faez Elias for his encouragement. We would like to thank our academic supervisor Masoumeh Parseh for her input regarding our research.

We would also like to thank Staffan Qvarnström for taking his time for a honest try to rotate the small capacitors on our microcontrollers, and to Jan på Frikab Produktion AB who did rotate them at free of charge. We could not have done it ourselves. Thanks to Täby Racketcenter who let us use their sports hall for several hours to take our measurements.

And at last, we would like to thank all our friends we met at KTH, for all the energy and memory we got and made our time at KTH bearable.

(8)
(9)

1.1 Illustration of trilateration. . . 2

1.2 Illustration of AoA and triangulation. . . 2

1.3 Illustration of how an IMU operates. [9] . . . 3

1.4 Illustration of multipath propagation. . . 4

2.1 Illustration of the GATT structure. . . 11

2.2 Illustration of trilateration, where. . . 12

2.3 Illustration of triangulation. . . 14

2.4 ULA . . . 15

2.5 IQ samples . . . 16

2.6 Simple schematic over a current sensor with high and low side. . . 19

2.7 Illustration of multipath propagation. . . 20

2.8 SPI Overview. . . 24

2.9 SPI timing diagram. [48] . . . 24

2.10 I2C timing diagram. [49] . . . . 25

3.1 Picture of the LAUNCHXL-CC2640R2F development kit. [51] . . . 28

3.2 Final configuration of capacitor. [52] . . . 28

3.3 Angle coverage of the BOOSTXL-AOA Antenna [52] . . . 29

3.4 Block Scheme of the BOOSTXL-AOA Antenna [52] . . . 29

3.5 The slave and the IMU. . . 30

3.6 How the USB cable was cut and the current was measured. The green and blue wires are the UART transmission lines. . . 31

3.7 The setup of nodes and PC. [18] . . . 32

3.8 Illustration of configuration 1. . . 33

3.9 Illustration of configuration 2. . . 34

(10)

3.11 An illustration of the trilateration approach. . . 37

3.12 Timing diagram of the IMU transmission. [53] . . . 38

3.13 An illustration of the AoA Only system. . . 42

3.14 A flow chart of the AoA compensation system. . . 43

3.15 A flow chart of the AoA fused with the IMU. . . 44

3.16 Ideal case measurement. . . 45

3.17 Tinfoil coated cardboard boxes. . . 46

4.1 The x and y position over a 5 minute interval. . . 48

4.2 Histogram with standard deviation for the estimated x and y position. . 48

4.3 The x and y position over a 5 minute interval. . . 49

4.4 Histogram with standard deviation for the estimated x and y position. . 50

4.5 The x and y position over a 5 minute interval. . . 50

4.6 Histogram with standard deviation for the estimated x and y position. . 51

4.7 The x and y position over a 5 minute interval. . . 51

4.8 Histogram with standard deviation for the estimated x and y position. 52 4.9 The x and y position over a 5 minute interval. This is the AoA only system. 53 4.10 Histogram of the measured data for the AoA only system. . . 53

4.11 The x and y position over a 5 minute interval with the AoA with multipath compensation system. . . 54

4.12 Histogram of the measured data for the AoA with multipath compensation system. . . 55

4.13 The x and y position over a 5 minute interval with the AoA with IMU system. . . 55

4.14 Histogram of the measured data for the AoA with IMU system. . . 56

4.15 The x and y position over a 5 minute interval for the AoA only system. . 57

4.16 The x and y position over a 5 minute interval with the AoA with multipath handling system. . . 57

4.17 The x and y position over a 5 minute interval with the AoA with IMU system. . . 58

4.18 The current consumption over 60 second interval. The increase for the passive devices in the beginning is when they start to process and sample the AoA data. . . 59 4.19 Estimated position with RSSI in the sports hall. The real position of the

(11)

4.20 Estimated position with RSSI in office environment. The area the trilateration approach has estimated is very large. . . 60

(12)
(13)

4.1 Test design to force multipath propagation with the cardboard boxes 40cm next to the antennas. The slave device was positioned at (1,1). . . 52 4.2 The path of the slave during the test. . . 56 4.3 The mean current consumption for the devices during an operation. . . 58 4.4 The mean execution time for 30 tests for all the cases. . . 59 4.5 The mean execution time for estimating the position of the slave by

trilateration with RSSI. . . 61 5.1 The result from the static office case, with regards to the X-position. . . 66 5.2 The result from the static office case, with regards to the Y-position. . . 66

(14)
(15)

AoA Angle of Arrival

ATT Attribute Protocol

BLE Bluetooth Low Energy

CISC Complex Instruction Set Computer

CPHA Clock Phase

CPOL Clock Polarity

CTE Constant Tone Extension

EKF Extended Kalman Filter

FIFO First-In First-Out

GAP Generic Access Profile

GATT General Attribute Profile

GPS Global Positioning System

I2C Inter-Integrated Circuit

IMU Inertial Measurement Unit

IPS Indoor Positioning System

ISM Industrial, Scientific, and Medical

IQ In-Phase and Quadrature

KF Kalman Filter

MEMS Microelectromechanical System

(16)

LIST OF TABLES

MOSI Master-Out Slave-In

PC Personal Computer

PCB Printable Circuit Board

RF Radio Frequency

RISC Reduced Instruction Set Computer

RSSI Received Signal Strength Indication

RTOS Real-Time Operating System

SCK Serial Clock

SCL Serial Clock Line

SDA Serial Data Line

SDK Software Development Kit

SIG Special Interest Group

SPI Serial Peripheral Interface

SS Slave Select

TI Texas Instruments Inc.

UART Universal Asynchronous Receiver Transmitter

ULA Uniform Linear Array

(17)

1 Introduction

1

1.1 Background . . . 1 1.2 Problem Description . . . 3 1.3 Research Question . . . 4 1.4 Motivation . . . 4 1.5 Methodology . . . 5

1.5.1 Ideal Case Design . . . 6

1.5.2 Worst Case Design . . . 6

1.5.3 Validity . . . 7

1.6 Ethics . . . 7

1.7 Division of Work . . . 7

2 Frame of reference

9

2.1 Bluetooth . . . 9

2.1.1 Generic Access Profile . . . 10

2.1.2 General Attribute Profile . . . 11

2.1.3 Attribute Protocol . . . 12 2.2 Positioning Methods . . . 12 2.2.1 Trilateration . . . 12 2.2.2 Triangulation . . . 13 2.3 Positioning Techniques . . . 14 2.3.1 Angle of Arrival . . . 14

2.3.2 Received Signal Strength Indication . . . 17

2.3.3 Inertial Measurement Unit . . . 17

2.4 Current sensor . . . 18

(18)

CONTENTS

2.6 Extended Kalman Filter . . . 20

2.7 Microcontroller . . . 22

2.8 Real-Time Operating System . . . 22

2.9 Communication protocols . . . 23

2.9.1 Serial Peripheral Interface . . . 23

2.9.2 Inter-Integrated Circuit . . . 25

2.9.3 Universal Asynchronous Receiver Transmitter . . . 26

3 Implementation

27

3.1 Hardware Architecture . . . 27 3.1.1 LAUNCHXL-CC2640R2F . . . 27 3.1.2 BOOSTXL-AOA . . . 28 3.1.3 IMU module . . . 30 3.1.4 Current Sensor . . . 31 3.2 Software Architecture . . . 31 3.2.1 SIMPLELINK CC2640R2 SDK . . . 31 3.2.2 AoA Implementation . . . 32 3.2.3 RSSI Implementation . . . 36 3.2.4 IMU Implementation . . . 37 3.2.5 Execution time . . . 39 3.3 Sensor Fusion . . . 39 3.4 Complete System . . . 41 3.4.1 AoA Only . . . 41

3.4.2 AoA with compensation . . . 42

3.4.3 AoA fused with IMU . . . 43

3.5 Case Design . . . 44 3.5.1 Ideal Case . . . 45 3.5.2 Worst Case . . . 46

4 Results

47

4.1 Ideal Case . . . 47 4.1.1 Sports Hall . . . 47 4.1.2 Office Environment . . . 49 4.2 Worst Case . . . 51 4.2.1 Office Static . . . 52

(19)

4.2.2 Office dynamic . . . 54

4.3 System Performance . . . 57

4.4 RSSI. . . 59

5 Discussion and Conclusion

63

5.1 Discussion . . . 63

5.1.1 Execution Time . . . 63

5.1.2 Power Efficiency . . . 64

5.1.3 Precision over time . . . 64

5.2 Conclusion . . . 66

5.3 Future Work . . . 67

(20)

Chapter 1

Introduction

There is a high demand for Indoor Positioning Systems (IPS) thanks to the wide application possibilities. For example, it could be used in the health sector, industry, disaster management, and surveillance [1]. This master thesis will look into making a more robust and accurate positioning system for indoor applications in collaboration with Knightec, Solna, Sweden.

1.1

Background

Baichuan et. al. [2] predict that localization, timing and navigation will have a big positive impact on our lives. Yang and Shao [3] propose several suggestions for indoor localization. However, due to the complexity of the positioning system and limitations of the indoor environment, the problem with high accuracy and at low cost for positioning is still unsolved. They also state in [2] that there is no indoor positioning system today that can balance the cost, accuracy and complexity. Some usual techniques for wireless positioning systems are:

Radio Signal Strength Indication (RSSI) is a radio- frequency method that measures the distance between the transmitter and receiver by comparing the energy of the signals [4]. This method can be used to trilaterate an object’s position by using three receivers with a known position. The technique can localize an object’s position by geometry, where each receiver generates a circle and the position is given by the intersection of the three circles [5]. This technique is presented in Figure 1.1.

(21)

Figure 1.1: Illustration of trilateration.

Angle of Arrival (AoA) measures the angle from which a signal arrives with a receiving antenna array. The method can be used to triangulate an object’s position by using two beacons with a known position, then the coordinates of the object can be calculated with geometry [6]. The AoA method and the triangulation technique is presented in Figure 1.2.

(a) Angle of Arrival [7] (b) Triangulation Figure 1.2: Illustration of AoA and triangulation.

(22)

CHAPTER 1. INTRODUCTION

Inertial Measuring Unit (IMU) is a sensor that makes use of an accelerometer and a gyroscope to measure the forces that act upon it in different directions and rotations, see Figure 1.3. From these forces, the distance traveled can be calculated. The biggest disadvantage with an IMU is that it is relying on its previous position and its errors will accumulate over time. [8]

Figure 1.3: Illustration of how an IMU operates. [9]

Bluetooth Low Energy (BLE) is a short-range wireless communication standard that requires low energy with a low cost, making it compatible with many devices [10]. Connection between devices is handled by the Bluetooth protocol, making it easy to pair devices together compared to other wireless communication standard, such as WiFi [11]. In January 2019, Bluetooth Special Interest Group (SIG) released a new standard, Bluetooth 5.1. The new standard introduces the possibility to measure the AoA of a signal [7].

1.2

Problem Description

The main issue for localization using wireless signals indoors is the multipath propagation problem. The best accuracy is achieved when there is no objects between the signal transmitter and receiver, so called line of sight. This is hard to achieve in an indoor environment where there is objects that both break line of sight and reflects signals. Multipath propagation occurs when one signal, for instance, reflects off objects and reaches the antenna several times, from different angles. An illustration can be seen in Figure 1.4. Since the AoA method measures the angle from which a signal arrives, the multipath propagation has to be mitigated due to the distortions which impacts the accuracy negatively. [12]

(23)

In order to mitigate the multipath propagation, data from other sensors (e.g. IMU) can be combined through sensor fusion [13].

Figure 1.4: Illustration of multipath propagation.

1.3

Research Question

Considering the AoA, RSSI and IMU techniques for positioning a mobile robot, which combination is most suitable to merge together with sensor fusion to mitigate the multipath propagation problem of AoA while considering:

• Execution time • Power efficiency • Precision over time

1.4

Motivation

Current technologies for indoor positioning are not accurate and fast enough for most real-world applications. This might change with the Bluetooth 5.1 AoA feature. Knowing how accurate this technology could be made by mitigating the impact from multipath propagation would lay a good foundation for future research and product developments. There has not been much research done on the new standard. At the start of the project, only two studies have been found on the Bluetooth 5.1 AoA, one doing simulations and one doing empirical experiments, therefore more research is needed. [10], [14]

(24)

CHAPTER 1. INTRODUCTION

Since Bluetooth is widely used by all different kinds of portable devices, implementation of this new technology would happen with time, as new devices are made according to the new Bluetooth standard.

One example of application could be indoor robot tracking, which could be used to make advanced logistic systems and smart factories. Another example would be tracking patients at a hospital, in order to quickly quarantine and stop the spread of a contagious disease.

1.5

Methodology

The work of the thesis was deemed to be qualitative research, which is characterised by understanding the underlying meaning of a phenomenon and uses small data sets to reach a conclusion. The strategy chosen for this thesis was a descriptive case study since it can be based on qualitative research and is used to investigate a phenomenon in real life situations, where the edge between the phenomenon and situation is not obvious [15]. The goal of the thesis was to evaluate the possibility of making an indoor positioning system with Bluetooth signals. More specifically, to mitigate the multipath propagation problem by analysing the outcome of different settings to see which one provides the best accuracy balanced with efficiency. The phenomena investigated in the thesis is the multipath propagation problem in its real world context [16].

Multiple cases were developed, ideal and worst, with different scenarios as a static or dynamic environment to be compared for each technique concerning execution time, power efficiency and precision over time. Where static refers to the tracked object is stationary during the measurement, while dynamic refers to that the tracked object is moving. The dynamic case was limited to not move faster than walking speed. The purpose was to study the influence of multipath signals on the techniques and the results were presented as a histogram with a normal distribution of the position to provide an understanding of the data from a statistical context. [17].

The best environment for testing the accuracy of the positioning system is in an open space with no metal or concrete obstructions, with as few interfering signals as possible and on raised platforms made of cardboard [18]. This laid the foundation of the case design and the purposes of the cases.

(25)

1.5.1

Ideal Case Design

To be able to test the performances of the proposed systems in an indoor environment, the accuracy of the system in ideal conditions was of interest. Two ideal cases were developed to get a reference for how well the different systems performed in a static environment with as low multipath propagation as possible. The first ideal case was designed for a sports hall with open space and a high ceiling. The configuration of the devices with the best results and the lowest impact from multipath signals were used as a reference in the second ideal case, which was performed in an office environment.

The purpose of the ideal case in an office environment was to verify the configuration from the ideal case in the sports hall. The verification was to see if there was any significant difference in the performance of the systems with regards to disturbances from the multipath phenomena. This set up was used to get a controlled environment where disturbances could be introduced.

1.5.2

Worst Case Design

The worst cases were developed for an office environment in order to test the performances of the systems with the presence of multipath signals with regard to the configuration from the ideal case. To be able to test the performances, obstacles covered in tinfoil were used to introduce multipath in a controlled manner, inspired by [19], who made a case study on multipath propagation of GPS signals. Two worst cases were designed, static and dynamic. In the static worst case, the configuration of the devices in the system was static while the obstacles were introduced in a pre-determined sequence to see how well the systems could mitigate the multipath signals that occur due to the obstacles.

In the dynamic worst case, the obstacles were introduced in a controlled manner, just like in the static case. In addition, the tracked object was moved between known coordinates in the office.

The purpose of the two worst cases were to verify how well the system could mitigate disturbances with the presence of reflecting objects, both static and dynamic.

(26)

CHAPTER 1. INTRODUCTION

1.5.3

Validity

For high internal validity with good reliability for the thesis, how the data has been measured has been honest, clear, and with variation to minimize any confounding factor. Also, the configuration of the system has been the same for the cases and techniques. In addition, the tests have been performed with different disturbance intervals to ensure that the result is not for one particular setup. For high external validity, all the results are presented with regards to the hardware used and their configurations and functionalities. Also, the test environment is presented in detail.

1.6

Ethics

The main ethical concern with the methodology for this project was the representation of the data from the cases. The data could, both by purpose or unconsciously, be manipulated or exaggerated for a good result. Also, due to too little previous knowledge within the field the data could be misinterpreted and presented as more promising than it actually was. Among this, the design of the test cases had to be clearly defined, the environment and what was neglected or not. If the results are overstated or claimed to be better than they actually are, it could lead to starvation of other research.

1.7

Division of Work

During this project, the workload has been equally shared throughout the work. The background study was done together to formulate a research question, as well as the methodology and literature study. This was important for the collaboration, so both the authors had the same vision and understanding of the whole project. It was only during the implementation the workload was divided somewhat. Linus had more focus on the implementation of the IMU and software, while Philip had more focus on the sensor fusion and trilateration with RSSI. However, the authors have contributed to every stage in the project, such as parallel programming but that one of the authors had more responsibility for the topic. Any part of the project not mentioned here has been divided equally between the authors. This was so both could discuss problems and share knowledge with each other throughout the project. Both authors are happy with their contributions to the thesis and feels that the division of work has been fair.

(27)
(28)

Chapter 2

Frame of reference

This chapter presents the theoretical background for a Bluetooth based indoor positioning system. Different techniques and their theory of operation are presented, with regards to the scope of the thesis.

2.1

Bluetooth

Bluetooth is a technique for short ranged wireless communication between devices. In 2010 Bluetooth 4.0 was introduced, also known as Bluetooth Low Energy (BLE). This standard was designed for devices that does not need large amount of data and require low power consumption [20], [14], making it possible for devices to operate over a long time on a single battery, up to months or even years [21]. In 2016, Bluetooth SIG released Bluetooth 5 with BLE improvements such as double the speed, four times the range and eight times the capability of amount of data [22]. Bluetooth operates within the globally unlicensed industrial, scientific and medical (ISM) frequency band at 2.4GHz, and BLE uses 40 channels within the ISM band with a space of 2MHz. Since the ISM band is unlicensed there is a lot of traffic within it, such as WiFi signals. To avoid interference with signals and to maintain stable and robust connection with devices Bluetooth uses adaptive frequency hopping [23], the hopping pattern has the possibility to exclude frequencies that are already in use [24].

To establish a connection between two or more devices they must first pair with each other. A crucial aspect with wireless communication is the security. To avoid eavesdropping for instance, Bluetooth shares secret keys during the pairing process

(29)

to verify the devices has the same keys and encrypt the data [24]. For instance, to maintain a connection with the desired device, the devices share an “access code” which is including the devices’ unique ID from their manufacture [25].

The kind of data that a Bluetooth device can transmit and receive is defined by different profiles for different purposes and the devices must support the same profiles to be compatible. One profile could be to transfer contact information from a mobile phone to a car, stream music to portable headphones or data from a multi-sport watch which measures the pulse. [26]

Bluetooth SIG released their new standard 5.1 in January 28, 2019. One of their new main features in this standard is the ability to detect the direction from which an Bluetooth signal is coming from, and claim they can estimate the direction with high accuracy. Previously standards have only had the feature for positioning by measuring the signal strength for distance. One method in version 5.1 is Angle of Arrival, it is a method that requires an antenna array with multiple antennas. [7]

2.1.1

Generic Access Profile

Generic Access Profile (GAP) is the part of the Bluetooth architecture that handles the connection between two devices. This includes device discovery, connection between devices and termination of the connection. A Bluetooth device can assume one of four different roles according to the GAP protocol. The four roles are Peripheral, Central, Broadcaster and Observer. [27]

The Peripheral waits for a Central to initiate a connection. It advertises its name and purpose so the connecting Central knows beforehand what it tries to connect to. A Peripheral does not read the advertisement data of another peripheral, therefore, two peripherals do not establish a connection between each other. [27]

The Central scans for advertising data and may choose to connect to a advertising device based on the data it sends out. When a connection is established, communication can proceed in both directions between the Peripheral and the Central. [27]

The Broadcaster sends out advertising data just like the peripheral, however, it does not accept connections. The Observer does the opposite of the broadcaster, it scans for advertisement data but it does not connect to any of the devices. [27]

(30)

CHAPTER 2. FRAME OF REFERENCE

2.1.2

General Attribute Profile

General Attribute Profile (GATT) handles the data to be transmitted with Bluetooth. It follows a specific hierarchical structure as can be seen in Figure 2.1 called the Attribute Table.

Figure 2.1: Illustration of the GATT structure.

At the top of the table is the Service, which contains one or more Characteristics that makes sense to keep together. The Characteristic is the actual data along with a definition ID that describes what the data is for. This data can either be read from or written to, from the connected device, depending on the desired setting. The characteristics are each defined with their own Universally Unique Identifier (UUID) which defines the type of data the characteristic contains, e.g. temperature or heart rate. [27]

When a connection between two devices is established, one of the devices will be given the role of server, while the other will be given the role of client. The server is the device which host a service, while the client is the device that connects and reads or writes to the service. It is common for the server to have a peripheral GAP role and the client to have a central GAP role. [27]

(31)

2.1.3

Attribute Protocol

Attribute Protocol (ATT) is a layer below the GATT layer. It handles the communication between the server and the client. It allows the client to read what services the server offers, or read or write the value of a characteristic. GATT provides the structure of the data while ATT provides the communication of that data between the devices. [27]

2.2

Positioning Methods

2.2.1

Trilateration

Trilateration is used to determine the position of a node by estimating the distance from three different nodes with known location. The distance between two nodes can be measured with the RSSI (See Section 2.3.2). This means the unknown node is on the perimeter of a sphere with a radius of the measured distance, centered around the known node. By finding the intersection of three spheres around known nodes, an approximate position of the unknown node can be made. An illustration of trilateration in two dimensions can be seen in Figure 2.2, where the position of the known nodes can be expressed as (xn, yn), where n = 1, 2, 3. The position of the unknown node is

(x4, y4), and the distance between a known node and the unknown is dn. [28]

(32)

CHAPTER 2. FRAME OF REFERENCE

The distance between the unknown node and a known node can be calculated using Pythagoras theorem:

(xn− x4)2+ (yn− y4)2 = d2n (2.1)

This can be applied to the other nodes and expressed as a system of equations in order to find the intersection of the spheres:

    (x1− x4)2+ (y1− y4)2 (x2− x4)2+ (y2− y4)2 (x3− x4)2+ (y3− y4)2     −     d2 1 d22 d2 3     =     0 0 0     (2.2)

By solving this for x4and y4the position of the unknown node can be found. However,

this is only possible in an ideal scenario. In a real-world application, there will always be an error, which means that no point of intersect can be found. Instead, the result that gives the least amount of error is treated as the correct answer. Finding the lowest error becomes an optimization problem. [29]

The error depends on different factors, such as hardware, software, or the environment. The hardware factors could be the power output of the signal transmitter, where the power is not constant, giving a weaker or stronger signal strength even though there is no change in distance. Another hardware factor is that the antenna does not transmit a signal omnidirectionally, meaning the signal is weaker or stronger depending on how much the antenna is facing the receiver. The software could also be a source of error. Finding the lowest error is an optimization problem, and the algorithms solving these could get stuck in a local minimum, instead of finding the global minimum. Using a better algorithm is more demanding in terms of computational power and might not be a viable option. The biggest issue for trilateration using RSSI is the multipath propagation, which is an environmental source of error. Scattering and reflections of the transmitted signals is a big source of error. For accurately measuring the position of a node using this method, the environment should be open and multipath free, where the nodes have line of sight. [29]

2.2.2

Triangulation

Triangulation is a method of positioning that makes use of trigonometric relationships, namely, the law of sines. By placing two beacons at a fixed, known distance from each

(33)

other, and letting both of them measure the direction of a signal from an object of unknown position, it is possible to calculate that position. [6]

The law of sines states that:

A sinα = B sinβ = C sinγ (2.3)

Where A, B, and C are the sides of the triangle, and α, β, and γ are the opposite angles respectively. An illustration of triangulation can be seen in Figure 2.3. The needed information is the two angles of arrival, θ2 and θ3, to calculate the third angle, θ1, as

well as the baseline distance, d1between the two beacons.

Figure 2.3: Illustration of triangulation.

The distances d2 or d3 can then be solved for using Equation 2.3. The first step is to

calculate θ1 = 180°− θ2− θ3. From there d2and d3can be calculated by:

d2 = d1sinθ2 sinθ1 , d3 = d1sinθ3 sinθ1 (2.4) The distance ℓ, from the object to the baseline, can also be calculated:

ℓ = d1 sinθ2sinθ3 sin(θ2+ θ3) (2.5)

2.3

Positioning Techniques

2.3.1

Angle of Arrival

Angle of Arrival (AoA) is a method to estimate the angle of an incoming signal, this method is based on measuring the phase difference of the incoming signal from the source [30]. To measure the phase difference an antenna array can be used to sample the incoming signal, which is a collection of identical elements (antennas) positioned

(34)

CHAPTER 2. FRAME OF REFERENCE

at equal distance. The transmitting signal from the source corresponds to a wave that is propagating radially, and if the size of the antenna array is much smaller than the distance to the source (is in the far-field) the incoming wavefront can be assumed to be planar to the array. It is also assumed that the antenna array and the source are coplanar, stationary and that the medium the signal is travelling through is homogenous. [31]

Figure 2.4 is an illustration of an Uniform Linear Array (ULA), the distance d between the elements should be < λ

2 to avoid aliasing, where λ is the wavelength of the signal.

This also entails that it is possible to always determine which of the elements are closest to the transmitter. The distance between the elements results in the incoming signal will have a time delay which is measured as a phase difference at the receiving antennas. [32]

Figure 2.4: ULA

By using an Radio Frequency (RF) switch with at least two antennas which samples the incoming signal, the phase difference ϕ can be measured by comparing the phase shift in the In-phase and Quadrature (IQ) samples. See Figure 2.5.

With regards to the geometry in Figure 2.4, the distance the wave front must travel to reach the second antenna is r and can be expressed as:

r = dsinθ (2.6) where d is the distance between the antennas and θ is the angle of the incoming wave front with regards to the antenna plane. With the measured phase difference ϕ of the

(35)

Figure 2.5: IQ samples

signal between the two antennas in Figure 2.5, the distance r can also be expressed as:

r = λϕ

(2.7)

With equation 2.6 and 2.7 we can express the angle of direction:

θ = arcsin λϕ

2πd (2.8)

Bluetooth 5.1 Standard One of the new main features in the BLE 5.1 standard is AoA. These techniques requires antenna arrays to determine the direction of the signal and uses a Constant Tone Extension (CTE) for the IQ sampling. The purpose of the CTE tone, is that under a specific time interval it sends out a constant tone of 1’s, with a constant frequency and wavelength, under which period the IQ sampling can be made to estimate the phase difference between the antennas. Algorithms and equations to calculate the angle from the IQ-samples are not specified in their core specification, instead they mention it is up to the manufactures to develop their own algorithms that is most suitable for their applications. [7], [14]

(36)

CHAPTER 2. FRAME OF REFERENCE

2.3.2

Received Signal Strength Indication

Received Signal Strength Indication (RSSI) is a method of measuring the intensity of an incoming signal. It can be used to give an approximation of the distance between the signal transmitter and receiver. It works best when the signal is allowed to propagate in line of sight with no interference’s. The signal strength will follow the inverse square law, p ∝ d−2, which states that the power p is relative to the inverse square of the distance d. In practice, there will be multipath propagation that will diminish the signal strength even further.[33]

In Equation 2.9 the formula for calculating the RSSI can be seen.

RSSI =−(10n log10d + A) (2.9)

Where RSSI is the measured signal strength indication at the receiver, n is the path-loss exponent, d is the distance between transmitter and receiver, and A is the absolute power in dBm.

The absolute power is defined by the signal strength at one meter from the transmitter. It is calculated with a path-loss exponent for free space, which is 2 [6]. The path-loss exponent depends on the environment and has to be calculated for each set up [34]. This can be done by solving Equation 2.9 for n and make measurements between nodes at a known distance. When the path-loss exponent and the absolute power has been determined, the distance can be calculated by measuring the RSSI.

2.3.3

Inertial Measurement Unit

An Inertial Measurement Unit (IMU) is an independent device that can estimate its motion and orientation in space with an accelerometer, gyroscope, and sometimes also a magnetometer. By measuring the linear acceleration in three orthogonal axes it can estimate its displacement and by measuring the angular velocities around its axis it can estimate its orientation in space. Magnetometers measure the earth’s magnetic field locally to determine the device heading [35].

Accelerometers are sensing the acceleration linearly in its three axes, which entails that it is also affected by the surrounding gravitational force. Therefore, the output data from the accelerometer must be calibrated with respect to the local gravitational field which affects its performance and also with respect to the desired application.

(37)

The IMUs’ sensitivity must also be considered. The error in the measurement causes dead reckoning in the output data. To obtain the velocity and position of the IMU the accelerometer data can be integrated twice with regards to time, which entails that the positioning error increases quadratically. To obtain the orientation the angular velocity is integrated once with an outcome of a linear error. [36]

The knowledge about the IMUs physical constraints is essential when designing a system and it is important to keep in mind what type of application it will be used in. The main reason an accelerometer is preferred over a gyroscope is that the power consumption from the accelerometer is a fraction compared to a gyroscope [37].

2.4

Current sensor

There is a high requirement on today’s complex portable devices, such as computers, battery chargers, and mobile phones to be energy efficient [38]. Hence, it is important to sense and control the current flow through the systems. By sensing the current flow, the ability to protect and make a more robust device is also possible since it can sense suddenly changes in the current. Measuring the voltage drop over a sensing resistor is the most practical way to sense the current [39]. The accuracy is also of importance, and the sensing resistor value is crucial. If it is large, the current measurements will be better at the expense of a greater current loss in the system [40].

A current sensor measures the current ISfrom a power supply over a low value shunt

resistor RS, and can be placed either on high or low side of the load, see Figure 2.6.

The voltage drop over RS is fed through an operational amplifier which gain gm is set

by the manufacturer. The output current IOis converted to output voltage VOthrough

an external resistor RL. The output voltage VOis an analog signal which can be read by

a microcontroller to calculate the current through the load.

IO= gm(VIN +− VIN−) (2.10)

Where the voltage (VIN + − VIN−) is equal to RSIS, and the output voltage can be

expressed as:

(38)

CHAPTER 2. FRAME OF REFERENCE

Figure 2.6: Simple schematic over a current sensor with high and low side.

2.5

Multipath Propagation

The multipath propagation phenomena occurs when a signal takes multiple different paths from the transmitter to the receiver due to reflections. This error affects wireless positioning methods negatively, such as the distance and direction approach presented above. A transmitter sends out a signal in a spherical propagation, outwards from the transmitter in every direction. A receiving antenna is omnidirectional which means it can not determine whether the path of the signal is in line of sight or has reflected off of an object. This will result in that the receiver perceives the position of the transmitter at a different position than it actually is, See Figure 2.7, if multipath occurs.

A signal is sent out from the transmitter in every direction, hence the same signal will take multiple paths to the receiver if there are objects in the proximity reflecting the signal. The reflected signal will have a phase shift compared to the direct signal depending on the difference in the time it takes to reach the receiver. This phase shift will cause the signal to interfere with itself, causing errors in data transmission and measurements. Due to a high refraction index, meaning the material does not allow the signal to pass through it, metal alloys are big contributors to multipath propagation [19].

(39)

Figure 2.7: Illustration of multipath propagation.

2.6

Extended Kalman Filter

Kalman filter (KF) is a linear optimal estimation algorithm, used to estimate variables in a noisy process that cannot be measured directly. The method is widely used in many different applications such as navigation and positioning for example. KF is based on Gaussian distribution of the data and is recursive, where it combines the measured state with the predicted to obtain an optimal estimation of the state. Due to Gaussian distribution of the noise the deviation of the predicted state will also be Gaussian distributed. [41]

Since KF is a linear estimation algorithm, it is only suitable for linear systems. This means that the observation equation must be linear and that is not common in the real world. However, there are other variants of the KF to handle nonlinear systems, such as the Extended Kalman Filter (EKF). EKF are widely used for inaccurate and noisy signals, such as in IPS, and can also be used for sensor fusion to combine different sensor data to one output. For instance in [42], they used an EKF to fuse IPS signals with wheel encoders and an IMU for a more accurate and stable localization of a robot.

The EKF linearize the nonlinear system locally at each time step k around the mean value of the present estimated data with Jacobians of the system model and measurement. The EKF estimates its output in a two step process, prediction and update.

(40)

CHAPTER 2. FRAME OF REFERENCE Prediction step

In the prediction step, a priori estimate ˆx−of the system is made. It predicts its current state with the previous state estimate and the present input uk, where f is the function

representing the system model. The covariance of the priori estimate Pk is estimated with the previous covariance, the Jacobian Fk of the partial derivatives of f , and Q

which is representing the noise covariance of the process [42].

ˆ x−k = f (ˆxk−1, uk) (2.12) Fk = ∂f ∂x ˆxk−1;uk (2.13) Pk = FkPk−1FkT + Q (2.14) Update step

In the update step, the estimated state and the covariance are updated by using the estimation from the prediction step and the current measurement yk to calculate

a posterior estimate ˆxk of the system that is used to update the priori state. The

measurement function is h.

An approximation of the linearization of the observation is calculated with the Jacobian of the measurement function h.

Hk=

∂h

∂x xˆk (2.15)

With the Jacobian Hkthe Kalman gain Kkcan be calculated with the priori covariance

Pk−and the measurement noise covariance R [42]. The gain will determine how much the measured variables or the priori state estimation will affect the calculations of the posterior ˆxkand Pk.

Kk = Pk−HT(HPk−HT + R)−1 (2.16)

ˆ

(41)

Pk= (I − KkH)Pk− (2.18)

The EKF is very vulnerable to the systems dynamics, if it is highly nonlinear it will give poor results since it linearizes around the current estimated data which follows the curve of the signal. It may also result in high computational cost due to the Jacobians that must be calculated at every time step if it is not possible to calculate them analytically. [43], [41]

2.7

Microcontroller

A microcontroller is a small processor with peripherals such as memory, timers, and input and output pins. It is often used to control tasks for which an entire PC is redundant. It has less processing power, but on the other hand less power consumption and can respond faster to real-time events. In addition, it has a smaller physical size than a PC. This makes it a popular choice for managing specific control tasks. [44]

The peripheral devices commonly associated with microcontrollers differs from the peripherals used for general purpose computers. A general purpose computer usually has a monitor along with human interface devices such as a mouse and keyboard. The microcontroller interacts with the environment through timers, analog to digital converters, and input and output pins. [45]

Most microcontrollers use an architecture called Reduced Instruction Set Computer (RISC). This architecture allows for a higher execution speed on the cost of having to do more operations compared to the alternative Complex Instruction Set Computer (CISC). The CISC architecture can do more with less operations on the instructions taking up more memory. [44]

2.8

Real-Time Operating System

A real-time operating system (RTOS) is often used when one microcontroller has to manage several tasks in real time. The RTOS mission is to ensure that all tasks meet their deadlines. A deadline is the longest amount of time a task has to finish executing in order to fulfill its purpose. The RTOS gives each task a certain amount of time to run

(42)

CHAPTER 2. FRAME OF REFERENCE

based on the different scheduling technique implemented. There is a preemptive task scheduling method that gives each task a higher priority the more important the task is. If a higher priority task has to run while a low priority task is running, the higher priority task will preempt the other and execute to completion first. [46]

Another method of scheduling is round robin, which gives each task the same pre-determined amount of time to execute. This has the advantage of being simple to implement while still being quite effective. However, if an important task is running and its time is up, important deadlines can be missed. Round robin is therefore not the best if there is certain tasks that are more time critical than others. [45]

2.9

Communication protocols

This section explains the theory behind the communication between a microcontroller and an external module such as an IMU.

2.9.1

Serial Peripheral Interface

The Serial Peripheral Interface (SPI) is a four line synchronous communication protocol for high-speed transmission over short distances designed by Motorola, inc.. It is full-duplex communication meaning the slave and master exchange information in both directions at the same time. An 8-bit data register is placed at the master and one at the slave, giving a 16-bit register. The data is serially shifted from the master data register to the slave data register through a Master-Out Slave-In (MOSI) line, and at the same time from the slave data register to the master data register through a Master-In Slave-Out (MISO) line. The shifting follows the clock pulses in the Serial Clock (SCK) line. An illustration of a SPI setup can be seen in Figure 2.8. SPI allows for one master and one or more slaves which are selected with a Slave Select (SS) line. The number of wires used is directly proportional to the number of slaves, since each slaves require their own slave select line. [47]

(43)

Figure 2.8: SPI Overview.

Before transmission begins, the selected slave’s SS line will be pulled low and will stay low until the transmission is done. The clock will then stop idling and send out clock pulses and transmission will start, see Figure 2.9. [47]

Figure 2.9: SPI timing diagram. [48]

The transmission sequence depends on the clock polarity (CPOL) and clock phase (CPHA). If the clock polarity is set to low, the clock is in idle at 0 and has pulses of 1’s, and vice versa if the clock polarity is set to high. The clock phase handles the timing of the data shift. When the phase is set low, the trailing edges of the clock pulse save the next bit in a temporary memory slot, while leading edges shift the previously saved bit

(44)

CHAPTER 2. FRAME OF REFERENCE

into the data register. A phase set to high will save the bit on leading edges of the clock pulse and shift it into the data register on the trailing edges. [47]

2.9.2

Inter-Integrated Circuit

Inter-Integrated Circuit (I2C) is a two line serial data bus for communication between

integrated circuits. It was designed by Philips Semiconductors to be simple yet efficient. The design allows for several master and slaves on the same data bus. Data is transmitted over a data line (SDA) and synchronized with a clock line (SCL). When no data is being transmitted, both lines idles at a high state. The transmission start by the master pulling the data line low while the clock line remains high, this is the start signal. The transmission sequence can be seen in Figure 2.10. [49]

Figure 2.10: I2C timing diagram. [49]

The master node controls the clock line and sends a start signal to initiate a transmission. Following the start signal, a 7-bit address is sent to a slave it wants to communicate with, followed by a Read/Write bit to tell the slave if the master wants to transmit or receive a message. Each slave has its own address and responds with an acknowledgement bit when the master sends out the slaves address on the data line. Depending on the state of the Read/Write bit, the master and slave will become either the transmitter or receiver. The transmitter sends a byte and the receiver responds with an acknowledgement bit. The master then sends another start signal, for more data to be transmitted, or a stop signal. The stop signal consist of a low to high transition on the SDA line while the SCL line is high. [49]

(45)

2.9.3

Universal Asynchronous Receiver Transmitter

Universal Asynchronous Receiver Transmitter (UART) is a serial communication protocol, used between two peripherals on the same bus and often over a short distance. Both of the devices communicates via their transmitter (TX) to the receiver (RX) on the other device. Due to UART being asynchronous, which means it does not use any clock for the communication, both the devices needs to have the same configuration with baud rate, data length and logical start- and stop bit. [50]

When a message is about to be sent and the bus is in idle (logic high), UART sets a start bit at the beginning of the message as low so the receiver knows that there is a incoming message. Then it sends the data, in order with the least significant bit first and with a stop bit as high in the end of the message, so the bus goes to idle again if there is no more data to be sent. The communication is bidirectional, which means data can be sent either way between the devices. [50]

(46)

Chapter 3

Implementation

This chapter explains the implementation of the techniques presented for the project. It is divided in hardware, software, and the integration between these two, along with the case design to evaluate the performance of the proposed systems.

3.1

Hardware Architecture

This section will describe the hardware used in the project.

3.1.1

LAUNCHXL-CC2640R2F

The LAUCNHXL-CC2640R2F launchpad is a development kit from Texas Instruments Inc. (TI) designed for rapid prototyping of BLE 5.1 applications. It has 30 Digial Input/Output pins which can be used as General Purpose Input/Output pins and supports a wide variety of communication protocols, including SPI. It is optimized for low power applications and comes with 128KB of in-system programmable flash memory. A picture of the CC2640R2F can be seen in Figure 3.1. [51]

Four CC2640R2F launchpads were used in this project. One for the node which position is measured, which was called the slave. Two for the BOOSTXL-AOA antennas measuring the AoA, which were called passives and one for the node that manages the communication between all the launchpads. The last one was called master.

(47)

Figure 3.1: Picture of the LAUNCHXL-CC2640R2F development kit. [51] In order to use the external antennas, the launchpad had to be configured by moving a capacitor from the internal antenna on the PCB, to the external antenna JSC connector, see Figure 3.2.

Figure 3.2: Final configuration of capacitor. [52]

3.1.2

BOOSTXL-AOA

The antenna array used in this project are two BOOSTXL-AOA from TI, which are developed for evaluation of AoA signals with a LAUNCHXL-CC2640R2F. The antenna array consists of two ULA perpendicular to each other, where each has three 2.4 GHz dipole antennas. Each antenna can cover ±90◦ angle of an incoming signal, and the two ULA’s together can cover up to ±135◦, see Figure 3.3. TI states that since dipole antennas are differential, their signal needs to be balanced which is done by a marchand balun on the antenna. The balanced signal from the antennas are fed to a RF switch, U2 and U3 in Figure 3.4. They in turn are connected to the array switch U1 to

(48)

CHAPTER 3. IMPLEMENTATION

connect each of the ULA’s to the JSC connector which is connected to the LAUNCHXL-CC2640R2F board. [52]

Figure 3.3: Angle coverage of the BOOSTXL-AOA Antenna [52]

(49)

3.1.3

IMU module

The IMU used in this project is the ADXL343, which is a three-axis MEMS accelerometer. A picture of the IMU connected to the slave can be seen in Figure 3.5. The ADXL343 can measure dynamic acceleration from motion and static acceleration with gravitation, and has a measurement range from ±2g ±4g ±8g ±16g. The accelerometer uses a First in, First out (FIFO) memory buffer to reduce the overall system power consumption. The x, y and z-axis has their own specific addresses on the IMU, where the FIFO samples are read to in a burst. To make sure that all the new data has been read, according to the datasheet, there must be a delay of at least 5µs until the next read. The ADXL343 modulates its power consumption automatically with regards to its output data rate, and can be as low as 23µA. [53]

(50)

CHAPTER 3. IMPLEMENTATION

3.1.4

Current Sensor

To measure the power consumption for each of the devices during operation, the INA169 current sensor [54] was placed between the device and the node manager. A USB cable was modified to enable the UART communication between the master and the two passive devices with the node manager, and still be able to measure the current the devices consumed during operation. See Figure 3.6 for schematic of the measurement.

Figure 3.6: How the USB cable was cut and the current was measured. The green and blue wires are the UART transmission lines.

From the datasheet [54], TI provided Equation 3.1 for measure the current Is. Where

Rs = 10Ω, RL = 10kΩ and Vo is the analog output voltage for a microcontroller to be

able to read. Is = Vo1kΩ RsRL (3.1)

3.2

Software Architecture

This section will describe the software architecture of this project.

3.2.1

SIMPLELINK CC2640R2 SDK

The Software Development Kit (SDK) from TI provides the framework on which this project was built upon. It comes with example projects that implements the Bluetooth Low-Energy stack on a TI microcontroller with TI-RTOS to give a foundation to developers. TI-RTOS was used to create tasks and manage processes on the microcontroller. In this project, the Bluetooth stack was handled by the TI-RTOS tasks. Data and actions are queued as messages and processed in a first-in first-out order. The data could either be sent over bluetooth, or via USB-cable to a PC. The data sent over

(51)

Bluetooth was the CTE signal or the IMU measurements. The PC worked as a node manager, telling each launchpad what to do, and to collect the data from the antennas and the IMU. See Figure 3.7 for an overview of the nodes and PC.

Figure 3.7: The setup of nodes and PC. [18]

3.2.2

AoA Implementation

A system for triangulation with AoA was set up with regards to TI’s recommendations [18] as seen in Figure 3.7, where the slave is the object to be positioned. The communication between the devices are controlled by a central node manager, which in this case is a PC. The master and two passive nodes are connected to the PC with USB and communicates with UART.

The node manager handles the connection and set up for the system with a python script. In which the specific ports to the master and the two passives are declared. First, the node manager will send a identify request over UART to the master and waits for a respond to then send a identify request to the two passives nodes. When the PC has found the devices, it sends out a scan request to the master node to start scan and establish a BLE connection with the advertising slave device. When the master has established a connection with the slave device, it sends the connection information

(52)

CHAPTER 3. IMPLEMENTATION

to the passives nodes via the node manager so they can track the connection to the slave.

When the connection is set up with all the devices, the node manager tells the master and the passive devices to set up AoA parameters over UART, and the master in turn tells the slave to set up its AoA parameters wireless over the Bluetooth connection. The slave will then append the CTE package at the end of every message. The two passive devices will follow the connection to the slave and when they receive a CTE package they will calculate the angle to the slave and send it the node manager over UART. The master and slave will continue to be connected and the passives will track the connection and calculate the angles by IQ sampling, see subsection 2.3.1 in the Background chapter.

In the node managers python script, the received messages from the passives nodes are stored in a csv file with information of which antenna array, RSSI value and the angle of the incoming CTE signal. The sampling time for the node manager is 5Hz. The csv file was then imported in a matlab script, where the position of the slave was calculated relative to the passive antennas.

In the matlab script, three different configuration of the slaves position were enabled, see Figure 3.8−3.10. The angles measured from the antennas to the slave are expressed as θ1 and θ2 and are translated to β and γ. The distance a is known between the

antennas. From the geometry, the equations 3.2−3.7 for the different cases were expressed as:

(53)

c = a· sin γ sin α = a· sin (90 − θ2 ) sin(180− (90 − θ1 )− (90 − θ2 )) (3.2) x = c· cos(90 − θ1 ) y = c· sin(90 − θ1 ) (3.3)

Figure 3.9: Illustration of configuration 2.

c = a· sin γ sin α = a· sin (90 − θ2 ) sin(180− ( θ1 + 90)− (90 − θ2 )) (3.4) x =−c · cos(90 − θ1 ) y = c· sin(90 − θ1 ) (3.5)

(54)

CHAPTER 3. IMPLEMENTATION

Figure 3.10: Illustration of configuration 3.

b = a· sin β sin α = a· sin (90 − θ1 ) sin(180− (90 − θ1 )− (90 + θ2 )) (3.6) x = b· cos(90 − θ2 ) + a y = b· sin(90 − θ2 ) (3.7)

To prevent corrupt data from noise, variables that did not match the constraints set in matlab were overwritten by previous value. Such as if both the measured angles are obtuse or if the calculated angle α is less than 5◦. If the angle is less than 5 it would mean that the tracked object is very far away in either the x or y-axis and would result in lower accuracy.

The angles from the antennas were sampled at 5Hz and separated and filtered with a Butterworth filter with a cutoff frequency at 0.3Hz, a passband of the ripple at 0.3dB, and a ripple stopband at 1dB. The position of the slave was expressed in x, y coordinates relative to the left antenna which position were set to origo.

(55)

3.2.3

RSSI Implementation

Trilateration requires three nodes that can measure the RSSI value from the slave, and requires another configuration than AoA where the slave should be between all the nodes, see subsection 2.2.1 in the Background chapter. From the AoA implementation, the two passives nodes provided the node manager with RSSI value from the slave but not the master. Therefore, the master was configured to be able to read the RSSI from the slave. A periodic event was implemented on the master which read the RSSI value and sent it to the node manager over UART as the data type int8. The periodic event happened every 100ms, as fast as the hardware allowed. The node manager saved the RSSI value from the master in a new csv file to be implemented in matlab.

Firstly, the measured RSSI values are smoothed with a Savitzky-Golay filter separately to reduce noise in the raw data. To calculate the path-loss exponent n in the environment, a calibration measurement A was made at a distance d 1m between the devices, where A is a constant expected RSSI value at 1 meter from the slave. From Equation 2.9 in the Background chapter, n can be expressed as:

n =−RSSI + A

10log10d (3.8)

Then the distance d to the slave device from each of the nodes can then be calculated by:

d = 10A−RSSI10n (3.9)

With known locations of the nodes, three circles are made with the distance d as their radius for each of them. The slave’s position is in the area where the three circles intersects with each other. By drawing a line through where each of the circles intersects with another, an estimated position for the slave can be measured in the point where the three lines intersects. See Figure 3.11.

(56)

CHAPTER 3. IMPLEMENTATION

Figure 3.11: An illustration of the trilateration approach.

3.2.4

IMU Implementation

The IMU was connected to the slave with an SPI connection using a bitrate of 10 kbit/s. A separate TI-RTOS task was created to handle the connection. In this new task, the slave node acts as master towards the IMU, and initiates the communication. The slave can either read from, or write to the registers of the IMU in a similar fashion to I2C,

determined by the first byte sent from the slave. Figure 3.12 shows the transmission sequence between the slave and the IMU. The first bit in the first byte tells the IMU if the slave wants to read or write, and the following bit tells if the transmission is a multiple byte transmission or not. Following the first two bits is a 6-bit address to the register of the IMU.

If the first bit is set, and the second is not, the slave indicates it wants to read one byte from the IMU. The one byte value of the register specified will be sent back and the transmission will stop. If the first two bits are set, the slave indicates it wants to read multiple bytes. The slave will give a start address and the IMU will respond with the value at that register, the next byte sent will be value at the next register. The IMU will

(57)

Figure 3.12: Timing diagram of the IMU transmission. [53]

keep sending bytes until the slave cancels by stopping the clock signal.

The IMU is initiated by turning off the measurement mode and making the adjustments wanted to the settings. It is turned off by the slave writing a byte of zeros to the register for measurements. Then the resolution is set to the lowest measurement range of±2g. The lowest resolution was chosen to gain as much data as possible, and then filter the noise in matlab. Subsequently, the FIFO-mode (explained in subsection 3.1.3) is enabled. When these options are set, the measurement mode is turned on again.

The IMU data for x, y, and z accelerations is stored in six different registers. This means that each direction is a 16-bit value stored in two 8-bit registers. To get a reading from the IMU on the proper format the two complementing registers have to be read and saved into a 16-bit signed integer. This is done by storing the first register value in the least significant 8 bits and the second register value in the most significant 8 bits. In order to combine the IMU with AoA the IMU data was also stored in a csv file on the node manager. The data is sent from the SPI task to the BLE task. Thereafter the data is sent from the slave to the master via Bluetooth and then from the master to the node

(58)

CHAPTER 3. IMPLEMENTATION

manager over UART. The sampling time of the IMU data is 5Hz, which is most likely sub-optimal. A higher sampling time was wanted, however, it was considered too time consuming to implement. This was due to the limitations of the amount of data that can be sent over Bluetooth while simultaneously sending the CTE packets.

In the matlab script the IMU data was filtered to remove noise. This was done by doing a stationary reading over a couple seconds to get a threshold of which the values below it was set to zero.

3.2.5

Execution time

To measure the execution time for the systems described in 3.4, the time for all the simulated processes were recorded. The time for the devices to establish a connection and send data was not of interest. The performance of the overall system to estimate the position that was the focus. The code was measured using built-in MATLAB functions. The execution time was measured each time a triangulation or trilateration calculation was made. As well as a simulink simulation of 5 minutes. This means that the times measured has no real information about the system by themselves, but only when compared to each other a conclusion can be drawn.

3.3

Sensor Fusion

An EKF was designed for sensor fusion and better overall performance of the system. The extended version of the Kalman filter was chosen despite having a linear system, for potential future implementations with non-linear systems. The filter is based on the input data uk which are the Cartesian coordinates x,y representing the position of

the slave in 2D. For object tracking, the position and velocity of the object is of interest and was defined as the vector ˆxat the time stamp k:

ˆ xk =        ˆ xpos,k ˆ xvel,k ˆ ypos,k ˆ yvel,k        (3.10)

References

Related documents

We made an attempt to evaluate the Bluetooth Low Energy protocol in conjunction with Smartphones, the way it works in indoor environments, how it is affected by multipath and

in order to estimate the importance of these different variables for outcome, a step-wise linear regression anal- ysis where CoRe-om at treatment end was

This Master Thesis aims at investigating and evaluating the performance of the existing device-based and network-based methods and scenarios in order to address a proper 3D

• Redo the motion detection algorithm: when no motion is detected by the inertial sensors, the position should be updated using the average of the last Wi-Fi readings. This

An alternative method using a technology and positioning technique with sufficiently high accuracy could allow the parking to be based on being inside the respective parking zone

The suggested solution uses commercially available Wi-Fi access points to observe the received signal strength when a device probes for nearby access points. The information

However, in this project, time series analysis takes over only when the channel is unstable and the received signal strength could not maintain a steady

As a project aiming for building an experimental system, the result is presented as an assessment of the reliability of the system. The system implementation result mainly focuses