Advances in Automaton Engineering Band 4 Editor: Clemens Gühmann

Jürgen Helmut Funck Synchronous data acquisiton with wireless sensor networks

Universitätsverlag der TU Berlin

Jürgen Helmut Funck Synchronous data acquisition with wireless sensor networks The scientifc series Advances in Automation Engineering is edited by Prof. Dr.-Ing. Clemens Gühmann. Advances in Automation Engineering | 4

Jürgen Helmut Funck Synchronous data acquisition with wireless sensor networks

Universitätsverlag der TU Berlin Bibliographic information published by the Deutsche Nationalbibliothek The Deutsche Nationalbibliothek lists this publication in the Deutsche Nationalbibliografe; detailed bibliographic data are available on the Internet at http://dnb.dnb.de.

Universitätsverlag der TU Berlin, 2018 http://verlag.tu-berlin.de

Fasanenstr. 88, 10623 Berlin Tel.: +49 (0)30 314 76131 / Fax: -76133 E-Mail: [email protected]

Zugl.: Berlin, Techn. Univ., Diss., 2017 Gutachter: Prof. Dr.-Ing. Clemens Gühmann Gutachter: Prof. Dr.-Ing. Gerd Scholl Gutachter: Prof. Dr.-Ing. Reinhold Orglmeister Die Arbeit wurde am 12. Oktober 2017 an der Fakultät IV unter Vorsitz von Prof. Dr.-Ing. Olaf Hellwich erfolgreich verteidigt.

This work is protected by copyright.

Cover image: vickysandoval22 | https://www.fickr.com/photos/115327016@ N06/12603289253/ | CC BY 2.0 https://creativecommons.org/licenses/by/2.0/

Print: docupoint GmbH Layout/Typesetting: Jürgen Helmut Funck

ISBN 978-3-7983-2980-5 (print) ISBN 978-3-7983-2981-2 (online)

ISSN 2509-8950 (print) ISSN 2509-8969 (online)

Published online on the institutional Repository of the Technische Universität Berlin: DOI 10.14279/depositonce-6716 http://dx.doi.org/10.14279/depositonce-6716 Credits

This thesis is the result of my time as research assistant at the Chair of Electronic Measurement and Diagnostic Technology at the Technische Universitat¨ Berlin. I’d like to take this opportunity to give my special thanks to Prof. Dr.-Ing. Clemens Guhmann,¨ the head of this chair, who encouraged my research into the topic and has shown a consistent, benevolent interest in my work. Furthermore, I’d like to thank Prof. Dr.-Ing. Gerd Scholl, head of the Chair of Electrical Measurement Engineering at the Helmut-Schmidt-University, University of the Federal Armed Forces Hamburg, and Prof. Dr.-Ing. Reinhold Orglmeister, head of the Chair of Electronics and Medical Signal Processing at the Technische Universitat¨ Berlin, for spending their time to examine this rather comprehensive thesis. My thanks also go to Prof. Dr.-Ing. Olaf Hellwich, head of the Chair of Computer Vision and Remote Sensing at the Technische Universitat¨ Berlin, who acted as a mentor for me in my frst years of study and now chaired my doctoral committee. I’d also like to express my appreciation for my former colleagues at the Chair of Elec- tronic Measurement and Diagnostic Technology, the talks and discussions with whom inspired and encouraged me. They contributed to an amiable working atmosphere that was a constant source of support. I owe thanks to the members of the joint mechatronic workshop of the Chairs of Elec- tronic Measurement and Diagnostic Technology and of Electronic and Medical Signal Processing for helping me to reft and extent the induction motor test bench as well as for etching innumerable PCB-layouts for my research. Furthermore, I thank Dr.-Ing. Henri Kretschmer and Mr. Torsten Huter¨ from the Virte- nio GmbH for readily supporting me, when I had questions regarding the sensor nodes or their programming. I also like to thank the students who I was allowed to counsel during their projects, bachelor’s and master’s theses. They helped to extend the capabilities of the and thus made it more useful not only for my research but also for other research projects. Finally, I’d like to thank my friends and family for their unconditional support and understanding during all phases of my research.

v

Abstract

Wireless sensor networks (WSN) are predicted to play a key role in future technological developments like the internet of things. Already they are beginning to be used in many applications not only in the scientifc and industrial domains. One of the biggest challenges, when using WSNs, is to fuse and evaluate data from diferent sensor nodes. Synchronizing the data acquisition of the nodes is a key enabling factor for this. So far research has been focused on synchronizing the clocks of the nodes, largely neglecting the implications for the actual measurement results. This thesis investigates the relation between synchronization accuracy and quality of measurement results. Two diferent classes of time synchronous data acquisition are investigated: event detection and waveform sampling. A model is developed that de- scribes a WSN as a generic multi-channel data acquisition system, thus enabling direct comparison to other existing systems. With the help of this model it is shown, that syn- chronization accuracy should best be expressed as uncertainty of the acquired timing information. This way, not only the contribution of the synchronization to the over- all measurement uncertainty can be assessed, but also the synchronization accuracy required for an application can be estimated. The insights from the uncertainty analysis are used to develop two distinct approaches to synchronous data acquisition: a proactive and a reactive one. It is shown that the reactive approach can also be used to efciently implement synchronous angular sam- pling, i.e. data acquisition synchronous to the rotation of a machine’s shaft. Further- more, testing methods are suggested, that evaluate the synchronized data acquisition of an existing WSN as a whole. These methods can be applied to other data acquisition systems without changes, thus enabling direct comparisons. The practical realization of a WSN is described, on which the developed data acqui- sition methods have been implemented. All implementations were thoroughly tested in experiments, using the suggested testing methods. This way it was revealed, that a system’s interrupt handling procedures may have a strong infuence on the data acquisi- tion. Furthermore, it was shown that the efective use of fxed-point arithmetic enables synchronous angular sampling in real-time during a streaming measurement. Finally, two application examples are used to illustrate the utility of the implemented data ac- quisition: the acoustic localization of two sensor nodes on a straight line and a simple order tracking at an induction motor test bench.

vii Kurzfassung

Drahtlose Sensor Netzwerke (WSN) werden voraussichtlich entscheidend fur¨ techni- sche Entwicklungen wie das Internet der Dinge sein. Schon jetzt werden sie in zahl- reichen Anwendungen u.a. in Wissenschaft und Industrie eingesetzt. Eine der großten¨ Herausforderungen hierbei ist, die Daten von verschiedenen Sensorknoten gemeinsam auszuwerten. Dies ist oft dann nur sinnvoll moglich,¨ wenn die Daten synchron auf- genommen wurden. Bisher konzentrierte sich Forschung auf die Synchronisation der Uhren auf den Sensorknoten. Die Auswirkungen auf die Messergebnisse selbst wurden hingegen kaum untersucht. Diese Dissertation untersucht die Zusammenhange¨ zwischen Synchronisationsgenau- igkeit und Qualitat¨ der Messergebnisse. Zwei Klassen von zeitsynchroner Datenerfas- sung werden dabei betrachtet: die Detektion von Ereignissen und die Aufnahme von Kurvenformen. Es wird ein Modell entwickelt, welches ein WSN als ein allgemeines mehrkanaliges Datenerfassungssystem beschreibt. Dies ermoglicht¨ den direkten Ver- gleich zwischen WSN und anderen Messsystemen. Weiter wird mit Hilfe des Modells gezeigt, dass die Synchronisationsgenauigkeit vorzugsweise als Unsicherheit der Zeit- information angegeben werden sollte. Hierdurch kann nicht nur der Beitrag der Syn- chronisation zur gesamten Messunsicherheit bestimmt, sondern auch die von einer An- wendung tatsachlich¨ benotigte¨ Synchronisationsgenauigkeit abgeschatzt¨ werden. Ausgehend von den durch die Unsicherheitsbetrachtung gewonnenen Erkenntnissen werden ein proaktiver und ein reaktiver Ansatz zur synchronen Datenaufnahme entwi- ckelt. Mit dem reaktiven Ansatz konnen¨ Messdaten auch efzient drehwinkelsynchron, d. h. synchron zur Drehbewegung einer Maschinenwelle, aufgenommen werden. Es werden Testverfahren vorgeschlagen, mit denen sich die Synchronizitat¨ der Datenerfas- sung fur¨ ein WSN als Ganzes uberpr¨ ufen¨ lasst.¨ Diese Verfahren lassen sich unverandert¨ auf andere Messsysteme anwenden und ermoglichen¨ somit direkte Vergleiche. Es wird die praktische Umsetzung eines WSN beschrieben, auf dem die entwickelten Methoden zur Datenerfassung implementiert wurden. Alle Implementierungen wurden mit den vorgeschlagenen Testverfahren untersucht. Hierdurch konnte gezeigt werden, dass die Interrupt-Bearbeitung der Sensorknoten entscheidenden Einfuss auf die Mess- datenerfassung hat. Weiter konnte durch den Einsatz von Fixed-Punkt-Arithmetik die drehwinkelsynchrone Datenerfassung in Echtzeit realisiert werden. Schließlich wird die Nutzlichkeit¨ der implementierten Datenerfassung an zwei Anwendungen gezeigt: der akustischen Ortung zweier Sensorknoten sowie einer einfachen Ordnungsanalyse.

viii Contents

1. Introduction1 1.1. Thesis structure ...... 2 1.2. Thesis contribution ...... 3

2. Literature review5 2.1. Wireless sensor networks ...... 5 2.1.1. Hardware ...... 5 2.1.2. Software ...... 13 2.1.3. Network topologies ...... 16 2.1.4. Network protocols ...... 18 2.1.5. Conclusions ...... 27 2.2. Time synchronization protocols ...... 28 2.2.1. Classes of synchronization ...... 28 2.2.2. Building blocks of synchronization protocols ...... 30 2.2.3. Evaluation of synchronization protocols ...... 35 2.2.4. Synchronization protocols for wireless sensor networks . . . . . 36 2.2.5. Synchronization protocols in other domains ...... 40 2.2.6. Conclusions ...... 44 2.3. Data Acquisition with wireless sensor networks ...... 44 2.3.1. Data acquisition ...... 45 2.3.2. Time synchronous data acquisition ...... 48 2.3.3. Wireless sensors and smart sensors ...... 49 2.3.4. Conclusions ...... 51 2.4. Synchronous angular sampling ...... 52 2.4.1. Signifcance and applications ...... 52 2.4.2. Algorithms ...... 54 2.5. Conclusions ...... 56

3. Theoretical foundations 59 3.1. Time and synchronization ...... 59 3.1.1. Time ...... 59 3.1.2. Clocks ...... 61 3.1.3. Synchronization ...... 63 3.1.4. Generalized time ...... 63

ix Contents

3.2. Data acquisition ...... 63 3.2.1. Uniform sampling ...... 64 3.2.2. Nonuniform sampling ...... 66 3.2.3. Data acquisition structures ...... 68 3.3. Digital resampling ...... 70 3.3.1. Spectral efects and flter requirements ...... 70 3.3.2. Filter algorithms ...... 74 3.3.3. Number formats ...... 83 3.4. Quality of measurements and signals ...... 87 3.4.1. Measurement uncertainty ...... 87 3.4.2. Signal quality ...... 92 3.4.3. Estimation of signal parameters ...... 94

4. Modeling 99 4.1. System model ...... 99 4.1.1. Event detection ...... 99 4.1.2. Waveform sampling ...... 100 4.2. Acquisition errors ...... 101 4.2.1. Event detection ...... 101 4.2.2. Waveform sampling ...... 106 4.2.3. Specifcation of synchronization precision ...... 113 4.3. Estimation of the required synchronization precision ...... 113 4.4. Approaches to time synchronous data acquisition ...... 114 4.4.1. Event detection ...... 115 4.4.2. Waveform sampling ...... 115 4.5. Approaches to synchronous angular sampling ...... 116 4.6. Testing data acquisition systems ...... 118 4.6.1. Synchronous event detection ...... 118 4.6.2. Synchronous waveform sampling ...... 119 4.6.3. Synchronous angular sampling ...... 121

5. Implementation 123 5.1. Wireless sensor network for experiments ...... 124 5.1.1. Sensor nodes ...... 124 5.1.2. Execution environment ...... 128 5.1.3. TDMA-protocol ...... 134 5.1.4. Data acquisition framework ...... 135 5.1.5. Application transducers ...... 147 5.1.6. Installation at induction motor test bench ...... 157 5.2. Time synchronous data acquisition ...... 159 5.2.1. Synchronization services ...... 159 5.2.2. Event detection ...... 165 5.2.3. Waveform acquisition ...... 165

x Contents

5.3. Synchronous angular sampling ...... 168 5.3.1. Choice of resampling algorithm ...... 168 5.3.2. Filter adaptation ...... 172 5.3.3. Filter design ...... 172 5.3.4. Implementation of flter algorithm ...... 174 5.3.5. Network integration ...... 177

6. Experiments 181 6.1. Wireless sensor network ...... 181 6.1.1. Power consumption ...... 181 6.1.2. Data throughput ...... 188 6.2. Time synchronous event detection ...... 192 6.2.1. Experimental setup ...... 193 6.2.2. Relative drift of clocks ...... 194 6.2.3. Synchronization precision ...... 195 6.2.4. Power consumption ...... 203 6.2.5. Conclusions ...... 204 6.3. Application example: acoustic localization ...... 205 6.3.1. Model ...... 205 6.3.2. Estimation of required synchronization accuracy ...... 206 6.3.3. Experiments ...... 207 6.3.4. Results ...... 209 6.3.5. Uncertainty analysis ...... 212 6.3.6. Conclusions ...... 216 6.4. Time synchronous waveform acquisition ...... 217 6.4.1. Experimental setup ...... 217 6.4.2. Signal quality ...... 218 6.4.3. Missing samples ...... 224 6.4.4. Power consumption ...... 225 6.4.5. Conclusions ...... 226 6.5. Synchronous angular sampling ...... 227 6.5.1. Analysis of measurement chain for angular sampling ...... 227 6.5.2. Test of resampling algorithms ...... 231 6.5.3. Acquisition of generated signals ...... 236 6.5.4. Data acquisition at motor test bench ...... 240 6.5.5. Conclusions ...... 246

7. Conclusions and outlook 247 7.1. Summary ...... 247 7.2. Conclusions ...... 248 7.3. Outlook ...... 250

Bibliography 263

xi Contents

Appendix 285

A. Sensor Nodes 287

B. Evaluating the polynomial kernel of a transposed Farrow flter 291

C. Application sensors 294 C.1. Microphone ...... 294 C.2. Current and voltage sensors ...... 295 C.3. Rotary encoder ...... 297

D. Angular resampling fler 298 D.1. Filter design ...... 298 D.2. MATLAB implementation ...... 300 D.3. C implementations ...... 302 D.3.1. C foating-point implementation ...... 302 D.3.2. C fxed-point implementation ...... 306 D.3.3. C header fles for foating- and fxed-point ...... 313

E. Results of event timestamping experiments 315 E.1. Network confguration 2 ...... 315 E.2. Network confguration 3 ...... 317 E.3. Network confguration 4 ...... 319 E.4. Network confguration 5 ...... 321 E.5. Network confguration 6 ...... 323 E.6. Network confguration 7 ...... 324 E.7. Network confguration 8 ...... 326

xii Nomenclature

Notations

Notation Description E(x) expectation value of random variable x Qm.n Q-format of a fxed-point number Var(x) variance value of random variable x X( jω) Fourier transform of x(t) ∆x systematic error in x ∆x diference in x x¯ empirical mean of x δx random error in x ϵx error in measurement of x F {x(t)} Fourier transform of x(t) O( f (x)) Bachmann–Landau notation, i.e. grows asymptotically like f (x) σx true standard deviation of x X matrix x vector ˆx estimate or measurement value of x ˜x value or measurement for x that is aficted by error a { b event a happened before event b f (x) mathematical function fX probability density function of random variable X sx empirical standard deviation of x ux standard measurement uncertainty of x x′ modifed version of x′/quantity similar to, but diferent from x x(t) continuous time signal x[n] discrete time signal th xn n member of a set of values

xiii Symbols

Symbols

Symbol Description Unit G weighting factor of probability distribution H transfer function of a LTI-system L interpolation factor M decimation factor th Ni i N number of elements or samples OS R oversampling ratio O signal order, i.e. signal component whose frequency is an integer multiple of the rotational frequency P0.25 25 %-percentile of a distribution P0.75 75 %-percentile of a distribution P probability Qm.n Q-format of a fxed-point number Q flter order R rate change factor Ts sampling interval s Tclock clock resolution s Tsync (re)synchronization interval s Ttick clock resolution s T time interval s Uk expanded uncertainty with coverage factor k arb Vdc DC voltage V Vpp peak-to-peak voltage V V electrical voltage V W signal bandwidth rad/s Φ angle interval rad αt signifcance level of a statistical test αrms RMS-value of a signal arb 2 αrot angular acceleration rad/s α amplitude of a sine wave arb δ Dirac delta function η RMS-value of signal noise arb ωN Nyquist frequency rad/s ωp flter passband edge rad/s ωs sampling frequency rad/s ωsignal signal frequency rad/s ωstop flter stopband edge rad/s ω angular frequency rad/s ϕ rotation angle rad

xiv Symbol Description Unit ρ clock drift ppm σ true standard deviation ϑ temperature °C c(t) clock s ci sensitivity factor of uncertainty contribution arb fg flter 3 dB-cutof frequency Hz fϕ angular rate 1/rev f frequency Hz hc counter of a clock h impulse response of a LTI-system k coverage factor of uncertainty l counting index nrot rotational speed rpm n counting index pt p-value of a t-test p clock precision s q numeric resolution or counting index s empirical standard deviation t time instant s uc combined standard uncertainty arb u standard uncertainty arb vsound speed of sound m/s v degrees of freedom w white noise arb x generic quantity or signal arb

Abbreviations

6LoWPAN IPv6 over Low-Power Wireless Personal Area Networks ADC analog-to-digital converter API application programmers interface ASCII American Standard Code for Information Interchange BIPM International Bureau of Weights and Measures BLE low energy BNC Bayonet Neil-Concelman connector BSD Berkley Software Distribution

xv Abbreviations

CAN Controller Area Network bus CIC cascaded integrator-comb flter CMOS complementary metal-oxide-semiconductor CMSIS Cortex Microcontroller Software Interface Standard CoAP Constraint Application Protocol CPU central processing unit CRC cyclic redundancy check CSMA carrier sense multiple access CSMA/CA carrier sense multiple access with collision avoidance CRB Cramer-Rao´ bound DAG directed acyclic graph DAQ data acquisition DC direct current DFT discrete Fourier transform DSP digital signal processor DSSS direct-sequence spread spectrum DMA direct memory access DMM digital multimeter DTLS Datagram Transport Layer Security ECG electrocardiogram EMSP Chair of Electronics and Medical Signal Processing at the TU Berlin ETA Elapsed Time on Arrival EU European Union FFD full-function device FFT fast Fourier transform FIFO frst in, frst out bufer FIR fnite impulse response flter FPU foating-point unit FTSP Flooding Time-Synchronization Protocol

xvi Abbreviations

GPIO general-purpose input/output pin GPS Global Positioning System GUM guide to the expression of uncertainty in measurement HTTP Hypertext Transfer Protocol HRTS Hierarchy Referencing Time Synchronization ID identifcation number IEC International Electrotechnical Commission IETF Internet Engineering Task Force IIR infnite impulse response flter IP Internet Protocol IPv6 Internet Protocol version 6 IRQ interrupt request ISA International Society of Automation ISM industrial, scientifc and medical ISO International Organization for Standardization LED light-emitting diode LLN low-power and lossy network LTI linear time-invariant system LOADng Lightweight Ad hoc On-Demand - Next Generation MAC medium access control MDT Chair of Electronic Measurement and Diagnostic Technology at the TU Berlin MEMS microelectromechanical systems MSTL MDT smart transducer library MUX multiplexer NAD noise and distortion NCAP network-capable application processor NTP Network Time Protocol OS operating system OSR oversampling ratio

xvii Abbreviations

PC personal computer PCB printed circuit board PI proportional-integral PHY physical layer PLL phase-locked loop PLC power-line-cycle PPG Photoplethysmogram PPS one pulse per second PTP Precision Time Protocol RAM random access memory RBS Reference Broadcast Synchronization RC resistor-capacitor circuit/oscillator RDC radio duty-cycling rev revolution RF radio frequency RFD reduced-function device RITS Routing Integrated Time Synchronization RMS root-mean-square value RMSE root-mean-square error RPL Routing Protocol for Low-Power and Lossy Networks RTC real-time clock RTP Real-Time Transport Protocol RTSI Real-Time System Integration bus SAR successive approximation ADC SCTS Self-Correcting Time Synchronization S&H sample-and-hold SI International System of Units SINAD signal-to-noise and distortion ratio SNMP Simple Network Management Protocol

xviii Abbreviations

SNR signal-to-noise ratio SPI serial peripheral interface STFT short-time Fourier transform TCP Transmission Control Protocol TDMA time division multiple access TEDS transducer electronic data sheet THD total harmonic distortion THE total harmonic energy TIM transducer interface module TPSN Timing-Sync Protocol for Sensor Networks TSCH time-synchronized channel hopping TSMP Time Synchronized Mesh Protocol UART universal asynchronous receiver transmitter µC microcontroller UDP User Datagram Protocol USB Universal Serial Bus UTC Coordinated Universal Time VM virtual machine WISA Wireless Interface for Sensors and Actuators WLAN wireless local area network WSN wireless sensor network WTIM wireless transducer interface module

xix

1. Introduction

Wireless sensor networks (WSN) are networks of small, low-cost sensing devices with integrated processing capabilities that communicate wirelessly with each other [64, 138, 50]. They are seen as a key component in technological visions like ambient intelligence [64], the internet of things [128] or cyber-physical systems [80]. Already a broad spectrum of applications for WSNs has been explored in areas including envi- ronmental monitoring, health care, home automation, condition monitoring, industrial automation and scientifc data acquisition [64, 138, 50].

The key advantage of WSNs is the ease of installation and extension that arises from not having to lay cables [64, 81, 113, 63, 59]. The resulting reduction in working time together with reduced material usage can lead to signifcant cost reductions [64, 63]. Furthermore, digitizing and processing sensor data directly at the spot, where it is acquired, can increase its quality as well as its utility. Other advantages of WSNs are the mobility of the wireless sensing devices [64] and the possibility to easily extend their capabilities through software updates [63].

WSNs are a comparatively new research topic, with only few publications before the year 2000 [138]. However, in the last 16 years, WSNs have enjoyed strongly increas- ing attention from scientist and science funding bodies [138]. WSNs are an inherently multidisciplinary area of research. The topics involved range from the miniaturization of electronic components over energy storage, low power electronics, radio communi- cation and software design to measurement data processing and user interaction [64].

One of the biggest challenges, when using WSNs, is to efciently combine and process the measurements from multiple sensor nodes. Knowing the time relation between data from diferent nodes is a prerequisite for deriving a consistent observation of the environment. Therefore, synchronizing the data acquisition of multiple nodes is of key importance. So far, a lot of research efort has been put into accurately and efciently synchronizing the clocks of wireless sensor nodes [79, 119, 64]. However, the efect of the synchronization accuracy on the quality of measurement results has hardly been studied. Not even a commonly accepted measure of synchronization accuracy seems to exist. Furthermore, the focus on synchronizing clocks has occluded the fact, that in many applications it is more important to synchronize to external events or processes. An example of this is the angular position of a rotation machine in synchronous angular sampling.

1 1. Introduction

The goal of this thesis is to investigate key metrological aspects of synchronous data acquisition with WSNs, especially the relation between synchronization accuracy and quality of measurement results. The results of this investigation are used to optimize strategies for time synchronous data acquisition. Furthermore, the strategies for time synchronous sampling are generalized, in order to enable synchronous angular sam- pling on a WSN. A focus is put on applications in the scientifc and industrial domains. As WSNs are a very multidisciplinary topic, this thesis aims to be understandable to readers from various backgrounds in engineering and computer science. Therefore, fundamental concepts from the individual disciplines are briefy introduced before their usage.

1.1. Thesis structure

This thesis is structured as follows: Chapter 2 - Literature review The current literature on WSN, time synchronization and synchronous angular sam- pling is reviewed in this section. Through this, key concepts and terminology in those felds are introduced as well. The results of this review are used to identify defciencies in the current state of the art. At the end of the chapter the guiding questions of this thesis are formulated. Chapter 3 - Theoretical foundations This chapter lays the theoretical foundations for those following. It starts by reviewing the essential properties of time, synchronization and clocks. After this, the structures and theorems fundamental to data acquisition are given. The basic ideas and algorithms for digital resampling are treated, as they will be used to process and synchronize data in later chapters. Finally, the concept of measurement uncertainty as defned by the guide to the expression of uncertainty in measurement (GUM) and quality indicators for acquired waveforms are introduced. Chapter 4 - Modeling The models and quantitative measures, that describe the efect of synchronization ac- curacy on the quality of measurements, are developed in this chapter. Building on this modeling, a method to estimate the required synchronization accuracy is derived. Fur- thermore, strategies for the synchronous data acquisition with WSNs and methods to test the synchronization precision are developed. Chapter 5 - Implementation This chapter describes the WSN that was built-up for this thesis and used in the experi- ments. First, the general aspects of the WSN are introduced, including the sensor nodes and software environment, that were chosen. Second, the software framework for data acquisition and applications sensors, that were developed for this thesis are described.

2 1.2. Thesis contribution

Furthermore, the installation of the WSN at an induction motor test bench is presented. Finally, the implementations of time synchronized data acquisition and synchronous angular sampling on the WSN are described in detail. Chapter 6 - Experiments The experiments, which were done to characterize the implementations of synchronous data acquisition, and their results are presented in this chapter. First, the data throughput and power consumption of the WSN are investigated. Next, the synchronous event timestamping of the WSN is examined and used for the acoustic localization of sensor nodes. Furthermore, experimental results for synchronous waveform acquisition with the WSN are discussed. The chapter concludes with synchronous angular sampling experiments on simulated signals as well as at an induction motor test bench. Chapter 7 - Conclusions and outlook This chapter summarizes and discusses the key results of the investigations. As a re- sult of this discussion, answers to the guiding questions of this thesis are formulated. Finally, possible directions for new research following this thesis are outlined.

1.2. Thesis contribution

The key contributions of this thesis can be summarized as follows: 1. Models for the time synchronous data acquisition with WSNs have been devel- oped (see section 4.1 and 4.2). Those, models have been proven to be useful for describing and optimizing synchronous data acquisition with a WSN (see section 4.4). 2. Measures of quality for synchronous data acquisition have been defned in sec- tion 4.2. These measures can be used to calculate the measurement uncertainty according to the GUM as demonstrated for the example of acoustic localization in section 6.3. 3. It has been shown, that infuences other than synchronization errors, e.g. signal noise, analog group delay and even the clock resolution itself, can lead to equiv- alent errors in the measurement result (see sections 4.2 and 6.3). Thus, further optimizing the synchronization accuracy is not sensible, if its infuence is small compared to those other error sources. 4. It has been shown in section 4.2.1.6, that the uncertainty of a synchronized clock can be expressed through an efective clock resolution. This enables a fast and intuitive evaluation of synchronized time sources. In this, the efective clock resolution is similar to the efective number of bits, which is commonly used to characterize analog-to-digital converters.

3 1. Introduction

5. A procedure, that can be used estimate the required synchronization accuracy given the maximum desired uncertainty in the measurement result, has been de- fned in section 4.3. This appears to be the frst systematic approach to determin- ing the synchronization accuracy required for an application. 6. Methods to test synchronous data acquisition that can easily be applied to any data acquisition system have been defned in section 4.6. Thus, a direct compar- ison between WSNs and other data acquisition systems becomes possible for the frst time (see sections 6.3 and 6.4). 7. Two distinct approaches to time synchronous data acquisition have been identi- fed: a proactive and a reactive one (see section 4.4). The characteristic advan- tages and disadvantages of these approaches have been analyzed and investigated in experiments (see sections 6.2 and 6.4). 8. Experiments on synchronous data acquisition have been done, which show that delays in the sensor node software can cause errors in synchronous data acquisi- tion, that are far larger than the synchronization errors of the clock. These delays were mostly caused by interrupt blocking sections in the duty-cycling operations of the node (see section 6.2). This shows that the real-time performance of a sen- sor node is essential to synchronous data acquisition capabilities. All subsystems of the sensor node software should be designed with this in mind. 9. It has been shown in section 4.5 that resampling a signal, that has been acquired at a constant time interval, over a constant angle interval, is equivalent to trans- ferring the signal from a nonuniform angle sampling grid to a uniform one. This enables a better founded treatment of the problem, by using nonuniform sampling theory. 10. Synchronous angular sampling has been implemented on the WSN in real-time (see sections 5.3 and 6.5). This was achieved through the efcient use of fxed- point arithmetic. It is, to the best of the author’s knowledge, the frst such imple- mentation on a WSN.

4 2. Literature review

This chapter presents a review of the literature on synchronous data acquisition with wireless sensor networks. An overview of the currently available hard- and software as well as the state-of-the-art protocols is given in section 2.1. Due to their special relevance to the purpose of this thesis time synchronization protocols are reviewed sep- arately in section 2.2. Section 2.3 gives an overview of current applications and solu- tions for data acquisition with wireless sensor networks. The literature on a special type of synchronized data acquisition: synchronous angular sampling is reviewed in section 2.4. Finally the conclusions that can be drawn from the literature review are presented in section 2.5.

2.1. Wireless sensor networks

Wireless sensor networks (WSNs) are defned by most authors as networks of small, low-cost devices with sensing, processing and communication capabilities [64, 138, 50]. Despite the literal meaning of the term, it is generally understood that they can also contain actuator components [64]. This section gives an overview of the state-of-the-art in WSNs regarding hardware, software and protocols with a focus on applications in the scientifc and industrial domain.

2.1.1. Hardware

The electronic devices that form WSNs are called wireless sensor nodes, motes or sim- ply sensors [50]. In [64], their main components are named as: sensor and actuator circuits, microprocessor, wireless communication interface and power supply. Within the past years many diferent hardware platforms for wireless sensor nodes have been developed. Overviews of the platforms used by the scientifc community can be found in [10, 184, 166]. A review of diferent platforms for the use in industrial applications can be found in [59]. The sensor nodes used by the scientifc community are often just bare printed circuit boards (PCBs) and do not include a power supply or actual sensing circuits. The pur- pose of these nodes is to serve as basic test systems in a lab environment. Alternatively,

5 2. Literature review they can be used as a generic basis for building application specifc sensor nodes. Of those basic general purpose nodes, the family of mica nodes, originally developed at the university of Berkeley and later marketed by Crossbow and Memsic inc., have been amongst the most widely used [184, 64, 138, 50, 56, 87, 77, 42]. The Tmote Sky sensor nodes [183] have served as a reference platform for the operating system [186] for a long time. Now, nodes like the Z1 [192] or econotag [167] gradually replace them [186]. Other sensor nodes used by the scientifc community are the GINA [92] and MANTIS [13] nodes. Examples of sensor nodes developed at German universi- ties are the SPISA (Technische Universitat¨ Berlin) [117, 181], ESB (Freie Universitat¨ Berlin) [50] and INGA [171] nodes (Technische Universitat¨ Braunschweig) nodes. In recent years an increasing number of sensor nodes using ARM’s Cortex-M3 core have emerged, e.g. the Preon32 [179] or OpenMote-CC2538 [176]. Table 2.1 shows the key features of typical general purpose nodes. A more comprehen- sive table of sensor nodes is provided in appendix A (tables A.1 to A.3). Unfortunately, diferent manufacturers specify the power consumption for diferent operational condi- tions. Likewise, sensor nodes do contain a difering amount of components, e.g. the MicaZ includes a battery holder, whereas the Preon32 does not even include a volt- age regulator. Thus, the numbers for power supply and dimensions merely illustrate the range that can be found, but are not well suited for direct comparisons between individual nodes. Apart from the general purpose sensor nodes, application specifc sensor nodes have been developed in research projects (see table 2.2). Examples are the sensor node developed for condition monitoring in the ECoMoS project [63] or a pulseoximeter developed by the chair of Electronics and Medical Signal Processing (EMSP) at the TU Berlin [108]. Examples of commercial sensor nodes that are tailored to specifc applications are the wireless temperature sensor STM 330 by EnOcean and the wireless data acquisition module WSN-3202 by National Instruments. Based on the properties of the sensor nodes described above as well as literature on WSNs the common properties of the key components: controller, communication in- terfaces, clocks, sensing hardware and power supply will be given in the following.

6 2.1. Wireless sensor networks

Table 2.1.: Examples of basic general purpose sensor nodes. MicaZ Tmote Sky Spisa Preon32 CPU family Atmel AVR TI MSP430 dsPIC ARM Cortex-M3 CPU bit [MHz] 8 16 16 32 CPU clock [MHz] 8 ≤ 8 7.37 8 ... 72 RAM [kB] 4 10 2 64 FLASH [kB] 128 48 48 256 wireless standard IEEE 802.15.4 IEEE 802.15.4 none IEEE 802.15.4 frequency band 2.4 GHz 2.4 GHz 433 MHz 2.4 GHz ADC resolution [bit] 10 12 12 12 max. sampling- [kS/s] 15 200 100 1000 rate interfaces GPIO, I2C, GPIO, UART, GPIO, UART, GPIO, UART, SPI, UART I2C I2C, SPI I2C, SPI, CAN, USB supply voltage [V] 2.7–3.3 2.1–3.6 5.6–6.6 2.7–3.6 power active [mW] 36 5.4 n/a 11.1–84.9 power sleep [mW] 0.048 0.0153 n/a 3.9 power sending [mW] 88.2 65.4 n/a 47.9–121.8 power receiving [mW] 95.1 58.5 n/a 53.1–126.9 dimensions [mm] 58 x 22 32 x 80 70 x 74 27.5 x 19 (l x w) operating system Contiki, Contiki, custom (Contiki), Java TinyOS TinyOS manufacturer Berkeley, Moteiv TU Berlin Virtenio Crossbow, Memsic reference [173] [183] [117, 181] [179] n/a = no information available

7 2. Literature review

Table 2.2.: Examples of application specifc sensor nodes. ECoMoS EMSP STM300/330 WSN-3202 CPU family TI TI MSP430 8051 n/a TMS320C55x CPU clock [MHz] 16 16 16 n/a wireless protocol custom Bluetooth EnOcean IEEE 802.15.4 frequency band 868 MHz 2.4 GHz 868 MHz 2.4 GHz sampling-rate [S/s] ≥ 32, 000 500 ∼ 0.001 (typ.) ≤ 1 sensors vibration pulseoximeter temperature analog voltage application vibration building pollution data analysis, automation monitoring acquisition condition monitoring power supply thermal batteries solar batteries, harvester harvester external life on batteries ∞ > 24 h ∞ 1 m–3 y supply voltage [V] 1.8 ∼ 3.3 V 2.1–4.5 3.6–30 max. power [mW] 36 146.9 99 n/a power sleep [mW] < 0.01 n/a ≥ 0.0006 n/a dimensions [mm] 58 x 45 n/a 43 x 16 x 8 42 x 86 x 124 (h x ∅) (l x w x h) (l x w x h) reference [63] [108] [175] [209, 206, 207] n/a = no information available

8 2.1. Wireless sensor networks

2.1.1.1. Controller

Wireless sensor nodes almost exclusively use microcontrollers that have a Harvard ar- chitecture [130]. They contain a central processing unit (CPU), non-volatile program memory (FLASH), volatile data memory (RAM) as well as a number of peripheral units, like analog-to-digital converters (ADCs), timers or digital communication inter- faces. The microcontrollers used tend to be small, low-cost and low-power models. In the past 8 bit microcontrollers like those of the AVR family from Atmel and 16 bit microcontrollers like those of the MSP430 family from Texas Instruments were used almost exclusively. Their processor clock was typically in the range of 4–16 MHz. Memory sizes were in the range of 2–16 kB for the RAM and 48–256 kB for the FLASH. Typical examples of this class of sensor nodes are the Micaz [173], Tmote Sky [183] or Z1 [192] sensor nodes. Despite some authors predicting that the ad- vances in computer technology would not lead to more capable sensor nodes [130], there has been a trend towards more powerful microcontrollers in recently developed sensor nodes. They are mostly based on low-power ARM processors with Cortex-M3 core and feature processor clocks of up to 72 MHz, RAM sizes of up to 96 kB and FLASH sizes of up to 512 kB. Examples are the econotag [167], Preon32 [179] or OpenMote-CC2538 [176]. Most microcontrollers have a power consumption in the range of several 10 mW when operating, but can reduce it to 1–100 µW by entering a sleep-mode. Most microcon- trollers ofer a set of diferent sleep modes that allow the user to select the remaining functionality. An analysis given in [63] shows that using a more potent microcon- troller may result in a lower overall power consumption because calculations are fn- ished quicker and the node can rest longer in sleep-mode. In other words, more potent microcontrollers often have a better efciency in terms of energy per executed instruc- tion [63].

2.1.1.2. Communication interfaces

The second essential component of a wireless sensor node is its wireless communica- tion interface. In most cases it uses electromagnetic waves in the radio frequency (RF) spectrum as a transmission medium 1. See section 2.1.4.1 for a discussion of transmis- sion standards and frequency bands. Most wireless sensor nodes, e.g. the MicaZ [173] and Preon32 [179], use dedicated transceiver chips. These transceivers take care of the low level communication, like modulation and demodulation. They usually contain a bufer for incoming as well as outgoing data and have a digital interface over which the controller can read and

1Examples of other transmission media are sound and ultrasound waves as well as infrared and visible light pulses [64].

9 2. Literature review write entire data packets. In some cases this functionality is already implemented as an additional peripheral on the microcontroller, e.g. in the OpenMote [176].

There is a wide consensus that the wireless transceiver has a major infuence on a node’s total power consumption [64, 130, 34, 63]. In [64] it is stated that transceivers typically consume about 20 ... 30 mW when transmitting, but the power actually radiated is only about 1 mW, i.e. the energy cost of signal processing clearly outweighs that of the actual transmission. Furthermore, the power consumption during reception may even be higher than during transmission: typically 10 ... 40 mW. Shucker et al. [130] state that the energy cost of transmitting one bit is approximately one thousand times higher than that of processing a bit. A similar statement is made in [112]: transmitting 1 Kb over 100 m and executing 3 million instructions require the same amount of energy. This is echoed by the fndings reported in [59] that calculating the fast Fourier transform (FFT) on a wireless sensor node and only transmitting the frequency limes of interest can save over 98 % of energy compared to transmitting the entire raw data.

Apart from the wireless communication interface wireless sensor nodes have a number of wired interfaces that enable them to communicate with other devices like external sensors or computers. Simple digital interfaces like a universal asynchronous receiver transmitter (UART), a serial peripheral interface (SPI) or an interface for the I2C-bus are present on nearly all sensor nodes (compare table 2.1). But also more complex interfaces like USB or CAN-Bus can be found, e.g. on the Preon32 node.

2.1.1.3. Clocks

Wireless sensor nodes need a stable clock signal for time keeping, to run the processor and for the wireless communication. The oscillator circuits used to generate it are mostly crystal- or RC-oscillators and less frequently MEMS-resonators [137].

Crystal-oscillators have a frequency stability in the range of 1–100 ppm [137]. How- ever, their power consumption is relatively high and rises with the clock frequency. RC-oscillators are much cheaper and require less power [137]. Furthermore, they can be integrated into the silicon chip of the microcontroller enabling smaller sensor nodes. Yet their frequency stability is only in the order of several 1000 ppm.

As a consequence, many sensor nodes use a separate 32 kHz crystal oscillator for time keeping, e.g. the Inga [171] and Preon32 [179] nodes. This makes it possible to turn of the high-frequency clock of the processor during sleep modes to minimize the power consumption. Another possibility is to run the processor from a less stable RC-oscillator, thus saving power without losing accuracy for time keeping. This also speeds up the wake-up from sleep modes because RC-oscillators need less time to start than crystal oscillators [137].

10 2.1. Wireless sensor networks

2.1.1.4. Sensing hardware

The actual sensors used in wireless sensor nodes are highly application specifc and generally the same that are used in other sensing devices, e.g. thermocouples in [39] or MEMS accelerometers in [80]. According to [149] the cost for the sensors can easily surpass that of the rest of the node hardware. The controllers of wireless sensor often contain a number of peripheral modules that help interfacing to sensor circuits. One of the most important is the ADC, which can be used to digitize analog volt- ages. The ADCs in wireless sensor nodes are mostly successive approximation (SAR) types with a resolution of 10–12 bit and a maximum sampling rate in the order of 10– 100 ksamples/s, in some cases up to 1 Msamples/s (see table 2.1). Furthermore, the con- trollers usually contain a number of timer modules, which can be used to measure times. They are 8–32 bit wide and can be clocked through a variable prescaler either directly from the processor clock or from an external oscillator.

2.1.1.5. Power supply

For the user to have the full beneft of a wireless sensor not only its communication but also its power supply has to work without wires [76]. As a consequence most wireless sensor networks are currently using batteries for power supply [121]. Other types of energy storage, e.g. ultracapacitors, have been investigated, but one disadvantage is common to all: the fnite capacity of the storage limits the maximum time that the sensor node can be operated [121]. A possibility to overcome this limitation is to obtain electrical energy from ambient en- ergy sources. This energy-harvesting or -scavenging has been investigated for a variety of energy sources including: solar radiation, thermal gradients, mechanical vibrations and RF-energy [121, 64, 114]. A range of commercial energy harvesting solutions for solar, thermal and mechanical energy is provided by the company EnOcean [169]. The Powercast Corporation ofers a solution to harvest energy from RF-sources in the 850– 950 MHz frequency band [178]. A problem common to all energy harvesting solutions is that the amount of power actually available may strongly vary over time. Thus, they have to be combined with an energy storage and power management circuitry that pro- vides a continuous power supply to the sensor node [64]. Table 2.3 shows an overview of the energy- and power densities that typically can be expected from energy storages and energy harvesting solutions. Comparing that to the power consumption of wireless sensor nodes in tables 2.1 and 2.2 shows that power on a wireless sensor node is scarce. Only very large energy storages or harvesters can sustain the active power consumption of a wireless sensor node, which typically is of the order of several 10 mW, for a long time. Therefore it is often important to put the node into a sleep mode, where the power consumption is much less (0.001–1 mW), as

11 2. Literature review

Table 2.3.: Typical energy- and power densities of power supplies for wireless sensor nodes. Power source Power density Energy density Reference [mW/cm2][J/cm3] primary battery 0.090 mW/cm3·yr a 2880 [121] secondary battery 0.034 mW/cm3·yr a 1080 [121] solar (outside) 10 - [114] solar (inside) 0.01 - [114] temperature diference 0.025–10 - [114] vibrations 0.004–0.1 - [114] RF-harvesting 0.0001–0.001 - [114]

aMean power density for one year of operational lifetime. often as possible. In some applications, however, it may be more feasible to use a mains connected power supply that obliterates these restrictions on power consumption (see e.g. [113]). A possibility to keep many advantages of a mains powered solution without having to use wires is to transmit power through electromagnetic coupling. Powercast, for exam- ple, sells a transmitter that generates RF-energy for its corresponding harvesters. Another means of wireless power transmission is inductive power transfer with loosely coupled coils [101, 160]. ABB provides an inductive power supply with a frequency of 120 kHz for their wireless automation products that is capable of supplying 10– 100 mW to all sensors within a 6 × 6 × 3 m volume [136]. A wireless temperature sensor developed under the supervision of the author uses a closely coupled inductive power supply with a frequency of 3 kHz and secondary power output of 112 mW [Fun6, Stud4].

2.1.1.6. Cost and size

Many authors, e.g. [50], envisage wireless sensor nodes that are so small that they are barely visible and can be deployed nearly everywhere. Another vision often expressed is that sensor nodes will become so cheap that they can be deployed in huge masses without signifcant cost [50]. In this context wireless sensor nodes are often referred to as smart dust [50]. Today’s wireless sensor nodes are still quite far away from this vision. According to [149] the term smart rocks might be more ftting for them. The PCBs of most wireless sensor nodes have edge lengths of several centimeters. Adding power supply and casing volumes of 10 ... 1000 cm3 are easily reached. Although it has been demonstrated that

12 2.1. Wireless sensor networks complete sensors nodes with a volume below 1 cm3 are technologically possible [99, 100], this kind of miniaturized sensor nodes does not appear to be used in most practical applications. Possible reasons are the costs and the design limitations connected to miniaturization.

According to [149] the typical a cost of one sensor node is about 100 $. This is in good agreement with the price for a single OpenMote-CC2538 which is 90 ¤ as of June 2015 [176]. When adding a power supply and a casing this cost often increases signifcantly. Application specifc sensor circuits can add to the price of a sensor node even more [149]. Kagelmaker et al. estimated the cost for one complete sensor node including housing, sensors and energy harvester to be about 800 ¤ in the ECoMoS project [63]. The entire cost of installing and running the system of 1000 sensors over a ten year period was estimated to be 865,000 ¤. Comparing this to the 1,450,000 ¤ estimated for a similar system using a wired feld bus the wireless solution is signifcantly cheaper. This is due to cheaper hardware (1,320,000 ¤ wired vs. 805,000 ¤ wireless) and greatly reduced installation costs (120,000 ¤ wired vs. 10,000 ¤ wireless) [63].

2.1.2. Software

There is a wide consensus that the severely limited energy supply, computing power, memory size and communication bandwidth present unique challenges to software de- sign for WSN [34, 130, 64]. Many projects have therefore been using simple pro- grams that are specifcally designed for the given application and run directly on the sensor nodes [63, 60, 108]. However, also a number of operating systems, that are specially designed for wireless sensor nodes, have been described [34, 130, 64, 30] and used [113, 42, 87, 77]. These operating systems are often so minimal that they may not even be operating systems in the conventional sense [130] but rather execution environments as [64] suggests.

A review of wireless sensor operating systems (OSs) as of 2011 is given by Dutta and Dunkels in [34]. The main tasks of such OSs are described as providing a higher level abstraction of hardware as well as managing energy consumption, task execution and communication. The key advantage of using an OS is that it makes application programs simpler and more portable. Wireless sensor OSs are seen to be similar to embedded real-time operating systems regarding the hardware constraints. A major diference, however, is the much higher communication intensity in wireless sensor OSs [34].

Dutta and Dunkels [34] argue that since wireless sensor nodes have to simultaneously read sensors, process data and communicate with other nodes, concurrent process ex- ecution is essential. As opposed to the multi-threaded execution model found in con- ventional OSs, many wireless sensor OSs use an event driven one. Under this model

13 2. Literature review external or internal events cause the execution of handler functions that are usually exe- cuted to the end. The entire program can be modeled as a state machine with the handler functions managing the transitions. Advantages of the event based model are reported to be greatly reduced memory requirements and shorter execution times. This model works very well as long as the CPU is idle most of the time and handler functions exe- cute fast. If, however, longer calculations are performed, the CPU may be blocked for a long time, as handler functions often cannot be interrupted [34]. Shucker [130] argues that this is a major disadvantage, because the programmer always needs to care about the execution time and porting algorithms from other platforms becomes complicated. As a consequence, hybrid execution models like protothreads have been developed, which allow for a programming style similar to multi-threaded systems but avoid the use of multiple stacks [34, 32]. Other approaches implement multi-threading libraries on top of an event-driven kernel [34].

Another challenge for wireless sensor OSs is the efcient management of memory. It is stated in [34] that in order to avoid fragmentation of data memory, dynamic memory allocation is usually avoided. Instead the programmer preallocates static bufers for diferent tasks. This also has the advantage that the memory requirements of a program are mostly known at compile time [34].

It is stated in [34], that in order to minimize the power consumption, unused compo- nents need to be switched of whenever possible. Doing this duty-cycling through the task management of the OS or the device drivers helps to keep application programs simple [34]. However, Shucker [130] argues that the energy management is often more efcient when controlled by the application, as it has more knowledge about the future behavior of the program.

Shucker [130] states that the network communication stack of a wireless sensor OS may be much more complex than the application program. Due to this complexity communication protocols are discussed separately in section 2.1.4.

2.1.2.1. Wireless sensor operating systems

Dutta and Dunkels name TinyOS and Contiki as the two most widely known wireless sensor OSs [34]. This view is supported by [8]. Other operating systems mentioned in [34] are: Mantis OS (MOS), SOS and LiteOS. Due to their relevance to the re- cent research on WSNs the key characteristics TinyOS and Contiki shall be introduced briefy:

TinyOS [189, 85] is an open source operating system developed specifcally for wire- less sensor networks. It was started by the University of Berkeley together with Intel Research and Crossbow Technology around the year 2000. Now, it is developed by a

14 2.1. Wireless sensor networks worldwide community [154, 189]. TinyOS is written in NesC, a dialect of C that en- ables the user to create applications by connecting diferent components through spec- ifed interfaces [85, 130]. It supports an event-based execution model where every task is invoked by an event and runs to completion [64, 130]. Furthermore, TinyOS contains a comprehensive network communication stack. TinyOS is widely used throughout the scientifc community. In [64] it is even regarded as the de-facto standard OS for wire- less sensor networks. Many wireless sensor protocols have frst been implemented for TinyOS, e.g. the FTSP time synchronization protocol [87] and the CTP data collection protocol [43]. The weaknesses of TinyOS are that its unusual programming model cre- ates a comparatively steep learning curve and that it is not well suited for longer running computations [142]. Newer versions of TinyOS include a multi-threading library that aims to reduce these problems [142]. Contiki [186, 30] is an open source operating system designed for wireless sensor net- works. It was started in 2002 by Adam Dunkels at the Swedish Institute of Computer Science and is now being developed by a worldwide community [151]. It is closely linked to the company Thingsquare later founded by Adam Dunkels [186, 140]. Contiki is written in the C programming language. Like TinyOS it uses an event driven execu- tion model, but supported optional multi-threading from the beginning [30]. Contiki’s key features are protothreads, a very memory efcient way of thread-like program- ming [32], and a full IP networking stack [186]. Amongst its other features are the ability to dynamically load code during runtime, a lightweight fle system for fash memories and a command shell [30, 186]. The target application area of Contiki is the internet of things [186]. Contiki is used in a variety of commercial products in- cluding clip-on powerline sensors, smart thermostats and an urban noise monitoring system [186]. More recently developed OSs are Nano-RK [174, 36], RIOT OS [182, 8] and OpenOS [177, 147]. Nano-RK is a preemptive real-time operating system for wireless sensor networks developed at the Carnegie Mellon University. The frst paper about it was published in 2005 [36]. Nano-RK explores a number of alternative concepts in real- time communication [174]. However, it seems not to be used outside the Carnegie Mellon University. RIOT OS was frst released in 2013 [182]. Its aim is to bridge the gap between standard OS and wireless sensor OS [8]. RIOT OS is implemented in C and C++. It puts a stronger emphasis on real-time capabilities than TinyOS or Contiki. RIOT OS also uses an IP-based network stack and is oriented towards the internet of things [182]. The OpenWSN project had its frst release in 2011 [177]. It is focused on developing an open source network communication stack for the internet of things that is based on standards like IEEE 802.15.4 and 6LoWPAN. However, it also contains a simple priority based non-preemptive scheduler called OpenOS [8]. In [5] the embedded real-time operating system FreeRTOS [170] is extended with a wireless communication stack and used for a WSN. Another alternative to using a specialized wireless sensor OS is programming the wireless sensor nodes using higher

15 2. Literature review level programming environments like the Java virtual machine marketed by Virtenio [190] or LabVIEW that is supported by some sensor nodes from National Instruments [175].

2.1.3. Network topologies

According to [64] a WSN can be represented as a graph, where each sensor node is represented as a node. An edge exists between two nodes, if they can communicate directly. The topology of a WSN is defned as the subset of this graph that is actually used for communication [64]. It is commonly assumed that the network graph of a WSN and thus also its topology may change frequently due to node mobility or changes in the environment [34, 64, 194].

Three general classes of WSN topologies are described in [64]: In a fat topology all nodes have the same functionality, whereas in a hierarchical topology some nodes have specialized roles. A typical form of the latter is a network where several nodes form a backbone and communication only takes place to and along the backbone as shown in fgure 2.1e. The third class is a clustered topology, where nodes are grouped into clusters. Communication takes place mostly within these clusters. Cross-cluster com- munication is only possible via gateway nodes.

In [34] three diferent types of nodes for a hierarchical network topology are defned: Leaf nodes have the least processing power and tightest power constraints. They only acquire data and communicate with the next mesh node. Mesh nodes, having slightly more power available, also relay communication for other nodes. Finally root nodes or base stations establish the connection to the user or external networks. They are described as being mains-powered and having signifcantly more processing and stor- age capabilities than mesh or leaf nodes [34]. A similar concept is described in the IEEE 802.15.4 standard [194]. Here, reduced-function devices (RFDs) communicate only with the next full-function device (FFD). FFDs can communicate with FFDs as well as RFDs.

Apart from those general classes, a number of typical topology forms are described in the literature. In [34] a star topology is described where all nodes only communicate directly with a central coordinator (see fgure 2.1a). Furthermore, a multi-hop mesh is described, where the topology graph can take any form (fgure 2.1c). It is stated in [34] that a multi-hop mesh has higher reliability and reach as well as lower power consumption compared to a star. In [64] it is, however, reported that multi-hop commu- nication only radiates less power in form of radio waves, but may in total consume more power due to additional computations on the forwarding nodes. In [120] two additional network topologies are described: networked star (fgure 2.1d) and tree (fgure 2.1b).

16 2.1. Wireless sensor networks

Figure 2.1.: Topologies for WSNs.

A discussion of WSN topologies for industrial applications is given in [38]. It is stated that star networks are more power efcient but can handle only small numbers of nodes. Mesh networks, on the other hand, can cover larger ranges with many nodes but need more power and have higher latencies [38]. A possible compromise is seen in a star- mesh hybrid topology, which seems to be equal to the networked star described in [120]. In [59] it is stated that the star topology fts naturally with monitoring applications, since all nodes will usually be placed around the device to be monitored. If multiple devices are monitored, [59] suggests to extend the concept and use a topology equivalent to the networked star topology. Another kind of classifcation is made in [38, 120] by distinguishing between ad-hoc and infrastructure networks. Whereas infrastructure networks extend already exist- ing wired networks with wireless communication in the last hop, ad-hoc networks are multi-hop wireless networks that dynamically adapt to changes in the environment. The IEEE 802.15.4 standard uses a similar approach to network topology and defnes a star network with a static topology, as well as a peer-to-peer (mesh) network that can self-organize and may come in the form of a clustered tree similar to a networked star [194].

17 2. Literature review

2.1.4. Network protocols

General reviews of WSN protocols can be found in [138, 64, 50, 34]. They largely stress the need for wireless protocols to deal with frequent and unpredictable transmission er- rors, while efciently using the scarce resources of the sensor nodes. WSNs are there- fore also often characterized as low-power and lossy networks (LLNs) [109, 144]. Spe- cifc discussions of protocols for industrial applications found in [125, 53, 23, 38, 59] largely agree with that but emphasize the need for secure and reliable data transmis- sions. Furthermore, depending on the application, guaranteed maximum transmission delays are required [23, 136]: > 10 ms for process automation and data acquisition, 1– 10 ms for control applications, maintenance and diagnosis applications may even work without hard timing guarantees [23]. The required data throughput is reported to be higher in industrial applications than in other applications [59] of WSNs. Yet, it is not always a top priority [136]. Network communication involves many diferent tasks, which are commonly addressed by a number of diferent protocols. They are typically categorized into several layers similar to those defned in the ISO/OSI reference model [38, 34, 64]. The following protocol layers for WSNs are described in [38]:

• physical layer (ISO/OSI layer 1) • data link layer (ISO/OSI layer 2) • network layer (ISO/OSI layer 3) • transport layer (ISO/OSI layer 4) • upper layers (ISO/OSI layer 5–7) Similar layer defnitions can be found in [34, 64]. A review of the most relevant proto- cols in the diferent layers is given in the following sections. This is concluded with an overview of the most widely used protocol stacks.

2.1.4.1. Physical layer (PHY)

The physical layer (PHY) mainly deals with encoding and transmission of the data us- ing some physical medium [64]. In most applications electromagnetic waves in the RF spectrum are used as transmission medium [64]. Mostly license-free industrial, scien- tifc and medical (ISM) radio frequency bands are chosen, of which the 2.4 GHz band is by far the most popular [64]. Sometimes also the 433 MHz or 868 MHz frequency bands are used. In those bands it is possible to achieve a higher transmission range at the same radiated power. Yet, they can only sustain lower data rates [198]. Higher frequency bands on the other hand, have the advantage of favoring smaller antenna sizes [64].

18 2.1. Wireless sensor networks

There is a wide consensus that a number of physical phenomena can cause frequent and unpredictable transmission errors, referred to as fading [64, 34, 136, 21]. Exam- ples are dampening or refection of electromagnetic waves by static or moving objects in the transmission path [64, 136, 21]. Since the frequency bands used by wireless sen- sor networks are open also to other wireless transmission systems, interference between diferent radio signals is also a major issue [64, 136]. It is even common for the original signal to be interfered by its own refections 2 [64]. Furthermore, wireless communica- tion can be disturbed by electromagnetic radiation from machinery. It is interesting to note in this context that according to [136] typical industrial processes do not radiate signifcant power at frequencies above 1.5 GHz. According to [64] one approach to address these problems is to use direct-sequence spread spectrum (DSSS) modulation. It multiplies the original signal with a pseudo- random sequence known to both transmitter and receiver. This spreads the signal energy over a wider frequency band and lets it appear to be random noise to other systems. At the same time the receiver can recover the signal more easily from a noisy background by using correlation techniques [64]. Another method, discussed in [64, 136] is the frequent and pseudo-random change of transmission frequency. This reduces the likeli- hood of an interference destroying larger parts of the transmission [136]. Furthermore, several antennae at diferent locations may be used simultaneously to reduce the likeli- hood of fading 3 [136]. Several physical layer protocols have been standardized. According to [34] the one defned by the IEEE 802.15.4 standard [194] is the most popular in WSNs. It is intended for simple, low-cost radio systems with limited power and short transmission range. In [59] it is also reported to be the best suited for industrial applications. Table 2.4 shows the frequency bands, transmission channels and data rates defned in the IEEE 802.15.4 standard [194]. In all bands DSSS is used to achieve a more robust transmission [194]. The radiated power is not defned in the standard, but it is stated that typically it is in the range of −3 ... 10 dBm [194].

Table 2.4.: Frequency bands, transmission channels and data rates in the IEEE 802.15.4 standard [194]. Frequency band Number of Channels Bit rate Region [MHz][kbps] 868–868.6 1 20 Europe 902–928.0 10 40 North America 2400–2483.5 16 250 worldwide

2This phenomenon is called multi-path fading. 3This technique is called antenna-diversity.

19 2. Literature review

The physical layers defned in the standards IEEE 802.15.1 (Bluetooth) and IEEE 802.11 (WLAN) have also been discussed for the use in wireless sensor networks [59, 198, 23]. Both use the 2.4 GHz frequency band and defne higher data rates than IEEE 802.15.4: 1 Mbit/s in IEEE 802.15.1 and > 10 Mbit/s in IEEE 802.11 [23]. Fur- thermore, IEEE 802.15.1 uses frequency hopping to increase transmission robustness [23]. However, the radiated power and the power consumption of the transceiver chips are signifcantly higher for IEEE 802.15.1 and IEEE 802.11 than for IEEE 802.15.4 [59, 23]. Therefore, [59] concludes that they are not well suited for the use in wire- less sensor networks. Nevertheless, the company ABB uses a modifed version of the IEEE 802.15.1 physical layer in their industrial wireless products [136, 205]. The ver- sion 4.0 of the Bluetooth specifcation introduced the Bluetooth Smart technology also known as (BLE). It is much more power efcient than the original Bluetooth [164]. Compared to IEEE 802.15.4, BLE appears to be signifcantly more efcient at low data rates (≪ 1 kB/s), whereas at higher data rates (≥ 1 kB/s) it is about equal4 [131, 98]. While BLE appears to be increasingly adopted in consumer products, applications using it for WSNs currently seem to be rare.

2.1.4.2. Data link layer

Karl and Willig [64] state that in WSNs the most important function of the data link layer is to coordinate the access to the shared communication medium. One reason for this is that minimizing the listening and idle times of the wireless transceiver is essential to saving energy. Another reason is that multiple nodes sending at the same time on the same frequency channel will destroy each others’ messages, which is called a collision. Therefore the medium access control (MAC) is treated as a separate layer in [64]. It has a key infuence on the throughput efciency, stability, fairness and delay of the wireless communication [64]. In [64] two classes of MAC-protocols are distinguished: contention- and schedule- based. In contention-based protocols every node tries to transmit whenever it has data ready [64]. This may lead to collisions which waste energy and reduce the data through- put. Therefore, protocols try to avoid collisions, i.e. by listening for an ongoing trans- mission before starting their own or through randomized transmission delays [64]. To save energy nodes, typically listen only for short periods of time. The sending nodes then try to learn about the listening times of their neighbors and only send data when those are listening [64, 34]. In schedule-based MAC-protocols every node is assigned a time slot for transmis- sion [64]. This has the advantage of avoiding collisions while enabling higher through- put and more precisely timed sleeping periods. The major disadvantage of schedule-

4A direct comparison between IEEE 802.15.4 and BLE is difcult, as their power consumptions are strongly dependent on the chosen transmission parameters. In case of IEEE 802.15.4 it is even dependent on the MAC protocol used.

20 2.1. Wireless sensor networks based protocols is the efort that is needed to setup and adapt the schedule to changing requirements. This makes it especially difcult to manage large and frequently chang- ing networks. In addition, the schedule needs to be communicated to the participating nodes and all nodes need to be synchronized to a common time, which both introduce additional communication and memory overhead [64].

A classic example of a contention-based MAC-protocol is carrier sense multiple access with collision avoidance (CSMA/CA) [64]. Here a node listens before sending data. If an ongoing transmission is detected the node waits for a random period of time and then tries again. If the channel is free the node sends its data and waits for an acknowl- edgement from the receiver. If no acknowledgment is received within a given period of time, it assumes that the transmission failed and tries to send the data again.

The ContikiMAC protocol, introduced in [29], is a contention-based MAC-protocol optimized for energy efciency. It is based on a review of previously existing protocols in [34]. In ContikiMAC a receiver periodically wakes up and checks the channel for RF-energy. If this suggests that a transmission is underway, it keeps its receiver on to receive the packet. Otherwise is goes back to sleep. When a node needs to send data, it repeatedly transmits the packet until it receives an acknowledgement. By recording the timing of the acknowledgements a sender learns about the receiver’s sleep schedule and can use this information to minimize the number failed transmission attempts. In [29] it is reported that ContikiMAC needs signifcantly less energy for a wake-up operation of the receiver than previous protocols. As this is deemed the most frequent operation in the network, ContikiMAC is therefore seen to be very energy efcient [29].

A classic example of a schedule-based MAC-protocol is time division multiple access (TDMA) [64]. Here, time is divided into periodically repeating frames. Each time frame consists of a number of time slots which can be assigned to individual nodes for their transmissions. Typically a beacon packet is transmitted at the beginning of every frame to synchronize all nodes.

The Time Synchronized Mesh Protocol (TSMP), introduced in [110], is a schedule- based protocol optimized for the use in industrial applications. Here nodes are assigned time-frequency slots for their send and receive operations. Typically the frequency channel is changed after every slot to increase robustness5. Time synchronization is achieved by including timestamps in the data and acknowledgement packets. When no communication has taken place for a long time (≈ 48 s), so-called keepalive packets are sent to maintain synchronization. Delivery rates above 99.9 % at duty-cycles of about 0.01 % have been reported for TSMP [110]. A MAC-protocol very similar to TSMP has recently been defned in IEEE 802.15.4e, an extension to the IEEE 802.15.4 standard [204]. The general approach of TSMP and IEEE 802.15.4e is referred to as time-synchronized channel hopping (TSCH) by some authors [135].

5This technique is called frequency-hopping.

21 2. Literature review

The classic IEEE 802.15.4 defnes a schedule-based MAC-protocol that contains con- tention access periods, i.e. time-slots that are not dedicated to any node but in which all nodes can access the channel using CSMA/CA [194]. Other data link layer tasks named in [64] are framing, error control, fow control and link management. Typically the data is organized into relatively short frames or packets, e.g. 127 bit in the IEEE 802.15.4 standard. Furthermore, error checking mechanisms like the cyclic redundancy check (CRC) [64, 194] are employed. Also, data link frames are often encrypted [194, 203, 110].

2.1.4.3. Network layer

Routing, packet forwarding and packet format adaptation are named as typical network layer services in [34]. It is also stated in [34] that unlike in conventional networks many-to-one (data collection) and one-to-many (data dissemination) are the dominant communication patterns in WSN. Direct communication of individual nodes (one-to- one) is deemed to be rare. Similar views are also expressed in [109, 64]. Furthermore, the topology of a WSN changes much more frequently than that of a conventional wired network. Therefore, the routing protocols originally developed for wired networks, are generally not well suited for WSNs [64]. Flooding is a primitive approach to data forwarding in a multi-hop WSN, which is often described in the literature [34, 64, 50]. Here a sending node broadcasts its data to all its neighbors, which in turn re-broadcast it to their neighbors. This way the entire network is fooded with the data. A unique message identifer ensures that every packet is resent exactly once by every node. While fooding is efective in ensuring that the data reaches its destination, it leads to a lot of unnecessary packets being sent and may also increase number of packet collisions [34]. According to [64], routing algorithms that calculate minimum cost paths for packet transmission in a wireless network perform best in terms of energy consumption and data throughput. Typical cost metrics are the number of hops from source to destina- tion [64], the expected energy for end-to-end transmission [64] or the expected num- ber of transmission attempts in individual hops [34]. In [64] two classes of routing protocols are described: proactive protocols maintain accurate routing information all the time, while reactive protocols only build it when needed. Furthermore, protocols that calculate the routing paths in a centralized or distributed fashion can be distin- guished [64]. Finally, the routing information may be stored by the nodes or a packet may contain the route it is to be sent along6 [21]. A list of requirements on routing protocols for WSNs in industrial application is given in [109]. It advocates the use of a proactive protocol and states that the routing protocol

6This is called source-routing.

22 2.1. Wireless sensor networks should support multiple cost metrics, prioritize packets depending on the application and quickly recompute paths in case of topology changes. Load balancing should be done between diferent nodes and their energy state should be taken into account. Fur- thermore, the protocol should support redundant routes.

A proactive routing protocol that has been designed by the Internet Engineering Task Force (IETF) to meet the requirements set in [109] is the Routing Protocol for Low- Power and Lossy Networks (RPL) [155]. It has received considerable attention in the literature [34, 128, 144]. According to [144] it has been found to show satisfactory performance especially regarding the speed of route repairs.

Furthermore, [144] compares RPL to a state-of-the-art reactive routing protocol: the Lightweight Ad hoc On-Demand - Next Generation (LOADng) protocol [24]. The key fnding is that RPL outperforms LOADng in nearly all scenarios. The only exception is a network with extremely low trafc [144].

According to [109] networking protocols for WSNs should be compatible to version six of the Internet Protocol (IPv6), as it supports a large address space and provides easy connectivity to other networks, e.g. industrial Ethernet solutions. In [34] it is stated that the layered architecture of IP-protocols allows to retain many optimizations for WSNs and at the same time ensures interoperability with other networks. A standardized so- lution to efciently transport IPv6 network trafc over IEEE 802.15.4 based wireless links is 6LoWPAN [128]. It defnes header compression mechanisms that signifcantly reduce transmission overhead [34, 128]. Furthermore, it supports splitting larger IPv6 data packets (up to 64 kB) into smaller fragments that ft into the much smaller wireless data frames [128]. However, this fragmentation requires large memory bufers on the receiver side as all received fragments of not yet reassembled packets have to be stored. The loss of individual fragments can further complicate the situation. Therefore, it is recommended in [128] to avoid fragmentation in the network layer whenever possi- ble. 6LoWPAN has received considerable attention in the literature [34, 128, 203] and has been implemented on most wireless operating systems and protocol stacks includ- ing Contiki [186], TinyOS [70], RiotOS [182] and OpenWSN [177] (see also section 2.1.2.1).

2.1.4.4. Transport layer

According to [34] reliable and unreliable data transfer, congestion avoidance and fow control are common transport layer services. Furthermore, encryption is often used in the transport layer to provide confdential end-to-end communication [203, 21]. Flam- mini et al. [38] state that the transport layer is usually only implemented in WSNs if they are to be accessed through other networks, e.g. the internet.

23 2. Literature review

The problem of reliable end-to-end data transfer has often been discussed in the con- text of the transport layer: Dutta and Dunkels [34] state that the end-to-end acknowl- edgments needed in this context generally cause too much trafc for WSNs. Karl and Willig [64] also argue that it is not practical to achieve reliable end-to-end data transfer solely in the transport layer. Instead it should also be dealt with in the network and application layer.

Various WSN-specifc transport layer protocols are discussed in [64]. However, it is also stated there that no generally applicable protocol has emerged yet [64]. Due to the increasing use of IP-based protocols in WSNs much attention has been given to the use of the two dominant internet transport layer protocols: TCP and UDP. Both protocols are frequently implemented as part of WSN-operating systems, e.g. Contiki [186], TinyOS [70], RiotOS [182] or OpenWSN [177] (see also section 2.1.2.1).

The Transmission Control Protocol (TCP) is a connection oriented protocol that ensures reliable transmission through end-to-end acknowledgments [128]. However, it gener- ates a signifcant amount of additional protocol data [128]. Furthermore, its congestion control mechanism reduces the packet-rate whenever data loss is detected resulting in suboptimal performance on lossy links [64]. Therefore [128] and [64] agree that TCP is generally not well suited for the use in WSNs.

The User Datagram Protocol (UDP) is a connectionless protocol that uses best-efort data transmission [128]. 6LoWPAN provides a header compression mechanism that eliminates most of the protocol overhead from UDP [128]. According to [128] UDP is a suitable choice for most applications in WSNs and is also most frequently used. UDP’s lack of end-to-end reliability can be compensated by a suitable application protocol [33].

2.1.4.5. Upper layers

According to [38, 34] all protocol layers above the transport layer are usually condensed into a generic application layer in WSNs. Data representation and transfer of data items are the typical services of this layer [34]. Shelby and Bormann state that it is often feasible to use standard internet application protocols like HTTP, SNMP or RTP in WSNs [128]. A lightweight alternative to the Hypertext Transfer Protocol (HTTP) for the implementation of web services is the Constraint Application Protocol (CoAP) [129]. It is implemented in many wireless operation systems, e.g. Contiki [73] and OpenWSN [147]. Application layer protocols for industrial feld buses like the HART protocol have also been used as application level protocols in WSNs [109, 133]. The IEEE Standard for a Smart Transducer Interface for Sensors and Actuators also defnes an application layer protocol that can be used on top of a 6LoWPAN-based WSN (see section 2.3.3).

24 2.1. Wireless sensor networks

2.1.4.6. Protocol stacks

A number of diferent protocol stacks for WSNs have been developed. Figure 2.2 gives an overview of the most prominent ones in the context of industrial automation and the internet of things.

Figure 2.2.: Protocol stacks for wireless sensor networks.

The Wireless Interface for Sensors and Actuators (WISA) was developed by ABB for the use in the control level of factory automation [136]. It comprises a complete wire- less ecosystem consisting of a protocol stack, wireless sensor and actuator nodes as well as a wireless power supply (see also section 2.1.1.5). It is optimized for high transmission reliability, minimum latency transmission and a high node density. The overall data throughput was not a priority [136]. Commercial products based on WISA have been available since 2004. Although WISA was originally an entirely proprietary technology, eforts appear to be made to turn it into an industrial standard [145]. As a physical layer, WISA uses a modifed version of IEEE 802.15.1 (Bluetooth) which uses antenna diversity to make the transmission more robust [136]. In the data link layer a custom TDMA-MAC is used in combination with frequency hopping and frequency di- vision duplex. No network layer protocols are implemented since only a star topology is supported. A simple custom protocol with acknowledgments from the base station is used in the transport layer. In [136] a telegram error rate below 10−9 is reported. The transmission latency is given as 1–5 ms in the typical and 20 ms in the worst case [136]. Furthermore, it is shown that the performance of a WISA transmission deteriorates only slightly under the infuence of a wireless local area network (WLAN) [136]. The WirelessHART standard is developed by the HART Communication Foundation as a part of the HART feld bus for process automation. The frst version of the Wire- lessHART specifcation was ofcially released in 2007 [21]. WirelessHART uses the physical layer of IEEE 802.15.4 in the 2.4 GHz band [21]. Its data link layer is based on the TSMP protocol [110]. Encryption is used both in the data link and in the transport

25 2. Literature review layer. In the network layer three diferent centralized proactive routing algorithms are supported: graph routing, source routing and superframe routing. All can be use to build a self-organizing and self-healing multi-hop mesh network with redundant transmission paths. In the transport layer end-to-end acknowledgments are used to ensure reliable transmission. The application layer of WirelessHART is the same as in HART, allowing for seamless integration of WirelessHART devices into a HART network [21]. The ISA100.11a standard is developed by the International Society of Automation (ISA) [203]. Its frst version was ofcially released in 2009. ISA100.11a is intended to be used in non-critical industrial monitoring and control applications that tolerate latencies in the order of 100 ms. It was designed to enable scalable and extensible networks with robust and deterministic communication on low energy nodes. The ISA100.11a standard is intended to be compatible with a wide range of existing com- munication standards including e.g. HART, FOUNDATION Fieldbus, Modbus and PROFIBUS [23]. ISA100.11a uses the physical layer of IEEE 802.15.4 in the 2.4 GHz band [203]. Its data link layer is based on the TSMP protocol [110]. The network layer of ISA100.11a is intended to be compatible with IPv6 networks using 6LoWPAN, while a custom centralized proactive routing protocol is used. Various network topologies are supported including star, star-mesh and mesh. UDP is used in the transport layer and a custom object oriented protocol in the application layer [203]. ISA100.11a defnes encryption mechanisms in both the data link and the transport layer. ZigBee is a wireless standard developed by the ZigBee Alliance [188]. It is indented for the use in applications like home and building automation, smart metering and health care [74]. The frst ZigBee specifcation was released in 2004. Since then it has been updated and extended multiple times [74]. ZigBee uses IEEE 802.15.4 as physical and data link layer [74]. In the network layer ZigBee uses three diferent routing protocols: a proactive tree-based protocol, an on-demand protocol (AODV [106]) and source rout- ing [74]. ZigBee has an object based application layer that defnes application profles including: home automation, building automation, health care and smart energy [74]. Furthermore, security and encryption are managed at the application layer [74]. Several commercial implementations of ZigBee are available, e.g.: BitCloud (Atmel) [163], EmberZNet PRO (Silicon Labs) [168], Z-Stack (Texas Instruments) [161]. The OpenWSN project aims to implement an open source protocol stack for the inter- net of things based on open standards [147, 177]. It is developed at the University of Berkeley and other research institutions. Its frst release was in 2011. OpenWSN uses IEEE 802.15.4 as physical and IEEE 802.15.4e as a data link layer [147]. The network layer employs IPv6 with 6LoWPAN header compression and RPL as a routing proto- col. The user can choose between UDP and TCP as transport layer protocols. In the application layer CoAP or standard internet protocols like HTTP are used. Encryption in the link layer as well as end-to-end encryption using DTLS is supported [177]. Scholl et al. report ZigBee as being widespread in home automation, WirelessHART as the de-facto standard for process automation and WISA as most promising for factory

26 2.1. Wireless sensor networks automation [125]. Christin et al. compared the WISA, WirelessHART, ISA100.11a, ZigBee and IEEE 802.15.4e for the use in industrial automation with a focus on their real-time performance and security mechanisms [23]. They concluded that Wireless- HART and ISA100.11a ofered the most complete set of real-time mechanisms. Those protocols were said to be well suited for process automation but still failed to satisfy the strict real-time requirements of many factory automation applications [23]. WISA was reported to perform better in this respect but also to have higher energy demands and to have problems with interoperability. ZigBee was judged to be insufcient for industrial applications due to lacking frequency diversity mechanisms. At the time of writing of [23] the IEEE 802.15.4e standard was still under development but was deemed to be very promising.

2.1.5. Conclusions

WSNs are networks of small, low-cost sensor or actuator modules. Today the typical volume of a module is in the range of 10 ... 1000 cm3 and its typical cost between 100 and 1000 ¤. Thus the expected cost reduction from the use of WSNs is estimated be mainly due to reduced installation and maintenance costs but sometimes also due to cheaper hardware. The modules are commonly based on low-cost and low-power microcontrollers. An increase in memory sizes and computing power has been visible over the past years with 32 bit ARM controllers being increasingly favored over 8 or 16 bit architectures. The key limitations of wireless sensor nodes are energy supply, cost and size. Today, most sensor nodes are powered from batteries that can only supply a fnite amount of energy. Energy harvesting solutions have the potential of overcoming this limitation. Yet at the moment, they can only generate very low amounts of electrical power, which in addition may vary greatly over time and are often difcult to predict. Thus, whenever it is not possible to power the nodes from mains power or with an inductive power supply, power saving strategies are of great importance. The most efective strategy for this purpose seems to be duty-cycling, i.e. operating parts of the sensor node only for a short time and then putting them to sleep. The limitations of the sensor hardware in terms of size, cost and power also limit the software that can be run on a wireless sensor node. This has lead to the development of specialized operating systems that aim to reduce the processor and memory usage. Yet also here, a trend towards programming models also found on standard computers is visible. In addition to the limited energy, frequent changes and data loss in the wireless trans- mission medium pose major challenges for communication protocols in WSNs. Thus, a plethora of specialized communication protocols has been suggested. However, most only address one of the many communication tasks and compatibility with other pro- tocols is not always warranted. In the physical layer IEEE 802.15.4 transceivers in the 2.4 GHz band are predominantly used. The protocols for the MAC layer can be

27 2. Literature review divided into two classes: contention-based and scheduled protocols. In industrial ap- plications there is a clear preference for scheduled protocols, as they provide a greater degree of determinism and more data throughput. This is, however, at the expense of fexibility. Additionally, frequency hopping is often used to increase the robustness to interference. In the networking and application layers there is a trend towards IPv6- based protocols as they simplify the integration of WSNs into existing networks. The RPL routing protocol, which proactively maintains a routing tree, is commonly used in this context. Smaller networks, especially in industrial applications, often make use of a much simpler star topology. Already, a number of standardized protocol stacks have been suggested. In the industrial domain WirelessHART and ISA100.11a are the most prominent. ISA100.11a is designed towards IPv6-compatibility and displays interest- ing parallels to the OpenWSN-stack, which is mainly oriented towards the internet of things.

2.2. Time synchronization protocols

Time synchronization is widely seen as an important service in a WSN [79, 119, 64]. Romer¨ et al. [119] state that it is needed to communicate the time of observations or actions to the user, to manage communication within the WSN and to interpret sensor readings. The challenge for time synchronization protocols in WSN is reported to be the management of a possibly large network with dynamically changing topology, while putting a minimum burden on the scarce resources of the sensor nodes [119]. Typical tradeofs described in [119] are those between synchronization quality on the one hand and the additional communication, computation or memory use on the other hand. This section reviews the current state-of-the-art regarding time synchronization in WSNs. Summaries of synchronization protocols for WSNs can be found in [79, 119, 64]. There, the numerous existing protocols are classifed according to a number of crite- ria that are given in section 2.2.1. Furthermore, the protocols are commonly subdivided into several blocks, which are presented in section 2.2.2. Evaluation methods for wire- less sensor nodes, commonly found in the literature, are given in section 2.2.3. Section 2.2.4 presents an overview of the currently most relevant time synchronization protocols for WSNs. Finally, section 2.2.5 reviews a number of time synchronization protocols from other domains and compares them to those used in WSNs.

2.2.1. Classes of synchronization

It is pointed out in [119] that time synchronization may have many diferent forms. In order to choose the optimal time synchronization approach for a given application it is vital to realize the form of synchronization actually needed. This section summarizes the classes of time synchronization commonly found in the literature.

28 2.2. Time synchronization protocols

Internal or external: Romer¨ et al. [119] distinguish between internal and external time synchronization. While internal time synchronization only requires all member of a network to be synchronized, external time synchronization additionally requires the synchronization to an externally provided time scale. A similar distinction can be found in [64].

Implicit or explicit: According to [119] time synchronization may be done implicitly by adding synchronization information to packets that would be sent anyway. Alterna- tively it can be done explicitly by sending dedicated synchronization messages.

Continuous or on-demand: In continuous synchronization, synchronization be- tween the nodes is always upheld, while in on-demand synchronization it is achieved only when needed [119]. According to [119] on-demand synchronization may either be triggered by external events or when a certain time instant is reached. A priori time synchronization, as described in [64], is similar to continuous synchronization, as it achieves synchronization before it is actually needed. A posteriori or post-facto time synchronization achieves a synchronization of timestamps for an event after the event has occurred [64]. It is described as an example of event triggered on-demand synchro- nization [119].

Scope: According to [119] the scope of synchronization defnes which nodes actu- ally take part in it. In [64] synchronization protocols are classifed as to which nodes they actually synchronize: In broadcast synchronization all nodes within a broadcast domain are synchronized. In receiver-receiver synchronization all nodes that receive a signal are synchronized but not the sending node. In sender-receiver the sender and the receiver are synchronized.

Absolute or relative: Relative or rate synchronization only ensures that time inter- vals are the same on all nodes, i.e. it makes all clocks run at the same rate. Absolute synchronization additionally ensures that all clocks show the same time [119, 64].

Synchronization or transformation: Synchronization is mostly defned as making diferent clocks show the same time [119]. However, an alternative may be to transform the timestamps when communicating events to other nodes instead of actually changing the node’s clock [119].

Instants or intervals: According to [119] time information may either be repre- sented by a single time value, possibly with an added uncertainty measure, or as time intervals, where the true time is assumed to be between a lower and an upper bound. A similar notion is expressed in [64] where it is stated that synchronization protocols may either give absolute or stochastic guarantees on their precision.

29 2. Literature review

Kusy et al. [77] analyzed the applications of WSNs that require time synchronization. They concluded that most applications’ needs can be satisfed by one of the four canon- ical time synchronization services shown in table 2.5. It is stated that virtual global time is often implemented because it is conceptually simple. Yet, it is argued that this requires continuous, a priori synchronization and often causes an unnecessarily high communication overhead. It is found that the majority of services requiring time syn- chronization can be implemented with less efort using only on-demand or a posteriori synchronization [77].

Table 2.5.: Canonical time synchronization services and their typical applications according to [77]. Canonical service Synchronization class Typical application event timestamping on-demand, a posteriori intrusion detection countersniper system source localization data series timestamping continuous habitat monitoring (during acquisition), structural monitoring on-demand (otherwise), environment monitoring a priori/a posteriori volcano event monitoring target classifcation beamforming virtual global time continuous, a priori debugging traces coordinated action on-demand, a priori scheduled data collection communications scheduling

2.2.2. Building blocks of synchronization protocols

Time synchronization protocols are structured into several blocks in [64, 119]: Resyn- chronization event detection or synchronization maintenance decides when it is time for nodes to synchronize. Remote clock reading obtains the present value of a remote clock. Remote clock estimation establishes the relation between a local and a remote clock using one or more readings. Clock correction decides how synchronization er- rors are compensated. Finally, synchronization mesh setup deals with the organization in multi-hop networks. This section gives a summary of the main techniques used in every block.

30 2.2. Time synchronization protocols

2.2.2.1. Synchronization maintenance

Both [119] and [64] report that in order to continuously maintain synchronization, it has to be refreshed periodically, because node clocks tend to drift apart. In [119] an equation for the maximum resynchronization period Tround is given:

ϵt,max − ϵt,sample Tround ≤ . (2.1) ρmax

Here, ϵt,sample is the remaining error directly after synchronization, ϵt,max is the maxi- mum accepted synchronization error and ρmax the maximum drift of the clock.

2.2.2.2. Remote clock reading

The task of remote clock reading is to establish the values of a remote clock and the local clock at a common time instant. Figure 2.3 shows the message exchanges in the most common remote clock reading techniques.

Figure 2.3.: Remote clock reading techniques according to [119]: a) unidirectional syn- chronization, b) round-trip synchronization, c) reference broadcast.

In unidirectional synchronization a node Ni simply sends a message containing its local i clock value ta to a second node N j (see fgure 2.3a). Thus, the time of reception is i i i known to be tb = ta + d > ta, where d is the delay. Now a common reading of the i ≈ j − clocks may be estimated by: ta tb (dmin + dmax)/2, where dmin and dmax are the upper and lower bounds for the delay [119]. Often eforts are made to minimize the delay so that it can be neglected d ≈ 0 [87]. An advantage of unidirectional synchro- nization is that it is possible for one sending node to synchronize many receiving nodes with only one broadcast message [119].

31 2. Literature review

In round trip-synchronization the node N j sends a synchronization request to node Ni i which sends back the timestamp tb (see fgure 2.3b). Node N j then estimates the time j ≈ j − tb tc D/2, where D is the round trip transmission delay. This way node N j can synchronize to node Ni. However, in order for node Ni also to synchronize to node N j at least one additional message needs to be send. Compared to unidirectional syn- chronization round-trip synchronization has the advantage that it puts an upper bound j j j on the synchronization error since ta < tb < tc. Its major disadvantage is that it only performs pairwise synchronization causing the number of message exchanges to in- crease linearly with the number of nodes. Thus, modifcations exist where other nodes synchronize themselves by listening to the communication between N j and Ni [119].

In reference broadcast synchronization two nodes Ni and N j or more listen to a broad- cast message sent by the node Nk (see fgure 2.3c). Then node Ni sends its timestamp i j ≈ i j − j ta to node N j which can calculate the time tb ta + D, where D = tb ta is the delay between the reception of the broadcast from Nk and the message from N j, that can be measured locally on N j. The main advantage of the reference broadcast synchroniza- ′ tion is that the delays from node Nk to Ni and N j are usually almost equal d ≈ d , thus a very small synchronization error can be achieved [119]. In all clock reading techniques presented above the message delays d play an important role. It is stated in [119] that the uncertainty of transmission delays in WSNs are large compared to those in wired networks. Five sources of transmission delays are given in [87]: 1. Send time: time between the application issuing the send command and the start of the medium access. 2. Medium access time: time that the node spends waiting for access to the trans- mission medium. 3. Transmission/reception time: time that it takes to transmit the message. It is identical to the time that is needed to receive it. 4. Propagation time: time needed for the radio signal to travel from the sender to the receiver 5. Receive time: time between the reception of the signal and the arrival of the data in the application. Similar lists can also be found in [79, 119]. Figure 2.4 shows typical values for the diferent delay times given in [87]. The key result is that the processing of the packet and especially the channel access can cause large uncertainties while the transmission process itself is largely deterministic. Therefore, many authors recommend generating the timestamps at the lowest level possible, i.e. in the MAC- or physical layer [119, 87, 77]. A further analysis of timestamping errors on the Mica2 sensor node in [87] revealed that the interrupt latencies were the largest source of uncertainty in this case.

32 2.2. Time synchronization protocols

They are reported to be typically around 5 µs. Sometimes also values of up to 30 µs were reached.

Figure 2.4.: Typical message delay sources according to [87].

2.2.2.3. Remote clock estimation and clock correction

Many methods have been suggested to improve the precision of the synchronization by combining multiple readings of the remote clock. The simplest method, presented in [64], is to calculate the mean of multiple readings of the clock ofset. Assuming zero drift and a zero-mean white Gaussian distribution for the synchronization error, this reduces the variance of the synchronization error to:

σ2 σ2 = one , (2.2) mean N

2 where σone is the variance of one reading and N the number of readings used. Linear regression is presented in [64, 119] as a way to estimate both ofset and drift of a clock. In [119] it is, however, stated that it is sensitive to outliers and may perform badly if the drift is not constant. Romer¨ et al. also point out a tradeof between the quality of estimates and the efort in terms of memory and computation time, when choosing the number of samples for regression. Two heuristic methods that estimate the drift of a clock based on multiple samples of the upper and lower bound for synchronization have been described by [158]. They are reported to be very robust to outliers while requiring only minimal memory and computation time [158]. Another method described in [119] is the use of a digital phase-locked loop (PLL). Here the clocks are synchronized by adjusting their rate through a proportional-integral (PI)- controller. According to [119] this method requires less memory but may need more

33 2. Literature review time to converge than linear regression. Furthermore, the frequent clock updates from the control loop may interrupt sleep-periods of the controller and increase its energy consumption [119]. A number of maximum-likelihood estimators have been suggested that optimally es- timate the clock ofset or drift when the synchronization error is not Gaussian dis- tributed [64, 83, 141]. Many of their authors assume an exponentially distributed mes- sage delay during synchronization [83, 141]. Finally, various Kalman flter designs have been suggested for time synchronization in WSN [2, 6, 86, 67].

2.2.2.4. Network organization

When synchronizing nodes in a multi-hop network to a common reference the synchro- nization needs to be somehow propagated in the network. Romer¨ et al. [119] state that the simplest solution, i.e. relying on the network layer and synchronizing all nodes directly to a reference node in a logically one-hop topology, will result in large syn- chronization errors. This is due to message delays along multiple physical hops being very difcult to predict and control. It is argued in [119], that instead synchronization algorithms should deal with the multi-hop communication directly. A common obser- vation in this context is that the overall synchronization error increases with the number of hops [119, 44]. This section summarizes the techniques commonly used to solve this problem. In out-of band synchronization all nodes can communicate directly with at least one master node [119]. The master nodes themselves have access to the reference time, e.g. through a GPS receiver. This method is conceptually very simple as it removes the multi-hop synchronization problem. However, it is seldom feasible as out-of band synchronization sources like GPS are often too expensive or not available [119]. Another approach is to form clusters of nodes that can reach each other through broad- cast messages [119]. Within such a cluster the nodes can be synchronized using single hop unidirectional or reference broadcast synchronization. Some nodes may belong to multiple clusters and serve as time gateways that translate time information from one cluster to the other. There is a tradeof between the size of a cluster on the one hand and the synchronization error, energy consumption or the translation efort on the other hand [119]. According to [119] the formation of synchronization trees, similar to those used by routing algorithms (compare section 2.1.4), is the most common technique for multi- hop synchronization. It is stressed that this tree should be optimized towards having a minimum depth and that it needs to be dynamically repaired on topology changes. A disadvantage of tree-based multi-hop synchronization is that physically co-located nodes may have large distances in the tree resulting in large local synchronization er- rors. Schmid et al. [123] argue that while it may seem attractive from an efciency

34 2.2. Time synchronization protocols point of view to use the same tree for routing and synchronization, this will result in a suboptimal synchronization quality. They suggest that to construct the tree for synchro- nization the frequency error variance of a node should be used as a cost metric instead of the expected number of transmissions used by many routing protocols. In the unstructured approach the multi-hop synchronization problem is not explicitly solved [119]. Instead, nodes add synchronization information to packets that are trans- mitted for other reasons. The advantage of this approach is that its communication overhead is very low [119].

2.2.3. Evaluation of synchronization protocols

Synchronization protocols may be evaluated with regard to various criteria. Karl and Willig [64] name the following: • precision • energy consumption • memory usage • error tolerance Romer¨ et al. [119] additionally stress the importance of the convergence time, i.e. the time a protocol needs to establish synchronization.

2.2.3.1. Precision measures

According to [119] the precision is to be given as a single scalar value for an entire network. They defne the instantaneous precision p(t) as: { } p(t) = max ci(t) − c j(t) i, j where ci(t) is the clock value of the i-th node at the time t. It is also mentioned in [119] that alternative defnitions of the precision exist that use the standard deviation, the average absolute value or the 99 %-quantile of the pairwise clock diference instead of the maximum. Furthermore, a steady state precision P is defned in [119]. It describes the synchro- nization precision in a network after the initial stabilization of the synchronization. The time needed to reach this steady state is called the convergence time tconv. It is defned as: { } P = max p(t) , t ≥ tconv t Alternative defnitions use the average instead of the maximum [119].

35 2. Literature review

It is stated in [119] that the usage of these difering precision measures often makes results reported by diferent authors difcult to compare. The fact that the precision heavily depends on the scope and time, for which it is measured, further complicates the situation [119].

2.2.3.2. Evaluation methods

Several methods have been used to evaluate synchronization protocols. Romer¨ et al. [119] summarize them as: measurements on target platform, simulations and analytic calculations. Measurement on the target platform are reported to provide the most real- istic precision values but do not scale well with network size. Simulations on the other hand can handle also very large networks and make it simple to keep external condi- tions constant. Finally, analytic calculations are the only way to determine absolute worst-case boundaries.

It is stated in [119] that no common benchmark for synchronization algorithms is avail- able yet. This is attributed to the diversity of synchronization algorithms and their respective applications.

2.2.4. Synchronization protocols for wireless sensor networks

A large number of synchronization protocols have been suggested for WSNs. Table 2.6 gives an overview of the most prominent or interesting protocols. For each protocol the classes of synchronization, types of building blocks used and assumptions made are given. More extensive overviews can be found in [79, 119, 64].

Reference Broadcast Synchronization (RBS) was the frst protocol to use reference broadcasting to minimize synchronization errors. It uses linear regression to determine the relative ofsets and drifts of all clocks in a broadcast domain [119, 35]. These values are then used to transform timestamps on transmission from one node to another [119]. Multiple broadcast domains can be linked through gateway nodes resulting in a clustered network organization√ [119, 35]. The synchronization error in this setup is reported to grow only with O( n) [119].

Hierarchy Referencing Time Synchronization (HRTS) is another protocol that utilizes reference broadcasting [119]. The main diference to RBS is that HRTS uses a central node to collect the reception timestamps of the broadcast, whereas in RBS the nodes exchange them directly [119]. Furthermore, HRTS uses a separate frequency channel for synchronization and organizes the network in a tree [119, 26].

36 2.2. Time synchronization protocols

Table 2.6.: Overview of time synchronization protocols for WSN. Protocol RBS HRTS FTSP RITS TPSN SCTS TSCH Internal/External I E I I E E I Implicit/Explicit E E E I E E mostly I Cont./On-demand C/OCCOC/OCC scope subsets all all subset all all all classes Rate/Ofset R&O O R&O O O R&O (R)&O Sync./Transf. T S S T S S S broadcast com. X X X - X X - bidirectional com. - X - - X - X constant rate - - - X - - - bounded drift ------X extra sync. channel - X - - - - - assumptions MAC timestamping - - X X X - X clock reading RB RB UD UD RT UD special clock estimation LR ONE LR ONE ONE PLL ONE

blocks organization cluster tree food routing tree 1-hop DAG source [119] [119] [119] [77] [119] [118] [135] abbreviations clock reading: UD=unidirectional, RT=round-trip RB=reference broadcast abbreviations clock estimation: LR=linear regression, ONE=one sample, PLL=phase-locked loop

The Flooding Time-Synchronization Protocol (FTSP) uses broadcast messages to syn- chronize all nodes in a broadcast domain to a central reference node. The nodes syn- chronized this way start sending broadcast messages themselves leading to a synchro- nization food. To minimize synchronization errors due message delay uncertainty FTSP timestamps incoming and outgoing messages directly in the MAC-layer. Fur- thermore, linear regression is used to determine ofset and drift of the nodes’ clocks [119, 87]. In FTSP the node with the lowest ID is always chosen as the central refer- ence. This way only internal time synchronization can be achieved, because it is not guaranteed that this node has access to an external time reference. Yet, it also enables the network to easily recover from node failures [119]. Some authors see FTSP as the current de facto standard for time synchronization in WSNs [124].

Routing Integrated Time Synchronization (RITS) is an on-demand, a posteriori syn- chronization protocol. It is based on the Elapsed Time on Arrival (ETA) primitive where nodes transmit the elapsed time since an event instead of its timestamp. Ne- glecting clock drift between the time of an event and the reception of the message, a receiving node can calculate the event timestamp on its local timescale by subtract- ing the elapsed time from the reception timestamp. Like in FTSP timestamping in the MAC-layer is used to minimize synchronization errors. In Routing Integrated Time Synchronization (RITS) this elapsed time is simply updated with the transmission de- lay in every node that a message passes. The communication overhead introduced by

37 2. Literature review

RITS is minimal as no additional synchronization messages are sent, only a feld with elapsed time needs to be added to every message [77].

The Timing-Sync Protocol for Sensor Networks (TPSN) uses round-trip synchroniza- tion and MAC-layer timestamping to achieve very accurate synchronization. The net- work is organized in a spanning tree [119].

The Self-Correcting Time Synchronization (SCTS) uses a digital phase-locked loop (PLL) to synchronize several clocks. Time information is transmitted in FTSP-like broadcasts. SCTS is claimed to efciently compensate for ofset and drift errors while needing less memory and computation time than approaches using linear regression [118].

A number of MAC-protocols employ TSCH in order to achieve both, robust commu- nication and time synchronization (see section 2.1.4.2). When using TSCH, receiving nodes measure the diference between the start of a time slot, as determined from their local clocks, and the actual time when the transmission starts. This ofset is then trans- mitted back to the sending node in an acknowledgement packet. To prevent loosing synchronization, when no regular communication is happening for a long time, nodes issue special synchronization messages called keepalive packets. For this purpose ev- ery node has an estimate of its maximum local clock drift which it uses to calculate the maximum allowed time between two synchronization events (compare section 2.2.2). Network-wide synchronization is achieved by assigning one or more synchronization parents to every node thus creating a directed acyclic graph (DAG).

Table 2.7 shows reported experimental results for the precision of the synchronization protocols described above. It is striking that diferent authors report largely diferent results for the RBS and TPSN protocols. This may be due to the use of diferent sensor nodes, clock resolutions Tclock and synchronization periods Tsync. But also diferences in the software implementations and experimental methods may play a role. In case of the TPSN protocol the huge diferences between the values reported by [42] and [118] may also be related to the fact that [42] measured timestamp diferences between nodes directly after a posteriori synchronization, while [118] continuously monitored the clock diferences of the number of nodes between periodic synchronizations.

Due to the diferences in the experimental methods and precision measures a direct comparison of the protocols is hardly possible. Yet, it can be concluded that with cur- rent synchronization protocols precisions in the order of 1–10 µs can be achieved for a single hop. The results given for FTSP at diferent synchronization periods Tsync show that a more frequent exchange of synchronization messages improves the syn- chronization accuracy. When the number of hops increases, the synchronization preci- sion decreases for all protocols. On direct comparison by the same authors protocols like SCTS that correct ofset and drift have a clear advantage over those like TPSN that only correct ofset [118].

38 2.2. Time synchronization protocols

Table 2.7.: Experimental precision of synchronization protocols. Precision Conditions Ref.

max. std. avg. scope duration Tsync node Tclock [µs][µs][µs] hops nodes [s][µs] - 11.2 - 1 5 30 broadc. n/a Mica 2.00 [35] 93.0 - 29.1 1 2 200 samp. n/a Mica 0.25 [42] RBS - 22.5 20.4 1 2 1 h 10 MANTIS n/a [26] - 31.5 28.9 3 4 1 h 10 MANTIS n/a [26] - 23.5 21.2 1 2 1 h 10 MANTIS n/a [26] HRTS - 32.1 29.5 3 4 1 h 10 MANTIS n/a [26] 6.5 - 1.5 1 2 18 h 30 Mica2 0.14 [87] FTSP 8.5 - 2.2 1 2 18 h 300 Mica2 0.14 [87] 14.0 - 3.0 6 60 50 min 30 Mica2 0.14 [87] RITS 80.2 - 7.9 10 45 900 samp. - Mica2 0.14 [77] 44.0 - 16.9 1 2 200 samp. n/a Mica 0.25 [42] TPSN 73.6 - 22.7 5 6 100 samp. - Mica 0.25 [42] 3, 860.0 530.0 1, 280.0 1 10 300 samp. 25 Mica2 16.00 [118] 9, 070.0 4, 000.0 3, 070.0 1 10 2000 samp. 50 Mica2 16.00 [118] 1, 760.0 282.0 1, 162.0 1 10 300 samp. 25 Mica2 16.00 [118] SCTS 1, 728.0 316.0 1, 126.0 1 10 500 samp. 50 Mica2 16.00 [118] TSCH 60.0 1 2 500 s 60 GINA 30.52 [135]

Abbreviations: broadc.=broadcasts, samp.=samples

39 2. Literature review

2.2.5. Synchronization protocols in other domains

Time synchronization is important not only for WSN. A number of time synchro- nization techniques have been developed in diferent domains, some of which are in widespread use and very mature. This section presents the most well known of those synchronization techniques outside and analyzes them for their relevance to WSN.

2.2.5.1. Internet: NTP

The Network Time Protocol (NTP) is used to synchronize the clocks of computers connected to the internet [96]. It was frst standardized by the IETF in 1985 [94] and has recently been updated to its fourth version [95]. According to [96] NTP is continuously being used by 10–20 million servers and clients all over the world. In NTP a client synchronizes to a server using round-trip synchronization [97]. Clock ofset and drift are estimated and digital PLL is used to control the clocks [97]. The network organization is based on a tree-structure, which is independent of the underly- ing physical network. At the root is a server that has access to national time standards, e.g. through GPS or DCF77 (see sections 2.2.5.3 and 2.2.5.4). The depth of the tree is measured in strata, where a stratum 1 server is at the root, stratum 2 servers syn- chronize to stratum 1 servers, etc. [96]. Many stratum 1 servers and thus also many synchronization-trees exist on the internet. Clients may synchronize with many difer- ent servers in order to make use of redundancy and diversity efects [97]. Thus, they may be part of more than one tree. The synchronization accuracy of NTP is generally reported to be in the order of several milliseconds [96, 27], but eforts are being made to achieve microsecond precision [96]. Romer¨ et al. argue that while being most advanced and time-tested NTP is not well suited for the use in WSNs [119]. It is said to consume too much energy, as servers need to be always reachable by clients, the digital PLL-requires frequent processor activity and only continuous synchronization is supported. Furthermore, it is deemed to be not fexible enough as its hierarchy is mostly static and confgured manually. Also the network independent nature of its hierarchy is seen to be detrimental, as it may cause large and unpredictable end-to-end delays that the protocol is not designed to meet. Finally, it is stated that NTP does not scale well over many strata/hops. Thus, time needs to be injected at many places in a large network, as it is done in the internet [119].

2.2.5.2. Industrial automation: PTP

The Precision Time Protocol (PTP) was developed to enable sub-microsecond syn- chronization in Ethernet networks [27, 200]. Additional design goals were to minimize

40 2.2. Time synchronization protocols computational requirements, network load and administration efort. PTP is standard- ized in the IEEE 1588 and IEC 61588 standards. It is part of many real-time automation bus systems, e.g. Ethernet/IP or PROFInet. Today PTP is used in a large number of ap- plications like motion control, energy distribution, data-acquisition and geo-sciences. PTP uses a tree structured network organization where slave clocks synchronize to their respective masters. A clock that is a slave to one clock and a master to others is called a boundary clock. The clock that is used as the reference for the entire network is called grandmaster (see fgure 2.5). PTP defnes a Best-Master-Clock-Algorithm that automatically builds an optimal synchronization tree based on clock parameters like precision, stratum, drift or variance [27]. In PTP the remote clock reading works as follows: a master synchronizes its slaves through unidirectional synchronization (see fgure 2.6). First a Sync-message is sent M and later a Follow UP-message that contains the timestamp tsync of the Sync-message. f S S Afterwards, the slave can calculate its o set to f f using the receive timestamp tsync of S M − S the SYNC-message: to f f = tsync tsync + d. In this two-message design the only time- critical operation is the generation of send and receive timestamps which is usually performed directly in the hardware. The rest of the protocol can be implemented in software minimizing the requirements on the hardware. To improve the accuracy of the synchronization the transmission delay d is measured from time to time using a round- trip technique (messages Delay Req and Delay Resp in fgure 2.6). However, in order for this mechanism to work transmission delays have to be symmetric and constant. Therefore, network switches should usually serve as boundary clocks in order to avoid variable forwarding delays afecting the synchronization [27]. PTP requires a control loop on the slaves to adjust the local clock to the master clock based on the calculated ofsets, but does not defne an algorithm for this [27, 200]. In [27] the precision of pure software PTP implementations is reported to be typically in the range of 10 ... 200 µs. An implementation using hardware-generated timestamps and a 50 MHz crystal-oscillator is reported with a precision of 60 ns [27]. Although PTP was originally designed for Ethernet networks it can theoretically be implemented on any multi-cast network [27]. Cho et al. [22] implemented PTP for a WSN using specialized synchronization hardware as well as a temperature controlled crystal oscillator with a frequency of 37.5 MHz and an accuracy of 1.5 ppm. Toma et al. [143] implemented PTP on a commercial XBee module. Wobschall et al. [157] state that an unmodifed implementation of PTP is not well suited for WSNs. The main reason is that standard PTP messages are too large for a single IEEE 802.15.4 frame and therefore require fragmentation. They suggest using a modifed version with shortened messages and without Follow Up-messages. A diferent modifcation is suggested in [37]. Here the timing information of the Follow Up-message is integrated into the second fragment of the Sync-message. Table 2.8 gives an overview of the reported performance for the individual PTP implementations.

41 2. Literature review

Figure 2.5.: PTP network structure [200]. Figure 2.6.: PTP synchronization mes- sage exchange [200].

It can be observed that like in table 2.7 very diferent precision values are reported for the same synchronization protocol. Furthermore, the values show that, using special- ized synchronization hardware as well as a high clock resolution and short synchroniza- tion intervals, synchronization precisions well below 1 µs can be achieved. However, the energy consumption is expected to rise under these conditions. Unfortunately, not all authors report values for this.

2.2.5.3. Countrywide: DCF77

DCF77 is a long wave radio transmitter that is used to disseminate the ofcial time in the Federal Republic of Germany [57]. Similar transmitters are used in many other countries (see [153]). The DCF77 transmitter uses a highly accurate carrier frequency of 77.5 kHz and has a transmission range of about 2000 km [57]. Bits are transmitted by lowering the signal amplitude for 0.1 s or 0.2 s at the beginning of a second. This way a message containing the current time is transmitted every minute. Additionally, pseudo- random phase noise is added to the signal to enable a more accurate synchronization of receivers. For two receivers spaced 50 km apart a maximum synchronization error of 20 ... 50 µs is reported [57]. The DCF77 system is essentially a unidirectional broadcast synchronization protocol similar to one-hop FTSP. According to [64] it is not feasible to use systems like DCF77 in WSNs as he receiving circuits are generally too large, too costly and too energy-hungry. Furthermore, it may not be possible to pick up the signal everywhere due to occlusions by buildings or terrain [64].

42 2.2. Time synchronization protocols

Table 2.8.: Performance of PTP implementations for WSNs. Precision P Conditions Ref.

max. std. avg. duration Tsync Tclock platform [µs][µs][µs][mW][s][µs]

0.045 n/a 1000 samp. 0.02 0.027 special sync. [22] hardware, TXCO 2.283 0.350 0.481 0.154 24 h 5.00 0.500 XBee [143] 10 1 n/a 2.00 0.063 special sync. [157] hardware, precision crystal 100 0.1 n/a 10.00 0.063 special sync. [157] hardware, precision crystal 0.500 n/a 50 samp. 1.00 0.534 SunSPOT [37]

Tsync = synchronization interval, Tclock = clock resolution

2.2.5.4. Global: GPS

Today the Global Positioning System (GPS) is the world’s principle source of accu- rate time [3]. It uses a system of satellites that possess highly stable synchronized atomic clocks. The GPS-system time is synchronized to the Coordinated Universal Time (UTC) as estimated by the United States Naval Observatory [3] (compare section 3.1.1). Each satellite continuously broadcasts messages containing its position and the current GPS-system time. After receiving timestamped messages from four diferent satellites a receiver can set-up four equations and solve them for the unknowns posi- tion (three coordinates) and GPS-system time [3]. This way synchronization precisions of 20–500 ns are achieved [57, 3]. Using the signal from one GPS-satellites as a ref- erence broadcast, even higher synchronization accuracies of 5–20 ns can be achieved. This method, called GPS Common-View is used by the international standards organi- zations for time transfer between diferent timing centers [3]. Many observations over a long period of time and complex signal processing algorithms are necessary to reach the high accuracies given above [3]. According to [64] it is not feasible to use GPS as a source of synchronized time in WSNs. The receiving circuits are deemed to be too large, too costly and to energy- hungry. In addition, it is probably not possible to receive the GPS signal everywhere wireless sensor nodes are deployed.

2.2.5.5. Laboratory equipment: digital pulses

Many laboratory devices use digital pulses transmitted through a wire to synchronously trigger data acquisition. One example is the Real-Time System Integration bus (RTSI)

43 2. Literature review used in data acquisition cards from National Instruments [208]. Furthermore, many frequency normals and GPS receivers output a one pulse per second (PPS) signal for other devices to synchronize to [57, 11].

2.2.6. Conclusions

Time synchronization is a multi-faceted problem. Depending on the application difer- ent classes of time synchronization are actually needed. Optimizing a synchronization protocol for a specifc application may result in increased performance and efciency. In WSNs the weak processors and small memories of the sensor nodes together with the small communication bandwidth pose signifcant challenges for time synchronization protocols. Most critical for the synchronization precision are the transmission delays during the synchronization procedure. Timestamps should therefore be generated as close as possible to the actual sending process. Estimating and correcting the clock’s drift can greatly reduce the required synchronization interval. Many diferent synchro- nization protocols have been suggested for WSNs. Unfortunately the absence of a common precision metric and varying experimental methods make direct comparisons difcult if not impossible. Furthermore, the properties of the underlying hardware, es- pecially the stability and resolution of the clock, have a major infuence on the observed performance. Yet, FTSP with a reported precision in the order of several microseconds and a relatively simple design may currently be considered to be the best protocol. On the other hand the trend towards MAC-layer protocols with integrated time synchro- nization, like IEEE 802.15.4e, may set a diferent de facto standard in the future, as they provide time synchronization at no additional cost. Implementations of PTP on wireless sensor nodes show that with optimized hardware and frequent synchronization, even precisions of 50 ns can be achieved. Those come close to the precisions achieved by state-of-the-art synchronization techniques in other domains with wired PTP or GPS. However, it remains an open question whether the use such high precision synchro- nization techniques is really feasible in practical applications and whether the benefts justify the efort. Similarly fltering techniques ranging from simple moving-average to complex Kalman flters may be used to increase the synchronization precision or lower the message exchange rate. Yet it is not clear, where the optimal tradeof between computational complexity and synchronization accuracy lies.

2.3. Data Acquisition with wireless sensor networks

Data acquisition is one of the major applications for WSNs. Section 2.3.1 presents an overview of data acquisition applications reported in the literature. The relation of wireless sensors to smart sensors is examined in section 2.3.3. Finally, section 2.3.2 looks into strategies for time-synchronous data acquisition.

44 2.3. Data Acquisition with wireless sensor networks

2.3.1. Data acquisition

Welsh [149] reports on his experience with a WSN for volcano monitoring. In this application 10–20 sensor nodes recorded seismic and acoustic signals with a sampling rate of 100 samples/s. The deployment of the nodes was rather sparse and irregular with nodes placed several hundreds of meters apart. Finally, it was observed that the scien- tists tended to be rather conservative regarding the data acquisition. Welsh summarized this with the sentence [149]:

Scientists simply want all of the data produced by all of the sensors, all of the time.

Thus, it was suggested that WSNs should transmit data based on an application domain specifc prioritization in order to minimize wireless trafc. Additionally, all data should be logged to a local memory on every node for later analysis.

A deployment of a WSN for process monitoring in an oil refnery is reported in [113]. Fifteen Tmote Sky nodes were connected to fow and pressure sensors that were already installed. All data was logged at central base station. To facilitate debugging all nodes were individually coupled with industrial personal computers (PCs) that were accessi- ble through Ethernet. Power over Ethernet was used to power both nodes and industrial PCs. The entire deployment covered an area of 2500 m2 with at most 3 hops between a node and the base station. The nodes’ software used the Contiki operating system extended with a TDMA-based MAC-layer and a custom tree-based routing protocol. Data collection over a period of 30 min showed an end-to-end data loss below 0.25 %. The average power consumption of all nodes except the base station was in the range of 0.1 ... 1 mW.

Pfugradt et al. [108] describe a WSN for the monitoring of cardiovascular activity. They used custom sensor nodes with two MSP430 microcontrollers, where one ac- quired data and the other managed the wireless communication. In contrast to most other applications Bluetooth was used for the wireless transmission. The nodes were equipped with an electrocardiogram (ECG) or Photoplethysmogram (PPG) and a three- axis accelerometer, all of which were sampled at a rate of 500 samples/s. The microcon- troller responsible for data acquisition was always active and continuously acquiring samples, but the Bluetooth interface was set to sleep mode between the wireless mes- sages to save power. The resulting mean active current is reported to be 40 mA. As the sensor nodes were supplied by lithium-ion batteries with a capacity of 1300 mAh, continuous measurements were possible for more than 24 h.

Medina et al. [91] present a WSN that, using ultrasonic ranging, can determine node positions with an accuracy below 1 mm. IEEE 802.15.4/ZigBee is used together with a TDMA-MAC-layer for the wireless communication. The network topology is a one- hop star. Time synchronization in the MAC-layer is used to minimize power consump- tion by activating the wireless transceiver only when communication is expected. In the

45 2. Literature review given application, the nodes have an average current consumption of 11.8 mA allow- ing for 167 h of operation. Ultrasonic pulses with a carrier frequency of 40 kHz were generated at the sending nodes and sampled with a rate of 17.78 kHz at the receiving nodes using a bandpass sampling scheme. The sampled signal was fed through a digital correlator. Further digital signal processing on the nodes determined the time-of-fight of the ultrasonic pulses, which was used to calculate the node’s position. Hou and Bergman describe a WSN for condition monitoring of electrical motors [60]. IEEE 802.15.4/ZigBee is used for the wireless transmission. The network consists of one coordinator and three leaf nodes using a single-hop star topology. Current and vibration signals are recorded with a sampling rate of 3.1 ksamples/s. The fast Fourier transform (FFT) is used to compute the signal spectra locally on the nodes. A neu- ral network classifer performs local fault classifcation. Only the classifcation results are transmitted to the coordinator where decision level fusion is done. One diagno- sis run consists of data acquisition, signal processing and result communication. The sensor enters into a sleep state between the diagnosis runs. An analysis of energy con- sumption showed that running the fast Fourier transform (FFT) and neural network on the node needs only 22.3 mJ per run, whereas transmitting the raw data would require 33.7 mJ. Using two AAA alkaline batteries as power source this enabled 121 h of oper- ation with one diagnosis run every 3 s. Using a fxed-point FFT-algorithm instead of a foating-point, this could be increased to 150 h. The system was demonstrated to detect imbalances as well as loose feet, i.e. an inadequate motor fxture. Another wireless condition monitoring system was developed in the ECoMoS project [63, 12, 156]. Here the aim was to detect bearing faults of machines in a paper factory. A custom node hardware was designed that contained a vibration sensor, a fxed-point digital signal processor (DSP) and a thermal energy harvester. Wireless transmission was done in the 868 MHz band using a custom protocol. Vibration data was sampled with a rate of 32 ksamples/s. The signal spectrum was calculated and evaluated directly on the nodes. Only the diagnosis results were transferred to a central control station. One diagnosis consisting of measurement, evaluation and transmission was reported to last for 10 s and to need less than 250 mJ. Using a similar sleeping pattern as in [60] the energy obtained from the thermoelectric harvester was sufcient to run one diagnosis every 30 min. A very diferent wireless sensor for machine vibration monitoring is described in [61]. It uses a two-processor architecture, where an 8 bit processor with integrated wireless interface manages the communication and a more powerful 32 bit ARM Cortex-M3 processor manages the data acquisition. IEEE 802.15.4 is used in beacon-enabled mode for the MAC-layer. Data is acquired at a rate of 20 ksamples/s, stored to a Micro-SD card and only transmitted after the acquisition. The system is reported to consume 403.3 mW in full operation and 0.518 mW in full sleep. Using a 1000 mAh lithium battery as energy source, this leads to a lifetime of 9.17 h in operation and 297.6 d in sleep mode. Table 2.9 gives an overview the described data acquisition applications and the used node hardware.

46 2.3. Data Acquisition with wireless sensor networks

Table 2.9.: Examples of data acquisition with WSNs. C µ a a / / battery 9.17 h star, 1 hop IEEE 802.15.4, 2.4 GHz Vibration measurement (beaconed) beacons 0.5 403.3 a 2 / ≈ harvester ∞ vibration vibration 1 hop, backbone IEEE 802.15.4, 868 MHz Condition monitoring FFT, diagnosis none 7.4 ≤ current lab desk factory n IEEE 802.15.4, 2.4 GHz Condition monitoring none none periodic FFT, neural network s - - 87.85 ns µ 1 ultrasound vibration, between nodes IEEE 802.15.4, 2.4 GHz ranging periodic beacons peak-detection < C custom custom custom custom, 2 µ clock resolution = s µ 24 h 167 h 150 h clock > custom custom custom custom custom ECG, PPG human body 2–6 m Bluetooth, 2.4 GHz Medical Ultrasonic beacons T 2 1 120 35.4 ... a 0.5 17.78 3.1 32 20 a continuous bursts bursts bursts bursts a - 6.4 s 3 s 30 min n / / / ∞ pressure, fow acceleration, 2500 m 2.4 GHz Process monitoring (modifed) synchronization interval, = sync T a a 0.1 a IEEE 802.15.4, aa none none periodic none correlation, a TDMA Bluetooth TDMA IEEE 802.15.4 custom IEEE 802.15.4 a n a tree, 3 hops star, 1 hop star, 1 hop star, 1 hop many stars, a n / / / / / / / / / [149] [113] [108] [91] [60] [63, 12, 156] [61] n geophone between nodes monitoring 0.1 n ] s vailable, / a ] ksamples [ mW [ o information n = a / operation time n avg. power sensors seismometer, network extent 200. . . 400 m Examplenumber of nodes Volcano 10–20PHY 15sensor node 3 n sampling rate custom 7synchronization Tmote Skyon node signal n processing n custom, 4 2 power supply n battery mains power battery battery battery therm. energy MAC n execution environment custom Contiki synch. accuracy - - 100 data acquisition n topology n activity interval n n

47 2. Literature review

2.3.2. Time synchronous data acquisition

Time synchronous data acquisition is essential to many but not all application exam- ples presented in the previous section. Pfugradt et al. [108] used two diferent wireless senor nodes to measure the Pulse Transit Time, i.e. the time between a peak in the Electrocardiogram and the start of the pulse wave. Any synchronization error directly leads to an error in this measurement. Both, nodes trigger their sampling with a timer clocked from a 16 MHz crystal oscillator with 50 ppm accuracy. Synchronization mes- sages were sent at an interval of 250 ms. The nodes adjusted their local timer values in order to compensate for ofset and drift. This way a maximum sampling jitter of 100 µs could be achieved. Medina et al. measured the time-of-fight of ultrasonic pulses to determine the node positions [91]. Sending and receiving nodes were synchronized through two synchro- nization messages sent by the network coordinator at the beginning of a TDMA-frame, i.e. every 6.4 s. As in PTP, the frst message was used as a common reference point and the second message contained the exact time at which the frst was sent (compare section 2.2.5.2). The timestamps were generated directly in the MAC-layer to achieve a good precision. All nodes in the network used the synchronization information to calculate their local drifts and ofsets. To lower the standard deviation of consecutive drift estimates an IIR-lowpass flter was used. The calculated drifts and ofsets were used by the sending nodes to calculate the correct time for sending a pulse and by the receiving nodes to correct the pulse detection times. A detailed analysis of the measure- ment error for the time-of-fight given in [91] shows that a clock ofset causes a bias in the measurement and a drift a bias that changes over time. With the ofset and drift compensation of the clock this error was smaller than 0.01 µs. A much larger bias of about 250 µs was introduced through the group delay of the receivers’ analog bandpass flters. Therefore, it was suggested in [91] to remove this infuence by calibration. Another error contribution came from the variance of the correlator output which de- pends on the signal-to-noise (SNR) of the received ultrasonic signal. It was estimated to be about 0.71 µs in [91]. Finally, the clock resolution was identifed as a major infuence factor. At a clock resolution of 1 µs its error contribution was found to be about 0.6 µs. The overall error of the time-of-fight measurement was reported to be 0.6 ... 1.9 µs for distances between the nodes of 2 ... 5.5 m. The error increases with the distance due to a reduction in the SNR of the received signal. The resulting positioning accuracy was reported as 0.31 ... 0.64 mm. The wireless sensor presented for vibration measurement in [61] uses periodic messages at an interval of 2 s for synchronization. The corresponding start of frame pulses from the wireless transceiver are wired directly to a microcontroller interrupt and used to adjust both ofset and drift of an internal timer, which used to trigger the sampling of the input signal. This way an average synchronous triggering error of 87.85 ns (max. 190 ns) between two neighboring nodes was achieved during the acquisition of 200 samples.

48 2.3. Data Acquisition with wireless sensor networks

An even more powerful wireless system for synchronous data acquisition is described in [159]. It is based on a 600 MHz ARM Cortex-A8 processor and uses WLAN for data transmission. The sampling rate is synchronized to the PPS output signal of a GPS receiver. This way, a synchronous triggering error of 15 ns could be achieved at a sam- pling rate of 100 ksamples/s. No information is given on the systems power consumption or cost. Yet, it is to be assumed that the system is too costly and needs too much power to be considered a wireless sensor node in the conventional sense.

2.3.3. Wireless sensors and smart sensors

Smart sensors are increasingly being used in measurement applications. According to [57] a smart sensor not only converts a physical or chemical signal into an electrical one, but also digitizes it and performs signal processing. The signal processing may take any form ranging from simple scaling to complex fltering or self-calibration algo- rithms. The IEEE 1451 standard defnes a smart transducer as a sensor or actuator that . . . provides functions beyond those necessary for generating a correct representation of a sensed or controlled quantity . . . with the aim to facilitate its integration into ap- plication setups [196]. Thus, according to these defnitions every wireless sensor node as described in section 2.1 is also a smart sensor.

2.3.3.1. The IEEE 1451 family of standards

The IEEE 1451 family of standards has been introduced with the aim to improve inter- operability between transducers from diferent manufactures, thus enabling a plug-and- play style of use [196]. It defnes a transducer as a device that is either a sensor or an ac- tuator. Every smart transducer under the IEEE 1451 standard should be described by a transducer electronic data sheet (TEDS), which contains all relevant information about it in a standardized machine-readable form. Transducers are connected to transducer interface modules (TIMs). They provide a standardized command interface, contain the TEDS and perform signal conversion as well as conditioning. Many TIMs may be connected to a network-capable application processor (NCAP). It provides a network based user interface and can perform arbitrary processing functions. Figure 2.7 shows an overview of the IEEE 1451 reference model. Various diferent hardware interfaces are defned for the communication between TIMs and NCAP including USB, CAN, WLAN, Bluetooth, ZigBee and 6LoWPAN. A short summary of the current members of the IEEE 1451 family is given in table 2.10.

49 2. Literature review

Figure 2.7.: IEEE 1451 reference model according to [196]. Grayed out parts are out of scope for IEEE 1451.

Table 2.10.: Members of IEEE 1451 family of standards. Standard Contents IEEE 1451.0 Common functionalities, commands and TEDS IEEE 1451.1 Common object model and interface specifcations IEEE 1451.2 Point-to-point communication interface between TIM and NCAP IEEE 1451.3 Wired bus communication between TIM and NCAP, e.g. USB or CAN IEEE 1451.4 Mixed analog/digital interface between transducers and TIM IEEE 1451.5 Wireless communication between TIM and NCAP, e.g. 6LoWPAN

50 2.3. Data Acquisition with wireless sensor networks

2.3.3.2. IEEE 1451 in wireless sensor networks

IEEE 1451 is explicitly intended to be used in WSNs. Adaptation layers for the com- munication between NCAP and TIM over 6LoWPAN and other wireless technologies are defned in IEEE 1451.5 [197]. Higuera and Polo [54, 55] describe an implementa- tion of IEEE 1451 for TinyOS using TelosB sensor nodes. They discuss three possible network architectures for implementing IEEE 1451 on a WSN: In the frst, there is only one NCAP. It is also the gateway node that connects the WSN to another network, e.g. the internet. In the second, multiple NCAPs are connected via a backbone network. Finally in the third, the WSN is not connected to any other network and the NCAP serves as network coordinator. In all three cases the other nodes in the network work as TIMs.

A very similar implementation using the same operating system and node hardware is described in [45]. The memory footprint of this implementation is reported with 2.900 kB RAM and 26.660 kB Flash on the TIM 3.295 kB RAM and 19.014 kB FLASH on the NCAP. A HTTP-server was implemented on the NCAP to allow access from web applications. Five wireless transducer interface modules (WTIMs) with light, tem- perature and humidity sensors were constructed and tested on a university campus. The fnal intended application was the monitoring of a wildlife habitat.

2.3.4. Conclusions

Wireless data acquisition has been used in a wide range of applications. Most appli- cations still rely on customized hard- and software solutions. Quite often, relatively powerful hardware is used for the nodes, e.g. a two processor architecture where one manages the data acquisition and the other the communication. This, however, comes at a clear penalty regarding power consumption. The vast majority of data acquisition applications use batteries for power supply. Operational lifetimes range from several hours to about half a year, depending on the highly application specifc power con- sumption. Applications using energy harvesting are currently rare. Reasons may be the relatively low amount of power that can be harvested and a difcult design process. When possible, mains powered solutions are chosen, as they signifcantly reduce the design efort and provide an unlimited operational lifetime.

In the MAC-layer schedule based protocols are used almost exclusively. The presented applications use only few nodes (2. . . 20). Thus, a simple one-hop star topology is used in the majority of cases. The only application with a multi-hop network uses a three-hop tree topology.

The, MAC-protocols are the major source of time synchronization, which is generally performed in a continuous manner. Specialized synchronization protocols are generally

51 2. Literature review not used. However, key techniques like MAC-layer timestamping and drift compensa- tion are often adopted. A very interesting fnding of [91] is that the measurement errors caused by synchronization inaccuracies may be marginalized by other error infuences, like the input signal noise. The sampling rates used for data acquisition vary in the range of several samples to tens of kilosamples per second. Two major acquisition patterns can be observed: continu- ous streaming and acquisition bursts with longer sleep periods in between. The latter is especially used to minimize power consumption in monitoring applications. Another strategy to minimize the amount of data transmitted as well as to save power is to pro- cess the data directly on the nodes and only transmit the results. The users of the data, on the other hand, often prefer to have access to the entire raw data. A possible com- promise may be only transmitting the processed data but storing the raw data locally on the sensor nodes for ofine analysis. As all wireless sensor nodes digitize and process the acquired data they may be con- sidered smart sensors. The IEEE 1451 defnes a standardized interface to all kinds of smart sensing systems that abstracts from the underlying communication architecture. Wireless sensor nodes that use this standard may be integrated more easily into future measurement applications.

2.4. Synchronous angular sampling

Synchronous angular sampling is an important tool for the analysis and diagnosis of rotating machinery. It is also referred to as synchronous sampling [72], angle do- main sampling [15] or angular sampling [9, 17]. Section 2.4.1 briefy introduces the defnition of synchronous angular sampling and its main uses. An outline of current algorithms for synchronous angular sampling is given in section 2.4.2.

2.4.1. Signifcance and applications

Synchronous angular sampling is commonly defned as the acquisition of samples at equidistant angular steps with reference to a rotating shaft [72, 15, 17]. Thus the orders, i.e. phasors that rotate with instantaneous frequencies that are integer multiples of the reference shaft’s rotational frequency, will appear at constant frequencies in the sampled signal, even if the rotational speed of the shaft is changing over time [15]. This signifcantly simplifes later processing of the order signals, as signal processing and analysis methods are commonly defned for constant frequency signals [15]. Figure 2.8 illustrates the process of synchronous angular sampling.

52 2.4. Synchronous angular sampling

Figure 2.8.: Principle of synchronous angular sampling.

A concept closely related to synchronous angular sampling is order tracking. In [18, 72] it is defned as: Frequency analysis of the instantaneous root-mean-square values of pe- riodic components of rotating machine vibrations as a function of rota- tional speed. However, in [15, 17] any digital signal processing method intended primarily for rotat- ing machinery is named order tracking. According to [15] synchronous angular sampling is the second most often used method in rotating machine analysis and diagnosis. Its key advantage is the possibility to per- form a leakage free discrete Fourier transform (DFT) with a constant order resolution over time [15]. Its major disadvantage is that this order resolution is not very high, which causes problems at non-stationary order amplitudes [15]. According to [72] the main application of synchronous angular sampling is the analysis and diagnosis of rotating machinery at variable speeds. This is especially interesting, as it allows covering the entire speed range of a machine in a short time. This way, critical resonant frequencies and instabilities in rotors or bearings can be detected. Fur- thermore, varying the rotational speed helps to decide whether observed phenomena are rotation related or not. Finally, specifc errors can be detected, since they often give rise to signal components at characteristic orders [72].

53 2. Literature review

2.4.2. Algorithms

Originally, synchronous angular sampling was performed by directly controlling the sampling instants with a rotational encoder connected to the reference shaft [72, 18] (see fgure 2.8). This, however, has the disadvantage that a variable anti-aliasing flter is needed, which in general is difcult to construct and very expensive [72, 15]. For these reasons synchronous angular sampling, today, is almost exclusively performed digitally. In this case the signal is frst acquired at a constant analog sampling rate over time and later resampled at the desired angular instants [18, 15] (see fgure 2.9).

Figure 2.9.: Principle of synchronous angular resampling.

This synchronous angular resampling, was introduced by Hewlett Packard in 1989 [15, 111], but the details were considered to be proprietary and not published. Today, many commercial hard- and software products provide synchronous angular resampling, but the implementation details are generally not disclosed [14].

A simple method for synchronous angular resampling has been described in [17]. Here, spline-interpolation is used to obtain the signal values at the desired angular instants. However, this method is only suitable for small speed changes as the lowpass charac- teristic of the spline-interpolation is not very good and would lead to aliasing errors during resampling at larger speed changes (compare section 3.3.2).

Two more sophisticated methods for synchronous angular resampling have been pub- lished in [14]. The frst is upsampled linear interpolation, where the signal is frst up- sampled by a factor L and then interpolated to the desired angular instants using linear interpolation (see fgure 2.10). The lowpass flter after the upsampling suppresses inter- polation images and ensures that the signal is sufciently narrow-band to be used in the linear interpolation. In order to avoid aliasing errors the sampling rate at the output of the linear interpolator needs to be at least as large as the original sampling rate. As this can lead to undesired oversampling, an optional decimation stage can be used to reduce

54 2.4. Synchronous angular sampling the output rate by a factor M. The SNR of the output signal is strongly infuenced by the upsampling factor L: higher L lead to a better SNR. Simulations in [14] resulted in an SNR of 50 dB at L = 2 and one of 60 dB at L = 16. The method generally requires a high computational efort. However, this can be reduced by calculating only those upsampled values actually needed for the interpolation as well as by using polyphase interpolation and decimation flters (compare section 3.3.2.1).

Figure 2.10.: Block diagram of upsampled linear interpolation algorithm [14].

The second method for synchronous angular resampling presented in [14] is an upsam- pled interpolation flter. Here samples are interpolated at the desired angular instants using truncated sinc-interpolation. This corresponds to frst reconstructing a continuous signal from the acquired samples, continuously fltering it with a lowpass flter and then sampling it again (see fgure 2.11). The impulse response of the lowpass flter is equal to a truncated sinc-function. It is stressed in [14] that this method is computationally very efcient as it only requires 12–18 multiply and add operations per output sample, if the values of the sinc-function have been calculated in advance. However, a large num- ber of these precalculated values are needed. If fewer values are used more broadband noise is introduced in the output signal. The SNR of the method is reported to be in the range of 70 ... 80 dB for 18 times 512 to 8192, i.e. 9.216 ... 147.456, precalculated values.

Figure 2.11.: Block diagram of upsampled interpolation flter [14].

55 2. Literature review

2.5. Conclusions

WSNs are networks of small, low-cost sensor and actuator devices. Although WSNs have been a subject of research for more than 15 years this feld is still very much in development. The trend in wireless sensor node hardware is towards low-power 32 bit ARM processors. Radio transceivers based on the IEEE 802.15.4 standard using the 2.4 GHz frequency band are used in the majority of applications. In most cases wireless sensor nodes are powered using batteries. Applications based on energy harvesting look interesting but are still very rare. Reasons are the low amount of power harvested and problems to reliably predict it during system design. Thus, the power consumption of wireless sensor nodes has to be minimized regardless of whether batteries or energy harvesting is used. However, in some applications it is feasible to power the nodes directly from the power grid or through an inductive power supply. In these cases, power consumption is much less critical.

Starting from very diverse experimental systems and protocols wireless sensor software is slowly converging towards some standards. There is a tendency to use solutions already known from conventional systems, e.g. multi-threading schedulers or IP-based network protocols. Yet, the limitations of wireless sensor nodes in terms of power consumption, computational power and memory size still pose major challenges for software development. Today a number of specialized operating systems for WSN are available. Yet, many applications still use entirely custom execution environments. For the MAC-layer, protocols based on time-synchronized channel hopping (TSCH) are increasingly being used not only in industrial applications. In the networking and higher protocol layers, a trend towards IPv6-based protocols is clearly visible. The IEEE 1451 standard defnes a common interface not only to wireless sensors but to all kinds of smart sensors. It may greatly ease system integration eforts in the future.

Time synchronization is a key factor in many applications using WSNs. It has been shown to be a multi-faceted problem with much room for optimization by tailoring the kind of time synchronization to the individual application. A plethora of protocols for time synchronization has been suggested. The generation of timestamps in the MAC- layer, as close as possible to the actual sending process, has been shown to be key to maximizing synchronization precision. Direct comparisons between synchronization protocols are very difcult, as precision numbers reported in the literature are often based on diferent assumptions and measurement methods. Furthermore, the properties of the underlying hardware, especially the stability and resolution of the clock, have a major infuence. Yet, some authors see the FTSP-protocol as the current state-of-the-art for time synchronization in WSN. A diferent kind of standard for time synchronization in WSN may well be set by time synchronized MAC-protocols that are already predom- inantly used as a means for synchronization in data acquisition applications. Various experiments with synchronization on wireless sensor nodes have shown that synchro- nization accuracies well in the sub-microsecond region can be realized, thus coming

56 2.5. Conclusions close the accuracy provided in other domains by state-of-the-art synchronization tech- niques like PTP or GPS. However, such high synchronization accuracies always require a high efort in terms of communication and processor load. Thus, they may even turn out to be incompatible with a number of applications. The main challenge here seems not to be to achieve maximum synchronization accuracy, but to fnd the right balance between efort and precision for a given application. Surprisingly little research has been done on this question so far. Data acquisition applications using WSN often use duty-cycling to minimize their power consumption. Two major activity patterns can be distinguished: In the frst a sensor node continuously acquires and sends data. In the second a sensor node acquires one block of data, processes and transmits it and then enters a sleep mode until the next acquisition is due. Processing the data on the nodes and only transmitting the results can greatly reduce the amount of wireless trafc as well as the power consumption. Yet, access to the raw data may be essential in some applications. Practically all data acquisition application today simply use a continuous, a priori time synchronization, although this strategy is argued to be suboptimal by authors that concentrate on time synchronization protocols. Synchronous angular sampling is frequently used to analyze and diagnose rotating ma- chinery. As it synchronizes the sampling to the rotation of a reference shaft, it may be seen as a special case of synchronized data acquisition that is distinct from time synchronized data acquisition. Only few algorithms for synchronous angular sampling have been published. No implementation of synchronous angular sampling using a WSN is known to the author. Yet, distributing the task over multiple wireless sensors could be very attractive, as it can greatly reduce installation times and costs. Based on this analysis of the current state-of-the-art four major questions have been identifed that have not yet been sufciently addresses: • How can synchronization precision be defned and measured in a way that is meaningful for measurement applications? • Which synchronization precision is sufcient for a given application? • Which is the best strategy for time synchronized sampling? • How can synchronous angular sampling be best implemented on a WSN? The aim of this dissertation is to provide answers to those questions.

57

3. Theoretical foundations

This chapter summarizes the theoretical background necessary for understanding the modeling and analysis in this thesis. First, in section 3.1, a defnition of synchronization is given and its relations to time and time measurement through clocks are investigated. In order to better understand the infuence of synchronization on the acquired data, the basics of data acquisition using uniform and nonuniform sampling are presented in section 3.2. An important tool to synchronize data after its acquisition is digital resampling. Its theoretical background and fundamental algorithms are given in section 3.3. Finally, the state of the art quality indicators for measurement results and acquired signals are discussed in section 3.4. Those indicators will be used to assess the infuence of synchronization errors on measurement results in the following chapters.

3.1. Time and synchronization

The Oxford advanced learners dictionary defnes the verb to synchronize as to make something happen at the same time as something [148]. Thus, in order to understand synchronization it is essential to know what “at the same time” means. The concept of time itself is closely linked to its representation through clocks. This section starts with a brief summary of the philosophical and technical aspects of time in section 3.1.1. In the next step, in section 3.1.2, the mathematical modeling of clocks as a source of time is discussed. This modeling is used to defne synchro- nization in the context of WSNs in section 3.1.3. Finally, section 3.1.4 shows that the fundamental properties of time do not only apply to physical time itself.

3.1.1. Time

Time appears to be fundamental to our everyday lives. Most of us intuitively use it daily without problems. Yet, its actual defnition has puzzled philosophers for cen- turies [75]. The early Christian philosopher Augustine de Hippo famously wrote in his “Confessions” [104]: What, then, is time? If no one asks me, I know what it is. If I wish to explain it to him who asks me, I do not know.

59 3. Theoretical foundations

He also writes later [104]: Yet I say with confdence that I know that if nothing passed away, there would be no past time; and if nothing were still coming, there would be no future time; and if there were nothing at all, there would be no present time. This also appears to express the basic consensus in the philosophy of time: time some- how manifests itself through the change of things (compare [75]). In one of the fun- damental papers on synchronization in computer science, Lamport writes about time [78]: It is derived from the more basic concept of the order in which events occur. Within classical physics, physical time is the one universal reference that can be used to unambiguously order all events [20, 78, 193]. Yet, a consequence of Einstein’s special theory of relativity is that even the order of events is dependent on the position of the observer [20]. However, within the scope of this thesis the classical view of a universal time will be used, since in most practical measurement setups dimensions and speeds are small enough to neglect relativistic efects. In order to defne a quantitative representation of the abstract physical time, i.e. a timescale which allows for the unique ordering of events, two things are needed: a fxed reference point in time and a measure of the time interval, between an event and this point. However, there is no one and only true choice for either [3]. Historically, humans have measured larger time intervals by the change of night and day as well as the coming and going of the seasons. Both are linked to the earth’s celestial movements, which were the original reference for the system of time units that is used today: one day equaling one revolution of the earth around its own axis, is divided into 24 hours, which in turn are divided into 60 minutes each and every minute into 60 seconds. A period of 365 days equals approximately one revolution of the earth around the sun. Since irregularities in the earth’s movements were discovered later, other natural pro- cesses were used to defne time intervals [3]. Today the internationally agreed defnition of the basic time unit, the second, is [195]: The second is the duration of 9 192 631 770 periods of the radiation cor- responding to the transition between the two hyperfne levels of the ground state of the caesium 133 atom. The second is currently the basic physical unit that can be reproduced with the highest accuracy [3]. The international reference timescale, the UTC, is established by the International Bu- reau of Weights and Measures (BIPM) based on aggregate data from atomic clocks around the world [3]. In order to keep UTC synchronized with earth’s movement

60 3.1. Time and synchronization around the sun, leap years, i.e. years with one extra day, are introduced at regular intervals. Furthermore, leap seconds can be introduced by international agreement at the end of a month [3]. The reference time point for UTC is the supposed year of Christ’s birth. A number of other timescales exist, that like UTC use the second as the basic unit of time intervals but have diferent reference points. A famous example is the Unix time, which is used by many computers. It measures time in seconds since 00:00:00 on the frst of January 1970 [150].

3.1.2. Clocks

Devices that measure physical time are called clocks. Today they are almost exclusively made up of an oscillator, which generates events at a fxed time interval, and a counter, which counts them [119, 3]. Examples of this design are mechanical clocks, where the oscillator is realized as a pendulum and the counter by a gearbox with a dial; digital clocks with quartz oscillators and digital counting circuits; or even atomic clocks, where photon emissions of caesium 133 atoms are used to generate an electrical signal at 9,192,631,770 Hz, whose periods are counted [3]. In order for such a clock to represent a standardized timescale, e.g. UTC, the point in time at which it was started needs to be added to the counter value. This immediately leads to the following widely used clock model [118, 64, 119]:

c(t) = hc(t)Tclock + t0. (3.1)

Here, the clock value c at the time t is given by the value of a counter hc scaled with its 1 counting period Tclock and shifted by an ofset t0 . Bearing in mind that the key characteristic of time is the ordering of events, this model can be generalized as follows: a clock is a function c, that maps physical time t to a real number such that [118, 64, 119]:

t1 < t2 ⇒ c(t1) < c(t2). (3.2)

A slightly diferent clock defnition is given in [78]. Here, a clock is defned as a mapping C of real numbers to events, such that C(a) < C(b), if event a happened before event b:

a { b ⇒ C(a) < C(b). (3.3)

An ideal clock according to (3.1) would map physical time onto itself [118]:

cideal(t) = t. (3.4)

1 The counter value hc is by defnition discrete. However, this fact is not paid much attention to by most authors [118, 64, 119]. Instead clock and counter are largely treated as if they where continuous.

61 3. Theoretical foundations

Thus, its clock rate f (t) would be exactly one at all times [119, 118]:

dc (t) f (t) = ideal = 1, ∀t. (3.5) ideal dt However, the rate of a real clock generally difers from this ideal, i.e. the clock has a drift ρ , 0 [119]:

ρ(t) = f (t) − 1. (3.6)

This may be caused, e.g. by production tolerances of the oscillator or by temperature variations. A drift of ρ = −1 would mean that a clock has stopped. With a drift of ρ < −1 a clock would run backwards. Thus, a reasonable assumption for most practical clocks is [119]:

ρ(t) > −1, ∀t. (3.7)

In many applications the clock drift changes only very slowly with time. Thus, a model with constant drift can be used for short timespans [119]:

f (t) = const. ⇒ ρ(t) = const. (3.8)

⏐ ⏐ Often manufacturers give an upper bound on the clock drift ⏐ρ(t)⏐ ≤ ρmax, ∀t, which can be incorporated into the model. If timespans are so large that the change of drift be- comes relevant, it is usually reasonable to assume an upper bound Θmax for the change rate [119]:

dρ(t) ≤ Θ . (3.9) dt max

Apart from the low frequency changes in clock rate, which are generally referred to as drift, every oscillator shows some fuctuations in its period from cycle to cycle. This phenomenon is called jitter and can be described by adding a random error δt(t) to the clock value:

c jit(t) = hc(t)Tclock + t0 + δt(t) (3.10)

Finally, a real clock may also difer from the ideal clock by a constant ofset:

∆c = c(t) − cideal(t). (3.11)

This may be due to inaccuracies in the clock’s assumed starting time.

62 3.2. Data acquisition

3.1.3. Synchronization

As already stated in the introduction to this section, synchronization makes things hap- pen at the same time. With reference to clocks, this generally means that two clocks show the same clock value at the same physical time. Thus, two clocks ci(t) and c j(t) are synchronized to the precision p if [64]: ⏐ ⏐ ⏐ci(t) − c j(t)⏐ < p (3.12)

If this condition holds true for all pairs of clocks from a set i, j ∈ {1, 2, ... , N}, it is called a synchronized set of clocks. If the ideal clock is included in the set, the set is called externally synchronized, if not, it is called internally synchronized [64, 119].

The diference ϵsync.(t) = ci(t) − c j(t) is called the synchronization error. It is the result of the individual clocks’ drift, jitter and ofset with reference to physical time (see section 3.1.2).

3.1.4. Generalized time

From the previous discussion of time and clocks, it becomes apparent that the key property of physical time, i.e. its ability to order events, may not be exclusive to it. Any function that fulflls the clock property (3.3) can be used, to uniquely order events, regardless of whether it is synchronized to physical time or not. The only property required by (3.3) is that the function is monotonically increasing. Thus, also other physical quantities may be used as a substitute for time in a given application. One example would be the rotational position of a machine shaft, provided that it doesn’t stop or change direction (see also sections 2.4 and 4.5). Any such clock or group of clocks can be seen as creating its own individual timescale. However, combining observations from diferent timescales is only possible, if the clocks have been synchronized. Seen in this light, the key function of international time standards, like the second or the UTC, is to facilitate the communication of time information.

3.2. Data acquisition

Data acquisition is the process of obtaining data from measurements for storage and analysis [84]. Today, data acquisition is mostly done with acquisition systems that produce digital data for storage and processing on a computer system. Two very distinct types of data acquisition are treated in this thesis:

63 3. Theoretical foundations

1. In event detection the occurrence of an event, e.g. a sound pulse or the cross- ing of a light barrier, is detected and the time of occurrence is recorded, i.e. a timestamp is assigned to the event.

2. In waveform sampling a digital representation of a physical signal, e.g. voltage or sound, is obtained [201]. This process involves both the sampling at discrete time instants and the quantization of the amplitude values [66, 48]. The result- ing digital representation is called a waveform. It consists of a set of amplitude values with timing information. The latter may be given directly as a set of time values or indirectly through the timestamp of one sample and a constant sampling interval.

3.2.1. Uniform sampling

Sampling is the conversion of a continuous signal x(t) into a discrete one x[n] by taking its value at discrete time instants tn. For uniform sampling the timing instants are given by a constant sampling interval Ts [102]:

x[n] = x(tn) = x(nTs). (3.13)

The Nyquist-Shannon sampling theorem states that a signal x(t) is uniquely determined by its samples x[n], if its Fourier transform X( jω) is zero for frequencies larger than half the sampling frequency ωs [102]: ω π X( jω) = 0 for |ω| ≥ s = . (3.14) 2 Ts

ωs The frequency ωN = 2 is called the Nyquist frequency and 2ωN the Nyquist rate [102].

3.2.1.1. Spectrum of uniformly sampled signals

Sampling can be modeled mathematically by the multiplication of the signal x(t) with a comb function s(t) [102] 2:

∑∞ s(t) = δ(t − nTs) (3.15) n=−∞ xs(t) = x(t)s(t), (3.16)

2 The resulting signal xs is strictly speaking still continuous, but it is only nonzero at the sampling instants.

64 3.2. Data acquisition where δ is the Dirac delta function. In the frequency domain the multiplication becomes a convolution: 1 X ( jω) = X( jω) ∗ S ( jω), (3.17) s 2π where Xs, X and S are the Fourier transforms of xs, x and s. Thus, the spectrum Xs of the sampled signal is the periodic repetition of the continuous signal spectrum X (see fgure 3.1).

Figure 3.1.: Amplitude spectra of a continuous signal X, corresponding sampled signal Xs and ideal reconstruction flter Hideal.

If the signal bandwidth W is larger than the Nyquist frequency ωN, i.e. the Nyquist- Shannon sampling theorem is violated, the original spectrum and its repetitions will overlap [102]. This phenomenon is called aliasing, as it lets energy from higher fre- quency components appear at lower frequencies as shown in fgure 3.2.

Figure 3.2.: Example of an amplitude spectrum with aliasing. Dotted green lines show the individual repetition spectra. Red flled areas mark frequency intervals where a reconstructed signal would be distorted by aliasing.

65 3. Theoretical foundations

3.2.1.2. Reconstruction of uniformly sampled signals

A consequence of the Nyquist-Shannon sampling theorem is that the continuous signal can be perfectly recovered from its samples, if they are free of aliasing. From the spectral representation of the sampled signal in fgure 3.1 it is apparent that this can be done by applying an ideal lowpass flter with the cutof frequency ωN [102]:

X( jω) = Xr( jω) = Hideal( jω)Xs( jω) (3.18) x(t) = xr(t) = hideal(t) ∗ xs(t) (3.19) ∞ ∑ sin [π(t − nTs)/Ts] = x[n] (3.20) − n=−∞ π(t nTs)/Ts

3.2.2. Nonuniform sampling

For nonuniform sampling the time interval between the sampling instants is not con- stant. Instead the signal is acquired at a set of time instants {tn}n∈š [88]. A conse- quence of this is that no unique sampling frequency can be defned anymore and that the Nyquist-Shannon sampling theorem does not apply. However, a sampling theorem for nonuniform sampling given in [88] states, that a continuous signal is uniquely de- termined by its nonuniform samples {tn}, if the average sampling frequency is above the Nyquist rate [88]:

If the nonuniform samples {tn} satisfy the Nyquist rate on average, it can uniquely represent a band-limited signal [. . . ] if the samples are not the zero-crossings of a band-limited signal of the same bandwidth. The set {tn} is then called a sampling set. [. . . ] If the average sampling rate is higher than the Nyquist rate, irrespective of the set {tn}, there is always a unique solution.

3.2.2.1. Spectrum of nonuniformly sampled signals

In [89, 88] the spectrum of nonuniformly sampled signals has been derived, for the case that the nonuniform sampling instants tn deviate from a uniform grid nTs by a fnite amount, i.e.:

tn = nTs + Θ(tn), (3.21) where Θ(tn) is a band-limited function. Then the signal xs sampled at the nonuniform time instants tn can be modeled as the product of the original signal x and the comb

66 3.2. Data acquisition function xp:

xs(t) = x(t)xp(t) (3.22) ∑∞ xp(t) = δ(t − tn). (3.23) n=−∞

The Fourier series expansion of xp yields [88]: ⏐ ⏐ ⎡ ⎤ ⏐1 − Θ˙ (t)⏐ ∞ ( Θ ) ⏐ ⏐ ⎢ ∑ 2πlt 2πl (t) ⎥ xp(t) = ⎢1 + 2 cos − ⎥ (3.24) T ⎣⎢ T T ⎦⎥ s l=1 s s ⏐ ⏐ ⎡ ⎤ ⏐1 − Θ˙ (t)⏐ ∞ ( Θ ) ⏐ ⏐ ⎢ ∑ 2πlt 2πl (t) ⎥ xs(t) = x(t) ⎢1 + 2 cos − ⎥ , (3.25) T ⎣⎢ T T ⎦⎥ s l=1 s s

It is noted in [88] that xp is essentially a phase modulated signal. Figure 3.3 shows an example from [88] of the spectrum of a series of nonuniform sampling pulses xp.

Figure 3.3.: Example spectrum of a nonuniform comb function [88].

3.2.2.2. Reconstruction of nonuniformly sampled signals

If the bandwidth of Θ is WΘ < π/Ts, the modulation spectra of xp do not overlap with the base band component [88]. Thus, lowpass fltering yields [88]: ⏐ ⏐ ⏐1 − Θ˙ (t)⏐ xp,lp(t) = (3.26) Ts

If in addition the bandwidths W and WΘ of x and Θ fulfll the condition π/Ts > W + WΘ, there is also no overlap with the base band component in xs and lowpass fltering yields [88]: ⏐ ⏐ ⏐1 − Θ˙ (t)⏐ xs,lp(t) = x(t) . (3.27) Ts

67 3. Theoretical foundations

Thus, the original signal can be recovered as [88]:

xs,lp(t) x˜(t) = ≈ x(t). (3.28) xp,lp(t)

3.2.3. Data acquisition structures

For waveform sampling, data acquisition systems employ a typical sequence of pro- cessing steps [65, 84, 48]. Figure 3.4 shows this sequence, also referred to as the digital measurement chain. First, a sensor converts the physical signal xphys(t) into an electri- cal signal xel(t). This then is amplifed or dampened in order to ft the input range of the successive processing elements. A lowpass flter, the anti-aliasing flter, ensures that all signal components above half the sampling frequency are damped below an acceptable 3 level . Next, the fltered signal x f ilt(t) is sampled by a sample-and-hold (S&H) circuit and its amplitude is quantized by an ADC. After this, the signal x[n] is fully digital and ready for further processing.

Figure 3.4.: Digital measurement chain [48].

When multiple signals have to be acquired simultaneously, the obvious solution is to let multiple instances of the digital measurement chain sample the signals in parallel and to collect the digital data via a data bus (see fgure 3.5(a)). Yet, this is often too expensive. Instead, analog multiplexer are used to sample all channels sequentially with the same ADC and S&H circuit (see fgure 3.5(b)). Thus, in such a multiplexed setup truly synchronous sampling of the channels is not possible. Instead the acquisition instants are shifted at least by one switching interval Tmux of the multiplexer. Tmux itself is greater or equal to the minimum conversion time of the ADC. The maximum time ofset between two channels is (N − 1)Tmux, where N is the number of channels [48]. However, this is ofset is commonly deemed small enough to be neglected.

3This is often one quantization step of the ADC.

68 3.2. Data acquisition

(a) parallel

(b) multiplexed

Figure 3.5.: Structures of multi-channel data acquisition systems [48].

69 3. Theoretical foundations

3.3. Digital resampling

In digital resampling an already sampled signal is sampled again and translated to an- other sampling grid. As will be shown in chapter 4, this can be used to synchronize data even after its acquisition. Furthermore, digital resampling makes it possible to change the output sampling rate of data acquisition system without changing the hardware, es- pecially the anti-aliasing-flter. Thus, the use of digital resampling greatly increases the fexibility of a wireless sensor. This section starts by introducing the major classes of digital resampling algorithms and their spectral efects in section 3.3.1. After this the most relevant flter algorithms are briefy presented in section 3.3.2. Finally, in section 3.3.3, practical issues for the implementation of these algorithms on digital processors are discussed.

3.3.1. Spectral effects and flter requirements

This section starts with sampling rate reduction and increase by an integer factor (sec- tions 3.3.1.1 and 3.3.1.1). After this, sampling rate changes by a rational factor and arbitrary resampling are treated in sections 3.3.1.3 and 3.3.1.4.

3.3.1.1. Sampling rate reduction by an integer factor

th To reduce the sampling rate ωs of a discrete signal by an integer factor, only every M sample is kept and the rest are discarded [25]:

y[l] = x[Ml], M ∈ Ž. (3.29)

In the spectrum this leads to a convolution of the original signal spectrum with a delta ′ comb of the spacing ωs = ωs/M. Thus, the original spectrum is replicated at multiples ′ of the new sampling rate ωs as shown in fgure 3.6.

Figure 3.6.: Spectral efect of decimation. X: amplitude spectrum of original signal ′ sampled at ωs; Y: amplitude spectrum of signal resampled at ωs = ωs/M.

70 3.3. Digital resampling

′ If the original signal x has a bandwidth larger than the new Nyquist frequency ωN = ′ ωs/2, the spectral replications overlap and aliasing occurs. To avoid this, a digital lowpass flter is commonly used before decimation (see fgure 3.7).

Figure 3.7.: Sampling rate reduction by an integer factor (decimation).

In order to avoid all aliasing, the flter H in fgure 3.7 needs to have a stopband that ′ starts at the new Nyquist frequency ωN and dampens all signal components below an acceptable error threshold δs. The passband ωp of the flter should encompass the entire signal bandwidth that is to be used for further evaluation. In the passband the ripple caused by the flter should not exceed an error threshold δp. Figure 3.8(a) shows this type A tolerance scheme together with the signal spectra V after fltering and Y after decimation [93]. The required steepness of the flter is dependent on the relative ∆ ′ width of the passband ω = 2π(ωN − ωp)/ωs. Thus, at high rate change factors M the passband quickly gets very narrow and very steep flters with high orders are required: ′ ( ) ωN − ωp 2π ωs ∆ω = 2π = − ωp (3.30) ωs ωs 2M π ⇒ ∆ω < . (3.31) M

However, the required steepness of the flter can be reduced by accepting aliasing in the flter’s transition band (see fgure 3.8(b)). This is only a minor concession, as the transition band is generally not used for further evaluation [93]. In fact, the only signal bands that really need to be damped below δs, are the frequency bands of ±ωp around ′ multiples of the new sampling frequency ωs, as they are mapped to the flter’s passband during decimation (see fgure 3.8(c)). Very efcient flter structures exist for this type C tolerance scheme (compare section 3.3.2).

71 3. Theoretical foundations

(a) Type A: no aliasing.

(b) Type B: aliasing in transition bands.

(c) Type C: only passband aliasing free.

Figure 3.8.: Tolerance schemes for digital anti-aliasing flters (after [93]). V is the sig- nal amplitude spectrum after fltering and Y the signal amplitude spectrum after decimation. Red shaded areas mark the frequency bands where alias- ing may occur.

72 3.3. Digital resampling

3.3.1.2. Sampling rate increase by an integer factor

In order to increase the sampling rate of a discrete signal by an integer factor L, L − 1 zero-valued samples are inserted between two samples of the original signal [25]: { [ ] x l , for l = 0, ±L, ±2L, ... ; L ∈ Ž y[l] = L (3.32) 0, otherwise

This interpolation leads to an increase of the signal bandwidth (see fgure 3.9). Thus, in general, components from the spectral repetitions around the original sampling rate ωs appear in the baseband of the interpolated signal. This efect, called imaging, can be suppressed by fltering the interpolated signal with a lowpass flter (see fgure 3.10). ′ This flter also needs to have a gain of L in order to obtain an amplitude of 1/Ts = L/Ts in the output signal [122, 102]. Similar to an anti-aliasing flter, an anti-imaging flter can be designed to suppress all signal components above the original Nyquist frequency. However, the frequency bands critical for imaging, are actually only those of ±W around multiples of the original sampling rate ωs. Thus, it is sufcient for the flter to dampen only those bands. This can be used to construct very efcient flters, especially for highly oversampled input signals.

Figure 3.9.: Spectral efect of interpolation. X: spectrum of original signal at sampling rate ωs.

Figure 3.10.: Sampling rate increase by an integer factor (interpolation).

73 3. Theoretical foundations

3.3.1.3. Sampling rate change by a rational factor

Digital resampling that changes the sampling rate by a rational factor R = L/M can easily be achieved by combining an interpolator and a decimator with the integer factors L and M [25]. In this case, the digital lowpass flters after the interpolator and before the decimator can be replaced by one that fulflls the spectral requirements of both an anti-aliasing and an anti-imaging flter. This approach has been successfully been used to resample acquired data from motors at constants speeds in [47].

Figure 3.11.: Digital resampling with rational rate change factor.

3.3.1.4. Arbitrary resampling

In order to resample a signal at arbitrary time instants the hybrid discrete/continuous model shown in fgure 3.12 is used [7, 46]. First, the original discrete signal x[n] is modulated with a delta comb and fltered with a lowpass flter. If an ideal lowpass was used, this would implement the reconstruction theorem (3.20). Otherwise the resulting continuous signal y is an approximation of the original continuous signal. After the reconstruction, the continuous signal y is sampled at the desired new sampling instants ′ lTs. Thus, the lowpass flter also serves as anti-aliasing flter for the sampling stage. Although this process contains continuous intermediate signals and processing steps, fully discrete fltering algorithms can be obtained from it [7, 46]. One example is the transposed Farrow flter, which is described in section 3.3.2.4.

Figure 3.12.: Hybrid discrete/continuous model of digital resampling [7].

3.3.2. Filter algorithms

This section introduces a number of basic digital resampling algorithms. A focus is put on decimation flters, as they are more relevant for this thesis.

74 3.3. Digital resampling

3.3.2.1. FIR flters

Lowpass flters with fnite impulse response (FIR) are well suited for interpolation and decimation with integer rate change [25, 122]. The transfer function and diference equation of an FIR flter are [102, 25]:

∑Q H(z) = h[q]z−q (3.33) q=0 ∑Q y[n] = h[q] · x[n − q], (3.34) q=0 where Q is the flter order and h the impulse response of the flter. The diference equation of a FIR-decimator with the structure from fgure 3.7 can be directly obtained by combining (3.29) and (3.34):

y[l] = v[Ml] (3.35) ∑Q v[n] = h[q] · x[n − q] (3.36) q=0 ∑Q y[l] = h[q] · x[Ml − q], (3.37) q=0

A consequence of (3.37) is that although the lowpass fltering logically comes before the decimation, it is possible to calculate the entire FIR flter at the lower output rate. This is also referred to as the polyphase implementation of an FIR decimator, as it in- volves creating Q + 1 intermediate signals v, whose phase difers by one input sampling period (compare 3.13(a)). Corresponding polyphase FIR interpolation flters can also be derived [25].

Unlike infnite impulse response (IIR) flters, FIR flters are always stable and can be designed with a linear phase response. Since FIR decimation and interpolation flters in polyphase implementation are as efcient as IIR flters, FIR flters are generally preferred in resampling applications [122, 25]. Anti-aliasing flters of types A and B can be easily designed with FIR flters. Furthermore, iterative least-squares and equiripple design algorithms for FIR flters, allow approximating nearly any desired frequency response [102, 47].

A major disadvantage of FIR resampling flters is that the required flter order increases quickly with the rate change factor. Therefore, they are primarily used at small factors (range 1 ... 10).

75 3. Theoretical foundations

0 −20 −40 −60 −80

magnitude [dB] −100 −120 0 0.5 1 1.5 2 ω/ω’ [1] s

(a) Efcient flter structure. (b) Example frequency response.

Figure 3.13.: FIR decimation flter.

The minimum flter order Q of an FIR lowpass flter using equiripple design can be estimated as [102]:

−10 log (δpδs) − 13 Q = 10 , (3.38) 2.324∆ω where δp and δs are the allowed frequency response ripple in the pass- and stopband and ∆ω = 2π (ωstop − ωp) /ωs is the normalized transition bandwidth. For a type A decimation flter the stopband edge ωstop is directly dependent on the decimation ration M: ω ω = ω′ = s (3.39) stop N 2M

As the passband edge ωp has to be smaller than ωstop, it can be written as:

ωp = a · ωstop, 0 < a < 1 (3.40) aω = s (3.41) 2M Thus the transitional bandwidth becomes: 2π ( ω aω ) ∆ω = s − s (3.42) ωs 2M 2M π = (1 − a) (3.43) M Thus, the required flter order is proportional the rate change factor:

−10 log (δpδs) − 13 Q = 10 · M (3.44) 2.324π(1 − a)

76 3.3. Digital resampling

Table 3.1 shows the computational and memory requirements of a polyphase FIR deci- mator. A key feature of this flter is that the rate of mathematical operations, i.e. addi- tions and multiplications, is independent of the high input sampling frequency.

Table 3.1.: Computational and memory requirements of a polyphase FIR-decimator. flter order Q bufer number Q ′ addition rate Q · ωs 2π ′ multiplication rate (Q + 1) · ωs 2π ′ ωs operation rate (2Q + 1) · 2π

3.3.2.2. CIC flter

A diferent class of flters for decimation and interpolation with integer rate changes are cascaded integrator-comb (CIC) flters [58]. Their key feature is that they do not require any multiplications and can thus be implemented very efciently. As shown in fgure 3.14(a), a CIC-decimator of the order Q consists of a cascade of Q integrators before the decimation and Q comb flters after it [58]. In a CIC-interpolator the comb flters come before and the integrators after the interpolation.

0 −20 −40 −60 −80 magnitude [dB] −100 −120 0 2 4 6 ω/ω’ [1] s

(a) Filter structure. (b) Example magnitude frequency response.

Figure 3.14.: CIC decimation flter.

The frequency response of a CIC flter referenced to the higher sampling rate is:

( )Q ⎡MP−1 ⎤Q 1 − z−MP ⎢ ∑ ⎥ H(z) = = ⎢ z−q⎥ . (3.45) 1 − z−1 ⎣⎢ ⎦⎥ q=0

77 3. Theoretical foundations

Thus, a CIC is equivalent to a cascade of FIR flters and like them possesses a linear phase response. There are only three integer valued parameters in a CIC flter: the rate change factor M, the flter order Q and the diferential delay P [58]. The flter order is commonly chosen in the range of Q = 1 ... 6 and the diferential delay P = 1, 2. Figure 3.14(b) shows the magnitude frequency response of a CIC-decimator. It is obvious that CIC flters only ofer type C alias or imaging suppression. Furthermore, the passband attenuation is relatively high and alias suppression is only efective in narrow bands around multiples of the output sampling rate. The decisive advantage of CIC flters is that they can be used to realize very large M (above 100) at very little computational costs (see table 3.2).

Table 3.2.: Computational and memory requirements of a CIC-decimator. flter order Q bufer number Q(1 + P) ′ ωs ωs addition rate Q 2π + Q 2π multiplication rate 0 ′ ωs ωs operation rate Q 2π + Q 2π

3.3.2.3. Polynomial interpolation

Polynomial interpolation is often chosen to determine signal values at arbitrary points of time [14, 17, 139, 90]. It is an implementation of the hybrid model given in fgure 3.12, as the process can be modeled by frst constructing a continuous function by interpolation and then sampling at new time instants. Thus, the various polynomial interpolation methods can be described as continuous reconstruction flters. In [90] the impulse and magnitude frequency responses of three types of polynomial interpolation have been derived: sample-and-hold (S&H), linear and cubic interpolation. The results are shown in fgure 3.15. S&H-interpolation can be treated as zero-order polynomial interpolation. It is equiva- lent to convolving the discrete input signal with a rectangle function [90]:

⎧ 1, for 0 < t < T ⎪ s h (t) = ⎨ 1/2, for t = 0 and t = T . (3.46) S &H ⎪ s ⎩⎪ 0, otherwise

The resulting frequency response is [90]:

( ω ) sin π ω 2π ωs − jπ H (ω) = · e ωs . (3.47) S &H ω π ω s ωs

78 3.3. Digital resampling

S&H linear cubic S&H linear cubic

1.5 0 1 −20 −40 0.5 −60 −80 0 amplitude [1]

magnitude [dB] −100 −0.5 −120 −2 −1 0 1 2 0 2 4 6 t/T [1] ω/ω [1] s s

(a) Impulse responses. (b) Frequency responses.

Figure 3.15.: Polynomial interpolation flters.

Linear interpolation is equivalent to convolution with a triangle function [90]: { 1 − t/T , for |t| < T h (t) = s s , (3.48) lin. 0, otherwise with the frequency response [90]: ⎡ ( )⎤2 ⎢sin π ω ⎥ 2π ⎢ ωs ⎥ Hlin.(ω) = ⎢ ⎥ . (3.49) ω ⎣⎢ π ω ⎦⎥ s ωs

Finally, if four samples of the signal are interpolated by a cubic function using La- grangian interpolation and the center interval is evaluated, the impulse response of the flter is a piecewise polynomial: ⎧ 1 t t t ⎪ ( + 3)( + 2)( + 1), for − 2Ts < t ≤ −Ts ⎪ 6 Ts Ts Ts ⎪ 1 t t t ⎪ − ( + 2)( + 1)( − 1), for − Ts < t ≤ 0 ⎪ 2 Ts Ts Ts ⎨⎪ 1 t t t hcub.(t) = ( + 1)( − 1)( − 2), for − 0 < t ≤ Ts , (3.50) ⎪ 2 Ts Ts Ts ⎪ 1 t t t ⎪ − ( − 1)( − 2)( − 3) for Ts < t ≤ 2Ts ⎪ 6 Ts Ts Ts ⎩⎪ 0, otherwise The frequency response is then: ⎡ ( )2 ⎤ ⎡ ( )⎤4 ⎢ 2π ω ⎥ ⎢sin π ω ⎥ 2π ⎢ ωs ⎥ ⎢ ωs ⎥ Hcub.(ω) = ⎢1 + ⎥ ⎢ ⎥ . (3.51) ω ⎢ 6 ⎥ ⎣⎢ π ω ⎦⎥ s ⎣ ⎦ ωs

As can be seen from fgure 3.15(b), polynomial interpolation, especially at low orders, has only a very narrow passband with tolerable attenuation. The alias attenuation is

79 3. Theoretical foundations also relatively poor, as the flter slopes are not very steep. However, the magnitude frequency responses of polynomial flters show high damping around multiples of the input sampling rate. Thus, they provide a reasonable imaging suppression for highly oversampled signals.

Table 3.3.: Computational and memory requirements of a polynomial interpolation. S&H linear cubic bufer number 0 1 3 ′ ′ addition rate 0 3 ωs a 18 ωs a 2π′ 2π′ multiplication rate 0 3 ωs a 18 ωs a 2π′ 2π′ ωs a ωs a operation rate 0 6 2π 36 2π

aValues were calculated by the author assuming Neville’s algorithm and a uniform input sampling interval.

3.3.2.4. Transposed Farrow flter

The transposed Farrow flter [7] implements the hybrid flter model shown in fgure 3.12. As the model has only discrete in- and outputs the convolution integral (3.52) of the continuous fler ha can be reduced to a sum [7]: ∫ ∞ y(t) = x(τ)ha(t − τ) dτ (3.52) −∞ ∞ ′ ∑ ′ y[l] = y(lTs) = x(tn)ha(lTs − tn). (3.53) n=−∞

In a transposed Farrow flter, the impulse response ha is a piecewise polynomial of fnite length [7]:

Q∑−1 ∑M ha(t) = cm[q] fm(q, t), (3.54) q=0 m=0 where M is the polynomial order and Q the number of polynomial segments. The polynomials are expressed in terms of a kernel fm and polynomial coefcients cm that underlie a symmetry constraint:

⎧ ( − ′ )m ⎪ 2(t qTs ) ′ ′ ⎨⎪ T ′ − 1 , qTs ≤ t < (q + 1)Ts fm(q, t) = ⎪ s (3.55) ⎩⎪ 0, otherwise { cm[q] , m even cm[Q − 1 − q] = . (3.56) −cm[q] , m odd

80 3.3. Digital resampling

th The fractional interval µn ∈ [0, 1) specifes the location of the n input sample with th reference to the ln output sample, which is the output sample that occurs directly at or before it: ′ tn = (µn + ln)Ts. (3.57) ′ 4 The polynomial kernel fm evaluated for t = lnTs − tn can be expressed as : { m ′ (1 − 2µn) , µn , 0 fm(q, lTs − tn) = m . (3.58) (−1) , µn = 0 Substituting (3.54) to (3.56), (3.58) into (3.53) and rearranging the order of summation yields: ⎡ ⎤ n (q,l) Basis multipliers ∑M Q∑−1 ⎢ up∑   ⎥ ′ ⎢ ′ ⎥ y(lTs) = cm[q] ⎢ x(tn) fm(q, lTs − tn)⎥, (3.59) ⎢ ⎥ m=0 q=0 ⎣n=nlow(q,l) ⎦    Integrate & dump    Cm where nlow(q, l) and nup(q, l) mark the lower and upper boundaries of the interval, where ha is nonzero. The fltering equation 3.59 can be expressed as the structure shown in fgure 3.16.

Figure 3.16.: Structure of the transposed Farrow flter [7, 82].

The flter is made up of M + 1 parallel branches, each consisting of an integrate-and- dump (I&D) block and a fxed FIR subflter Cm(z) of the flter order Q − 1. The input samples x[n] are multiplied with powers of (1 − 2µn) or −1 and the results are accumu- ′ lated in the I&D blocks. At every output sampling instant lTs ,their outputs are fed into the subflters Cm(z) and the accumulators of the I&D blocks are reset. The output of the transposed Farrow flter is obtained by summing over the outputs of all subflters. 4 ′ m In [7] only fm(q, lTs − tn) = (1 − 2µn) is given. Yet, calculations of the author show that this leads to ′ errors, if the function is evaluated for lTs − tn = 0, i.e. µn = 0. See appendix B for details.

81 3. Theoretical foundations

Table 3.4.: Computational and memory requirements of a transposed Farrow flter. polynomial order M (typical=1. . . 3) number of pol. intervals Q (even number, typical=2. . . 10 ) bufer-number M + Q + 1 ′ settling time QTs ′ addition-rate (M + 1) ωs + [Q(M + 1) − 1] ωs [69] 2π ′ 2π multiplication-rate M ωs + 1 Q(M + 1) ωs [69] 2π 2 2π ′ ωs [ 3 ] ωs operation-rate (2M + 1) 2π + 2 Q(M + 1) − 1 2π

The transposed Farrow flter is very efcient in resampling signals, when the output sampling rate is lower than the input sampling rate. Its computational and memory requirements are given in table 3.4. Figure 3.17 shows a typical magnitude frequency response of a transposed Farrow flter. It is obvious that only type C alias suppression is provided. Furthermore, there is notable signal attenuation in the passband.

0 −20 −40 −60 −80 magnitude [dB] −100 −120 0 1 2 3 ω/ω’ [1] s Figure 3.17.: Example magnitude frequency response of a transposed Farrow flter.

3.3.2.5. Summary and flter cascades

Table 3.5 summarizes the properties of the resampling flter algorithms that have been introduced. An ideal resampling flter would provide type A alias suppression and low passband distortion for any rate change factor at a minimum flter order and computa- tional load. It is apparent that no flter can satisfy all these demands. For integer rate changes FIR flters ofer good frequency response properties, but can only efciently handle small rate change factors. CIC flters on the other hand are very efcient also for high rate change factors, but introduce signifcant signal distortions. Arbitrary rate changes are easy to implement with low order polynomial interpolation. However, this often does not ofer a satisfactory signal quality. The transposed Far-

82 3.3. Digital resampling

Table 3.5.: Comparison of resampling flter algorithms. Filter Rate change Alias Passband Required Computational factor type distortion order load Polyphase FIR M ∈ Ž A,B ++ - o CIC M ∈ Ž C-- ++ ++ S&H Interpolation R ∈ ’ none - - n/a ++ linear Interpolation R ∈ ’ none - - n/a ++ Cubic-Spline Interpol. R ∈ ’ none - n/a + Trans. Farrow R ∈ ’ C- + + n/a = not applicable row flter on the other hand has a much more complex algorithm, but ofers a good compromise between signal quality and computational complexity. Yet, it still shows signifcant passband attenuation. In many resampling applications the best results can be achieved by cascading diferent types of flters. In [58] it is, for example suggested, to use CIC flters only for the largest part of the rate change and to combine them with an FIR flter in the last stage. The frequency response of this FIR flter can then be designed to provide type A alias suppression as well as to compensate for the passband attenuation of the CIC flter. For similar reasons, transposed Farrow flters have been cascaded with FIR flters in the output stage [82].

3.3.3. Number formats

On computers, numbers need to be represented by a fnite number of bits. The two most common representations of real numbers are the fxed point and the foating point format. In both formats, numerical errors arise, as the infnite range and resolution of real numbers is mapped to a fnite number of bits. Understanding the number formats and the resulting numerical errors, is key to implementing flter algorithms in a way that is both efcient and accurate.

3.3.3.1. Fixed-point numbers

Signed integer numbers on a computer are generally represented in the two’s comple- ment [117]:

N−2 N−1 ∑ n A = −2 aN−1 + 2 an, (3.60) n=0

83 3. Theoretical foundations where A is the represented number, N the number of bits and an the bit values. By mentally multiplying the number with a scaling factor 2− exp(a), also fractional numbers can be represented [102, 117]:

⎡ N−2 ⎤ ⎢ ∑ ⎥ A = 2− exp(a) ⎢−2N−1a + 2na ⎥ (3.61) ⎣⎢ N−1 n⎦⎥ n=0    =a A = a · 2− exp(a), (3.62) where a is called the mantissa and exp(a) ∈ Ž the exponent. Only the mantissa and not the exponent is stored on the computer. Thus, the processor treats it the same as any other integer number. The programmer alone is responsible for interpreting and using a fxed-point number according to its exponent.

To denote fxed-point numbers with diferent exponents the Q-format is used [117]. A number in the Qm.n format has N = m + n + 1 bits, with m bits in the integer part, n bits in the fractional part and one bit for the sign. The range that can be represented is [−2m, 2m − 2−n] and the resolution is q = 2−n [117].

The fxed-point format of a number can be changed by bit-shifting the mantissa, i.e. multiplying it with a scaling factor [117]:

′ ′ a · 2− exp(a) = a · 2exp(a )−exp(a) ·2− exp(a ) (3.63)    =a′

Depending on the direction of the shift (right or left), trailing or leading bits are lost during this operation, which can lead to round-of or overfow errors (see also section 3.3.3.3).

Two fxed-point numbers A and B can only be added or subtracted, if they are in the same format Qm.n. In this case the result C is:

C = A ± B = a · 2− exp(c) ± b · 2− exp(c) (3.64) and may require the format Q(m + 1).n [117].

Multiplication of two fxed-point numbers is always possible:

C = A · B (3.65) C = a · b · 2−(exp(a)+exp(b)) (3.66)

However, the result requires signifcantly more bits, i.e. C is Q(m + k + 1).(n + l), if A is Qm.n and B is Qk.l [117].

84 3.3. Digital resampling

Division is similar to multiplication: A C = (3.67) B a C = · 2−(exp(a)−exp(b)) (3.68) b However, the result is in the format Q(m + l + 1).(n + k), if A is Qm.n and B is Qk.l [117].

3.3.3.2. Floating-point numbers

The biggest drawback of fxed-point number formats is their small dynamic range, i.e. it is generally not possible to accurately represent very small and very big numbers within the same number format, due to the fxed exponent [102]. Therefore foating point numbers, store the exponent as well as the mantissa. This makes it possible to dynamically adapt the exponent to the size of the number. The IEEE 754 standard defnes the following representation for a 32 bit foating point number [16]:

A = (−1)s(0.5 + f )2p−126, (3.69) where s is the sign bit, f a 23 bit number, that represents an unsigned fraction in the range [0, 0.5), and p an unsigned 8 bit integer, denoting the exponent. Arithmetic operations with foating-point numbers essentially work the same way as with fxed-point numbers. Yet, for foating-point numbers the computer has to perform the format changes necessary to keep a constant number of bits dynamically during the calculations. On powerful modern computers these calculations are accelerated by a hardware foating-point unit (FPU). Yet, on the low-cost embedded microprocessors typically used in WSN, a FPU is usually not available [117]. Thus, fxed-point calcu- lations generally run signifcantly faster than foating-point calculations on such hard- ware, as the programmer can minimize the needed format conversions in advance.

3.3.3.3. Numerical errors

Numerical errors arise in digital computations regardless of whether fxed- or foating- point numbers are used. In general, two types of numerical errors can be distinguished: overfow and quantization errors. The following analysis focuses on fxed-point arith- metic as it is more relevant for the use in WSN (compare section 3.3.3.2). Overfow errors arise when the result of a calculation needs more bits than are present in the output variable, e.g. when the sum of two 8 bit numbers is 100 + 50 = 150, but the largest representable output value is 127, because the output variable is also

85 3. Theoretical foundations

8 bit. This may cause large nonlinear errors, as the number wraps around and may be interpreted as negative, e.g. −106 in the example above. An interesting property of the two’s complement is that, if the sum of multiple values is within the representable range, it will be calculated correctly, even if intermediate results overfow [102]. Quantization errors arise because numbers cannot be represented with infnite precision. They are often also referred to as round-of or truncation errors, depending on whether a number is rounded to the closest number, which can be represented within the given resolution, or simply truncated after the least signifcant bit. Digital flters are afected by quantization errors in two ways: First, the quantization of their coefcients changes the flter characteristic. Second, quantization of results creates additional noise in the output signal. Regarding the coefcient quantization FIR flters are far less sensitive than IIR flters [102, 16]. Furthermore, higher order FIR flters are more strongly afected than lower order ones, as their zeros are placed more closely together [102]. In [71] it is even shown, that when approximating a desired frequency response with an FIR flter having fnite wordlength coefcients, there is a flter order Qmax, beyond which the approximation quality does not improve. The exact value of Qmax is dependent on both the number of bits for the coefcients and the desired frequency response. Calculation of Qmax is only possible through an iterative search algorithm. In [71], Qmax is calculated to be in the range of 36 ... 53 for 12 bit coefcients and six diferent target frequency responses. The additional noise in the output signal, caused by result quantization, is generally modeled to be stationary, white and uncorrelated with the signal. Its distribution is assumed as uniform with a variance of [16] (see also section 3.4.2.1): q2 σ2 = . (3.70) q 12 For a Qth-order FIR flter with rounding after every multiplication the output noise variance is [102, 16]: q2 σ2 = (Q + 1) . (3.71) q 12 If, however, the intermediate results are not rounded after every multiplication and instead an accumulator with double-wordlength is used the output noise variance is only [102, 16]: q2 σ2 = , (3.72) q 12 as rounding only takes place at the output stage. This optimization is only possible in fxed-point arithmetic, because in foating-point arithmetic rounding automatically takes place after every operation. Thus, using fxed-point arithmetic ofers better control over quantization errors and may, in some cases, even enable more accurate calculations [16].

86 3.4. Quality of measurements and signals

3.4. Quality of measurements and signals

A key characteristic of any measurement or data acquisition device is the quality of the results that can be expected from it. The measurement uncertainty, which is introduced in section 3.4.1, today is the accepted way to express the quality of any single valued measurement result. For acquired signals, that consist of a set of samples other qual- ity measures are used. These are introduced in section 3.4.2. Sine wave signals are frequently used to assess the performance of measurement systems (compare section 4.6). Therefore, algorithms to estimate their parameters and purity are given in section 3.4.3.

3.4.1. Measurement uncertainty

The concept of measurement uncertainty is defned by the guide to the expression of uncertainty in measurement (GUM) [199]. This international standard aims to pro- vide a universal method for evaluating and expressing the uncertainty of measurement results. The GUM has been created by a joint working group of a number of interna- tional institutions including the International Organization for Standardization (ISO), the International Electrotechnical Commission (IEC) and the International Bureau of Weights and Measures (BIPM). It is the basis of many national standards like the DIN 1319 [57].

3.4.1.1. Concepts

The measurement uncertainty is a quantitative measure of trust in the measurement re- sult . . . that characterizes the dispersion of values that could reasonably be attributed to the measurand [199]. It can only be applied to a measurand, which is a well defned physical quantity that can be characterized by a single value [199]. The GUM recom- mends using the standard deviation to express the measurement uncertainty. Often the measurement result is not obtained directly from an observation of the measurand, but calculated from a number of input quantities, that have been measured. Measurement uncertainty is understood to be caused by infuence quantities, i.e. quantities that are not the measurand, but have an efect on the measurement result [199]. Thus, infuence quantities can be seen as a special type of input quantity. A related concept is the measurement error, which is the diference between the true and the observed value. As in practice the true value cannot be determined exactly, the measurement error is an idealized concept [199]. Commonly, the error ϵx is modeled as having a systematic component ∆x and a random component δx:

ϵx = ∆x + δx, (3.73)

87 3. Theoretical foundations

The systematic error ∆x is constant and repeatable, while the random error δx arises from unpredictable, stochastic temporal or spacial variations. The GUM assumes that all known signifcant systematic efects have been removed from the measurement re- sult prior to its evaluation [199]. Thus, the measurement uncertainty is only caused by random and unknown systematic errors.

3.4.1.2. Evaluation of the uncertainty

The general procedure for evaluating the uncertainty of a measurement, given in [107], is as follows:

1. Model relationship between measurand and input quantities

2. Record measurements

3. Calculate results and uncertainties

4. Report results

A procedure, that focuses more on the calculation of the uncertainty itself, is given in the GUM [199]:

1. Express mathematical relationship between the measurand Y and the input quan- tities Xi: Y = f (X1, ... , XN )

2. Determine estimates ˆxi for input quantities Xi

3. Calculate standard uncertainty u(xi) for each input quantity Xi

4. Evaluate covariances between input quantities

5. Determine estimate ˆy for measurand Y

6. Calculate combined standard uncertainty uc(y) of measurand

7. Calculate expanded uncertainty Uk = kuc(y)

In the following, the calculation of the standard, combined and expanded uncertainty is described in more detail.

88 3.4. Quality of measurements and signals

Calculation of the standard uncertainty

When evaluating the standard uncertainties of the input quantities Xi, the GUM distin- guishes between type A and type B evaluation [199]:

Type A evaluation is based on empirical data. For N independent measurements xi,n of the input quantity Xi, the estimate ˆxi is in most cases given as the arithmetic mean:

1 ∑N x = X = x (3.74) ˆi i N i,n n=1

The standard uncertainty u(ˆxi) of this estimate is the empirical standard deviation s(ˆxi) of the estimate ˆxi, which is calculated from the individual observations as follows: √ 1 ∑N s(x ) = (x − x )2 (3.75) i N − 1 i,n i n=1 s(xi) u(ˆxi) = s(ˆxi) = √ (3.76) N The degrees of freedom v should always be given with the uncertainty; in this case: v = N − 1.

Another frequent application is the estimation of the parameters ai of a M-th order linear model [49, 199]:

y = X a + ϵ (3.77) with:

T y = (y1, ··· , yN ) (3.78) ⎛ ··· M ⎞ ⎜ 1 x1 x1 ⎟ ⎜ ⎟ X = ⎜ . . .. . ⎟ (3.79) ⎜ . . . . ⎟ ⎝⎜ M ⎠⎟ 1 xN ··· xN T a = (a0, ··· , aM) , (3.80) where X is a matrix containing the observed input values, y a vector of observed output values, a is the parameter vector and ϵ a vector with noise. Then, the estimate ˆa of the parameters that minimizes the noise energy in a least-squares sense is:

( T )−1 T ˆa = X · X ·X · y (3.81)    =D

89 3. Theoretical foundations

And the empirical variance of the estimate is [49, 199]:

2 2 s (ˆa) = s (ϵ) · (dii)N (3.82) with:

1 ∑N s2(ϵ) = (y − y )2 (3.83) N − M − 1 n ˆn n=1

( T )−1 and (dii)N a vector with the main diagonal’s elements from D = X · X . Again the standard uncertainty is the empirical standard deviation of the estimates:

u(a) = s(a). (3.84)

The degrees of freedom are: v = N − M − 1.

Type B evaluation is based on previous knowledge, like manufacturer’s specifcations or general knowledge about the process. In this case, the standard uncertainty is the standard deviation of the portability distribution that is assumed for a quantity. For example, when only upper and lower boundaries a+ and a− are given for an input quantity Xi, a uniform distribution is assumed and the standard uncertainty is [199]:

a+ − a− u(xi) = σ(x) = √ (3.85) 12 a = √ , if a = a+ = a−, (3.86) 3 √ where G = 1/ 3 is called the weighting factor for the distribution.

Calculation of the combined standard uncertainty

The combined standard uncertainty expresses the uncertainty of the estimate for the measurand. It is calculated from the standard uncertainties of the input quantities by Gaussian error propagation [199]:

N ( )2 ∑ ∂ f u2(y) = u2(x ) (3.87) c ˆ ∂x ˆi i=1 i N ∑ 2 = (ciu(ˆxi)) , (3.88) i=1

90 3.4. Quality of measurements and signals

Table 3.6.: Coverage factors and confdence levels for a Gaussian distribution [199]. Coverage factor k [1] 1.000 1.645 1.960 2.000 2.576 3.000 Confdence level p [%] 68.27 90.00 95.00 95.45 99.00 99.73 where f is a function expressing the mathematical relationship between input quantities Xi and measurand y and ci is the sensitivity coefcient of Xi. When there is correlation between the input quantities, the propagation law needs to be extended [199]:

N N−1 N 2 ∑ 2 ∑ ∑ uc (ˆy) = (ciu(ˆxi)) + 2 cic ju(ˆxi)u(ˆx j)r(Xi, X j), (3.89) i=1 i=1 j=i+1 where r(Xi, X j) is the correlation coefcient for the input quantities Xi and X j.

Calculation of the expanded uncertainty

Often the expanded uncertainty Uk = kuc(ˆy) is given in addition to the combined stan- dard uncertainty [107, 199]. Its meaning is that the intervalˆy ± Uk encompasses a large portion of the value distribution of y [199]. This concept is similar to the confdence interval in statistics. However, the defnitions only match exactly, when all contributing uncertainties have been obtained from type A evaluation [199]. The coverage factor k determines the size of the portion from the value distribution that is covered. It is gen- erally not possible to link k exactly with a level of confdence, as the exact probability distribution of y is usually unknown [199]. However, in most applications an approx- imately Gaussian distribution is assumed, due to the central limit theorem [57]. Table 3.6 shows a selection of coverage factors and confdence levels for a Gaussian distribu- tion. In metrology the common choice for the coverage factor is k = 2 [57, 107, 199].

Reporting of results

When reporting a measurement result, the estimateˆy of the measurand and its combined standard uncertainty should be given [199]. This is often done in the form of a complete measurement result [107]:

Y = ˆy ± uc(ˆy) (3.90)

If the extended uncertainty is used instead of the standard one, the coverage factor k has to be given. In addition, the estimates for the input quantities together with their uncertainties, sensitivity coefcients and degrees of freedom should be given, in order

91 3. Theoretical foundations

Table 3.7.: Example of an uncertainty budget. cient f infuence estimate distribution weight standard uncertainty sensitivity coe degrees of freedom uncertainty contribution assumed uncertainty √ δ SE G u c v u √ δI 1.000 A 0.010 A uniform 1/ √3 0.006 A 10.00 V 1 0.058 W δU 10.00 V 0.010 V uniform 1/ 3 0.006 V 1.000 A 1 0.006 W

uc 10.000 W 1 0.058 W Uk=2 10.000 W 0.116 W to make the calculation of the result transparent [199]. In [107] it is suggested to present this information as an uncertainty budget in a table. Table 3.7 shows an example of such an uncertainty budget. This presentation also helps to analyze the relative strengths of diferent input quantities and to optimize measurement setups, in order to minimize uncertainty.

3.4.2. Signal quality

When acquiring a physical signal, the result is a digital waveform, which is character- ized not by a single value, but by a set of samples (compare section 3.2). Therefore quantities other than the measurement uncertainty are needed to express its quality as a whole5. This section briefy presents the errors, which may occur in signals and measures to quantify the relative magnitude of those errors.

3.4.2.1. Signal errors

In general, signal errors can be interpreted as additive amplitude errors:

˜x(t) = x(t) + ϵx(t), (3.91) where x is the error-free signal and ϵ is an error term.

5These quality measures themselves are measurands that can be attributed with a measurement uncertainty.

92 3.4. Quality of measurements and signals

Common systematic signal errors with linear efect are ofset, gain, phase shift:

ϵx,o f f (t) = const. (3.92) ϵx,gain(t) = a · x(t), a ∈ ’, a = const. (3.93) ϵx,shi f t(t) = x(t + ϵt) − x(t), ϵt ∈ ’, ϵt = const. (3.94)

The consequence of (3.94) is, that the timing error ϵt can equally be expressed as an amplitude error ϵx. Small time errors ϵt can be easily transformed into amplitude errors and vice versa, by locally linearizing the signal [201, 65]: ⏐ dx(t) ⏐ ϵx(t0) = ⏐ · ϵt(t0) (3.95) dt ⏐ t=t0 ⎛ ⏐ ⎞−1 dx(t) ⏐ ⎜ ⏐ ⎟ ϵt(t0) = ⎜ ⏐ ⎟ · ϵx(t0). (3.96) ⎝ dt ⏐ ⎠ t=t0

Another kind of systematic error occurs, when a signal is fed through an amplifer with a non-linear characteristic a(x):

˜xnon−lin.(t) = a (x(t)) · x(t). (3.97) This also alters the frequency content of the signal and may especially give rise to new harmonic components, called harmonic distortions [201, 84].

Random signal errors are often modeled as zero-mean Gaussian white noise ϵx(t) = w(t), but also other probability distributions may occur [84]. A common type of addi- tive amplitude noise is the quantization noise that occurs in data acquisition systems, when the continuous signal amplitude is discretized. The quantization error ϵq is dis- tributed uniformly over the interval [−q/2, q/2], where q is the quantization step of the data acquisition system. The expectation value and variance of the quantization noise are [66]:

E(ϵq(t)) = 0 (3.98) q2 Var(ϵ (t)) = . (3.99) q 12

3.4.2.2. Signal purity measures

Three ratios are commonly used to quantify the purity of signals: the SINAD, the SNR and the THD. The signal-to-noise and distortion (SINAD) is the ratio of a signal’s root- mean-square (RMS) value αrms to that of noise and distortion (NAD) [201], i.e. the RMS of the error ϵ in (3.91): α SINAD = rms . (3.100) NAD

93 3. Theoretical foundations

The NAD can be split up into the energy of noise η2 and the total energy of harmonic distortions THE [201]:

NAD2 = η2 + THE. (3.101)

This leads to the defnitions of the signal-to-noise (SNR) ratio and the total harmonic distortion (THD) [201]: α SNR = rms (3.102) η √ THE THD = . (3.103) αrms All three ratios are commonly expressed in the logarithmic pseudo-unit Decibel (dB), e.g.:

SINADdB = 20 log10 (SINAD) dB. (3.104)

3.4.3. Estimation of signal parameters

In order to assess the quality of an acquired waveform, signal parameters like the am- plitude, or purity measures like the SNR need to be estimated from the samples. This section presents algorithms to estimate the parameters of acquired sine wave signals (section 3.4.3.1), the phase diference between two sine waves (section 3.4.3.1) as well as the purity of a sine wave (section 3.4.3.3).

3.4.3.1. Sine wave parameters

A sine wave signal is sufciently characterized by four parameters: amplitude α, ofset x0, phase shift ϕ and angular frequency ω [201]:

x(t) = α sin(ωt + ϕ) + x0, (3.105)

Alternatively, every sine wave can be expressed as the sum of a sine and a cosine com- ponent:

x(t) = A0 cos(ωt) + B0 sin(ωt) + C0, (3.106) √ ( ) with α = A2 + B2, ϕ = − arctan B0 and x = C [201]. The standard IEEE 1057 0 0 A0 0 0 recommends two algorithms to estimate the parameters of a recorded sine wave signal [201].

94 3.4. Quality of measurements and signals

The frst algorithm, referred to as the three-parameter algorithm, can be used to estimate the parameters: amplitude, phase and ofset, when the frequency ω of the signal is known [201]. The algorithm minimizes the sum of squared approximation errors:

N 2 ∑ 2 ϵ = (x[n] − A0 cos(ωtn) − B0 sin(ωtn) − C0) , (3.107) n=1 where x[n] are the signal samples taken at the times tn. The least-squares estimate ˆs T of the parameter vector s = (A0, B0, C0) is obtained through a closed form linear equation:

( T )−1 ( T ) ˆs = D0 D0 D0 x , (3.108) ⎛ ⎞ cos(ωt1) sin(ωt1) 1 ⎜ ⎟ ⎜ . . . ⎟ T with D0 = ⎜ . . . ⎟ and x = (x1, ... , xN ) . ⎝⎜ ⎠⎟ cos(ωtN ) sin(ωtN ) 1 The second algorithm, referred to as the four-parameter algorithm, estimates all pa- rameters of a sine wave, i.e. does not require the signal frequency to be known [201]. Based on an initial estimate of the signal parameters, it iteratively improves the estimate through the following equations:

( T )−1 ( T ) ˆsi+1 = Di Di Di x (3.109) ˆωi+1 = ˆωi + ∆ωi+1 (3.110) with ⎛ ⎞ ⎜ cos(ˆωit1) sin(ˆωit1) 1 −Aˆit1 sin(ˆωit1) ˆBit1 cos(ˆωit1) ⎟ ⎜ ⎟ D = ⎜ . . . . . ⎟ i ⎜ . . . . . ⎟ ⎝⎜ ⎠⎟ cos(ˆωitN ) sin(ˆωitN ) 1 −AˆitN sin(ˆωitN ) ˆBit1 cos(ˆωitN ) and

( ∆ )T ˆsi = Aˆi, ˆBi, Cˆi, ωi . The algorithm is reported to converge rapidly and achieve good results after fewer than six iterations [201].

95 3. Theoretical foundations

The Cramer-Rao´ bound (CRB) is a lower bound to the variance of an estimator like the three- and four-parameter algorithms. Thus, it can be used to get an impression of the estimate’s quality and how it is infuenced by various quantities. In [4] the CRB for the estimation of sine parameters have been derived: 2η2 Var(α) ≥ CRB(α) = (3.111) N ⎧ 2η2 ⎪ = 1 , three-parameter estimation ( ) ≥ ( ) = ⎨ N·α2 N·SNR2 Var ϕ CRB ϕ ⎪ 8η2 (3.112) ⎪ = 4 , four-parameter estimation ⎩ N·α2 N·SNR2 η2 Var(x ) ≥ CRB(x ) = (3.113) 0 0 N 24η2 12 Var(ω) ≥ CRB(ω) = = , four-parameter estimation (3.114) N3 · α2 N3 · SNR2 Thus, all estimates improve with an increasing number of samples and deteriorate with increasing signal noise. The variance of the phase estimate increases by a factor of four when the frequency has to be estimated as well.

3.4.3.2. Phase difference

The phase diference ∆ϕ of two sine waves x1,2 with the same frequency can be es- timated by estimating their phases ϕ1,2, using the three- or four parameter algorithm introduced above, and calculating the diference [115, 127]:

∆ϕ = ϕ1 − ϕ2 (3.115) However, when the frequency of the two sine waves is unknown, more accurate results can be obtained by estimating the parameters of both sine waves simultaneously [115]. The resulting seven parameter algorithm minimizes following error term [115]:

N 2 ∑ 2 ϵ = (x1[n] − A1 cos(ωtn) − B1 sin(ωtn) − C1) n=1 N ∑ 2 + (x2[n] − A2 cos(ωtn) − B2 sin(ωtn) − C2) , (3.116) n=1 where A1, B1, C1 are the parameters of the frst sine wave, A2, B2, C2 those of the second sine wave and ω is their common frequency. Minimization of the error term is done iteratively, similar as in the four parameter algorithm. The phase diferences estimated with this seven parameter algorithm have been found to show only half the variance of the estimates obtained from the four parameter algorithm [115]. According to [127], the seven parameter algorithm is currently the most accurate and robust algorithm for the estimation of phase diference.

96 3.4. Quality of measurements and signals

3.4.3.3. Noise and distortions

To estimate the SINAD of a recorded sine wave signal x, the standard IEEE 1057 rec- ommends to calculate the best ft ˆx using the four-parameter algorithm (see section 3.4.3.1) [201]. Then the NAD is the RMS diference between x and ˆx: √ 1 ∑N NAD = (x[n] − x[n])2 (3.117) N ˆ n=1 (3.118)

The SINAD can then be calculated by using the estimate ˆαrms, for the RMS-amplitude of x, that has been obtained from the sine ft as well: α SINAD = ˆrms (3.119) NAD

For the estimation of the total harmonic energy (THE), the standard IEEE 1057 suggests to estimate the RMS-amplitudes of the signal harmonics by repeatedly applying the three-parameter sine ftting algorithm to the ft residuals [201]. Then the THE is:

N 1 ∑h THE = α2, (3.120) 2 ˆh h=2

th where ˆαh is the amplitude of the h signal harmonic, i.e. the component with the frequency ωh = h · ω. By default the nine lowest harmonics of a signal are evaluated for the THE, i.e. Nh = 10 [201]. The THD is then calculated as: √ THE THD = (3.121) ˆαrms and the SNR as: √ N η = (NAD2 − THE) (3.122) N − Nh α SNR = ˆrms . (3.123) η

Using sine ftting for the estimation has the advantage over alternative methods, e.g. using the FFT, that it is less sensitive to errors from non-coherent sampling, i.e. the signal not having been recorded exactly over an integer number of periods.

97

4. Modeling

In this chapter models of synchronous data acquisition with WSNs are developed. This will provide frst answers to the central questions of this thesis. First, the modeling of a WSN as a data acquisition system is introduced in section 4.1. Section 4.2 describes the modeling of acquisition errors, which leads to the defnition of a useful measure of synchronization precision. This basis is used in section 4.3 to develop a strategy for estimating the synchronization precision necessary in a given application. Approaches to time synchronous data acquisition are suggested in section 4.4 and approaches to synchronous angular sampling in section 4.5. Finally, section 4.6 suggests ways to test the synchronization precision in the individual data acquisition scenarios.

4.1. System model

This section introduces the model of a synchronous multi-channel event detection sys- tem as well as that of a multi-channel waveform sampling system.

4.1.1. Event detection

In a multi-channel event detection system, every channel i detects events and assigns timestamps ti to them. The event detection is synchronous if all channels observing the same event a assign the same timestamp to it:

ti(a) = t j(a) ∀i, j. (4.1)

The model is equally applicable to WSNs as to other multi-channel event detection systems. In a WSN, one or more channels may be located on a single node. Figure 4.1 shows the model applied to a WSN.

99 4. Modeling

Figure 4.1.: Model of a generic multi- Figure 4.2.: Model of a generic multi- channel event detection sys- channel sampling system tem applied to a WSN. applied to a WSN.

4.1.2. Waveform sampling

By abstracting from the structure of a parallel multi-channel data acquisition system given in fgure 3.5, a model1 of a generic multi-channel sampling system can be ob- tained. Figure 4.2 shows the structure of the model: Every channel samples a continu- ous signal xi(t) based on a series of trigger pulses. These trigger pulses are generated from a monotonically nondecreasing clock at predetermined instants. At the output of the system, the sampled signals xi[n] are combined to form a vector-valued signal x[n] = (x1[n], x2[n], ... , xM[n]). Synchronous sampling is then defned as the acquisi- tion of samples xi[n] = xi(tn) from all input signals with the same set of timing instants tn [Fun2, Fun4].

This modeling is equally valid for WSNs as for other multi-channel data acquisition systems [Fun1, Fun2, Fun4]. In a WSN one or more channels may be located on a single node. All nodes transmit the acquired data to a common data sink, where the combined output signal x[n] is formed. This mapping of the model matches well with the IEEE 1451 standard for smart sensors: acquiring nodes can be treated as TIMs and the data sink as a NCAP. The modeling also shows that data acquisition applications tend to assume a star topology for the underlying system (compare section 2.1.3).

1This model has been previously published by the author in [Fun2, Fun4].

100 4.2. Acquisition errors

4.2. Acquisition errors

The frst central question of this thesis is how synchronization precision can be defned in a way that is meaningful for measurement applications. To answer this question, the infuence of synchronization and more generally timing errors on the fnal measurement result is modeled. This modeling is based on the concepts of the GUM that were intro- duced in section 3.4.1. First, the modeling of event detection is done in section 4.2.1. In a second step, waveform sampling is treated in section 4.2.2. Finally, section 4.2.3 concludes on a useful measure for synchronization precision.

4.2.1. Event detection

In case of event detection the measurement result is a single number, i.e. the time in- stant tevent at which the event occurred (compare section 3.2). Although comparatively simple, event detection already involves several steps. A typical acquisition chain is shown in fgure 4.3.

Figure 4.3.: Data acquisition chain for event detection.

First, the physical quantity that contains the event is transformed to an electrical quan- tity by a sensor, e.g. a photodiode in a rotary encoder. Then, an analog signal processing stage amplifes and flters the resulting electrical signal, in order to make the event eas- ier to detect. Next the processed signal is converted into a one-bit digital signal by a threshold comparator. The occurrence of an event is signifed by a rising or falling edge in the digital signal. This edge triggers the reading of a clock by a digital circuit, often a microcontroller. The resulting clock value is the timestamp ˆtevent of the event.

101 4. Modeling

The measurement result is expressed in accordance to (3.90) as:

′ tevent = ˆtevent ± ut. (4.2)

Here, ut is the uncertainty ofˆtevent. This uncertainty is caused by unknown delays in the acquisition steps or errors of the clock. The overall error ϵt inˆtevent shall be modeled as the sum of a systematic component ∆t and a random component δt:

ˆtevent = tevent + ϵt (4.3) = tevent + ∆t + δt. (4.4)

The contribution of the individual processing steps to the error ϵt and the measurement uncertainty ut is analyzed in the following.

4.2.1.1. Analog stage

The sensor and analog signal processing are summarized as the analog stage of the event detection chain. Due to various phenomena like internal capacities or inertia, many sensors have a lowpass characteristic. More generally, sensors are often modeled as linear time-invariant (LTI)-systems (H1 in fgure 4.3). Likewise, the amplifcation and fltering during the analog signal processing is generally modeled as a LTI-system (H2 in fgure 4.3). The group delay of these systems infuences the event’s propagation along the chain. Its error contribution is modeled to be purely systematic ∆t,ana. The reason for this is that the components of sensors and analog circuitry generally do not change their properties over time, apart from a small temperature drift.

4.2.1.2. Threshold comparator

In the threshold comparator, amplitude errors ϵx of the input signal change the time, at which an edge is generated, by ϵt,comp. For small errors ϵx the time error is given by (3.96). Constant amplitude errors, like gain or ofset errors, result in a systematic component ∆t,comp of ϵt,comp. Random amplitude noise causes a random error δt,comp. As amplitude noise is commonly modeled to be zero-mean and Gaussian, δt,comp is also assumed to be zero-mean and Gaussian, with a standard deviation of:

⎛ ⏐ ⎞−1 ⎜ dx(t) ⏐ ⎟ σt = ⎜ ⏐ ⎟ σx, (4.5) ⎝ dt ⏐ ⎠ t=t0 where t0 is the time of detection and σx is the standard deviation of the amplitude noise.

102 4.2. Acquisition errors

4.2.1.3. Digital circuit

The propagation delays in digital circuits are usually constant. Thus, a constant com- ponent ∆t,digi is contributed. However, when using the interrupt of a microcontroller to detect a digital edge and read the clock, interrupt blocking code sections may introduce a random delay δt,int (see also section 5.1.2.1). If an interrupt blocking code section is Tblock long, recurs with a period Trep and is uncorrelated with the event to be detected, the probability of it causing a delay is:

Tblock Pdelay = . (4.6) Trep

Its length is distributed uniformly between 0 and Tblock. The situation is the same, if the blocking section occurs randomly with a probability of Pdelay. If Tblock varies randomly between Tblock,min and Tblock,max, the edges of the uniform distribution will round of at the edges, as large delays are less likely in this case. The exact form depends on the distribution of Tblock. When multiple blocking sections occur independently of each other their probability densities superpose.

4.2.1.4. Clock reading

When reading a discrete clock c at a time instant t1 the result is the clock’s counter value hc,1 = hc(t1). This is commonly transformed into a time reading using the clock model from (3.1):

ˆt1 = hc,1Tclock + t0. (4.7)

However, as the clock counter is only incremented at discrete time instants, the infor- mation actually contained in the reading, is that t1 is somewhere in the interval between two clock updates:

hc,1Tclock + t0 ≤ t1 < (hc,1 + 1)Tclock + t0. (4.8)

Thus, there is a random error δt,read in the clock reading, that is uniformly distributed over the interval (−Tclock, 0], (see fgure 4.4(a)). The expectation value is: T E(δ ) = − clock , (4.9) t,read 2 i.e. the time estimate ˆt1 is biased. The variance of δt,read is:

T 2 Var(δ ) = clock . (4.10) t,read 12

103 4. Modeling

(a) single clock reading (b) diference of two readings

Figure 4.4.: Probability density distributions of clock reading errors.

A clock readingˆt1 often only becomes useful when the diference ∆ˆt to another reading ˆt2 is calculated, i.e.:

∆ˆt = ˆt2 −ˆt1. (4.11)

In this case, the probability density function fX,∆(δ∆t) of the random error δ∆t in ∆ˆt is obtained from those of the single clock readings through convolution:

∫ δ∆t fX,∆(δ∆t) = fX,t(u) fX,t(δ∆t − u) du. (4.12) −∞ The result is a triangular distribution (see fgure 4.4). This assumes that the two clock readings, i.e. the reading instants’ relative positions to the clock updates, are statisti- cally independent. It is not necessary that the clocks or reading instants are uncorre- lated. With the same clock resolution for both readings, the expectation value of δ∆t is:

E(δ∆t) = 0, (4.13)

i.e. the estimate ∆ˆt = ˆt2 −ˆt1 is unbiased, even though the individual estimates ˆt1,2 are. The variance of δ∆t is: 2 Tclock Var(δ∆ ) = 2Var(δ ) = . (4.14) t t,read 6

4.2.1.5. Clock errors

The clock value itself may contain errors, e.g. an ofset ˜t0 , t0 (compare (4.7)) or a drift error ρ , 0. Ofset errors cause a systematic error contribution:

∆t,o f f = ˜t0 − t0. (4.15)

104 4.2. Acquisition errors

Table 4.1.: Summary of error infuences on the detection time ˆtevent Infuence Cause Distribution

∆t,ana group delay of analog circuitry - ∆t,comp constant amplitude errors - ∆t,digi propagation delay in digital circuit - ∆ f systematic t,o f f clock o set error -

δt,comp amplitude noise Gaussian δt,read clock reading uniform/triangular δt,int interrupt delay approximately uniform

random δt,dri f t clock drift error uniform δt,sync synchronization error approximately Gaussian

If the drift is constant ρ(t) = a, the clock error ϵc increases linearly with time:

ϵc = c(t) − t = at, with a = const. (4.16)

Often synchronization algorithms are used to limit the maximum clock error ϵc,max by periodically resetting the error to a value ϵc,min that is close to zero (compare section 2.2.2.1). In this case the drift error of the clock becomes a sawtooth function. Thus, when reading the clock at random instants, the resulting error δt,dri f t is uniformly dis- tributed between ϵc,min and ϵc,max.

The synchronization process itself may also introduce an error δt,sync into the clock value. Many publications report this to be approximately Gaussian distributed [124, 22, 35, 26]. However, also non-Gaussian error distribution are reported, e.g. bimodal in [42] and one-side truncated Gaussian in [77]. Apparently, the synchronization error is the combination of many error infuences that, due to the central limit theorem, often verges on a Gaussian distribution but may also difer signifcantly from it.

4.2.1.6. Conclusions

Table 4.1 summarizes the modeled systematic and random error infuences on event de- tection times. The distribution of the combined random error δt is a superposition of the individual infuences and depends very much on their relative strengths. If, for example, the drift error is dominating, an approximately uniform distribution is expected. While a dominant infuence from amplitude noise would lead to a Gaussian distribution. If none of the infuences dominates the others, an approximately Gaussian distribution is expected due to the central limit theorem.

The known systematic infuences should be used to correct the estimate ˆtevent of the event time. The variance of the unknown systematic infuences and that of the combined

105 4. Modeling random error infuences constitute the uncertainty of the measurement (compare section 3.4.1): √ ′ − ∆ ± ∆ tevent = ˆtevent t , known Var( t,unknown) + Var(δt) . (4.17)       =ˆtevent,corr =ut

A measure for timestamping precision that allows for easy comparison between difer- ent systems can be obtained by solving (4.10) for the clock resolution Tclock: √ Tclock = 12σt, (4.18) where σt is the standard deviation of a clock reading. If this is replaced with the timing uncertainty ut, an efective clock resolution Tclock,e f f is obtained: √ Tclock,e f f = 12ut. (4.19)

It can be interpreted as the clock resolution of an ideal timestamping system with the same timestamping uncertainty. Thus, it enables fast and intuitive comparisons of timestamping systems, like the efective number of bits does for ADCs.

4.2.2. Waveform sampling

An acquired waveform consists of a number of signal values x[n] and their correspond- ing sampling instants tn. As signals are usually sampled on a uniform sampling grid, the sampling instants are often specifed only implicitly through the sampling interval Ts and the timestamp of the frst sample t0.

tn = nTs + t0. (4.20)

Errors in the signal values may result from the sensor, analog signal processing or the characteristic of the ADC. They are commonly categorized as follows (see also section 3.4.2.1):

• ofset error

• gain error

• non-linear distortion

• additive noise2

2This includes quantization noise.

106 4.2. Acquisition errors

As in the case of event detection, errors in the acquired time values can arise from delays along the digital measurement chain or errors of the clock. In a WSN one cause may be the suboptimal synchronization between the individual nodes. Yet similar efects may also occur in non-wireless acquisition devices, e.g. through multiplexed acquisition or propagation delays of the clock signal on its path. It is often not possible to distinguish between errors in the signal and errors in the time values, as both may change the shape of the signal in the same way (see section 3.4.2.1). Thus, a common approach is to assume the time information to be exact and to attribute all errors to the signal values.

In the following, the signal errors that arise from the time base errors ofset, drift (con- stant and changing), jitter and time step are analyzed. For each error, its efect on an acquired sine wave and its spectrum is shown as an example. The errors are modeled as happening before the sampling of the signal. Thus, continuous signals and spec- tra are analyzed. The acquired waveform is obtained by sampling the error containing signals. An analysis largely identical to this section has been published by the author in [Fun2, Fun4].

4.2.2.1. Offset

An ofset error ∆t0 in the time instants causes a time shift in the sampled waveform:

˜to f f set,n = tn + ∆t0 (4.21) ∆ x(˜to f f set,n) = x(nTs + t0) = ˜xo f f set(tn). (4.22)

Due to the shift property of the Fourier transform [103] the spectrum X˜o f f set(ω) of the acquired waveform is phase shifted towards the spectrum of the original signal:

X˜o f f set(ω) = X(ω) · exp (− jω∆t0) (4.23) = X(ω) · exp (− j∆ϕ) (4.24) with

∆ϕ = ω∆t0. (4.25)

107 4. Modeling

ideal offset 1 0.6 1 0.4 0.5 0 0.2

signal [arb.] −1 magnitude [arb.]

sampling instant [s] 0 0 0 50 100 0 50 100 0 0.2 0.4 sample no. sample no. normalized frequency

Figure 4.5.:E fect of time ofset on an acquired sine wave.

4.2.2.2. Constant drift

When the actual time instants drift away from the ideal ones by a constant rate ρ, the resulting waveform is stretched or compressed along the time axis:

˜tdri f t,n = [1 + ρ] · tn (4.26) x(˜tdri f t,n) = x([1 + ρ] · nTs) = ˜xdri f t(tn). (4.27) Due to the time-frequency scaling property of the Fourier transform [103] the spectrum of the sampled waveform is a frequency scaled version of the original one: ( ) 1 ω X˜ (ω) = X (4.28) dri f t |1 + ρ| 1 + ρ 1 = X (ω) (4.29) |1 + ρ| ˜ with ω ω = . (4.30) ˜ 1 + ρ

4.2.2.3. Jitter

Jitter between the ideal and real-time instants can be modeled by the addition of zero- mean white Gaussian noise wt:

˜t jitter,n = tn + wt(tn). (4.31)

108 4.2. Acquisition errors

ideal constant drift 1 0.6 1 0.4 0.5 0 0.2

signal [arb.] −1 magnitude [arb.]

sampling instant [s] 0 0 0 50 100 0 50 100 0 0.2 0.4 sample no. sample no. normalized frequency

Figure 4.6.:E fect of constant timing drift on an acquired sine wave.

As can be seen form (3.95), the efect of jitter in the sampling instants is equivalent to additive amplitude noise wx: ⏐ dx(t) ⏐ w (t ) = ⏐ · w (t ) (4.32) x n dt ⏐ t n ⏐t=tn x(˜t jitter,n) = x(nTs + wt(tn)) (4.33) = x(nTs) + wx(tn) = ˜x jitter(tn) (4.34)

If the signal is completely linear, like a triangle or sawtooth, the distribution of wx will be the same as that of wt. Otherwise, its distribution will be shaped by the distribution of the signal’s gradient dx(t)/dt. In the spectrum this noise is spread over a broad band of frequencies (see fgure 4.7). In [134] it is shown, that for a periodic signal x(t) the power of this noise is:

∑M a2 ω2 σ2 η2 = m m t , (4.35) jit 2 m=1 f 2 where am are the Fourier coe cients of x(t) at the frequencies ωm and σt = Var(wt). For a sine signal x(t) = α sin(ωt) equation (4.35) reduces to:

α2ω2σ2 η2 = t . (4.36) jit,sin 2 In this case, the signal’s SNR as a result of timing jitter is [65] (compare (3.102)): √ α/ 2 1 SNR = = (4.37) η jit,sin ωσt ( ) 1 SNRdB = 20 log10 . (4.38) ωσt

109 4. Modeling

The denominator in equation 4.38 can also be treated as the standard deviation of an angle jitter:

σϕ = ωσt (4.39) ( ) 1 SNRdB = 20 log10 . (4.40) σϕ

ideal jitter 1 0.6 1 0.4 0.5 0 0.2

signal [arb.] −1 magnitude [arb.]

sampling instant [s] 0 0 0 50 100 0 50 100 0 0.2 0.4 sample no. sample no. normalized frequency

Figure 4.7.:E fect of timing jitter on an acquired sine wave.

4.2.2.4. Steps and changing drift

Instantaneous updates to the underlying clock, e.g. by a synchronization protocol, may cause steps in the time grid: { tn − ∆t0 n < n0 ˜tstep,n = . (4.41) tn n ≥ n0 Alternatively, more gradual updates may be done, e.g. through a PLL. This causes a changing drift in the signal:

˜tdri f t,change,n = [1 + ρ(n)] · tn. (4.42)

In both cases the efect on the acquired waveform can be modeled by frequency modu- lating the original one with:

d˜t(t) ω(t) = 2π . (4.43) dt The result is a complex non-linear distortion of the signal that adds a number of modu- lation bands to the waveform’s spectrum (compare section 3.2.2.1).

110 4.2. Acquisition errors

ideal time step 1 0.6 1 0.4 0.5 0 0.2

signal [arb.] −1 magnitude [arb.] sampling instant [s] 0 0 0 50 100 0 50 100 0 0.2 0.4 sample no. sample no. normalized frequency

Figure 4.8.:E fect of a time step on an acquired sine wave.

ideal changing drift 1 0.6 1 0.4 0.5 0 0.2

signal [arb.] −1 magnitude [arb.] sampling instant [s] 0 0 0 50 100 0 50 100 0 0.2 0.4 sample no. sample no. normalized frequency

Figure 4.9.:E fect of changing drift on an acquired sine wave.

111 4. Modeling

4.2.2.5. Correction of signal errors

If the actual acquisition times ˜tn of the samples are known, it is theoretically possi- ble to perfectly correct the distortion to the acquired signal, as long as the sampling theorems for uniformly or for nonuniformly sampled signals apply (see sections 3.2.1 and 3.2.2). However, the interpolation methods given by the sampling theorems cannot be evaluated exactly, as they involve infnite sums. Even their approximate evaluation is often too computationally expensive. Yet, practical interpolation methods exist that work well as long as the sampling rate is signifcantly larger than the signals Nyquist rate (compare section 3.3). They can be used to correct for the phase shift of a tim- ing ofset or the signal stretching of a constant drift error. The interpolation methods for nonuniformly sampled signals are generally more complex than those for uniformly sampled ones (compare section 3.3 and 5.3.1). Yet, the available algorithms also enable the reconstruction of signals afected by changing drift, if the actual acquisition times are known with enough precision.

4.2.2.6. Measurement uncertainty

As stated in [199] a measurement uncertainty can only be attributed to a single value (see also section 3.4.1.1). In the case of a sampled waveform, one approach is to at- tribute an uncertainty to every signal value:

Xn = x[n] ± u(x[n]). (4.44)

Assuming that the uncertainty infuences are stationary, the same uncertainty u(x[n]) = ux can be used for all samples n.

The contribution ux, jit of timing jitter to the uncertainty ux of a periodic signal is given by (4.35):

∑M a2 ω2 σ2 u2 = σ2 = m m t , (4.45) x, jit x, jit 2 m=1 where am are the Fourier coefcients of x(t) at the frequencies ωm. More generally, the jitter induced uncertainty, for any band-limited signal x(t), is bounded through the frst moment M1 of its Fourier transform X(ω) [105, 66]:

2 2 2 ux, jit ≤ M1σt (4.46) ∫ W 1 ⏐ ⏐ M1 = |ω| ⏐X(ω)⏐ dω, (4.47) ω 0 where W is the bandwidth of the signal.

112 4.3. Estimation of the required synchronization precision

Small uncertainties of the timing ofset or small and frequent timing steps can also be 2 expressed through a variance σt and converted into amplitude uncertainties with equa- tions (4.45) and (4.46). Yet, for drift errors and rare larger time steps, it is not possible to derive a meaningful uncertainty this way, because they are not well described by a variance. However, in many cases not the entire waveform is of interest, but only some of its properties, e.g. its amplitude, phase or frequency. In those cases it is more sensible to treat these properties as the measurands and attribute uncertainties directly to them. In this case (4.25) can be used to transform between timing and phase and (4.30) to transform between drift and frequency uncertainty.

4.2.3. Specifcation of synchronization precision

A result of the previous modeling is that a timing uncertainty expressed as a standard deviation can be easily transformed into a contribution to the measurement uncertainty in many cases: e.g. the measurement of event timestamps, signal values or signal phase. The knowledge of a systematic timing error ∆t can similarly be used to correct the measurement result. Thus, specifying the synchronization precision by a timing ofset ∆t and a standard deviation σt or a single timing uncertainty ut appears to be most useful. To compare diferent systems the efective clock resolution as defned in (4.18) may be used.

4.3. Estimation of the required synchronization precision

The error modeling of the previous section can be used to give an answer to the ques- tion, which synchronization precision is needed for a given application. The basic approach is to set an upper limit to the overall measurement uncertainty and then use uncertainty analysis to calculate the maximum allowed timing uncertainty (compare section 3.4.1). More precisely, the following procedure is suggested:

1. Defne the measurand of the application and set an upper limit uc,max for the allowed measurement uncertainty. If it appears easier to set an upper limit ϵmax for the measurement error, use a suitably high coverage factor k and convert this into an uncertainty uc,max = ϵmax/k (compare section 3.4.1.2). 2. Build a mathematical model of the relationship between measurand and input quantities, especially the relationship between the measurand and the acquisition timing. The equations given in section 4.2 can be helpful in this step.

113 4. Modeling

3. Obtain a frst estimate for the maximum allowed timing uncertainty, by assuming that it is the only error infuence and inverting (3.88): ⏐ ⏐ ⏐∂ f ⏐ ct = ⏐ ⏐ (4.48) ⏐ ∂t ⏐ uc,max ut,max = (4.49) ct

4. Refne this estimate by taking the uncertainty contributions of other input quanti- ties into account and build an uncertainty budget. If not sufcient information on the other uncertainty contributions is available, ut,max should be chosen such that there is a margin for unknown uncertainties. The overall uncertainty uc,max can be modeled as the combination of the maximum timing uncertainty ut,max and the combined uncertainty uother of all other infuences: 2 2 2 uc,max = (ctut,max) + uother (4.50) ( )2 ( )2 ctut max u ⇔ 1 = , + other (4.51) uc,max uc,max √ ( )2 ctut max u ⇔ , = 1 − other (4.52) uc,max uc,max

The values of ctut,max/uc,max at given values for the margin uother/uc,max are shown in table 4.2. When the margin is at 50 % the timing uncertainty can still use 86.6 %. Reducing the contribution of the timing uncertainty below 10 % will hardly ever be necessary, because it does not signifcantly increase the uncertainty margin any more.

Table 4.2.: Uncertainty margin for other infuences at given timing uncertainty.

uncert. margin uother/uc,max [%] 25.0 50.0 66.6 80.0 90.0 99.5 timing uncert. ctut,max/uc,max [%] 96.8 86.6 74.6 60.0 43.6 10.0

4.4. Approaches to time synchronous data acquisition

In this section approaches to time synchronous data acquisition are developed for event detection (section 4.4.1) and waveform sampling (section 4.4.2). They are based on the classifcation of time synchronization protocols into a priori and a posteriori syn- chronization introduced in section 2.2.1 and the analysis of acquisition errors in section 4.2.

114 4.4. Approaches to time synchronous data acquisition

4.4.1. Event detection

The approach to time synchronous event detection is to use a time synchronization pro- tocol to obtain synchronized timestamps for the events. This may be done with the help of an a priori protocol that always maintains synchronized clocks on all nodes. Alter- natively, the event may frst be timestamped from a local unsynchronized clock and the synchronized timestamps are obtained later through a posteriori synchronization.

4.4.2. Waveform sampling

Two approaches to time synchronous waveform sampling can be formulated: a proac- tive and a reactive one [Fun2, Fun4]. They follow a similar philosophy as in time synchronous event detection but take more distinct forms: In proactive synchronized sampling synchronized clocks trigger the sampling on all acquisition channels at the same timing instants (see fgure 4.10(a)).

(a) proactive approach (b) reactive approach

Figure 4.10.: Sampling systems with diferent approaches to time synchronous sam- pling.

In reactive synchronized sampling all acquisition channels trigger sampling indepen- dent from each other using unsynchronized local clocks. Only after the sampling has

115 4. Modeling been done, timestamps are assigned to the samples from a synchronized clock (see fg- ure 4.10(b)). This may be done directly on the acquiring node using an a priori syn- chronized clock. Alternatively it can also be done during transmission to the sink using a posteriori synchronization. Under the reactive approach, the samples from diferent channels will in general not have been sampled at the same timing instants, i.e. they are not synchronous according to the defnition in section 4.1.2. However, it is possible to obtain synchronous samples through interpolation and resampling as long as the sig- nals have been sampled in accordance with the Shannon-Nyquist theorem (see section 3.2.1). Accurate resampling is even possible when the original samples do not lie on a uniform sampling grid (see section 3.2.2).

A hybrid approach that combines the proactive and reactive elements is also possible [Fun2, Fun4]: The samples are acquired based on a synchronized clock and later they are timestamped in order to increase precision.

In the proactive approach the most efort is put into triggering acquisition at the right time. This requires a very good real-time performance of the underlying soft- and hardware. Corrections made to the sampling clock, e.g. by a time synchronization algorithm will lead to increased timing jitter or signal distortion. No extra efort is needed for signal processing in the proactive approach.

In the reactive approach by contrast, the extra efort needed before and during acquisi- tion is minimal. The only crucial point at this stage is the generation of accurate time- stamps. After the acquisition, signifcant efort is needed for the resampling of acquired waveforms. The quality of the measurement result greatly depends on the accuracy of the algorithms used for resampling. So far, practical realizations of synchronized wave- form sampling seem to use only the proactive approach [108, 91, 61, 159].

4.5. Approaches to synchronous angular sampling

In analogy to time synchronous waveform sampling a proactive and a reactive approach to synchronous angular sampling can be formulated. In the proactive approach the sampling is controlled as to record the signal at equidistant angular instants. In the reactive approach the signal is recorded at equidistant time instants and only later re- sampled to the desired equidistant angular instants. Both approaches have already been used, though not under those names. Today, the reactive approach, also known as syn- chronous angular resampling, is generally favored over the proactive one. The main reason for this is that directly sampling at the desired angular instants leads to a vari- able sampling frequency. This requires a variable anti-aliasing flter which is mostly too complex or expensive to be realized (compare section 2.4.2).

116 4.5. Approaches to synchronous angular sampling

In order to better understand the process of angular resampling, its signal theoretic background was investigated. As stated in section 3.1.4 any monotonically nondecreas- ing quantity can be used as “time”. Thus, a signal’s representation in angle domain, i.e. as a function of the rotation angle ϕ, is just as valid as its representation in time domain, i.e. as a function of time t. The only constraint is, that the direction of rotation does not change, because otherwise ϕ would not be monotonically nondecreasing. By ap- plying the Fourier transform to a signal in time domain it is transformed into frequency domain. In analogy to this, applying the Fourier transform to a signal in angle domain transforms it to order domain, where the order is the analog of the frequency. A sig- nal in angle domain, in general, has a diferent shape and diferent “time-frequency” properties than the same signal in time domain. The amplitude properties of the signal, however, remain unchanged. Figure 4.11 shows an example of a signal x, that is repre- sented in time and in angle domain. In angle domain the signal is a constant frequency sine wave. In time domain it is a linear chirp function. This illustrates that, more gen- erally, signals recorded from rotation machinery at changing speeds, are non-stationary in time domain but stationary in angle domain. Thus, representing such signals in angle domain greatly simplifes later signal processing. This is the key advantage of syn- chronous angular sampling and the reason for its frequent use in the analysis of rotation machinery (see also section 2.4).

Figure 4.11.: Representation of the same signal in time- and angle domain. The marked positions show time, angle and signal values of a uniform sampling grid with spacing Ts in time domain.

A signal sampled on a uniform sampling grid in time domain, will in general, have been sampled on a nonuniform sampling grid in angle domain and vice versa (see fg- ure 4.11). Thus, the process of synchronous angular resampling (see section 2.4)

117 4. Modeling can be described as transferring a signal from a nonuniform angular sampling grid ϕn = ϕ(tn) = ϕ(nTs) to a uniform angular sampling grid ϕl = lΦs. This insight en- ables the application of nonuniform sampling theory to the problem (see section 3.2.2). Furthermore, it allows the use of resampling algorithms developed in other domains. Thus, the treatment of synchronous angular sampling becomes more comprehensive and theoretically better founded than previous approaches (compare section 2.4.2).

4.6. Testing data acquisition systems

In order to get meaningful results, the test measurements should be as similar as pos- sible to the later application. Yet, at the same time they should not to cause too much extra cost and provide repeatable and comparable results. So far publications on WSN- synchronization have mostly focused on measuring the synchronization precision of clocks. This however, makes it difcult to compare the results to non-wireless acqui- sition systems, where usually no fgure is given for synchronization precision. Fur- thermore, other parts of the system that may have a signifcant infuence on the mea- surement results, e.g. interrupt delays, are neglected. Therefore, this section presents testing methods that focus on the systems’ overall performance. They are all appli- cable to WSNs as well as to non-wireless data acquisition systems, in order to enable direct comparisons between the two. Three data acquisition scenarios are treated: event detection (section 4.6.1), waveform sampling (section 4.6.2) and synchronous angular sampling (section 4.6.3).

4.6.1. Synchronous event detection

Synchronous event detection by several event detectors means that all assign the same timestamp to the same event (compare (3.3)). The most straight forward way to test this is to generate an event that is detected by all detectors. This method has already been used to characterize the synchronization of clocks in [119, 87]. In the simplest case, the event is a digital edge that is wired to the interrupt inputs of all sensor nodes as shown in fgure 4.12. In order to avoid a bias from the test setup, it should be ensured that the propagation time from the event’s source is the same for all detectors. To obtain representative results, the timestamps of many diferent events should be evaluated. Doing this, the intervals between the events should be randomized, in order to avoid correlation with internal processes of the WSN. Furthermore, the time between two events should be signifcantly larger than the maximum expected synchronization error, in order to avoid ambiguities in matching timestamps to events. The obtained timestamps can be used to estimate the measurement error. If all detec- tors were perfectly synchronized, they would all generate exactly the same timestamp.

118 4.6. Testing data acquisition systems

Figure 4.12.: Setup for testing synchronous event detection.

Thus, the pairwise timestamp diference ∆t is a measure of the synchronization error. Its mean ∆t and standard deviation s∆t should be calculated for every detector pair. The results can be readily used within the error model introduced in section 4.2.1. The stan- dard deviation s∆t can also be used to calculate the efective clock resolution (compare section 4.2.3 and equation (4.14)): √ Tclock,e f f = 6s∆t (4.53)

A deeper insight may be gained by evaluating the histogram of the timestamp difer- ences. Its shape may ofer indications regarding the dominant error infuences (compare section 4.2.1.6). Furthermore, the average relative drift of the clocks can be obtained through linear regression.

4.6.2. Synchronous waveform sampling

Synchronous waveform sampling has been defned to be the acquisition of samples from multiple channels at the same timing instants (see section 4.1.2). Thus, it is sug- gested to test it by simultaneously acquiring the same signal on all channels (see fgure 4.13) [Fun1]. It is further suggested to use a sine wave signal, as signal generators for high accu- racy sine waves are readily available. Furthermore, the use of sine waves allows for easy spectral analysis and separation between linear and non-linear efects, as they are

119 4. Modeling

Figure 4.13.: Setup for testing multi-channel waveform sampling. eigenfunctions to LTI-systems. Many of the test methods for single-channel digitizing waveform recorders defned in the standard IEEE-1057 [201] are based on the acquisi- tion of a reference sine wave. The parameters of the sine wave used for the test need to be chosen with care. Its peak-to-peak amplitude should cover most of the system’s analog input range, in order to minimize the efect of quantization errors. A coverage of more than 90 % is rec- ommended in [201]. Yet, clipping should be avoided, as it may introduce signifcant distortion into the acquired signal. Furthermore, it is recommended that in order to ob- tain precise test results, an integer number J ≥ 5 of signal periods should be recorded. The signal frequency ωsignal should be chosen such that the sampling instants lie at diferent phase angles in every signal period, i.e.: J ω = ω , (4.54) signal M s where ωs is the sampling frequency and M the number of acquired samples. Then, J should be chosen to be a relative prime to M [201]. Finally, the tests should be repeated at several frequencies that together span the expected frequency range of the application, as the properties of ADCs are often frequency dependent [201]. Using the algorithms introduced in section 3.4.3, the error infuences modeled in section 4.2.2 can be readily estimated from the acquired sine waveforms. The frequency ωrec of the acquired waveform can be estimated with high accuracy using the four parameter algorithm introduced in section 3.4.3.1. By comparing it to the known true frequency of the sine wave ωsignal the frequency error ϵ f and clock drift ρ of the acquisition channel can be obtained:

ϵω = ωrec − ωsignal (4.55) ω ϵ ρ = rec − 1 = ω . (4.56) ωsignal ωsignal

120 4.6. Testing data acquisition systems

The four parameter algorithm also estimates the amplitude and ofset of the waveform, which can be used to determine the gain and ofset error of the acquisition channel. f f ∆ A time o set error ϵt0 between two channels leads to a phase di erence ϕ in the recorded signals [Fun1]:

∆ϕ ϵt0 = . (4.57) ωsignal

Similar to the synchronous event detection in section 4.6.1 the phase shift during the transmission from the signal source should the same for all channels, in order to avoid a bias from the setup. The algorithm introduced in section 3.4.3.2 can estimate the phase diference between two sine waves with an accuracy even higher than that of the four parameter algorithm, if their frequency is identical. This assumption will hold true in the suggested setup, as long as the frequency drift between the individual channels is negligible. However, the estimate for the phase diference can only be unambiguous for the interval [−π, π). Thus, the signal period should be chosen larger than the maximum expected time ofset error. The SNR of an acquired waveform can be estimated using the algorithm introduced in section 3.4.3.3. Time jitter during acquisition, caused e.g. by a synchronization algorithm, will decrease the SNR. Yet, it is hardly possible to determine the jitter based on the SNR as many other infuences contribute to it, e.g. additive amplitude noise. Thus, it is suggested to observe the infuence of the synchronization by comparing the SNR of the same data acquisition system with and without synchronization. The THD can also be estimated for an acquired waveform (compare section 3.4.3.3). Changing clock drifts or clock adjustments during the acquisition increase it. Again, it is not feasible to determine their strengths from the measured THD due to other infuence, e.g. the input non-linearity. Instead, their infuence should be observed by comparing the THD with and without synchronization. The estimation algorithms for the THD and SNR are closely linked and it is often difcult to distinguish between harmonic- and noise energy. Therefore, it is often more feasible to use the SINAD, which expresses their combined strength.

4.6.3. Synchronous angular sampling

To test synchronous angular sampling algorithms the use of linear chirp signals is rec- ommended in [14]. They are representative of signals from a machine undergoing a speed change. In addition, a pulse signal is needed that has pulses at equidistant phase angles thus simulating a tachometer signal. This choice of test signal is adopted here, also because linear chirp signals are transformed into constant frequency sine waves by synchronous angular sampling. This is very convenient, as it allows using the same

121 4. Modeling estimation algorithms to assess their quality, which have been previously suggested for waveform sampling. To check, whether the signal frequency is really constant, i.e. syn- chronous angular sampling was successful, the signal’s spectrogram, obtained form a short-time Fourier transform (STFT), should be examined.

Figure 4.14.: Setup for testing synchronous angular sampling.

122 5. Implementation

To test the modeling of the previous chapter in real measurements a WSN was built up and algorithms for time synchronization as well as data acquisition were implemented on it. The primary aim was to realize all variants of synchronous data acquisition discussed in chapter 4. A target application was data acquisition at a test bench for induction motors. Furthermore, the WSN should be easily adapted to new tasks in future research projects. Especially the monitoring and diagnosis of machines were intended as prospective applications. Another aim was to use the WSN for student projects as well as bachelor and master theses.

Based on these design goals the following requirements were defned:

• support for continuous data acquisition with on-line transmission

• support for signal processing directly on the sensor nodes

• high transmission data rates

• low transmission latency

• easy integration into an induction motor test bench

These requirements are in confict with a very low-power operation. Furthermore, us- ing comparatively large batteries or even mains power was feasible in most places at the test bench. Therefore, the WSN was not optimized for minimum power consump- tion. In order to integrate well with the existing test bench infrastructure, the WSN needed to support suitable hard- and software interfaces. Furthermore sensors were re- quired to measure digital signals, low voltage analog signals, voltages and currents at the induction motor, sound and temperature. In order to keep the implementation efort manageable and to accurately represent the state-of-the-art it was decided to build upon already existing hard- and software wherever feasible.

This chapter is structured as follows: Section 5.1 describes the hardware as well as the software of the WSN and its integration into the induction motor test bench. The im- plementations of time synchronization and time synchronous data acquisition are pre- sented in section 5.2. Finally, section 5.3 describes the implementation of synchronous angular sampling.

123 5. Implementation

5.1. Wireless sensor network for experiments

This section describes the WSN that was built-up. It starts with the hard- and software that were chosen in sections 5.1.1 and 5.1.2. The following sections 5.1.3 and 5.1.4 describe the software modifcations and extensions that were made by the author. Sec- tion 5.1.5 presents the application sensors that were created during the research for this thesis. Finally, section 5.1.6 describes the installation of the WSN at a test bench for induction motors.

5.1.1. Sensor nodes

The sensor node chosen for the WSN is the Preon32 from the Virtenio GmbH [190]. It was one of the frst sensor nodes to use a microcontroller with ARM’s Cortex-M3 processor core. Thus, it provided signifcantly more computing power and memory than previous 8 or 16 bit architectures at roughly the same energy cost. In addition to the microcontroller, a Preon32 sensor node contains an IEEE 802.15.4 compatible 2.4 GHz wireless transceiver, an 8 Mbit data fash memory and a 32 kHz real-time clock on a small PCB [179]. The block diagram of the Preon32 is shown in fgure 5.2. Table 5.1 shows the key features of a Preon32 sensor node. See tables A.1 to A.3 in appendix A for a comparison to other sensor nodes on the market.

Figure 5.1.: Preon32 on shuttle. Figure 5.2.: Block diagram of Preon32.

To be usable, the Preon32 needs to be soldered to another PCB that provides it with a power supply and usually also contains application specifc connectors and sensors. The Preon32Shuttle from Virtenio is used for this purpose (see fgure 5.1). It provides, amongst other things, a linear voltage regulator, a USB-interface that connects to the Preon32’s serial port via a USB-to-serial bridge, as well as a number of pin headers. Table 5.2 shows the key features of the Preon32Shuttle. The properties of the Preon32 that are most relevant for this thesis are discussed in more detail in the following sub- sections.

124 5.1. Wireless sensor network for experiments

Table 5.1.: Key features of Preon32 [179]. Table 5.2.: Key features of Preon32Shuttle [180]. CPU family ARM Cortex-M3 peripherals 4 LEDs CPU clock 8 ... 72 MHz 2 buttons RAM 64 kB digital interfaces 2x16 pin headers with program-FLASH 256 kB GPIOs, ADCs, UART, data-FLASH 8 Mb etc. wireless standard IEEE 802.15.4 1 USB2.0 connector frequency band 2.4 GHz supply voltage 3.6 ... 13.2 V ADC resolution 12 bit operating voltage 3.3 V max. sampling-rate 1000 kSamples/s (linear voltage reg.) interfaces GPIO, UART, I2C, dimensions 32 x 33 x 14 mm SPI, CAN, USB (l x w x h) supply voltage 2.7–3.6 V dimension(l x w x h) 27.5 x 19.0 x 3.3 mm operating system (Contiki), Java

5.1.1.1. Clocks and timers

The Preon32 contains three diferent oscillator circuits whose properties are summa- rized in table 5.3. A cascade of adjustable frequency divide and multiply circuits gen- erates the system clock for the CPU-core and the peripherals from a given clock source (see fgure 5.3). Using the internal 8 MHz RC-oscillator as a source, a system clock in the range of 8 ... 36 MHz can be generated. The maximum system clock rate of 72 MHz can only be achieved, when using the clock signal from the wireless trans- ceiver. This confguration, however, greatly increases the current consumption as it requires the wireless transceiver to permanently stay in active mode (compare section 5.1.1.4). Therefore the sensor nodes were run with a system clock of 36 MHz generated from the RC-oscillator throughout all experiments.

Figure 5.3.: Clock sources and their distribution on the Preon32.

125 5. Implementation

Table 5.3.: Properties of clock sources on the Preon32. Oscillator Frequency Tolerance internal RC-oscillator 8 MHz 2.2 % a transceiver output 1 MHz ≤ 40 ppm watch crystal 32.768 kHz 20 ppm

atemperature = −10 ... 80 °C

The microcontroller of the Preon32 contains a total of seven 16 bit timers. They can all be clocked from the system clock with a variable prescaler and can be used to measure times or generate periodic interrupts. Four of the 16 bit timers also have quadrature encoder inputs. Furthermore, the microcontroller contains an integrated real-time clock module. It has a 32 bit counting register and is clocked from the 32.768 kHz watch crystal.

5.1.1.2. Analog-to-digital converter

The microcontroller of the Preon32 contains two 12 bit analog-to-digital converters (ADCs). Each can be run at a maximum sampling rate of 1 MSample/s and possesses 15 multiplexed input channels. To efciently acquire large blocks of data the ADCs can be confgured to write the acquired data directly into an assigned memory space using direct memory access (DMA), i.e. without the involvement of the CPU. It is also pos- sible to automatically switch channels after every sample, i.e. doing time multiplexed multi-channel acquisition with one ADC (compare section 3.2.3).

5.1.1.3. Wireless transceiver

The Preon32 uses the wireless transceiver AT86RF231 from Atmel. Together with its predecessor the AT86RF230 it is one of the most frequently used chips in wireless sen- sor nodes. The AT86RF231 handles signal modulation as well as demodulation and has a 128 Byte on-chip frst in, frst out (FIFO)-bufer for incoming and outgoing pack- ets. It uses the 2.4 GHz frequency band and is compatible to IEEE 802.15.4, ZigBee and WirelessHART [162]. The transceiver can automatically verify the checksum of a received packet and send an acknowledgement. Also a number of automatic retransmis- sions can be confgured in case no acknowledgement is received. The microcontroller communicates with the wireless transceiver through a SPI-interface. In addition, a dig- ital line goes from the transceiver to the microcontroller that can trigger interrupts at various transceiver events, including the start of packet reception [162].

126 5.1. Wireless sensor network for experiments

5.1.1.4. Power consumption and sleep modes

The microcontroller of the Preon32 supports four power modes (see table 5.4). In RUN- NING mode, the CPU is active and performs operations. Furthermore, all peripherals may be operated or shut-down depending on the application’s needs. The power con- sumption in RUNNING-mode is highly dependent on the system clock frequency and the state of the peripherals. In IDLE-mode the CPU is shut-of, but the system clock is still running so that the peripherals can continue operating. In STANDBY-mode, also the system clock and the internal RC-oscillator are deactivated. Thus, no peripherals can operate any more. The only exceptions are the RTC that operates from an external watch-crystal and the external interrupts. The deepest sleep-mode is the POWEROFF- mode, which shuts-of the power supply to the entire processor core. This causes the contents of the registers and RAM to be lost except for a few special backup-registers. The wireless transceiver of the Preon32 has a complex state machine with a total of 13 diferent states. However, most of these states are purely transitional and only active for a very short time [162]. Thus, its power consumption is determined by the three major states: RECEIVE, TRANSMIT and SLEEP.

Table 5.4.: Major operating states and sleep modes of microcontroller and wireless transceiver on the Preon32. Values for Isupply are taken from [179].

Mode Isupply Description [mA] RUNNING 3.7a full operation 28.3b

C IDLE n/a CPU of, peripherals and internal RC-oscillator active µ STANDBY 1.3 CPU of, peripherals and oscillators deactivated POWEROFF 0.026 CPU of, core voltage of, RAM contents lost RECEIVE 12.3 listening for incoming packets TRANSMIT 14 sending a packet SLEEP 20 nA entire transceiver disabled transceiver

aCPU-clock = 8 MHz bCPU-clock = 72 MHz

127 5. Implementation

5.1.2. Execution environment

The Contiki operating system was chosen as the central part of the WSN’s software execution environment. Contiki is specifcally designed for WSNs and ofers a wide range of attractive features including a multi-process execution model, a set of diferent time services, comprehensive power management and profling mechanisms as well as a complete IPv6-based networking stack (see also section 2.1.2.1). Compared to the other widely used wireless sensor operating system, TinyOS, Contiki has the advan- tage of using standard C and a module-based approach. Thus, it is more accessible to beginners, especially students. Other OSs appeared immature (Nano-RK) or were not available (RIOT OS, OpenOS) at the time of decision (frst half of 2010). The use of an embedded real-time operating system like FreeRTOS was precluded, as the integration of wireless communication was poor at the time. Originally, the Preon32 was intended to be programmed in the Java-Programming language. While this approach enables programmers to quickly build programs for common applications, it very much limits the access to the capabilities of the underlying hardware. Furthermore, the exact tim- ing of operations is very difcult to control in such a virtualized execution environment and its overhead too high to allow for the implementation of powerful signal processing algorithms. The software execution environment of the WSN is completed by three other compo- nents: a frmware library with drivers for the Preon32 hardware, the Contiki platform for the Preon32, i.e. an adaptation layer and the CMSIS-DSP-library. The driver li- brary as well as the Preon32 Contiki platform were created by Virtenio. While the source code for the Preon32 platform was available to the author, the driver library was provided in binary form only. Contiki OS itself is open source and was obtained from the ofcial repository1. The version used was the development branch (Contiki 3.x) as of September 5th 20142. Table 5.5 summarizes the software components, as well as their authors and licenses. In the following subsections Contiki’s key features with re- gard to this theses goals are described. More information about Contiki and its internals can be found in [187, 186].

Table 5.5.: Components of the software execution environment. Software Component Author Form License Hardware driver library Virtenio GmbH binary proprietary DSP-library ARM source code & proprietary, free binary of charge Contiki-Preon32 platform Virtenio GmbH source code proprietary Contiki OS Contiki community source code BSD (3-clause )

1https://github.com/contiki-os/contiki 2git hash of commit: 4c4c468907534238d7962f0bb2315694e86da3a0

128 5.1. Wireless sensor network for experiments

5.1.2.1. Process and event handling

A Contiki process consists of a protothread (see section 2.1.2.1) plus some management information. Every Contiki deployment contains at least one process that is started automatically after the system has booted. Other processes may be started during the course of the program. Many Contiki services, e.g. the network stack, use processes that are started on initialization [187].

Contiki manages processes with a simple cooperative scheduler [187]. This means that processes cannot be interrupted by the scheduler. Instead processes themselves release the CPU, when they are done or wait for events. Thus, the programmer needs to ensure that no process blocks the CPU for too long. When a process releases the CPU, the scheduler invokes the next process that is ready to run. Contiki’s multithreading library, which would allow also for preemptive multitasking, is currently not available on the Preon32 platform.

Contiki supports inter-process communication through synchronous and asynchronous events [187]. When a synchronous event is posted, the sending process immediately stops operating and the receiving process is invoked with the event. Once the receiving process has fnished executing, the sending process continues to run. When an asyn- chronous event is posted, it is stored in a queue and delivered to the receiving process the next time it is run. A special type of asynchronous event is the poll event. It ensures that the receiving process is run as soon as possible, i.e. the next time the scheduler is executed.

In contrast to process events, interrupts are generated by the hardware and handled by predefned functions. On the Preon32 platform interrupts and processes together form exactly two preemption levels: Interrupts can preempt processes, but neither can interrupts preempt other interrupts nor processes other processes. No prioritization of interrupts or processes is currently supported.

In order to achieve a good real-time performance, events have to be handled with a maximum guaranteed latency and the variance of the actual latency should be low. Due to the design of Contiki’s process scheduling, only interrupts are suitable for this on the Preon32 platform. However, also interrupt-latencies can be adversely afected by the program design. Firstly, an interrupt routine that is executed, blocks other inter- rupts. Thus, interrupt handler functions should fnish quickly. A common pattern is to only do the time critical part of the interrupt response in the handler and send an event to a process, which does the rest. Secondly, hardware drivers often deactivate interrupt-handling during critical hardware interactions, e.g. the initialization of the ra- dio transceiver. Thus, both the maximum execution time of interrupt routines and the maximum length of critical code sections determine the maximum latency for interrupt handling.

129 5. Implementation

5.1.2.2. Time services

The Contiki operating system provides a number of time services that can be used by applications. The clock module provides the system time, which on the Preon32 platform is derived from the real-time clock of the microcontroller. When a sensor node is powered on, the clock is initialized with zero and keeps running as long as the power supply is connected. The hardware driver library uses a virtual 64 bit register −14 to count the ticks of the real-time clock (RTC). One RTC-tick is Ttick,rtc = 2 s ≈ 61.0 µs. Thus, it can run for about 3.6 · 107 y without wrap-around. However, the clock values in the Contiki operating system are 32 bit values. They can be read either in the −7 unit of seconds or clock ticks, which is Ttick,clock = 2 s ≈ 7.81 ms on the Preon32 platform. A number of timer libraries that use the clock module are available in Contiki. The timer library allows to set a timer that expires in a given time interval starting from the current time. The program needs to actively check whether the timer has already expired or not [187]. In the etimer library a Contiki process is run in the background that periodically checks all etimers for expiration [187]. When an expired etimer is detected, an asynchronous event is sent to the process that started the etimer. A similar mechanism is provided by the ctimer library. Here a callback function is executed on expiration [187]. Since all timer services described above require the software to check for expiration, they are not suited for real-time operation. The rtimer library, on the other hand, relies directly on hardware interrupts [187]. When an rtimer expires, a predefned handler function is called directly from the interrupt routine. To allow for a fner time resolu- tion, the rtimer library uses a separate clock module [187], which on the Preon32 plat- −14 form is the unscaled RTC: Ttick,rtimer = Ttick,rtc = 2 s. As the rtimer clock value is 32 bit wide, it wraps-around after about 72.8 h. In contrast to the software timer li- braries, the rtimer library is restricted to handle only one timer at a time. Furthermore, rtimer tasks need to be short as they execute in the interrupt context (compare section 5.1.2.1). Since the rtimer is essential for implementing synchronous data acquisition its relevant functions are shown in listing 5.1. Finally, the hardware driver library also provides access to the 16 bit hardware timers of the microcontroller (see section 5.1.1.1). Their clocks are derived from the microcon- troller’s system clock instead of the real-time clock. Thus, a much higher resolutions can be achieved. Yet, the timing precision is lower, due to the less precise oscillator. The hardware timers can also trigger interrupts and thus may be used as a replacement for the rtimer, when the lower width and precision are not critical.

130 5.1. Wireless sensor network for experiments

1 / ** * Description: post a real −t i m e t a s k 3 * Parameters: * task: pointer to the task 5 * time: time instant when the task is to be executed * duration: unused argument 7 * func: a function to be called when the task is exeuted * ptr: pointer that will be passed as argument to func 9 * Return value: 0 −> failure , otherwise −> s u c c e s s * / 11 i n t r t i m e r s e t ( s t r u c t r t i m e r * task, rtimer c l o c k t time , r t i m e r c l o c k t duration , rtimer c a l l b a c k t func , void * p t r ) ; 13 / ** 15 * Description: get the current time * / 17 # d e f i n e RTIMER NOW() rtimer a r c h n o w ( )

19 / ** * Description: get the time that a task last was executed 21 * Parameters: * task: the task 23 * Return value: the time that a task last was executed * / 25 # d e f i n e RTIMER TIME(task) ((task)−>time ) Listing 5.1: Key rtimer API-functions.

5.1.2.3. Network communication stack

Contiki’s network communication stack is implemented in a layered architecture, that uses a layer defnition slightly diferent from the ISO/OSI reference model (see fgure 5.4, compare section 2.1.4). While the network and transport layers are condensed into a common network layer, the data link layer is split up into three separate layers: the MAC-, radio duty-cycling (RDC)- and framer-layer. For every layer interaction an interface is defned, that allows for the modules in the individual layers to be exchanged independently of each other. This makes it relatively easy to modify and extend the network stack. Furthermore, Contiki supports a number of attributes that are assigned to packets, and infuence their processing in the various layers. Figure 5.4 shows an overview of Contiki’s network stack and the diferent options in the individual layers.

In the physical or radio layer, only one module is available, which is the driver for the Preon32’s transceiver chip. It was created by Virtenio and consists of an upper-layer, for which the source code was available, and a lower-layer in binary form. The framer- layer creates and parses MAC-layer data frames. Contiki provides an IEEE 802.15.4 compatible framer (framer-802154) and a framer to create packets with only minimal protocol overhead (framer-nullmac). Only the former was used for this thesis.

131 5. Implementation

Figure 5.4.: Layers and modules of Contiki’s network stack. .

The RDC-layer is responsible for duty-cycling the wireless transceiver of a sensor node. A minimal implementation that simply always keeps the transceiver on is provided by the nullrdc module. Alternatively, a module implementing the ContikiMAC- protocol [29] was used for this thesis. ContikiMAC tries to minimize the on-time of the transceiver (see also section 2.1.4.2). Another low-power radio duty-cycling proto- col X-MAC [19] is also available on Contiki. It is a precursor of ContikiMAC and has been largely superseded by it.

The MAC-layer coordinates the access of multiple nodes to the common communi- cation channel. Here Contiki provides a dummy implementation nullmac. It simply allows any node to send right away without any checks or collision avoidance mecha- nisms. In addition, a classic CSMA/CA is provided. No TDMA implementation was present. Therefore a basic one was created by the author (see section 5.1.3).

In the network layer, Contiki provides one of the world’s leading implementations of IPv6 for WSNs. It uses 6LoWPAN-header compression to minimize protocol over- head. The RPL-protocol is used for multi-hop routing and UDP for data transport. An alternative layer is provided by the rime network module [28]. It originally studied innovative ways of structuring the network stack of a WSN. However, today, there is a strong trend towards IPv6-based solutions (see section 2.5) and therefore this option was favored.

132 5.1. Wireless sensor network for experiments

5.1.2.4. Time synchronization service

Contiki already provides a simple time synchronization service in the timesynch mod- ule. It is described in section 5.2.1 to allow for a better overview on the implemented time synchronization services.

5.1.2.5. Power management

In order to minimize power consumption, Contiki supports the duty-cycling of the CPU as well as the radio transceiver. The duty-cycling of the transceiver is implemented in the RDC layer of the network communication stack (see section 5.1.2.3). The duty-cycling of the CPU is implemented in the main scheduler loop (see also sec- tion 5.1.2.1). Whenever no process is ready to run, the processor sleeps in a low-power mode. It is scheduled to wake up, when the next etimer expires (see section 5.1.2.2). When an interrupt occurs the sleep period aborted. For the Preon32 the IDLE-mode was chosen as the sleep mode. Its power consumption is larger than that of the STANDBY mode, yet it allows for peripherals to continue operating and thus does not interfere with ongoing measurements. Contiki contains a mechanism called powertrace that profles the power consumption of a sensor node during operation without any external instrumentation [31]. It sim- ply uses the rtimer to measure the accumulated times that the CPU spends running and sleeping. The same is done for the power modes of the transceiver. Based on the assumption that the power consumption in one state is always the same, a node’s overall power consumption can be estimated from this data. The power estimates of the powertrace module for the Preon32 are experimentally verifed in section 6.1.1. Powertrace is used throughout chapter 6 to observe the efects of diferent data acqui- sition algorithms on the nodes’ power consumption.

5.1.2.6. Command shell

Contiki provides a simple text-based command shell that is accessed through the serial interface of a sensor node. Commands are passed as a single line terminated by a line feed character (ASCII: 10). Parameters are passed in the same line as the command and separated by spaces (ASCII: 32). The output of shell commands is also printed to the serial line. When a command is detected, a corresponding process is started. Shell commands are defned together with their processes in application specifc modules. During the initialization of the shell, all commands are registered with the main shell engine. This mechanism makes it very easy to add, remove or defne new commands. The Contiki shell supports Unix-like pipelines making it easy to use the output of one command as input for another.

133 5. Implementation

5.1.3. TDMA-protocol

Scheduled MAC-protocols are generally seen as advantageous in industrial measure- ment applications, because they provide high data rates and are deterministic (see section 2.1.4). Unfortunately, the Contiki operating system did not provide a usable scheduled MAC-protocol (see section 5.1.2). For this reason, a simple TDMA MAC- protocol was implemented. The design goals were to increase the data throughput, to avoid packet collisions and to integrate time synchronization into the MAC-protocol. To keep the development efort feasible, a number of simplifcations were made: Only a single hop star topology is supported and the schedule is static. Every node has exactly one slot within a frame, during which it can send one packet. The TDMA-session starts immediately after the coordinator has booted and never ends. Figure 5.5 shows the structure of a single TDMA frame. In the beginning a beacon- packet is sent a by the coordinator node that contains a frame counter and the current timestamp. It serves to synchronize the nodes in the network. After the beacon, the nodes can send packets in their slots. These may be unicast messages to the coordinator or broadcast messages to the entire network. The length Tslot of a time slot is the time- on-air of the largest supported packet plus a grace time that accounts for inaccuracies in message timing.

Figure 5.5.: Structure of a TDMA frame.

Table 5.6 shows the parameters that were chosen for the WSN together with the re- sulting theoretical maximum data throughput. The resulting maximum latency by the MAC-layer is equal to the time T f rame needed for one frame. Precise timing of send operations is essential for the operation of a TDMA-protocol. As discussed in section 5.1.2.1, the optimal timing service for such tasks is the rtimer. Yet, using it for the TDMA-protocol would have had a number of important disad- vantages. Firstly, the send operation of the radio driver only returns after the entire packet has been sent. Thus, calling it directly from an rtimer-task would block other interrupts for up to 4.3 ms. This would make precise timestamping of external events impossible. Secondly, using the rtimer for the TDMA-protocol would make it im- possible to use it elsewhere, e.g. to trigger the acquisition of data. Therefore, it was

134 5.1. Wireless sensor network for experiments

Table 5.6.: Chosen TDMA-protocol parameters and theoretical performance. n 3 max. packet size 110 Byte Tbeacon 2.747 ms (45 Ticks)

parameter Tslot 6.714 ms (110 Ticks)

T f rame 21.667 ms (355 Ticks) max. throughput/node 46.2 packet/s (40.6 kbps)

result max. overall throughput 138.5 packet/s (138.5 kpbs) 1 Tick = 2−14 s ≈ 61.0 µs decided to use an internal hardware timer of the Preon32 instead. Furthermore, the packets are not directly sent in the timer interrupt routine. Instead, a poll event is issued to a Contiki-process that does the sending. As signifcant latencies may occur on this path, the sending process checks, whether there is still enough time within the slot, just before actually sending. If this check fails, the sending of the packet is postponed to the next slot. This way, of course, the actual data throughput is reduced, but it was still acceptable for the purpose of this thesis.

In order to save power, the leaf nodes turn of their wireless transceivers when they are neither transmitting nor expecting a transmission from another node. The coordinator node always has its radio on, as it is assumed to have access to mains-power.

5.1.4. Data acquisition framework

In order to easily adapt the WSN to a multitude of data acquisition scenarios a software framework, called the MDT smart transducer library (MSTL), was developed. It is based on the IEEE 1451 standard, as this describes a powerful generic smart data acqui- sition architecture, that is equally applicable to wireless and non-wireless measurement systems (see also section 2.3.3). However, not all required features of IEEE 1451 were implemented in MSTL. Currently the framework allows for one-shot as well as con- tinuous data acquisition. Furthermore, it is possible to discover the nodes of a network and to remotely confgure the acquisition channels.

Figure 5.6 shows the communication model of the MSTL. It follows mostly the IEEE- 1451 reference model (compare fgure 2.7). One or more Preon32 sensor nodes, acting as TIMs, acquire data from sensors, e.g. through their ADCs. A further Preon32 sensor node serves as NCAP and provides the user interface. The function of the MSTL is to provide generic interfaces for the interaction of transducer drivers and TIMs, TIMs and NCAP as well as NCAP and user applications. Thus, transducers or TIMs can be added or removed with only minimal modifcations.

135 5. Implementation

Figure 5.6.: Structure and communication model of the data acquisition framework.

Within MSTL the TIM-identifcation numbers (IDs) required by IEEE 1451 are equal to the two digit inventory numbers of sensor nodes. Thus, the TIM-ID uniquely identifes a physical sensor node at the Chair of Electronic Measurement and Diagnostic Tech- nology (MDT) at the TU Berlin. Two IDs, however, are reserved for special purposes: 0 addresses all TIMs in the network and 1 its NCAP. The following subsections briefy describe the implementation of IEEE 1451 key elements in the MSTL. Examples of typical data acquisition scenarios are given in section 5.1.4.6.

5.1.4.1. Transducers

Under the IEEE 1451 standard, transducers are handled as channels. Besides the actual acquisition channels, there are also virtual ones that read or control internal properties of the acquisition hardware, e.g. the sampling rate of an ADC. The TIM communicates with a transducer channel driver through a set of generic functions. Table 5.7 gives a brief overview of the functions currently implemented. In IMMEDIATE sampling mode, sampling may be started by an explicit trigger command from the user, or implicitly by a read operation on the transducer channel. IEEE 1451.0 also allows external trigger sources, but this function has not been implemented. Once sampling has been triggered, a channel acquires samples until its repetition count has been reached. The collection of all samples acquired at one trigger is called the data set of a transducer. It is stored in one or more output bufers of the transducer channel. There is also a CONTINUOUS sampling mode that, after having been triggered, endlessly acquires samples and writes data sets to the output bufers.

136 5.1. Wireless sensor network for experiments

Table 5.7.: Transducer and TEDS commands. Command Description setDataRepetition sets the number of samples acquired at one trigger setSamplingMode sets the sampling mode of the channel setDataTransmissionMode sets the transmission mode of the channel readDataSetSegment reads a segment from the data set of the transducer writeDataSetSegment writes a segment to the data set of the transducer triggerCommand triggers data acquisition (sensor) or data output (actuator) channelOperate puts the channel into operating mode channelIdle puts the channel into idle mode deviceClear clears the channel’s in- and output bufers readDataRepetitionCount read the number of samples at one trigger queryTEDS retrieves information about a TEDS (size, attributes, etc.) readTEDSSegment reads a segment from a TEDS writeTEDSSegment writes a segment of a TEDS

The transmission of the acquired data sets from a transducer’s output bufer to the NCAP is governed by the transmission mode. In user initiated mode (ON COMMAND) the bufer is only read when the user issues a read command to the NCAP. In stream- ing mode, data is automatically transmitted to the NCAP. This may happen either at a fxed time interval (INTERVAL) or whenever a bufer is full (BUFFERFULL). Refer to IEEE 1451.0 [196] for a more in depth description of the commands and their function- ality.

5.1.4.2. TIM

The TIMs manage the transducers and relay data between them and the NCAP. On start-up the Contiki application running on the TIMs calls an initialization function for every transducer channel, which registers its interface functions with the TIM. Thus, transducer channels can be added and removed with only minimal changes to the TIM software. After start-up, the TIM application starts a Contiki process that listens for commands from the NCAP on UDP-Port 5689. When a command arrives the corre- sponding transducer driver function is selected and called based on the channel number as well as the numerical ID of the command as defned in IEEE 1451.0 [196]. If the command requires a response to be sent to the NCAP, the transducer driver needs to call the corresponding functions from IEEE 1451.0 network layer. Commands regard- ing the TEDS are not handled by the individual transducer drivers. Instead a common TEDS manager module has been implemented. For every TEDS it maintains one fle on Contiki’s FLASH fle system, which it reads and writes as needed. IEEE 1451.0 specifes a number of diferent TEDS-types to describe diferent aspects of TIMs and transducers [196]. Table 5.8 gives an overview of the TEDS-types that are currently implemented in the MSTL.

137 5. Implementation

Table 5.8.: Types of TEDS implemented in the MSTL. TEDS-type Contents Calibration-TEDS scaling information to convert transducer data to SI-units Meta-TEDS general information about a TIM and its transducers Name-TEDS user-defned transducer channel name TransducerChannel-TEDS general information about a transducer channel PHY-TEDS information about the communication interface of the TIM

5.1.4.3. NCAP

The NCAP manages the TIMs in the network. It contains RAM-bufers for the TEDS and measurement data received from the transducer channels. Furthermore, it provides a user interface to the WSN through the Contiki-shell (see next section 5.1.4.5). A sensor node that acts as a NCAP can additionally also run the TIM application and acquire data. When the NCAP and this local TIM communicate, the IEEE 1451.0 layer bypasses the IEEE 1451.5 layer and relays the messages directly. The TIM application itself is identical to that running on normal TIM nodes.

5.1.4.4. Network layer

The network layer manages the transmission of commands and measurement data be- tween NCAP and TIMs by packing them into 6LoWPAN messages and passing those to Contiki’s network stack. As Contiki’s networking stack does not support interleaved reception of IPv6-packet fragments from diferent packets, fragmentation of larger messages is handled by the MSTL-network layer. In the current implementation the maximum MSTL-payload per packet is 60 Bytes and the maximum allowed size of an IEEE 1451.0 message is 256 Bytes.

5.1.4.5. User interface

Contiki’s shell is used on the NCAP to provide a user interface to the data acquisition framework. Table 5.9 shows an overview of the implemented shell commands. Most of them were adopted from the HTTP-application programmers interface (API) defned in IEEE 1451.0 [196]. Only the streaming functions are not from this API. The parameters to the commands are mostly transmitted as plain text separated by white spaces. Only, larger blocks of data are transferred to the NCAP as binary data encoded in an ASCII- character stream with base64 encoding [62] (commands WriteData and WriteTeds). All commands return two 16 bit binary numbers followed by the command specifc return data. The frst is the error codes as defned in IEEE 1451.0 and the second the number of data bytes that follow. The command specifc return data is a block of binary data.

138 5.1. Wireless sensor network for experiments

Table 5.9.: Implemented user commands. Group Command Description discovery TIMDiscovery get IDs numbers of known TIMs TransducerDiscovery get transducer channel numbers on TIM transducer- ReadData read data from transducer (one-shot) access MeasurementUpdate get bufered measurement data WriteData write data to transducer (one-shot) TEDS- ReadTeds read TEDS from transducer manager WriteTeds write TEDS on transducer UpdateTedsCache update TEDS cache on NCAP transducer- SendCommand send command to transducer manager StartTrigger trigger start of measurement streaming StartStream start continuous measurement StopStream stop continuous measurement

In order to simplify user access to the WSN, a MATLAB class interface that commu- nicates with the NCAP using its command shell has been created by the author. It provides equivalent functions for all shell commands from table 5.9. Furthermore, a LabVIEW program [Stud1] and an Android application [Stud14] that interface with the NCAP shell have been implemented in student projects.

5.1.4.6. Example acquisition scenarios

To illustrate the working of the data acquisition framework a simple one-shot and a continuous measurement will be described in more detail. Listing 5.2 shows the MATLAB script of the one-shot measurement. After connecting to the NCAP (lines 11,12) the program looks for connected TIMs and their channels (line 14 to 27). Figure 5.7 shows the sequence of communication during this pro- cess. To get a list of all known TIMs the script sends the TIMDiscovery command to the shell of the NCAP. In the consequence the IEEE 1451 layers query the RPL- neighbor table of the node and a list is returned that contains the IDs of all TIMs to which routes are known. The actual discovery of new nodes is done independently by the RPL-routing engine. When the TIM with the ID 41 has been found, the NCAP stops the search and obtains a list of the TIM’s transducer channels by issuing the TransducerDiscovery command. The IEEE 1451 layers then obtain the contents of the META-TEDS from the TIM, which contains the needed information. After this pro- cess the contents of the META-TEDS is cached on the NCAP, so that no transmission between TIM and NCAP takes place when its contents is read in line 30 of listing 5.2. At this stage, also other TEDS of the channel could be read to obtain more information about its properties and purpose, e.g. Name- or Channel-TEDS.

139 5. Implementation

1 %% Parameters %% timID = 4 1 ; % ID of TIM to acquire data from 3 adcChannel = 1 ; % channel to acquire data from perChannel = 2 ; % channel to control sampling period 5 muxChannel = 3 ; % channel to control the adc mux t i m e o u t = TimeDuration(3,0) ; % timeout for acquisition (3 s) 7 mode = IEEE1451 . SamplingMode .IMMEDIATE; % sampling mode

9 t r y %% 0. connection Setup 11 ncap = IEEE1451() ; ncap.connect( ’/dev/ttyUSB2’ ); 13 %% 1. scan for TIMs 15 timsFound = []; f p r i n t f ( 1 , ’tim discovery’ ); 17 while (˜isempty( setdiff (timID ,timsFound))) pause ( 1 ) 19 f p r i n t f ( 1 , ’.’ );

21 % read connected TIMs timsFound = ncap.timDiscovery() ; 23 end f p r i n t f ( 1 , ’OK\n’ ); 25 %% 2. read channels 27 c h a n n e l s = ncap. transducerDiscovery(timID);

29 %% 3. Read TEDs tedsTimMeta = ncap.readTeds(timID ,chanID ,timeout ,... 31 IEEE1451. TedsClass .META) ;

33 %% 4. configure transducer % set number of samples per block to 128 35 ncap.sendCommand(timID ,adcChannel , timeout ,... IEEE1451 . CommandClass .XDCR IDLE , . . . 37 IEEE1451 . CommandsXdcrIdle .SET XDCR CH REPETITION COUNT,128) ; % set sampling period to 1000 mirco s 39 ncap.writeData(timID ,perChannel ,timeout ,mode, uint32(1000)); % set input mux of adc to channel 19 41 ncap. writeData(timID ,muxChannel ,timeout ,mode, uint8(19));

43 %% 5 . s i n g l e −shot measurement d a t a = ncap.readData(timID ,adcChannel ,timeout ,mode); 45 catch e x c e p t i o n disp(exception.getReport()); 47 end

49 %% 6. Connection shutdown delete(ncap) Listing 5.2: MATLAB example of transducer discovery and one-shot acquisition.

140 5.1. Wireless sensor network for experiments

Figure 5.7.: Sequence diagram of the transducer discovery process.

After having detected the TIM and its channels, one transducer channel, an ADC, is confgured (lines 35 to 41 in listing 5.2). The sequence of communication is illus- trated by fgure 5.8. First, the number of samples per data block is set by sending the setDataRepetition command to the transducer channel with the help of the shell command SendCommand. After this, two virtual actuator channels are written that control properties of ADC: the sampling period (in µs) and the analog input multiplexer. In each case the shell command WriteData is used. This frst puts the corresponding channel into operation mode (command: channelOperate) and then writes data to its data set (command: writeDataSetSegment). Finally, the channel is put back into idle state (command: channelIdle). The data acquisition itself is done in line 44. Its communication sequence is shown in fgure 5.9. The shell command ReadData is used to frst put the acquisition channel into operating mode. The subsequent reading of the data set triggers the data acquisition on the channel. When the acquisition is fnished, the data is returned to the NCAP, which relays it to the PC.

141 5. Implementation

Figure 5.8.: Sequence diagram of the transducer confguration.

Figure 5.9.: Sequence diagram of one-shot acquisition.

142 5.1. Wireless sensor network for experiments

Listing 5.3 shows a MATLAB script that performs a continuous acquisition. The dis- covery and confguration steps would be identical to the one-shot case and have been therefore omitted. The corresponding sequence of communication is shown in fgure 5.10. First a new stream is started with the StartStream command. This causes the sampling mode of the transducer to be set to CONTINUOUS, its data transmission mode to BUFFERFULL and puts it into operating mode. In the given example the last action of the StartStream shell command is to start the acquisition by send- ing the triggerCommand to the transducer channel. By setting the last parameter of StartStream (the waitFlag) to 1 this step could be skipped. The acquisition would then be started with the shell command StartTrigger. This makes it possible to start acquisitions on multiple TIMs at the same time, by frst separately setting up all chan- nels for acquisition with StartStream and then sending StartTrigger as a broadcast command3. After the acquisition has started the transducer continuously streams data to the NCAP, where it is stored in a FIFO-bufer. The MATLAB program is then re- sponsible to repeatedly read and clear this bufer by issuing the measurementUpdate command on the shell. To stop streaming the stopStream command needs to be called, which also puts the transducer channel back into idle mode.

Figure 5.10.: Sequence diagram of a continuous data acquisition.

3Sending StartStream as a broadcast is often not possible as the IDs of acquisition channels may vary from node to node.

143 5. Implementation

%% Parameters %% 2 N = 2 4 ; % number of samples to acquire per block Nb = 1 6 ; % number of blocks to acquire 4 timID = 4 1 ; % ID of TIM to acquire data from adcChannel = 1 ; % channel to acquire data from 6 t i m e o u t = TimeDuration(3,0) ; % timeout for acquisition (3 s)

8 t r y %% 0. connection Setup 10 ncap = IEEE1451() ; ncap.connect( ’/dev/ttyUSB2’ ); 12 %% 1. discover and configure transducer 14 % ... (see one−shot acquisition)

16 %% 2. streaming measurement % s t a r t 18 ncap. startStream(timID ,adcChannel ,0) ;

20 % receive data d a t a = []; 22 t 0 = 0 ; t i c ( ) ; 24 while (isempty(data) | | (data.Length < (N*Nb) ) ) % try to get data new data 26 temp = ncap.measurementUpdate(timID ,adcChannel) ; i f (˜isempty(temp) && (max([temp.Length]) >0) ) 28 d a t a = append(data ,temp); t i c ( ) 30 f p r i n t f ( 1 , ’.’ ); e l s e 32 pause ( 0 . 1 ) end 34 % check for timeout 36 i f ( t o c ( ) > timeout.sec) e r r o r ( ’timed out waiting for data’ ); 38 end end 40 catch e x c e p t i o n 42 disp(exception.getReport()); end 44 %% 3. stop streaming 46 t r y ncap.stopStream(timID); 48 f p r i n t f ( 1 , ’DONE\n’ ); catch e x c e p t i o n 50 disp(exception.getReport()); end 52 %% 4. connection shutdown 54 delete(ncap) Listing 5.3: MATLAB example of continuous acquisition.

144 5.1. Wireless sensor network for experiments

5.1.4.7. Memory usage

Contiki as well as the added software for data acquisition follow the recommendations from the literature and avoid dynamic memory allocation (see section 2.1.2). Instead all bufers are allocated statically during compile time. This enables an easy static analysis of memory usage.

Figure 5.11(a) shows the usage of data memory (RAM) on a TIM programmed for synchronous angular sampling (see also section 5.3.5). This is the most resource de- manding application that has been realized for this thesis. The transducer drivers are the largest part and consume about 45 % of the memory. This is because the analog voltage sensor driver uses resampling flters with large bufers in this application. The MSTL library takes up about 10 %. Another 18 % are needed for the base system, consisting of the Contiki operating system, the device drivers supplied by Virtenio and other symbols mainly from the standard C library. The rest, about 25 % of the total memory space, is not statically allocated. However, some of it will be used by the program stack.

Figure 5.11(b) shows the usage of program memory (FLASH) on the same TIM. Only about 31 % of the total memory is used. Most of this is taken up by the base system. The MSTL and fltering algorithms need only about 7 % of the total memory. In other applications the amount of RAM allocated for transducer drivers is often signifcantly smaller. The size of the other memory sections does not change much between appli- cations.

MSTL transducer MSTL 7.9 kB 6.7 kB unused 10.6 kB 16.4 kB contiki 31.7 kB

drivers other 18.3 kB 0.4 kB drivers other 3.8 kB 10.5 kB transducer unused 29.0 kB contiki 177.1 kB 7.6 kB total: 64.0 kB total: 256.0 kB

(a) RAM (b) FLASH

Figure 5.11.: Maximum memory usage on a TIM.

145 5. Implementation

Figure 5.12(a) shows the usage of data memory (RAM) on the NCAP. The largest part is the NCAP application that uses about one third of the entire memory, most of it to bufer incoming data. Contiki, the MSTL and the device drives each use about 15 %. The memory consumption of Contiki and the MSTL is again mostly determined by the size of network communication bufers. For the device drivers the size of the serial communication bufer is by far the largest part. Figure 5.12(b) shows the usage of the program memory (FLASH) on the same NCAP. About one third of the entire memory is used. The MSTL and NCAP application to- gether need only about 10 % of the total memory, the rest is taken up by the base system. The investigated NCAP confguration is suitable for a wide range of applications with- out any changes. The only exception is when a local TIM is run on the same node (see section 5.1.4.3). In this case the size of communication bufers can be reduced in order to make room for it in the data memory.

transducer MSTL MSTL unused 10.2 kB 3.4 kB 16.0 kB 10.0 kB NCAP transducer 7.5 kB 0.5 kB other contiki 2.9 kB 35.9 kB

drivers drivers 16.5 kB 9.2 kB NCAP other unused 21.2 kB 9.6 kB 167.0 kB contiki 10.0 kB total: 64.0 kB total: 256.0 kB

(a) RAM (b) FLASH

Figure 5.12.: Maximum memory usage on a NCAP.

146 5.1. Wireless sensor network for experiments

5.1.5. Application transducers

A number of application transducers have been implemented for the data acquisition framework described in the previous section. They include both hardware modules and transducer drivers. Table 5.10 gives an overview of the transducers as well as the commands and operating modes supported by them. The microphone and the curren- t/voltage sensor are not included in table 5.10, as they are pure hardware modules that rely on software drivers already shown in the table. All transducers’ hardware and software will be described in more detail in the following.

Table 5.10.: Overview of commands and operation modes supported by the individual application transducers. Sensor powertrace digital event digital actuator analog voltage rotary encoder . f

Channel Name ADC sample period ADC-MUX flter select flter coe decimation ratio Type VS S A S VA VA VA VA VA S setDataRepetition X setSamplingMode XX setDataTransmissionMode X readDataSetSegment XXX writeDataSetSegment XXXXXX triggerCommand XXX

Commands channelOperate XXXXXXXXXX channelIdle XXXXXXXXXX deviceClear XXX readDataRepetitionCount X

IMMEDIATE XXXXXXXXX CONTINUOUS XXX modes Sampling

ON COMMAND XXXXXXXXX BUFFERFULL XX

modes INTERVAL X Transmission

Abbreviations channel type: A=actuator, S=sensor, VA=virtual actuator, VS=virtual sensor

147 5. Implementation

5.1.5.1. Powertrace sensor

The powertrace sensor is a virtual sensor that integrates Contiki’s powertrace mecha- nism into the data acquisition framework (see also 5.1.2.5). Thus, it enables wireless transmission of powertrace statistics. Whenever the sensor is read it returns a data set with the current powertrace data. Table 5.11 shows the data set of the powertrace sen- sor. It includes the accumulated times the sensor node has spent in the individual power modes since the node has booted and since the last read of powertrace data. The pro- tocol statistics at the end of the data set allow analyzing the power consumption of the individual protocols in more detail. Listening and transmit times are given for both in- coming and outgoing packets, to account for acknowledgement or beacon packets that are sent in the opposite direction.

5.1.5.2. Digital event sensor

The digital event sensor uses a user-interrupt request (IRQ) of the Preon32 to generate a timestamp whenever an event occurs. Both the IRQ and the event type (rising/falling edge) are confgured statically at compile time. The sensor supports both one-shot and continuous operation. Figure 5.13 shows the block diagram of the sensor.

Figure 5.13.: Block diagram of digital event sensor.

Whenever the confgured interrupt occurs, the Preon32’s rtimer is read and the times- tamp written to the sensor’s data set. Table 5.12 shows the structure of the sensor’s data set. The frst feld is one if an event occurred since the sensor was last cleared. Other- wise it is zero. The event counter contains the number of events since the sensor was initialized. Finally, the last feld contains the timestamp of the event. The sensor has a bufer that holds exactly one data set, which can be read through the sensor channel. If the sensor is in continuous operation the data set is send and the sensor is cleared immediately after an event occurred. Section 5.2.2 describes how the sensor can be used for time synchronous event detection.

148 5.1. Wireless sensor network for experiments

Table 5.11.: Data set of the powertrace sensor. Field Data type Unit timestamp unsigned 32 bit integer 2−14 s sequence number “ 1 time since start “ 2−14 s time in active mode (total) “ 2−14 s time in low power mode (total) “ 2−14 s time in transmitting (total) “ 2−14 s time in listening (total) “ 2−14 s time in idle transmitting (total) “ 2−14 s time in idle listening (total) “ 2−14 s time in active mode (since last read) “ 2−14 s time in low power mode (since last read) “ 2−14 s time in transmitting (since last read) “ 2−14 s time in listening (since last read) “ 2−14 s time in idle transmitting (since last read) “ 2−14 s time in idle listening (since last read) “ 2−14 s number of protocol statistics unsigned 16 bit integer 1 protocol statistics array of protocol statistics − protocol statistics number of input packets unsigned 32 bit integer 1 number of output packets “ 1 transmit time for input packets (total) “ 2−14 s listening time for input packets (total) “ 2−14 s transmit time for output packets (total) “ 2−14 s listening time for output packets (total) “ 2−14 s protocol identifer unsigned 16 bit integer 1 channel number unsigned 16 bit integer 1 transmit time for input packets (since last read) “ 2−14 s listening time for input packets (since last read) “ 2−14 s transmit time for output packets (since last read) “ 2−14 s listening time for output packets (since last read) “ 2−14 s

Table 5.12.: Structure of the digital event sensor’s data set. Field Data type Unit event state unsigned 8 bit integer 1 event counter unsigned 16 bit integer 1 timestamp unsigned 32 bit integer 2−14 s ≈ 61.0 µs

149 5. Implementation

5.1.5.3. Digital actuator

The digital actuator is a simple transducer that controls a digital output pin of the Preon32. Only single shot operation is supported. The pin of the actuator is confg- ured statically at compile time. The actuator’s data set consists of a single signed 8 bit integer. Writing a zero to the actuator channel causes a logic low-level at the output pin, writing a positive value causes a logic high-level. When a negative value is writ- ten, the pin generates a digital pulse of 1 ms length (see table 5.13). Figure 5.14 shows the block diagram of the digital actuator.

Table 5.13.: Control values of digital actuator. Channel value Output pin Figure 5.14.: Block diagram of digital actuator. > 0 HIGH = 0 LOW < 0 PULSE (1 ms)

5.1.5.4. Analog voltage sensor

This sensor serves to acquire analog voltage signals using the Preon32’s ADC. It sup- ports both one-shot and continuous operation. Signal fltering, resampling and scaling functions are included in the sensor, making it the most complex and versatile that was implemented. Figure 5.15 shows the block diagram of the analog voltage sensor. The entire sensor contains one sensor- and fve virtual actuator channels that control various properties of the acquisition and signal processing. At the input, the ADC-multiplexer, controlled through a virtual actuator, selects the analog input channels that are sampled. In ad- dition to the 16-ADC-channels of the Preon32, two virtual ADC-channels return sim- ulated signals: a ramp-signal and a unit impulse. Another two channels are reserved for the Preon32’s internal voltage reference and temperature sensor. Up to 8 channels can be selected by the multiplexer at any time. If multiple channels are selected, they are acquired time-multiplexed (compare section 3.2.3) and the output signal is vector valued. The samples in the vector are stored in interleaved mode, i.e. all samples ac- quired at the same time are stored consecutively and the channel changes from sample to sample [196]. The analog voltage sensor operates on blocks of data. Their size can be set through the repetition count of the ADC sensor channel. Another virtual actuator controls the sampling period of the ADC.

150 5.1. Wireless sensor network for experiments

Figure 5.15.: Block diagram of analog voltage sensor.

The acquired data is written to a memory space using DMA-transfer (compare section 5.1.1.2). This memory space is used as an acquisition bufer that can contain up to two blocks of data. During continuous acquisition these two blocks are alternately writ- ten and an interrupt is triggered every time one of them has been fully written. Inside the corresponding interrupt routine, the data block is copied to the processing bufer, which is a FIFO-bufer that can hold up to 3 data blocks. The acquired data may be fltered using an FIR-flter with up to 128 coefcients. The fltering algorithm is taken from the CMSIS-DSP-library provided by ARM. Filter coefcients and decimation ra- tio are controlled by virtual actuator channels. It is preceded by a CIC-decimator that can be confgured at compile time. Alternatively, the acquired data may be resampled with a simple S&H-resampler or the resampling flter discussed in section 5.3. The fltered data can be rescaled using a linear function, e.g. to convert it into units of the International System of Units (SI). The gain and ofset for this operation are loaded from the channels calibration-TEDS. Finally, the output data is stored in one-block output bufer, where it can be accessed through the ADC-sensor channel.

Table 5.14 shows the structure of the analog voltage sensor’s output data set. The frst feld is the sampling period, with which the samples were acquired. It is followed by the timestamp of the frst sample and the repetition count, which is the number of samples per channel. At the end of the data set is an array with the samples. Section 5.2.3 describes the generation of timestamps during the acquisition process and shows how the sensor can be used for synchronous data acquisition.

151 5. Implementation

Table 5.14.: Structure of analog voltage sensor’s data set. Field Data type Unit sample period unsigned 32 bit integer 2−30 s ≈ 0.931 ns timestamp unsigned 32 bit integer 2−14 s ≈ 61.0 µs repetition count unsigned 16 bit integer 1 samples array of signed 16 bit integers depends on scaling

5.1.5.5. Microphone

The microphone module contains a simple circuit that can be plugged on top a Preon32- Shuttle, in order to detect short bursts of sound. The module was designed and three prototypes built within a Bachelor’s project [Stud22] supervised by the author of this dissertation. No dedicated software driver was created for the microphone module Instead the digital event sensor, described previously in this section, was used. Figure 5.16 shows the block diagram of the microphone module. The signal of an electret microphone is fed through a highpass flter ( fg = 50 Hz) and amplifed with a variable amplifer. Within this process the negative part of the signal is cut of. After this, a comparator, with confgurable threshold and hysteresis, generates digital pulses out of the signal. This digital signal is connected to a user interrupt of the Preon32. The complete circuit diagram of the microphone module is given in appendix C.1.

Figure 5.16.: Block diagram of microphone module.

5.1.5.6. Current and voltage sensor

A sensor module was created that measures the currents and voltages of a 3-phase electric motor. No dedicated software driver was created for it. Instead the analog voltage sensor, previously described in this section, is used. Figure 5.17 shows the block diagram of the sensor module. It consists of four submodules: one current/ voltage transducer module for every phase and a signal conditioning module. The voltages are measured towards a virtual star point created by the internal resistances (47 kΩ) of the voltage transducers.

152 5.1. Wireless sensor network for experiments

Figure 5.17.: Block diagram of current and voltage sensor module.

The current/voltage transducer modules were created in a collaborative efort of the staf at the Chair of MDT at the TU Berlin. They convert the motor voltages and currents into proportional low voltage signals (±12 V) using closed loop converters. They also include anti-aliasing flters. Table 5.15 lists the key technical data of the current/voltage transducer modules. Their complete circuit diagram is given in appendix C.2. The conditioning module was created within a Master’s project [Stud9] supervised by the author. It maps the output signals of the current/voltage transducers to the input voltage range of the Preon32’s ADC. A Preon32Shuttle can be plugged into a socked on the module. The conditioning module’s circuit diagram is also given in appendix C.2. Figure 5.18 shows three current/voltage transducer modules and the signal conditioning modules installed in a control cabinet.

153 5. Implementation

Figure 5.18.: Three current/voltage transducer modules and signal conditioning module installed in a control cabinet.

Table 5.15.: Technical data of the current/voltage transducer module. voltage measurement input range ±720 V internal resistance 47 kΩ conversion factor (Vout/Vin) 1/60 V/V current measurement input range ±22 A nominal input current 10 ARMS internal resistance 30 mΩ conversion factor (Vout/Iin) 9/20 V/A anti-aliasing flter characteristic 8th-order lowpassa cutof frequency 2.0 kHz output voltage range ±12 V

afour 2nd-order Butterworth lowpass connected in series

5.1.5.7. Rotary encoder

The rotary encoder sensor acquires timestamps at equidistant angular intervals Φ that can be used e.g. for synchronous angular sampling (see section 5.3). The sensor only supports continuous operation. Figure 5.19 shows the block diagram of the sensor.

The sensor hardware consists of a circuit board (see fgure 5.20) that houses a Preon32 on a shuttle and provides an interface to an incremental rotary encoder. The interface to the encoder is a standard quadrature output with two square wave signals Ua1 and Ua2. Depending on the direction of rotation the phase shift between the signals is 90 ° or - 90 °. One period of the signals is equivalent to one angular step. In addition, a reference

154 5.1. Wireless sensor network for experiments pulse is generated every time the encoder crosses its zero position. All three signals are transmitted by the rotary encoder as diferential signals that are converted to standard 3.3 V CMOS-logic levels by comparators on the sensor board. The quadrature inputs are connected to the quadrature encoder interface of one of the Preon32’s hardware timers. The complete circuit diagram of the sensor board is given in appendix C.3.

Figure 5.19.: Block diagram of rotary encoder sensor.

The quadrature encoder interface of the timer automatically detects the direction of rotation and generates one counting pulse for every edge of the two signals, leading to four counts per signal period. When the value in the counter register reaches the value stored in a compare register an interrupt is generated and the counter is reset. In the interrupt routine, the current time of the sensor node’s rtimer is stored. This way timestamps are generated at uniform angular intervals. Alternatively, the timestamp generation can be triggered with a user interrupt. This enables the simulation of a rotary encoder signal with a simple square wave generator. The generated timestamps are stored in a bufer. An etimer is used to transmit bufered timestamps at a fxed time interval. Table 5.16 shows the contents of the data set trans- mitted by the sensor. The frst feld is the angular interval Φ, at which the timestamps

155 5. Implementation have been generated. Next is the angular position ϕ0 of the frst timestamp in the data set. It is obtained by summing over all angular intervals since the sensor started operat- ing. The repetition count denotes the number of timestamps in the data set. In order to reduce the amount of data, only the frst timestamp t0 in the data set is stored with full 32 bit resolution. For the other timestamps, the diference ∆T to the preceding times- tamp is stored as a 16 bit value. At the given rtimer resolution of 61 µs this means, that two timestamps may not be more than 2 s apart. This is not a signifcant limitation as rotary processes usually generate timestamps at a much higher rate.

Figure 5.20.: Rotary encoder sensor board with Preon32.

Table 5.16.: Structure of the rotary encoder sensor’s data set. Field Data type Unit Φ unsigned 32 bit integer 2−16 ° ϕ0 unsigned 32 bit integer ° repetition count unsigned 16 bit integer 1 −14 t0 unsigned 32 bit integer 2 s ≈ 61.0 µs ∆T array of signed 16 bit integers 2−14 s ≈ 61.0 µs

The standard confguration of the rotary encoder sensor used for this thesis, generates 30 timestamps per revolution. At rotary speeds in the range of 15 to 1500 rpm this leads to timestamp intervals in the range of 133 to 1.33 ms. The standard transmission interval is 100 ms, leading to 0 ... 76 timestamps being transmitted per interval.

156 5.1. Wireless sensor network for experiments

5.1.6. Installation at induction motor test bench

As the targeted application area of the WSN was motor test benches, an existing test bench for an induction motor was equipped with wireless sensors. The test bench was driven by a three-phase squirrel-cage induction motor. The mechanical load was gener- ated by a DC-motor, which was run as generator whose output energy was dissipated at a 1.9 Ω load resistance. Table 5.17 shows the specifcation data of the two motors.

Table 5.17.: Specifcation data of induction- and DC-motor. induction motor SIEMENS 1LA5 107-4AA20 supply voltage 380 V supply frequency 50 Hz rated current 6.8 A rated power 3 kW cos ϕ 0.81 1 rated speed 1415 rpm DC-motor SIEMENS 1GG5104-OEK30-2BU7Z supply voltage 18–150 V rated speed 50–2440 rpm rated current 25,5–26,0 A rated power 0,07–3,20 kW

Both motors were connected through a torque shaft (HBM T30FN) with a rated torque of 50 Nm and a rated speed of 3000 rpm. It measured the torque and shaft speed, gen- erating proportional analog voltage signals for both quantities. These signals were recorded by the test bench PC using a USB6009 data acquisition (DAQ)-card from National Instruments. An optical incremental rotary encoder (Heidenhain ROD426) with 6000 pulses/revolution was connected to the end of the shaft behind the direct cur- rent (DC)-motor (see fgure 5.22). The induction motor was driven by an inverter (SINAMCIS G120), which controlled both the amplitude and frequency of the mo- tor’s supply voltage. The entire test bench was controlled by a PC that ran a dedicated LabVIEW-Program. In order to install the WSN at the test bench, the NCAP was connected to a USB-port of the control PC (see fgures 5.21 and 5.24). The current/voltage sensor described in section 5.1.5 was installed in the control cabinet of the test bench, where it measured the voltages and currents at all three-phases of the induction motor (see fgure 5.23). The TIM of this sensor will be referred to as data TIM in this thesis. Another TIM with a rotary encoder sensor module (see section 5.1.5) was connected to the rotary encoder (rotation TIM in fgure 5.22). The wireless recording of the induction motor’s rotor temperature was realized through a TIM installed in the shaft of the test bench. Furthermore, a TIM with a vibration sensor was installed at the test bench. However,

157 5. Implementation the last two TIMs were not used in experiments for this thesis and have therefore not been described in detail.

Figure 5.21.: Test bench with installed wireless sensors.

Figure 5.22.: Rotary encoder and TIM at the back- Figure 5.23.: Control cabinet side of the breaking engine. with data TIM.

158 5.2. Time synchronous data acquisition

Figure 5.24.: Test bench setup.

5.2. Time synchronous data acquisition

This section describes the mechanisms for time synchronous data acquisition that were implemented. The aim was to support both approaches to synchronous data acqui- sition outlined in section 4.4. First, section 5.2.1 describes the implementation of the time synchronization services. The following sections describe their application to time synchronous event detection (section 5.2.2) and analog waveform acquisition (section 5.2.3).

5.2.1. Synchronization services

Contiki’s timesynch service (see section 5.1.2) was used for a priori synchronization. It was modifed, in order to exploit the time synchronization already provided by the TDMA-protocol (see section 5.1.3) [Fun4]. For a posteriori synchronization, the ETA- primitive (see section 2.2.4) was implemented [Fun4]. Essential for both synchroniza- tion services is the precise timestamping of packets in the radio driver.

159 5. Implementation

5.2.1.1. Timestamping in radio-driver

The timestamping was implemented by the author in the upper level of the radio driver, which was available as source code (radioAdv.c) (see also section 5.1.2). For outgoing packets, Contiki requires a radio driver to distinguish between normal data packets, which should be sent unaltered, and synchronization packets, where a timestamp should be written to the last four bytes. This is done through the packet type attribute that is set to TIMESTAMP for the latter. Timestamping on for the Preon32 was implemented such that the current rtimer-timestamp is written to an outgoing synchronization packet just before it is transferred from the processor to the transceiver- chip. Care was taken to disable all automatic back-of and retransmission mechanisms of the transceiver chip (compare section 5.1.1.3 and [162]). This way, the delay time Tsend,delay between timestamp generation and transmission is deterministic and as short as possible on this hardware platform. However, Tsend,delay depends linearly on the number of bytes Nbyte, f rame in the transmitted radio frame. The following equation was determined empirically and used to correct the generated timestamps:

Nbyte, f rame + 163 Byte Tsend,delay = , (5.1) 15 Byte/Tick where one clock-Tick is 61,0 µs. For incoming packets, reception timestamps should always be generated and stored in a packet attribute. On the Preon32, the provided hardware driver of the transceiver did already generate precise rtimer timestamps using the receive interrupt line of the transceiver (compare section 5.1.1.3). So those were just transferred to the packet at- tribute.

5.2.1.2. A priori synchronization

Contiki’s time synchronization service timesynch is scarcely documented, but seems to be a simplifed version of FTSP: Every node runs a Contiki process, the timesynch process, that periodically broadcasts a synchronization message with its current rtimer time (see fgure 5.25). The message also contains the authority level of a node, which describes its distance from the reference node, i.e. the reference node has the authority level zero, the nodes in one-hop distance from it authority level one, etc. When a node receives a synchronization message with a lower authority level than its own, it calcu- f local local lates its local clock o set to f f from its local reception timestamp trecv and the remote remote send timestamp tsend : local remote local to f f = tsend − trecv . (5.2) In addition, it sets its own authority level to that of the received message plus one.

160 5.2. Time synchronous data acquisition

Figure 5.25.: Remote clock reading technique of Contiki’s timesynch a priori syn- chronization service.

The global synchronized time is calculated by adding the local ofset to the local rtimer time. Applications can access it by calling the function timesynch time (see listing 5.4). This synchronized time is also included in the synchronization messages that a node itself broadcasts.

The interval Tsync between two messages starts a defned minimum value and is doubled after every message until a defned maximum value is reached. When a node changes its authority level, the interval is reset again to its minimum value. The aim of this mechanism is probably to quickly achieve synchronization in the beginning or after topology changes and to minimize the number of messages, when synchronization in the network has stabilized. To avoid collisions between synchronization messages from diferent nodes, a randomized delay is introduced in the timesynch process4 before the synchronization message is actually sent. Similar mechanisms are used for the route maintenance within the RPL routing protocol [109] or the CTP data collection protocol [43]. As the timesynch service uses the unidirectional remote clock reading technique (com- pare section 2.2.2.2), it is essential that the delay d between the generation of send and reception timestamps is constant and as small as possible, if a good synchronization precision is to be reached. Therefore the Contiki timesynch module relies on the ra- dio driver to generate the timestamps right at transmission and reception. This approach has been shown to enable high synchronization accuracies (see also section 2.2.4).

TDMA-Integration The TDMA-MAC described in section 5.1.3 is ideally suited to be combined with an a priori time synchronization. Therefore, a modifed version of the timesynch service was created by the author [Fun4], which does not generate synchro- nization messages by itself. Instead, the TDMA-beacons are used for synchronization.

4i.e. in the application layer.

161 5. Implementation

// returns the current synchronized time 2 r t i m e r c l o c k t t i m e s y n c h t i m e ( ) { 4 return RTIMER NOW ( ) + o f f s e t ; } 6 // convert a timestamp from rtimer time to synchronized time 8 r t i m e r c l o c k t t i m e s y n c h t i m e t o rtimer(rtimer c l o c k t s y n c h e d t i m e ) { 10 return s y n c h e d t i m e − o f f s e t ; } 12 // convert a timestamp from synchronized time to rtimer time 14 r t i m e r c l o c k t t i m e s y n c h r t i m e r t o time(rtimer c l o c k t r t i m e r t i m e ) { 16 return r t i m e r t i m e + o f f s e t ; } Listing 5.4: Application interface of the timesynch service.

The time synchronization service then only contains a handler function that is called f local when a beacon has been received and updates the local time o set to f f . This way all nodes within a TDMA-cell are synchronized to the coordinator clock without any additional synchronization messages or changes to the application interface.

6LoWPAN-Integration Unfortunately, Contiki’s time synchronization service was not compatible to its 6LoWPAN-stack, as the latter did not provide any mechanism to set or evaluate the time synchronization attributes of the packets. In order to rem- edy this, a modifed version of the UDP-sending function uip udp packet send was created for synchronization messages: uip udp packet send sync. It automatically extents the payload of a message by 4 Byte, that later are overwritten with the transmis- sion timestamp in the radio driver. In addition, the IPv6-fow label of the packet is set to SYNC FLOW=1. Contiki’s networking driver (sicslowpan.c) was modifed to exempt the last 4 Byte from the calculation and verifcation of the checksum in packets with this fow label. Furthermore, it tags these packets as TIMESTAMP packets when they are handed over to the MAC-driver. In order to access the timestamp information of incoming packets, two functions where added to the networking driver (sicslowpan.c). The frst, sicslowpan get reception timestamp, returns the reception timestamp of a packet. The second, sicslowpan - get packet timestamp, returns the timestamp that was sent with the packet. Fig- ure 5.26 shows the sequence diagram of a timesynch synchronization as described above.

162 5.2. Time synchronous data acquisition

Figure 5.26.: Sequence diagram of a timesynch synchronization with 6LoWPAN- integration.

5.2.1.3. A posteriori synchronization

The RITS-protocol, originally introduced in [77], defnes a simple but very efcient mechanism for a posteriori time synchronization. Its basic idea is to transmit the time Telapsed that has elapsed since an event occurred instead of the event’s timestamp tevent. This way the only additional information that a receiving node needs to calculate the local event’s timestamp relative to its local clock, is the local reception timestamp treceive:

local local tevent = treceive − Telapsed (5.3)

This mechanism is referred to as the Elapsed Time on Arrival (ETA)-primitive in [77]. It is illustrated in fgure 5.27.

As a consequence packets using ETA-time synchronization need to be handled difer- ently from other time synchronization packets. Therefore another special UDP-sending function uip udp packet send eta was created. Similarly, to the UDP-sending func- tion for timesynch synchronization messages, it sets a packet’s IPv6-fow label, in this case to ETASYNC FLOW=1. The message’s size is not extended. Instead it is assumed that the last 4 Byte already contain a timestamp that should be exempted from check- sum calculations. Furthermore, the packet is tagged as a newly created packet type: ETASYNC. When the radio driver processes such a packet, it assumes that its last 4 Byte contain a timestamp tevent. On transmission this timestamp is replaced by its diference Telapsed = trtimer − tevent to the current rtimer-time trtimer.

163 5. Implementation

Figure 5.27.: Remote clock reading technique of the ETA-primitive for a posteriori syn- chronization.

In contrast to Contiki’s packet attributes, the IPv6-fow label of a packet is transmitted with the packet. Therefore, the networking layer of the receiving node is able to rec- ognize packets using ETA-synchronization. When it does so, it calculates the event’s timestamp using (5.3). This timestamp is then written to the packet. Applications can access this timestamp with a call to sicslowpan get packet timestamp. Figure 5.28 shows the sequence diagram of sending a packet with RITS-synchronization.

Figure 5.28.: Sequence diagram of sending a packet with RITS-synchronization.

164 5.2. Time synchronous data acquisition

5.2.2. Event detection

Time synchronous event detection was implemented using the digital event sensor de- scribed in section 5.1.5.2. A priori as well as a posteriori synchronized event detection is supported. The focus was on continuous data acquisition, as this was relevant for the targeted applications. In both approaches, a 32 bit wide timestamp with a resolution of ∆t = 61, 0 µs is generated within the handler function of a user IRQ. In the case of a priori synchronization this timestamp is obtained from the timesynch-service. When a posteriori synchronization is used, the current rtimer time is used instead. At the start of a continuous measurement, the transducer driver starts a Contiki process that waits for events. When an event occurs, the IRQ-handler sends a poll event to this process (see also section 5.1.2.1), which in turn sends the data set with the event timestamp to the NCAP through the IEEE 1451 layers. If a priori synchronization is used, a standard data message is sent. If a posteriori synchronization is used, the mes- sage is marked as an ETA-message. Figure 5.29 shows the communication sequence during continuous synchronized event detection with a priori synchronization and fg- ure 5.30 that for a posteriori synchronization. A thorough experimental evaluation of both approaches is given in section 6.2. The IMMEDIATE acquisition mode can, at this stage, only be used in combination with a priori synchronization. It was not used for experiments within the scope of this thesis.

Figure 5.29.: Continuous event detection with a priori synchronization. Diferences to fgure 5.30 are highlighted in green.

5.2.3. Waveform acquisition

Time synchronous waveform acquisition has been implemented using the analog volt- age sensor described in section 5.1.5.4. It can acquire analog waveforms using either the proactive or the reactive approach introduced in section 4.4.2. A precursor of this implementation has been described by the author in [Fun4]. The reactive approach may be combined with a priori or a posteriori time synchronization. Again the focus was on continuous acquisition for both approaches. Like in the continuous event detection a Contiki process, in this case the daq process, which manages the data transfer, is started at the beginning of the acquisition.

165 5. Implementation

Figure 5.30.: Continuous event detection with a posteriori synchronization. Diferences to fgure 5.29 are highlighted in red.

5.2.3.1. Proactive approach

In the proactive approach the ADC is run with a block size of one, i.e. after hav- ing been triggered it acquires one sample. The rtimer is used to trigger the ADC at synchronized time instants. If more than one sample is acquired within one block, their sampling intervals are generated by one of the Preon32’s 16 bit timers (see section 5.1.1.1). Listing 5.5 shows the Contiki process that runs the data acquisition. The nth sampling instant tsample,n on the global timescale is defned as:

tsample,n = t0 + Ts · n, (5.4) where t0 is the start of acquisition and Ts the sampling interval. Using the timesynch- service, the sampling instants on the global timescale are converted to the local rtimer timescale of each node. This way the rtimers of all participating nodes are set to trigger acquisition synchronously. Similar to the event detection process shown in fgure 5.29, the ADC issues an interrupt when the acquisition of one block has been completed. The corresponding interrupt handler then issues a poll event to the daq process, which in turn reads the data and sends it to the NCAP.

5.2.3.2. Reactive approach

The reactive approach has been implemented in two variants. The frst one is very sim- ilar to the proactive approach, which facilitates direct comparisons. It is used during the experimental comparison of both approaches in section 6.4. Listing 5.6 shows the corresponding daq process. The only diferences to the proactive acquisition process in listing 5.5 are that the sampling instants are calculated without synchronization. In- stead, the data is sent using a posteriori synchronization with the RITS protocol (see section 5.2.1.3). The timestamp of the acquired data is derived from the rtimer and

166 5.2. Time synchronous data acquisition

1 PROCESS THREAD( d a q process , ev, data) { 3 static struct r t i m e r r t ; s t a t i c i n t i ; 5 PROCESS BEGIN ( ) ; 7 f o r ( i =0; i

15 / * read data and send it * / r e a d a n d s e n d ( ) ; 17 } PROCESS END ( ) ; 19 return 0 ; 21 } Listing 5.5: Proactive acquisition process.

set in the interrupt handler of the ADC, which is called at the end of acquisition. This procedure is similar to the reactive event detection process shown in fgure 5.30. The second variant of the reactive approach uses a priori instead of a posteriori time synchronization. This has been proven to be advantageous in situations where high data rates require using the TDMA-MAC and it is not desired to trigger the acquisi- tion directly from the program, e.g. to reduce the processor load or the sampling jitter. This variant of reactive synchronized data acquisition is used for the synchronous an- gular sampling in section 5.3. The ADC is used in continuous acquisition mode in this variant, i.e. it continuously acquires data triggered by an internal 16 bit timer of the Preon32 (see section 5.1.1.1). The acquired data is written to the acquisition bufer of the analog sensor using DMA-transfer (see section 5.1.5.4). Every time, one complete block has been acquired, the ADC-interrupt is triggered. Within the interrupt handler a timestamp is generated using the timesynch service. This timestamp corresponds to the acquisition time of the last sample in the block. Using also the timestamps from previous blocks the sampling rate and the acquisition time of the frst sample can be calculated with reference to synchronized time (compare section 5.3.5).

167 5. Implementation

1 PROCESS THREAD( d a q process , ev, data) { 3 static struct r t i m e r r t ; s t a t i c i n t i ; 5 s t a t i c r t i m e r c l o c k t t p r e v ;

7 PROCESS BEGIN ( ) ;

9 f o r ( i =0; i

13 / * yield cpu until sample has been acquired * / PROCESS YIELD UNTIL ( ev == PROCESS EVENT POLL ) ; 15 / * read data and send it * / 17 r e a d a n d s e n d e t a ( ) ;

19 / * save last time of execution * / t p r e v = RTIMER TIME(& r t ) ; 21 } PROCESS END ( ) ; 23 return 0 ; 25 } Listing 5.6: Reactive acquisition process.

5.3. Synchronous angular sampling

This section describes the implementation of synchronous angular sampling on the WSN. A partly identical description has been submitted for publication by the au- thor in [Fun7]. As stated previously in sections 2.4.2 and 4.5 digital resampling is the most feasible approach to synchronous angular sampling. Section 5.3.1 discusses the choice of resampling algorithm, section 5.3.2 its adaptation to synchronous angu- lar sampling. The design procedure for the chosen algorithm is given in section 5.3.3. Numeric details of its implementation are discussed in section 5.3.4. Finally, section 5.3.5 describes the integration of the resampling into the data acquisition framework introduced in section 5.1.4.

5.3.1. Choice of resampling algorithm

An algorithm for synchronous angular resampling should provide output signals with a good SINAD, i.e. high SNR and low THD, for a wide range of rotational speeds and also at fast speed changes (compare sections 2.4.2 and 4.5). Its input sampling rate ωin has to stay constant. It is given a lower bound by the maximum rotation frequency ωrot,max and the maximum order Omax in the output signal through the Shannon-Nyquist sampling theorem:

ωin ≥ 2ωrot,max · Omax. (5.5)

168 5.3. Synchronous angular sampling

With an angular sampling interval of Φs ≤ π/Omax and an oversampling ratio OSR ≥ 1, ωin can be expressed as: 2π ωin = OSR · ωrot,max · . (5.6) Φs

The output sampling rate ωout has to follow the speed changes dynamically: 2π ωout(t) = ωrot(t) · . (5.7) Φs Thus, the rate change factor R of the flter has to change dynamically over time:

ωout(t) 1 ωrot(t) R(t) = = . (5.8) ωin OSR ωrot,max The interval over which R varies is determined by the minimum and maximum rotation frequencies ωrot,min and ωort,max:

1 ωrot min 1 , ≤ R(t) ≤ ≤ 1. (5.9) OSR ωrot,max OSR

Another requirement on the algorithm is that it should be possible to run it on a wireless sensor node during a streaming measurement (see requirements for the WSN at the start of this chapter). Thus, the algorithm needs to support on-line data processing and must be computationally lightweight enough to be run in real-time. This favors algorithms that can be efciently implemented using fxed-point arithmetic (compare section 3.3.3). Furthermore, the algorithm should not consume too much of the sensor node’s little RAM and minimize oversampling at the output as to save transmission bandwidth. Three algorithms for synchronous angular resampling were already introduced in sec- tion 2.4.2. The spline-interpolation suggested in [17] is best suited for sampling rate increase. As a decimation flter it is only suitable for highly oversampled signals and small rate change factors, due to its small undistorted passband and low stopband at- tenuation (compare section 3.3.2.3). Figure 5.31 shows the block diagram of the upsampled linear interpolation described in [14] (see also section 2.4.2). Using an upsampling factor of typically L = 16, it can provide a good signal quality with an SNR of about 60 dB [14]. This requires an interpolation flter with narrow pass- and transition bands. Using (3.38), an order of Q = 101 has been calculated for an FIR interpolator, assuming L = 16, a signal bandwidth of ω /10 leading to ∆ω = 2π (ω /2 − ω /10) = π , and a maximum in Lωin in in 20 −3 5 ripple of δ1 = δ2 = 10 (=ˆ60 dB SNR) . 5A type A flter is required as imaging components outside the signal band might be mapped onto the signal band during linear interpolation (see sections 3.3.1 and 3.3.2.3).

169 5. Implementation

Figure 5.31.: Block diagram of upsampled linear interpolation algorithm [14].

The rate change factor of the flter is: L R (t) = R (t), (5.10) up,lin M lin where the only dynamic factor is the rate change factor Rlin of the linear interpolator. However, the output sampling rate of the linear interpolator ωlin must not be smaller than the original sampling rate ωin in order to avoid aliasing, i.e. L · Rlin(t) ≥ 1. Thus, both the interpolation flter and the linear interpolator have to be run at least at the relatively high input sampling rate. In addition, the downsampling factor M of the output decimator has to be at least as large as the ratio between minimum and maximum speed: ω ω M = lin ≥ in (5.11) ωout ωout,min with (5.6) and (5.7):

ωrot max M ≥ OSR · , (5.12) ωrot,min ωrot max nrot max M ≥ , = , . (5.13) ωrot,min nrot,min Considering that the flter order of an FIR decimator is proportional to its downsampling factor (see (3.44)), this means that the flter order increases with the speed range to be covered. Using (3.38), an order of Q = 101 has been calculated under the assumption of M = 10, ∆ω = 2π (ω /2 − ω /4) = π and a maximum ripple of δ = Mωout out out 20 1 −3 δ2 = 10 (=ˆ60 dB SNR). For a speed range of nrot,max/nrot,min = 100 it would be about Q = 1000. Such high flter orders are not only problematic because of increased operation rate and memory consumption, they also require a high numeric resolution in order to accurately represent their coefcients, especially when fxed-point arithmetic is used (compare section 3.3.3.3). The numeric examples in [14] only cover a range of 180 ... 720 rpm, i.e. nrot,max/nrot,min = 4. Another algorithm described in [14] is the upsampled interpolation flter (see also sec- tion 2.4.2). It uses the hybrid model for resampling (see section 3.3.1.4) and replaces interpolation flter and linear interpolator with a quasi continuous sinc-flter. This way a better signal quality (SNR: 70. . . 80 dB) can be achieved at a reduced computational load. However, a very large number of precalculated values for the flter’s impulse re- sponse is required to achieve this efciency. In [14] examples with 18 times 512 to

170 5.3. Synchronous angular sampling

8192, i.e. 9.216 ... 147.456, precalculated values are given. This means that assum- ing a 32 bit resolution6, at least 32 kB of memory would be needed to store all values, which is too much for most sensor nodes. Furthermore, the upsampled interpolation flter, sufers from the same problem regarding the high order of the output decimation flter as the upsampled linear interpolation.

As synchronous angular resampling can be reduced to a nonuniform reconstruction problem (see section 4.5), algorithms suggested for this task in other domains may also be used. A survey of nonuniform reconstruction algorithms for software defned radio receivers is given in [139]. As the algorithms for this task also need to be capable of real-time online data processing, there is a match with the requirements outlined above. The conclusion of [139] is that algorithms based on lowpass fltering and polynomial interpolation are the most interesting for the task.

Algorithms based on low pass fltering employ the hybrid model of a resampling flter (compare fgure 3.12). First, the continuous signal is reconstructed by modulating a delta comb with the acquired samples and feeding it through a lowpass flter. Then the continuous signal is resampled at the desired instants. However, this reconstruction method is only exact for uniformly sampled signals and an ideal lowpass flter. If applied to nonuniformly sampled signals it leads to multiplicative noise in the output signal (compare (3.27)).

Polynomial interpolation algorithms that use small polynomial orders sufer from the same problem as the spline interpolation in [17] that was discussed above. With higher polynomial orders the quality can be improved, but then the computational load quickly becomes too high [139].

Another reconstruction flter for radio communication was proposed in [82]. It is based on the method described by (3.28). Its block diagram is shown in fgure 5.32. The input signal, sampled at the time instants tn, is denoted as x(tn) = x[n]. Transposed Farrow flters are used to do the low-pass fltering of xs and xp as well as to translate the samples to a common uniform sampling grid with the sampling interval Tout/M. Two additional FIR lowpass flters with the transfer function G(z) are used to narrow the transition bands and to remove transition band noise [82]. It was observed in [82] that the input sampling rate of the transposed Farrow flters should be at least four times the signal bandwidth, in order to achieve a good reconstruction quality. Thus, the FIR decimator D(z) with a downsampling factor of M is used at the output. This flter structure is capable of ofering a good signal quality [82]. M is generally small, e.g. 2, thus the pass- and transition bands of the FIR-flters G and D are relatively large, enabling reasonably small flter orders. As all flters are designed with respect to the output frequency, this is independent of the input speed range. Thus, this fltering algorithm appears to be the best option for synchronous angular resampling with a WSN.

6Lower resolutions are unlikely to provide satisfactory results, as the value of the sinc function is 1 at the

171 5. Implementation

Figure 5.32.: Reconstruction flter proposed in [82].

5.3.2. Filter adaptation

The chosen resampling algorithm, as given in fgure 5.32, translates a signal from a nonuniform sampling grid {tn} to a uniform one tl = lTout. In order to use the al- gorithm for synchronous angular resampling, the input time instants tn need to be re- placed with the angular instants ϕn = ϕ(tn) and the output sampling interval Tout with the angular interval Φout. Yet in a practical setup, usually only the timestamps tn and ′ ′ tϕ,l′ = t(l Φout) are available (compare section 5.3.4), where l is the counting index at M-times the output rate. Thus, the angular instants ϕn need to be calculated by linear interpolation:

Φout/M ( ) ′ Φout ϕn = tn − tϕ,l′ + ln · , (5.14) ′ − ′ n tϕ,ln+1 tϕ,ln M

′ ≥ ′ where tϕ,ln+1 > tn tϕ,ln . However, the quantity that is actually needed for the operation of a transposed Farrow flter is the fractional interval µn (compare section 3.3.2.4). For synchronous angular resampling, it can be calculated as follows:

ϕn ϕn µn = M · − ⌊M · ⌋ (5.15) Φout Φout tn − tϕ,l′ = n . (5.16) ′ − ′ tϕ,ln+1 tϕ,ln

As the upper and lower Farrow flter in fgure 5.32 use the same fractional interval µn, its calculation only needs to be done once for both flters. Figure 5.33 shows the block diagram of the flter with the modifcations for synchronous angular resampling.

5.3.3. Filter design

The flter was designed assuming an input frequency ωin ≥ 2ωout and a signal band- width of Wsig ≤ ωout/4 (compare section 5.3.1). Thus, the passband edge was chosen as ωp = 0.25ωout, the stopband edge as ωstop = 0.5ωout and the decimation factor of the output stage as M = 2.

center and the values at the edges are very small.

172 5.3. Synchronous angular sampling

Figure 5.33.: Resampling flter adapted to synchronous angular resampling.

The coefcients for the transposed Farrow flter were taken from [7]. The impulse response of this flter consists of N = 4 polynomials of the order M = 3. The FIR flter G at the output of the Farrow flter was designed with the help of MATLAB, using an optimal least-squares design. Its passband characteristic was designed in such a way that it compensates for the passband ripple of the transposed Farrow flter. The flter order of G is Q = 61. The Output FIR decimator D was designed with MATLAB, using an optimal equiripple design. It has a flter order of Q = 34. The MATLAB code used for the flter design is given in appendix D.1.

The magnitude frequency responses of the individual flters are shown in fgure 5.34, that of the entire flter cascade in fgure 5.35. The latter neglects efects from demodu- lation by the divisor.

The entire designed flter has a maximum passband ripple of 0.004 dB and a minimum stopband attenuation of 62.8 dB. Better results might be achieved using the method for the calculation of optimal coefcients described in [146]. Yet, the current flter characteristics were already sufcient for the targeted applications.

farrow filter G(z) D(z)

0 −20 −40 −60 −80 magnitude [dB] −100 −120 0 1 2 3 4 5 6 7 8 9 10 ω/ω [1] out Figure 5.34.: Magnitude frequency responses of individual flters.

173 5. Implementation

0 −20 −40 −60 −80 magnitude [dB] −100 −120 0 1 2 3 4 5 6 7 8 9 10 ω/ω [1] out Figure 5.35.: Magnitude frequency response of cascade: transposed Farrow, G and D.

5.3.4. Implementation of flter algorithm

At frst the flter was implemented and tested in MATLAB. The implementation fol- lowed directly from the flter structure in fgure 5.33 and the equation of the transposed Farrow flter introduced in section 3.3.2.4. Its code is given in appendix D.2. After- wards, it was implemented in C, in order to be run on the Preon32. Since Preon32’s processor does not possess an FPU, it was not possible to run a foating-point imple- mentation of the algorithm in real-time. Therefore, the fnal implementation for the Preon32 was done in fxed-point arithmetic. Section 6.5.2 presents test results compar- ing the MATLAB, foating-point C and fxed-point C implementations of the algorithm. The fxed-point implementation of the algorithm is described in more detail in the fol- lowing.

5.3.4.1. Fixed-Point implementation

The transposed Farrow flter and the calculation of the fractional interval were imple- mented by the author. For the FIR flters G and D library functions from the CMSIS DSP library, provided by ARM [165], were used. To minimize the computational load and memory requirements of the implementation a 16 bit fxed-point format (Q0.15) was chosen for the in- and output values of the flter (compare section 3.3.3). This also covers the full digital output range of the ADC. However, it was not feasible to use this fxed point format throughout the entire flter algorithm for the following reasons: 1. The size of a Farrow flter’s output values is about N-times that of the input values x, where N is the number of input samples that contribute to one output sample. Thus, a 32 bit format (Q16.15) was chosen for the outputs of the Farrow flters and the following FIR-fltering. Also, the coefcients of the FIR-flters were taken as 32 bit numbers (Q0.31).

174 5.3. Synchronous angular sampling

2. The input sampling interval of 50 µs could not be represented precisely enough with only 15 fractional bits (2−15 s = 30.5 µs). Furthermore, at least 32 bit were needed to represent the full width of the sensor nodes’ timestamps. Thus, it was decided to use a 64 bit format (Q33.30) for the timestamps tϕ. This way the timestamps are represented with a resolution of 2−30 s = 0.931 ns and can accommodate the full timestamp resolution. 3. Many parts of the algorithm involve accumulators that need a larger number for- mat than their input values, in order to avoid overfows or severe rounding errors. Thus, they were also given wider number formats with up to 64 bit. Figure 5.36 shows an overview of the number formats used at the in- and outputs of the flter’s sub-blocks (compare fgure 5.32). In order to save memory, the input sam- pling instants tn are not input directly into the flter. Instead, the start timestamp t0 and sampling interval Tin of a block of input samples are used. The operations and number formats during the calculation of the fractional interval are shown in fgure 5.37. In order to minimize the memory requirements, the timestamps tn of the input samples are calculated from the sampling interval Tin at every step. As the number of input sam- ples is much larger than that of output samples, a signifcant amount of operations was saved by updating ∆tϕ only after the generation of a new output sample, i.e. a change in ln. Finally, Figure 5.38 illustrates the implementation of the Farrow flter (compare fgure 3.16). The fxed subflters Cm are implemented such that summation does not only take place at their outputs but at every stage in the delay line as in [7]. This way, only one bufer is needed for all four subflters at every stage. The complete code of the fxed-point implementation is given in appendix D.3.2.

Figure 5.36.: Number formats used in implementation of resampling flter.

175 5. Implementation

Figure 5.37.: Number formats used in the calculation of the fractional interval.

Figure 5.38.: Number formats used in the implementation of the Farrow flter.

176 5.3. Synchronous angular sampling

5.3.5. Network integration

Figure 5.39 shows the network layout that was chosen for synchronous angular resam- pling. One TIM, the data TIM, acquires analog samples uniformly over time using the analog voltage sensor described in section 5.1.5.4. It is synchronized to the clock of the NCAP with the timesynch-service (see section 5.2.1.2) and uses the second variant of reactive synchronous sampling described in section 5.2.3.2. The maximum acquisition block size is 2048 samples with one block per 102.4 ms. As described in section 5.2.3.2, the data acquisition process generate a timestamp tend at the last sample of every block. Using the timestamp from the previous block, the actual sampling interval Tin,i of the ith block is calculated:

tend i − tend i− T = , , 1 (5.17) in,i 2048

Before this division, the 32 bit timestamps (Q17.14) are extended to the 64 bit format (Q33.30) used by the flter and shifted 16 digits to the left. Due to the averaging over 211 samples, the efective time resolution after the division is 2−(14+11) s = 29.8 ns 7, which allows for an accurate representation of the sampling interval (nominally 50 µs). The resampling flter itself is integrated into the processing stage of the analog sensor (compare fgure 5.15).

Figure 5.39.: Network layout for synchronous angular resampling.

7The numerical resolution is of course 2−30 s = 0.931 ns.

177 5. Implementation

A second TIM, the rotation TIM, generates timestamps tϕ,l′ at equidistant angular in- tervals Φ using the rotary encoder described in section 5.1.5.7. This TIM is also syn- chronized to the NCAP using the timesynch-service. Thus, the timestamps tϕ,l′ are from the global synchronized time. They are bufered and transmitted as one block in a broadcast message at a constant interval of TBlock = 100 ms. The data TIM receives the timestamps tϕ,l′ and stores them in a second bufer. Every time a new data block becomes available, the data TIM resamples the bufered data until no ftting timestamps are available anymore. The resampled data is then sent to the NCAP. It also receives the timestamps from the rotation TIM making both, the resampled data and the rotation information, available to the user.

At the current implementation with an output sampling rate of fϕ = 15 samples/rev, the frst three signal orders can be represented accurately8. The limiting factor is the num- ber of timestamps tϕ,l′ that can be transmitted per interval. The TDMA-MAC protocol currently allows reliably transmitting up to 32 packets/s, i.e. 3 Packets in one 100 ms inter- val (see section 6.1.2). As one MSTL packet can carry a payload of 60 Byte (see section 5.1.4.4), this means that 180 Byte can be sent per interval. Considering the structure of the rotary encoder’s data set in table 5.16, it follows, that up to 83 timestamps can be transmitted per 100 ms interval. Thus, the product of maximum supported speed nrot,max and timestamp rate fϕ,t = 2 fϕ is limited to:

nrot,max 830 timestamps/s ≥ f · , (5.18) ϕ,t 60 i.e., at fϕ,t = 30 timestamps/rev, nrot,max = 1660 rpm is the maximum supported speed. If the number of output samples per revolution and thus also the number timestamps was to be increased, the maximum supported speed would be reduced. Similarly, it can be calculated that the maximum sampling rate possible at the output of the data TIM is about 840 samples/s, i.e.:

nrot,max 840 samples/s ≥ f · . (5.19) ϕ 60

Thus, the output sampling rate could be increased to up to 30 samples/rev, or the maxi- mum speed increased to up to 3360 rpm, if the timestamps could be transmitted more efciently. Possible solutions for this might be to interpolate every second tϕ on the data TIM, or to transmit the coefcients of a spline approximation, instead of the timestamps themselves.

In order for the resampling algorithm to work, the time interval Tϕ between two time- stamps tϕ must not be larger than the time interval TBu f f er, for which samples can be stored in the input bufer. For the current implementation this means that:

Tϕ ≤ Tbu f f er = 3 · 102.4 ms = 307.2 ms. (5.20)

8 The bandwidth of the resampling flter is 0.25ωout (compare section 5.3.3).

178 5.3. Synchronous angular sampling

Thus, the minimum supported speed is:

60 nrot,min = (5.21) Tϕ,max · fϕ,t 60 = = 6.5 rpm. (5.22) Tbu f f er · fϕ,t

Considering that some safety margin is needed, in order to compensate for latencies in the network communication, a minimum speed of 10 rpm is more realistic. Increasing the bufer size is hardly possible, as the three blocks of stored samples, together with the output bufer of the ADC already take up (3 + 2) · 2048 · 2 Byte = 20 kB, i.e. roughly one third of the sensor node’s entire RAM. Yet, the lower speed boundary could be reduced, if more timestamps were generated per revolution, i.e. if a higher fϕ,t was used.

179

6. Experiments

This chapter presents the experiments that were done to evaluate the performance of the WSN for the three types of synchronous data acquisition modeled in chapter 4 and whose implementations were described in chapter 5. Section 6.1 describes the mea- surements of the WSN’s power consumption and data throughput. The results of these measurements are used to better interpret the performance of the data acquisition in the following experiments. Section 6.2 shows experiments to evaluate the synchronous event detection of the WSN. Its infuence in a practical application, the acoustic local- ization of sensor nodes, is analyzed in section 6.3. Section 6.4 presents measurements to test the synchronous waveform sampling of the WSN. Finally, experiments on syn- chronous angular sampling are given in section 6.5. Throughout this chapter the indi- vidual physical sensor nodes used, will be identifed by their unique IDs (see section 5.1.4).

6.1. Wireless sensor network

This section presents experiments that were done to determine basic characteristics of the used WSN: its power consumption (section 6.1.1), data throughput and transmis- sion reliability (section 6.1.2). Although these were not in the focus of this thesis and therefore have not been fully optimized, they still are relevant performance metrics.

6.1.1. Power consumption

As power is often scarce in WSNs the power consumption of a wireless sensor node is an important performance metric (compare section 2.1.1). The Contiki operating system used in this thesis provides a mechanism called powertrace that estimates the power consumption of a node during operation. The experiments presented in this section serve to calibrate the powertrace mechanism for the Preon32 sensor node. Furthermore, the powertrace estimates were validated through comparison with mea- surements from a digital multimeter (DMM).

181 6. Experiments

6.1.1.1. Experimental setup

Figure 6.1 shows the experimental setup used to measure the current of the sensor nodes. A sensor node, mounted on a Preon32Shuttle, was connected to a laboratory power supply (Gossen 33K7EU5/2x25R1) with Vin = 3.8 V. The actual supply voltage Vsupply = 3.3 V of the Preon32 was generated from this by a linear voltage regulator on the Preon32Shuttle (see also section 5.1.1). A DMM (FLUKE 8846A) was used to measure the supply current. In some experiments a second node was used to communi- cate with and collect powertrace data from the node whose current consumption was measured.

The integration time Tinter for the dual-slope ADC of the multimeter was set to 100 power-line-cycles (PLC). At the given power-line frequency of 50 Hz this resulted in Tinter = 2 s. Thus, the current measurement of the multimeter was the average current drawn by the sensor node over this time. A PC connected to the serial interface of the multimeter was used to automatically acquire current readings with a MATLAB- script. The Preon32 was run from its internal RC-oscillator at a system clock frequency of 36 MHz throughout these experiments as well as in all other experiments in this chapter (compare section 5.1.1).

Figure 6.1.: Experimental setup used to measure the supply current of a node.

6.1.1.2. Current consumption measurement

The frst round of experiments served to measure a sensor node’s current consumption in the diferent power states. For this purpose a set of simple Contiki applications was created that all enter an infnite loop after initialization (see fgure 6.2). Thus, the con- trol over the microcontroller stays with the application and never returns to the Contiki scheduler (compare section 5.1.2). In order to measure the current consumption of the diferent microcontroller power modes, the wireless transceiver was turned of during the initialization of the program. Then in the infnite loop the microcontroller was re- peatedly put to sleep in the selected power mode for 10 min (see fgure 6.2 a)). To get an impression of how processor operations afect its current consumption a variable was

182 6.1. Wireless sensor network repeatedly incremented within the loop instead of calling the sleep routine (see fgure 6.2 b)). This will be referred to as power mode BUSY in the following descriptions. In order to measure the transceiver’s listening current consumption, it was turned on at the initialization of the program and the microcontroller was set to sleep in RUNNING mode in the infnite loop (see fgure 6.2 c)). Finally, the sleep routine in the infnite loop was replaced by the sending of a wireless packet of maximum length (127 Byte) (see fgure 6.2 d)). This way the node was sending out packets at the maximum possible rate. For this case, both the maximum (3 dBm) and the minimum (-17 dBm) transmis- sion power setting of the transceiver were investigated.

Figure 6.2.: Activity diagrams of test applications used to measure a sensor node’s cur- rent consumption.

In the experiments, the program for the investigated power mode was frst compiled and downloaded to the sensor node via its USB-interface. Then the USB-Interface was disconnected from the sensor node and the power supply was connected to the power socket of the Preon32Shuttle. After resetting the node and waiting for 1 min, 10 automated measurements of the node’s supply current were taken over a period of approximately 10 s. This was repeated for every investigated power mode. Table 6.1 shows the results of the current measurements with node number 41. The current values Isupply are the average values from the N = 10 measurements. The uncertainties Uk,I are the expanded uncertainties that were calculated for a coverage factor of k = 2 from the standard deviation smeas of the measurement values and the specifed uncertainty uDMM of the multimeter [40, 41]: √ s2 U = k · meas + u2 (6.1) k,I N DMM

183 6. Experiments

Table 6.1.: Current consumption of node 41 measured for the diferent power modes. Mode Current consumption

microcontroller transceiver Isupply Uk=2,I unit BUSY OFF 19.903 0.107 mA RUNNING OFF 17.273 0.063 mA IDLE OFF 6.778 0.016 mA STANDBY OFF 65.133 0.076 µA POWEROFF OFF 25.404 0.010 µA RUNNING LISTEN 30.861 0.161 mA BUSY TX (3 dBm) 28.654 0.014 mA BUSY TX (-17 dBm) 24.875 0.021 mA

Comparing the measured values in table 6.1 to the specifcation values in table 5.4, the current consumption measured for the POWEROFF mode matches very well. Also the values for the BUSY, RUNNING and IDLE modes are within the expected range. It is worth noting that there is quite a large diference in current consumption (about 15 %) between the microcontroller sleeping in RUNNING mode and the processor constantly incrementing a variable (BUSY mode). The current measured for the STANDBY mode is signifcantly lower than the one given in the specifcations (1.3 mA). Interestingly, a similar value could be measured by skipping the initialization of the wireless transceiver during the Contiki boot. The wireless transceiver apparently consumes more current, when left uninitialized compared to being shut-down after initialization. To separate the listening current consumption of the wireless transceiver from that of the microcontroller, the current consumption measured for the RUNNING mode with transceiver of was subtracted from that measured during RUNNING mode with lis- tening for wireless communication. The resulting value is about 1 mA higher than the specifed current consumption (see tables 5.4 and 6.2). To obtain the transmitting current consumption of the wireless transceiver the current consumption measured for the processor in BUSY mode was subtracted from that mea- sured during transmission. This was chosen, because the processor was constantly busy generating and sending packets to the wireless transceiver during these measurements. The resulting current consumption (about 8.7 mA for 3 dBm) is, however, much lower than the one specifed in table 5.4. To further investigate this phenomenon, a 10 Ω re- sistor was connected in series to the Preon32Shuttle and the voltage drop over it was measured with an oscilloscope (PicoScope 2205MSO). Figure 6.3 shows an extract of the measured current trace. Obviously, the current consumption is periodically chang- ing, with a period of about 6.5 ms. The length of the upper plateau (about 4 ms) fts well with time-on-air (∼ 4.3 ms) that is expected for the packet length used. Thus, the transceiver apparently does not stay in transmitting mode all the time, but goes through some intermediate states although the controller is constantly sending packets to it. As

184 6.1. Wireless sensor network a consequence the average current consumption is lower than that of the transmit state. For this reason the current of the upper plateau in the trace was used to determine the current in transmit state instead of the multimeter measurement. Its mean value was 34.2 mA and its standard deviation 0.22 mA over a total of 20 periods. Taking the precision of the oscilloscope ±15 mV and that of the resistor ±0.1 Ω into account the expanded uncertainty of the measurement was calculated. The results given in table 6.2 match very well with the specifcations.

node current mean current in plateau

40

30

20

amplitude [mA] 10

−2 0 2 4 6 8 10 12 14 16 18 time [ms] Figure 6.3.: Node current during transmission.

Finally, the measured current values were assigned to the four power modes used by Contiki’s powertrace mechanism (see section 5.1.2). The CPU-active mode in powertrace (short: cpu) was equated with the BUSY mode of the processor. For the low-power mode (short: lpm) the IDLE mode of the processor was used, as this is the mode Contiki’s scheduler switches to when no process is running (see 5.1.2.5). The current consumption for the listen and transmit modes in powertrace were calculated by subtracting the current consumption of the microcontroller from measured current values as explained above. For the transmit mode (short: tx) the maximum transmission power of 3 dBm was assumed, as this is the standard setting in Contiki.

Table 6.2.: Current consumption assigned to powertrace modes. Powertrace mode Current consumption

Imode Uk=2,mode unit cpu active (cpu) 19.90 0.11 mA low power (lpm) 6.78 0.02 mA listen (listen) 13.59 0.17 mA transmit (tx) 14.30 1.78 mA

185 6. Experiments

6.1.1.3. Power consumption estimation

In order to check the ability to predict a node’s power consumption from the recorded powertrace values, a second round of experiments was done. A comparison was made between the average power consumption of a TIM, as calculated from the average cur- rent measured by the multimeter, and that estimated from the powertrace values. The TDMA-MAC was chosen for the experiments as it caused a varying current profle that was approximately stationary within the integration time of the multimeter. Otherwise, the TIM was left idle, i.e. no measurement application was active. Three diferent confgurations of the TDMA-MAC were investigated:

1. Every node in the network, i.e. the NCAP as well as the TIM, always sent a packet in its assigned slot. If no packet had been handed to the network stack for transmission, a dummy packet was generated by the MAC-layer. This caused the nodes to frequently transmit as well as receive packets and also caused a higher load on the processor.

2. No dummy packets were generated. Thus, the only packets that were regularly transmitted were the beacons from the NCAP and the wireless trafc was strongly reduced compared to the frst confguration.

3. The same as the second confguration, but this time the wireless transceiver of the TIM was switched of between the beacons. This strongly reduced the time the wireless transceiver spent in listening mode.

The experimental procedure was the same for every confguration: First, the program was confgured and downloaded to the TIM. Then, its USB-interface was disconnected and the node was reset. After, waiting for one minute, powertrace values were read wirelessly from the TIM through the NCAP and current values were read from the multimeter alternately within a loop. A total of N = 10 measurements were acquired this way. To get an impression of the variance in power consumption between diferent nodes, the nodes 27, 31 and 41 were investigated this time.

After the N = 10 measurements, the average power consumption of the respective TIM was calculated in two diferent ways:

1. From multimeter:

1 ∑N P = V · I (6.2) DMM supply N supply,i i=1

2. From powertrace values: For every mode, its share in the power consumption was calculated from its current value in table 6.2 and its active time tmode recorded

186 6.1. Wireless sensor network

by powertrace for the time Ti between the frst and second collection of values in the loop: tmode Ppwrt.,mode,i = VsupplyImode (6.3) Ti This was repeated for every iteration. In the end, the power values were averaged over all N = 10 iterations.

Again, the expanded uncertainties were calculated for a coverage factor of k = 2. For the multimeter values their standard deviation and the precision specifcation of the multimeter were used [40, 41]. For the powertrace values the uncertainties of the current values shown in table 6.2 were used. The time readings were assumed to be accurate within one tick of the rtimer leading to an uncertainty contribution of ut = T√rtc = 17.6 µs. 12

Figure 6.4 shows the results of the power estimations. The diferences between the three confgurations are as expected. Signifcantly more power is consumed by the transmit mode in confguration 1 than in 2 or 3. The share of the listen mode is about the same in confgurations 1 and 2. In confguration 3 it decreases drastically. The processor load decreases from confguration 1 to 2, as fewer packets have to be processed. In confg- uration 3 the processor load increases again, due to the radio duty-cycling operations. The overall power consumption is dominated by the low power and the listening mode as they are active for most of the time.

The estimates from the powertrace values are similar to those obtained from the mul- timeter in all cases. Yet, they often don’t match within the calculated uncertainty inter- vals. This may be due to the fact that the actual power consumption of the processor in running mode is dependent on the types of instructions that it executes. In addition, pe- ripherals like the timer used by the TDMA-MAC probably cause an additional current consumption that is not accounted for in the simplifed model used by powertrace. Furthermore, the time reported by powertrace for every mode is calculated by sum- ming up the active times of the mode during operation. As every part of this sum is only precise up to one rtimer tick (Trtc ≈ 61 µs), the quantization errors may accu- mulate over time leading to an estimation uncertainty of unknown size. It increases in magnitude, when mode changes occur frequently. Apparently, diferences in power consumption between individual nodes running the same application are present but small and mostly negligible.

The original publication [31] on powertrace gives no indication as to the absolute accuracy that can be expected. There, it was only shown, that the fnal energy estimates before an energy storage had been exhausted, were essentially independent of the node or program. Yet, no comparison to the nominal energy capacity of the storage was made.

187 6. Experiments

Node 27 Node 31 Node 41 80

60 DMM pwrt. lpm

[mW] 40 pwrt. cpu

avg pwrt. listen P pwrt. tx 20

0 1 2 3 1 2 3 1 2 3 Configuration Configuration Configuration

Figure 6.4.: Power consumption of nodes as calculated from current measurements with multimeter (DMM) and as estimated from powertrace (pwrt.). The error bars show the expanded uncertainty Uk=2.

6.1.1.4. Conclusions

The current consumption of one node was measured for the diferent power modes using a relatively simple setup. Comparison with the specifcation values showed an essentially good match. Yet, it was also shown that modeling the power consumption with a small number of diferent modes is a signifcant simplifcation. Therefore, it is not always trivial to achieve and observe these modes in real operation. Nevertheless, the power consumption estimated using powertrace about matches that obtained from current measurements with a multimeter. Signifcant deviations were observed, that are probably due to simplifcations in the powertrace approach. Never- theless, the powertrace estimates are very useful for observing the efect of software changes on the power consumption and for comparing the contributions of diferent components.

6.1.2. Data throughput

In order to determine the transmission bandwidth usable for data collection in later experiments, the data throughput and the reliability of transmission were measured for the WSN. The IEEE 802.15.4 standard defnes a bit rate of 250 kbps for wireless communication in the 2.5 GHz band [194]. However, already the data link layer defned in IEEE 802.15.4 introduces an overhead so that the actually usable data bandwidth is signifcantly lower. Delays caused by the MAC-layer as well as failed transmissions and

188 6.1. Wireless sensor network consequent retransmissions further reduce the actual data throughput. As MAC-layer operations are always performed on a per packet basis, it is often more meaningful to evaluate MAC-layer performance in terms of packets per time instead of data amount per time. This section presents experiments that evaluate the RDC- and MAC-layer protocols used for this thesis (see also section 5.1.2) in terms of packet rate versus transmission success and power consumption.

6.1.2.1. Experimental setup

To evaluate the performance of the MAC-layer, a simple test setup was used, where one or more nodes each transmitted 1000 UDP-packets at a fxed rate. All packets had a payload of 60 Byte. An additional receiver node was used to count the number of successfully received packets. At the end of the experiment, this count was used to calculate the percentage of successful transmissions. Furthermore, powertrace data was recorded during the experiment. Table 6.3 shows the three confgurations of RDC- and MAC-layer that were investi- gated. For all layer-confgurations two diferent network topologies were examined: one sender and one receiver (one-to-one) as well as two senders and one receiver (two- to-one). The packet rate was varied between 1 and 64 packets/s for the one-to-one trans- mission and between 1 and 42 packets/s for the two-to-one transmission. For the TDMA- MAC the receiving node was chosen to be the coordinator, as this confguration is typical of data acquisition applications.

Table 6.3.: Confguration of network layers investigated for data throughput. Conf. RDC-layer MAC-layer 1 nullrdc CSMA 2 ContikiMAC CSMA 3 TDMA TDMA

6.1.2.2. Transmission success

Figure 6.5 shows the success rate during transmissions for one-to-one transmissions. Up to 32 packets/s, the success rate is 100 % for all investigated network confgurations. After this there is a clear drop in the transmission success for the TDMA-MAC while the other two confgurations maintain a near 100 % success rate even at the maximum investigated packet rate of 64 packets/s. The reason for this is that the simple TDMA- MAC, used in this thesis, is statically confgured for a network of three nodes. Thus, in one-to-one transmission only a third of the total bandwidth can be used. This limi- tation does not apply if CSMA-based protocols are used. With the TDMA-MAC, the

189 6. Experiments

receiver 110

100

90

80

70 success rate [%] 60

50 4 8 16 25 32 42 64 packet rate [1/s] CSMA,nullrdc CSMA,ContikiMac TDMA

Figure 6.5.: Transmission success during transmissions of one sender to one receiver.

theoretical maximum packet rate is 46 packets/s per node (see table 5.6). Yet in practice, a node will fail to use some of its allocated timeslots due to imprecision in the process scheduling, thus reducing the actual packet rate (see also section 5.1.3). The transmission success rate for two-to-one transmissions is shown in fgure 6.6. Here the TDMA-MAC is the only protocol that maintains a 100 % success rate up until a packet rate of 32 packets/s. For the CSMA-MAC without radio duty-cycling the suc- cess rate is only slightly worse, while for the confguration using ContikiMAC radio duty-cycling there is a signifcant deterioration already at 16 packets/s. This is due to the collisions that inevitable occur when multiple nodes transmit and a contention based MAC is used. For ContikiMAC this is particularly pronounced, because here a node makes many transmission attempts shortly after another.

6.1.2.3. Power consumption

Figures 6.7 and 6.6 show the average power consumption of the nodes during the ex- periments. In general the average power consumption is rising with the packet rate. Obviously, the confguration not using radio duty-cycling has about the maximum power consumption in all cases. On the receiver side the power consumption of the TDMA-MAC is mostly close to it and sometimes even surpasses it. This is because the TDMA-MAC does not use radio duty-cycling on the coordinator (see section 5.1.3). On the sender side where radio duty-cycling is used, the TDMA-MAC shows a power consumption that is at least as low as that of ContikiMAC. At higher data rates it is even signifcantly lower. The reason for this is that due to the scheduled transmission there are far fewer failed transmission attempts with the TDMA-MAC than with Con- tikiMAC.

190 6.1. Wireless sensor network

receiver 110

100

90

80

70 success rate [%] 60

50 4 8 16 25 32 42 64 packet rate [1/s] CSMA,nullrdc CSMA,ContikiMac TDMA

Figure 6.6.: Transmission success during transmissions of two senders to one receiver.

receiver sender 120 120

100 100

80 80

60 60

40 40 avg. power [mW]

20 20 4 8 16 25 32 42 64 4 8 16 25 32 42 64 packet rate [1/s] packet rate [1/s]

CSMA,nullrdc CSMA,ContikiMac TDMA

Figure 6.7.: Average power consumption during transmissions of one sender to one re- ceiver.

191 6. Experiments

receiver sender 120 120

100 100

80 80

60 60

avg. power [mW] 40 40

20 20 4 8 16 25 32 42 64 4 8 16 25 32 42 64 packet rate [1/s] packet rate [1/s]

CSMA,nullrdc CSMA,ContikiMac TDMA

Figure 6.8.: Average power consumption during transmission of two senders to one re- ceiver.

6.1.2.4. Conclusions

The investigation of the diferent RDC and MAC-layer confgurations showed that re- liable packet transmission is possible up to a rate of 32 packets/s. If multiple nodes are transmitting simultaneously the CSMA-MAC sufers from collisions during transmis- sions. Also its average power consumption at the sender side is signifcantly higher than that of the TDMA-MAC for the investigated packet rates. At much lower packet rates this picture may change, as the TDMA-MAC constantly sends beacons even if no communication takes place. At the receiver side, the power consumption for the TDMA is much higher. Yet, this was a deliberate design decision, as the coordinator is assumed to have access to mains power. Thus, the TDMA-MAC appears to be advantageous for most cases of networked data acquisition.

6.2. Time synchronous event detection

To characterize the performance of synchronous event timestamping in the WSN, the clocks of the involved sensor nodes were investigated frst. In a second step the times- tamping accuracies of the implemented a priori and a posteriori synchronization were compared. Furthermore, the interactions between the synchronization mechanism and the MAC-protocol were investigated.

192 6.2. Time synchronous event detection

6.2.1. Experimental setup

The experimental setup shown in fgure 6.9 follows the test procedure for event detec- tors that was introduced in section 4.6.1. For the experiments a WSN with one NCAP and two TIMs was used. Interrupt inputs of all three nodes were connected to the digi- tal output of a fourth sensor node that did not participate in the WSN. The connections were made with four identical 50 Ω Bayonet Neil-Concelman (BNC)-cables of 1.3 m length. On both TIMs and the NCAP the event sensor described in section 5.1.5.2 was used in continuous acquisition mode. The time synchronized event detection mecha- nism described in section 5.2.2 was used to generate a timestamp every time a pulse was detected. These timestamps were transmitted to the NCAP, from where they were read by a computer. The time between two pulses was chosen randomly from the interval [1.5, 2.5 ]s, us- ing the pseudo-random number generator of the standard C-library, on the pulse node. During the experiments data on the nodes’ power supply was collected using Contiki’s powertrace mechanism (see also sections 5.1.2 and 6.1.1). Furthermore, the clock corrections performed by the synchronization algorithm were recorded via the USB interface of each node.

Figure 6.9.: Experimental setup used for event timestamping tests.

Table 6.4 shows the network confgurations that were investigated during the exper- iments. The CSMA-MAC was always used in combination with the ContikiMAC- protocol. But, the actual radio duty-cycling was turned of in confgurations 1 to 6, in order to prevent it from infuencing the timestamping. The same was done for the TDMA-MAC. Furthermore, the synchronization interval of the a priori timesynch protocol was varied. For every confguration a total of 1000 timestamp triples were recorded over about 33 min.

193 6. Experiments

Table 6.4.: Network confgurations investigated in event detection tests. Conf. Sync. procedure Protocols Sync. interval MAC RDC min max [s][s] 1 none CSMA of -- 2 RITS a posteriori CSMA of -- 3 TDMA a priori TDMA of 0.02 0.02 4 timesynch a priori CSMA of 0.25 1.00 5 timesynch a priori CSMA of 4.00 16.00 6 RITS a posteriori CSMA on − − 7 TDMA a priori TDMA on 0.02 0.02 8 timesynch a priori CSMA on 0.25 1.00

Table 6.5.: Relative drifts between TIMs and NCAP. The uncertainties given are the expanded uncertainties (k = 2) calculated for the variances of the regression parameters.

TIM i RMSE ρN,i t-test (αt = 5 %)

pt Sig.? [Ticks][ppm][%] 1 0.61 10.376 ± 0.004 < 0.01 Yes 2 0.91 72.629 ± 0.006 < 0.01 Yes

Abbreviations: Sig.?=Is value signifcantly diferent from zero?

6.2.2. Relative drift of clocks

The frst network confguration, shown in table 6.4, served to characterize the clocks of the involved nodes. Thus, the event timestamping was performed without any time synchronization between the nodes. Figure 6.10 shows the timestamp diferences ∆t between the NCAP and the two TIMs. Without any synchronization, the ofset of the clocks is the time diference between powering on the diferent nodes. This is arbitrary and does not contain any useful information. Thus, the ofset was subtracted from the ∆t, in order to improve the visibility of the relative drift. Linear regression was performed on the ∆t to estimate the drifts ρN,i of the TIMs’ clocks relative to that of the NCAP. The variances of the estimates were calculated and used to determine their expanded uncertainties (coverage factor of k = 2). T-tests were done to check the signifcance of the drift estimates. Table 6.5 shows the results of the regression analysis.

194 6.2. Time synchronous event detection

3000 183.11 TIM 1 TIM 2 2000 122.07 [ms] [Ticks] t t ∆

∆ 1000 61.04

0 0.00 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure 6.10.: Recorded timestamp diferences of TIMs to NCAP without time synchro- nization. The initial clock ofset was removed to improve the visibility of the relative drifts.

The root-mean-square error (RMSE) of the linear fts is low (< 1 Tick) for both nodes. Thus, the behavior of their clocks can be well described by a constant drift model for the observed time interval. The relative drift between the NCAP and TIM2 is about seven times larger than that between NCAP and TIM1. This may be linked to the fact, that TIM2 (i.e. node 41) is from a diferent hardware revision than the other two (i.e. nodes 27 and 31) and uses a diferent clock oscillator.

6.2.3. Synchronization precision

Network confgurations 2 to 8 shown in table 6.4 were used to investigate approaches to synchronized event detection. In addition, the efects of the synchronization interval as well as the infuence of the MAC and RDC layer were studied. For the confgurations (3-5,7,8) using a priori synchronization, the maximum expected synchronization error ϵt,max can be calculated using (2.1). The drift values were taken from table 6.5. The synchronization error right after one synchronization event was assumed to be ϵt,sample = 0.5 Tick. This is motivated by the fact that a clock can only be set with a resolution of 1 Tick. Thus, it may not be possible to set the clock closer than 0.5 Tick to the actual time (compare section 4.2.1.4). Table 6.6 shows the results of this calculation. Ideally, the absolute values of the timestamp diferences between the nodes should be smaller or equal to the calculated values rounded to the next larger integer.

195 6. Experiments

Table 6.6.: Theoretical maximum synchronization errors rounded to next larger integer number of Ticks. Exact values obtained from (2.1) are given in brackets.

Conf. ϵt,max,N,T1 ϵt,max,N,T2 ϵt,max,T1,T2 [Ticks][Ticks][Ticks] 3 1 (0.50) 1 (0.52) 1 (0.52) 4 1 (0.67) 2 (1.69) 2 (1.52) 5 4 (3.22) 20 (19.54) 17 (16.82) 7 1 (0.50) 1 (0.52) 1 (0.52) 8 1 (0.67) 2 (1.69) 2 (1.52)

Abbreviations: N=NCAP, Ti=TIMi

Figure 6.11 shows a boxplot of the recorded timestamp diferences for each of the three node pairs in the experiment. Dashed green lines mark a ±1 Tick environment around zero. The medians of the individual series are shown as red lines. Blue boxes show the ranges covered by the center 50 % of all values. Their lower edges correspond to the 25 %-percentile P0.25 and the upper edges to the 75 %-percentile P0.75 respectively. Similarly the whiskers indicate the span of the center 95 % of all values 1. Values outside the range of the whiskers are shown as red crosses. Since the large spread of values in confgurations 6 to 8 dominates much of the visible range in fgure 6.11, fgure 6.12 shows the same data with zoomed vertical axis. In the majority of confgurations and node pairs the median time diference is zero. The only cases where the median is not in the ±1 Tick interval are in confguration 5 for pairs with TIM2. This, however, was expected due to high relative drift of TIM2 (see table 6.5). Comparing the results in fgures 6.11 and 6.12 to the theoretical maximum synchro- nization errors in table 6.6 shows, that the center 95 % of all timestamp diferences are within the predicted interval for confgurations 2 to 5. However, in nearly all cases there are also a few values outside these intervals. This is particularly pronounced in confg- urations 6 to 8, where also the center 95 % range is signifcantly larger than expected and values outside this range scatter even more widely.

1 As the timestamp diferences are discrete values, two of them may be exactly equal. In this case the center 95 % range of all values cannot be defned exactly. It is instead the smallest range that contains at least the center 95 % values. The same applies for the center 50 % range.

196 6.2. Time synchronous event detection

40 2.441 30 20 1.221 10 [ms] 1 [Ticks]

1 0 0.000 N,T t N,T

t −10 ∆ ∆ −20 −1.221 −30 −40 −2.441 40 2.441 30 20 1.221 10 [ms] 2 [Ticks]

2 0 0.000 N,T t N,T

t −10 ∆ ∆ −20 −1.221 −30 −40 −2.441 40 2.441 30 20 1.221

10 [ms] 2 [Ticks] 2 0 0.000 ,T 1 ,T T 1 t T −10 t ∆

∆ −20 −1.221 −30 −40 −2.441 2 3 4 5 6 7 8 CSMA TDMA CSMA CSMA CSMA TDMA CSMA RITS (0.02,0.02) TS(0.25,1) TS(4,16) RITS (0.02,0.02) TS(0.25,1) off off off off on on on

Network configuration

Figure 6.11.: Recorded timestamp diferences with synchronization. The red lines mark the median. The blue boxes show the center 50 % and the whiskers the center 95 % of all values. Values outside these ranges are drawn as red crosses.

197 6. Experiments

16 0.977 14 12 0.732 10

8 0.488 [ms] 1 [Ticks]

1 6 N,T t

N,T 4 0.244 t ∆

∆ 2 0 0.000 −2 −4 −0.244 16 0.977 14 12 0.732 10

8 0.488 [ms] 2 [Ticks]

2 6 N,T t

N,T 4 0.244 t 2 ∆ ∆ 0 0.000 −2 −4 −0.244 16 0.977 14 12 0.732 10

8 0.488 [ms] 2 [Ticks] 2 6 ,T 1 ,T T 1

4 0.244 t T t 2 ∆ ∆ 0 0.000 −2 −4 −0.244 2 3 4 5 6 7 8 CSMA TDMA CSMA CSMA CSMA TDMA CSMA RITS (0.02,0.02) TS(0.25,1) TS(4,16) RITS (0.02,0.02) TS(0.25,1) off off off off on on on

Network configuration

Figure 6.12.: Recorded timestamp diferences with synchronization with zoomed verti- cal axis. The red lines mark the median. The blue boxes show the center 50 % and the whiskers the center 95 % of all values. Values outside these ranges are drawn as red crosses.

198 6.2. Time synchronous event detection

Table 6.7.: Estimated statistical parameters of timestamp diference distribution.

Conf. Nodes mean std. skew ex. krut. pgauss n2σ Tclock,e f f [Ticks][Ticks][1][1][%][%][Ticks] 2 NT1 -0.14 0.72 11.2 251.0 < 0.01 99.9 1.8 2 NT2 -0.24 0.72 11.4 260.2 < 0.01 99.9 1.8 2 T1 T2 -0.10 0.58 -0.0 -0.0 < 0.01 99.9 1.4 3 NT1 0.20 0.68 -1.2 6.1 < 0.01 98.0 1.7 3 NT2 0.21 0.69 -1.2 6.1 < 0.01 98.3 1.7 3 T1 T2 0.01 0.60 0.0 0.1 < 0.01 99.7 1.5 4 NT1 0.12 0.84 -3.6 23.9 < 0.01 98.1 2.1 4 NT2 0.22 0.94 -3.6 25.3 < 0.01 98.1 2.3 4 T1 T2 0.10 0.71 0.1 0.0 < 0.01 97.4 1.7 5 NT1 1.12 0.91 -0.1 -0.5 < 0.01 92.6 2.2 5 NT2 9.14 5.37 -0.0 -1.2 < 0.01 100.0 13.2 5 T1 T2 8.02 4.62 -0.0 -1.2 < 0.01 100.0 11.3 6 NT1 -1.29 3.70 -5.6 38.0 < 0.01 96.6 9.1 6 NT2 -1.52 3.77 -5.3 34.6 < 0.01 96.8 9.2 6 T1 T2 -0.23 5.25 0.2 17.7 < 0.01 95.1 12.9 7 NT1 -1.39 5.10 -3.2 9.7 < 0.01 92.7 12.5 7 NT2 -1.49 5.24 -3.2 9.5 < 0.01 93.1 12.8 7 T1 T2 -0.10 5.24 -0.5 12.1 < 0.01 92.8 12.8 8 NT1 0.31 4.43 -2.1 25.6 < 0.01 94.4 10.9 8 NT2 0.66 4.19 -3.0 28.2 < 0.01 93.4 10.3 8 T1 T2 0.35 6.12 -0.3 12.4 < 0.01 96.0 15.0

Abbreviations: N=NCAP; T1=TIM1; T2=TIM2; std.= standard deviation; ex. kurt.= excess kurtosis; 2 pgauss= p-value of a χ goodness of ft test for a Gaussian distribution; n2σ= percentage of values within a ±2σ interval

For further examination, the histograms of timestamp diferences are shown in fgure 6.13. Fitted Gaussian probability density functions are also shown; as the analysis in section 4.2.1 revealed that an approximately Gaussian error distribution is likely. Table 6.7 shows a summary of statistical parameters that where estimated from the recordings. The histograms for confgurations 2 to 4, especially those of the pair (TIM1, TIM2), visually appear to agree quite well with a Gaussian distribution. Yet, all histograms clearly fail a χ2 goodness-of-ft test for a Gaussian distribution. The reason appears to be a lack of values in the tails of the distributions. The histograms of the pairs that in- volve TIM2 in confguration 5 seem to approximate a uniform distribution. Histograms of confgurations 6 to 8 show a wide spread of infrequent extreme values and sometimes multiple modes, that both cause large standard deviations.

199 6. Experiments

Conf.\Pair (NCAP,TIM1) (NCAP,TIM2) (TIM1,TIM2)

CSMA 60

2 RITS [%] 40 rel.

f f o 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks] TDMA 60

3 (0.02, 0.02) [%] 40 rel.

f f o 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks] CSMA 60

4 TS(0.25,1) [%] 40 rel.

f f o 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks] CSMA 60

5 TS(4,16) [%] 40 rel.

f f o 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks] CSMA 60

6 RITS [%] 40 rel. on f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks] TDMA 60

7 (0.02, 0.02) [%] 40 rel. on f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆t [Ticks] ∆t [Ticks] ∆t [Ticks] 60 N,T1 N,T2 T 1,T2 CSMA

8 TS(0.25,1) [%] 40 rel. on f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure 6.13.: Histograms of recorded timestamp diferences. Fitted Gaussian probabil- ity density functions are shown as red curves.

200 6.2. Time synchronous event detection

An observation common to all confgurations is that the histograms of the pairs, which consist of the NCAP and one TIM, are often skewed and have a strong excess kurtosis. The histograms of the pair that consists of two TIMs, on the other hand, mostly have a skew close to zero and less excess kurtosis. Also the means and standard deviations of timestamp diferences tend to be smaller for this pair. A not perfectly compensated delay in the transmission of synchronization timestamps between NCAP and TIMs is a plausible explanation for this behavior. In most cases the percentage n2σ of values that are within an interval of two standard deviations is larger than 95 %. In the other cases it is at least 92 %. This shows that even though the histograms of the timestamp diference signifcantly difer from a Gaussian distribution, their standard deviations are still a useful measure of the spread of values.

The values given for Tclock,e f f in table 6.7 show that in the best confgurations (2 to 4) the loss of timestamping precision due to synchronization can be roughly equated to putting a factor of 1.5 to 2.3 on the clocks resolution, i.e. about one bit of the clocks resolution is efectively lost (see also section 4.2.3). A comparison to the performance of other synchronization protocols from the literature is problematic due to diferences in the underlying platform and experimental methods (see also section 2.2.4). Yet, it can be noted that the observed synchronization precision is in the same order of magnitude as the results from other state-of-the-art protocols (compare table 2.7). An interesting fact is that the resolutions of the underlying clocks reported in the literature are disproportionately higher than in the present experiments. Thus, the implemented synchronization protocol may be said to be especially efcient in utilizing the clock resolution. In confguration 5 the distribution of timestamp diferences for pairs including TIM2 resembles a uniform distribution rather than a Gaussian one. As pointed out in section 4.2.1 this indicates a dominant error infuence from clock drift. This is confrmed by the timestamp diferences and clock updates during the frst 100 s that are shown in fgure 6.14. Here the sawtooth behavior typical of a drifting clock that is periodically corrected by a synchronization algorithm is clearly visible when TIM2 is involved. Further evidence to this point is that the drift of TIM2 relative to the NCAP and TIM1 has been found to be particularly strong (see section 6.2.2). In the other confguration using a priori synchronization this behavior is in theory also present. Yet, it is much weaker and probably shadowed by other infuences. Another efect of the clock drift is a bias in the mean timestamp diference of ∆tmax/2. This explains the increased median value for confguration 5 observed in fgure 6.12. Unfortunately, a classic correlation analysis of the timestamp diferences could not be performed, as they were acquired nonuniformly over time. Yet, apart from confguration 5 there is no obvious periodicity in the time diference values.

201 6. Experiments

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 10 20 30 40 50 60 70 80 90 100 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 10 20 30 40 50 60 70 80 90 100 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 10 20 30 40 50 60 70 80 90 100 t [s]

40 20 [Ticks] 1

T 0 c

∆ −20 0 10 20 30 40 50 60 70 80 90 100

40 20 [Ticks] 2

T 0 c

∆ −20 0 10 20 30 40 50 60 70 80 90 100 t [s] Figure 6.14.: First 100 s of recorded timestamp diferences and clock updates for con- fguration 5. Another phenomenon that needs further analysis is the occurrence of unusually large timestamp diferences especially in confgurations 6 to 8. The most probable cause for this are code sections during which interrupts are blocked (compare section 5.1.2.1). Table 6.8 shows a number of such code sections that could be identifed. Their length was obtained by setting a general-purpose input/output (GPIO)-pin high during their execution and measuring the pulse width with a logic analyzer (Tektronix TLA 704). The maximum execution time of the radio interrupt correlates very well with the max- imum timestamping diferences observed in confgurations 3 and 4. The duration of the radio on and of operations of the TDMA-MAC match equally well with the times- tamping diferences observed in confguration 7. The maximum timestamp diferences observed in confgurations 6 and 8 correspond to the maximum execution time of an rtimer task that ContikiMAC uses in its radio duty-cycle.

202 6.2. Time synchronous event detection

Table 6.8.: Known sections of interrupt blocking on Preon32. section duration [ms][Ticks] radio interrupt ≤ 0.59 ≤ 9.7 radio on 1.76 28.8 radio of 1.57 25.7 ContikiMAC rtimer task ≤ 2.30 ≤ 37.7

70

60 lpm cpu 50 listen 40 tx

30

avg. power [mW] 20

10

0 Node: N T1T2 N T1T2 N T1T2 N T1T2 N T1T2 N T1T2 N T1T2 N T1T2 1 2 3 4 5 6 7 8 CSMA CSMA TDMA CSMA CSMA CSMA TDMA CSMA none RITS (0.02,0.02) TS(0.25,1) TS(4,16) RITS (0.02,0.02) TS(0.25,1) off off off off off on on on Network configuration

Figure 6.15.: Mean power consumption of nodes during timestamping experiments es- timated from powertrace.

6.2.4. Power consumption

Figure 6.15 shows the powertrace statistics gathered during the timestamping experi- ments. The listening and low power modes dominate the overall power consumption, as they are active for most of the time. Consequently, the activation of the radio duty- cycling on the TIMs in confgurations 6 to 8 leads to the strongest power savings. No efect is visible on the NCAP because it does not use radio duty-cycling. It is assumed to always have access to mains power.

203 6. Experiments

In a priori synchronization smaller synchronization periods lead to increased power consumption from CPU operations and transmission activity. However, this efect is strongest on the NCAP and only small the TIMs. Active radio duty-cycling further increases the active power of the CPU. A posteriori synchronization is always slightly more power efcient than a priori, due to reduced CPU active times. The TDMA-MAC always causes more power consumption than the CSMA-MAC due to higher activity rates.

6.2.5. Conclusions

The majority of the measured timestamp diferences are within the expected bounds for synchronization precision. Interrupt blocking code sections were identifed as the cause of a relatively small number of more extreme values. If no signifcant drift occurs be- tween synchronization events, the distribution of the timestamp diferences looks very similar to a Gaussian distribution. Yet, it tends to be more strongly centered. Further- more, transmission delays between NCAP and TIMs often cause a slight asymmetry in the distribution. Yet, a Gaussian model still seems to be a useful approximation in most cases. No signifcant advantages of either a priori or a posteriori synchronization with regard to synchronization precision could be found. The best, i.e. minimal, standard deviation for both approaches was about s∆t = 0.60 Ticks. Thus the timing uncertainty of the WSN is at least:

s∆t ut = √ = 0.42 Ticks = 25.9 µs. (6.4) 2 This can also be interpreted as the loss of less than one bit on the clocks efective resolution. The absolute value of the observed synchronization precision is in the same order of magnitude as that reported in the literature for state-of-the-art synchronization protocols. In relation to the underlying clock resolution it even clearly better. The power consumption of the sensor nodes during the experiments was found to be most strongly infuenced by their current consumption in low power mode and the lis- tening current of the radio transceiver. Thus, using radio duty-cycling is the most ef- fective way to save power. Yet, the duty-cycling operation was found contain a number of interrupt blocking sections that adversely afect the timestamping precision. This efect illustrates the complex interactions of software on small resource constraint sys- tems like wireless sensor nodes. Overcoming this trade-of is not easy as hardware duty-cycling often requires wait periods that should not be interrupted. Yet, it is key to achieving both low-power and high precision operation. In a priori synchronization smaller synchronization periods cause higher power consumption. This efect, however, is strongest on the NCAP where at the same time it is not very critical. Yet, in a multi- hop network this increase is expected to be also visible on mesh nodes, which may have more constrained power supplies. A posteriori synchronization generally seems to have

204 6.3. Application example: acoustic localization a slight advantage in terms of power efciency over a priori synchronization. Yet, its use is only feasible, when the MAC protocol does not already include or require an a priori time synchronization.

6.3. Application example: acoustic localization

Acoustic localization techniques are used in a variety of applications, e.g. indoor po- sitioning [126, 91] or sniper localization [132]. WSNs are especially well suited for these tasks, as they are comparatively easy to install over large areas. Localization techniques are commonly based on the time-of-fight of acoustic signals between two or more nodes or the diferences in time-of-arrival at the nodes [132, 91, 126]. There- fore accurate time synchronized timestamping is of key importance for an accurate localization.

6.3.1. Model

A very basic example of acoustic localization was investigated. Figure 6.16 shows its general setup: two microphones and one acoustic source are located on a straight line. Both microphones detect sounds that are emitted by the source. If a sound is detected at the time t1 by the frst and at t2 by the second microphone, the distance d between the microphones can be calculated from the following equation:

d = vsound (t2 − t1) = vsoundTsound. (6.5) where vsound is the sound velocity and Tsound the time that the sound traveled between the microphones.

Figure 6.16.: General setup for passive acoustic localization on a straight line.

205 6. Experiments

6.3.2. Estimation of required synchronization accuracy

The measurand is the distance d. Its maximum location uncertainty is chosen as uc,max = 1 cm. Equation (6.5) already models the relationship between measurand and time- stamps. The sensitivity coefcients for the timestamps t1 and t2 are: ⏐ ⏐ ⏐ ∂d ⏐ ct = ⏐ ⏐ = vsound. (6.6) ⏐∂t1,2 ⏐

Thus, the frst upper limit for the timing uncertainty ut,max is:

2 2 2 uc,max = (ctut,max) + (ctut,max) (6.7)       from t1 from t2 uc,max ⇒ ut,max = √ (6.8) 2vsound with vsound = 343 m/s at ϑ = 20 °C [68]

⇒ ut,max = 20.6 µs. (6.9)

As nothing is known about other uncertainty infuences, e.g. comparator noise and jitter, at this point, a suitable error margin has to be included. Table 6.9 shows the max- imum timing uncertainty needed for various localization uncertainties and uncertainty margins.

Table 6.9.: Maximum timing uncertainty ut,max of a single timestamp in µs for diferent maximum location uncertainties ud,max and uncertainty margins for vsound = 343 m/s.

uncertainty margin/ud,max 0.0 % 50.0 % 90.0 % 99.5 % 10 cm 206.15 178.53 89.86 20.59 5 cm 103.08 89.27 44.93 10.29 2 cm 41.23 35.71 17.97 4.12 1 cm 20.62 17.85 8.99 2.06 1 mm 2.06 1.79 0.90 0.21

Previous experiments have shown, that the timestamping uncertainty of the WSN used is at least ut = 25.9 µs (see section 6.2). Comparing this to the values in table 6.9, a localization accuracy of about 2 cm should be achievable. If the observed accuracy was signifcantly worse, uncertainty infuences other than the synchronization accuracy, would need to be reduced in order to improve it. In order to have a realistic chance of reaching a localization accuracy of 1 cm the timestamping uncertainty would need to

206 6.3. Application example: acoustic localization be reduced to about 17.85 µs. However, it is unlikely that this can be achieved at the given clock resolution. The uncertainty√ of the clock reading that is caused by the clock resolution is already ut,clock = Tclock/ 12 = 17.62 µs and every time synchronization procedure will cause at least a small extra uncertainty.

6.3.3. Experiments

Figure 6.17 shows the experimental setup that was realized. Two TIMs were equipped with the microphone modules described in section 5.1.5. A piezo buzzer (Multicomp MCKPI-G2210L-3672) was used as a sound source. Its resonant frequency is specifed as (4.2 ± 0.5) kHz and its sound pressure as 90 dB at distance of 10 cm and an operating voltage of 12 V [202]. The two sensor nodes with microphones and the piezo buzzer were placed along the edge of a laboratory bench (see fgure 6.17). Microphones and piezo buzzer were oriented perpendicular to the bench’s plane, as this was found to lead to more stable sound detections and also simplifed fxation. Short burst of sound were periodically generated by the buzzer, which was connected to the output of a waveform generator (HAMEG HM8150). The buzzer was turned on and of using a square wave with a frequency of 1 Hz, a pulse width of 1 ms and an amplitude of 10 V.

Figure 6.17.: Setup for acoustic localization experiments.

207 6. Experiments

As described in section 5.1.5.5, the microphone modules set a digital output high when the sound level crosses a threshold. As no low-pass fltering is done, this usually leads to a train of digital pulses with about one pulse per signal period (see fgure 6.18). The outputs of the microphone modules were connected to interrupt-inputs of the corre- sponding sensor nodes. Detection timestamps where generated in the corresponding interrupt handlers. The interrupt of the sensor nodes were disabled for 2 ms after the detection of a pulse. This avoided the generation of multiple timestamps per sound burst. In addition to the sensor nodes, the digital outputs of the microphone modules were connected to the inputs of a frequency counter (HAMEG HM8123). It measured the interval Tsound,cnt. between the frst pulse on the frst input and the consecutive pulse on the second input. The WSN was confgured with the TDMA-MAC and a priori time synchronization (see section 5) as this combination had been proven to ofer both good synchronization accuracy (see section 6.2) and high transmission reliability (see section 6.1.2). Radio duty-cycling (RDC) was deactivated by default, as it had been found to cause signifcant timestamping errors (see section 6.2). Nevertheless, measurements with active RDC were recorded at selected distances in order to investigate the efect of the additional errors. Timestamps generated at the TIMs were transmitted to the NCAP and read into a PC. There the timestamps were matched and the time intervals Tsound,wsn were calculated. Two timestamps t2 and t1 were taken to belong to the same sound burst, if t2 > t1 and t2 − t1 < 10 ms. This corresponds to a maximum accepted distance of 3.43 m at a sound velocity of 343 m/s (literature value for ϑ = 20 °C [68]); which is much more than the maximum distance of 1.8 m possible in the setup.

6.3.3.1. Procedure

Before the experiments both microphone modules were placed at the maximum dis- tance from the piezo buzzer and their amplifers were set to generate approximately the same output voltage. Figure 6.18 shows the output of one microphone amplifer to- gether with the module’s digital output in this confguration. During the experiments the distance d between the two TIMs was varied between 20 ... 100 cm in steps of 10 cm. For every distance N = 60 time intervals were recorded with both the WSN and the frequency counter. For the distances 30, 50, 70, 90 cm also measurements with active RDC were recorded. During the experiments room temperature and air humidity were repeatedly monitored using a standard consumer thermo- and hygrometer (TechnoLine WS9119). The temperature was in the range of 26-28 °C and the humidity between 40 and 45 % throughout the experiments. Furthermore, the air velocity was repeatedly measured using a thermal anemometer (Testo 405-V1). It was below 0.02 m/s in all measurements.

208 6.3. Application example: acoustic localization

3 amplifier digital 2

1 amplitude [V]

0 −10 −5 0 5 10 time [ms] Figure 6.18.: Example output of microphone amplifer and digital pin.

6.3.4. Results

The time intervals measured by the frequency counter at the distances of 20, 40, 60, 80 and 100 cm were used to calibrate the localization system. The measurements were found to contain a number of values that signifcantly deviated from the majority of values. This was, probably caused by a microphone module triggering on a diferent peak from time to time. To remove these outliers a flter was applied, that selected the median of three consecutive samples. Thus, Nsamp = 20 samples per distance were used for calibration. Linear regression was used to calculate vsound and d0 in the model equation below. d = vsoundTsound + d0. (6.10) Figure 6.19 shows the measured time intervals and the calibration curve. The numerical results of the calibration process are given in table 6.10. Both, slope and ofset of the calibration curve have been proven to be statistically signifcant in a t-test (p < 10−27). The slope of the calibration curve is signifcantly lower than the speed of sound expected at the given environmental conditions (vsound = 347, 5 m/s at ϑ = 27 °C [68]). This may indicate that the sound received by the sensor nodes did not simply travel straight along the line of connection but was infuenced by multipath efects, like e.g. refection and superposition (see also the discussion of error infuences in section 6.3.5). The measurements taken at the distances of 30,50,70 and 90 cm were used to validate the ftted model. The RMSE for the validation points given in table 6.10 is equal to that of the ft, showing that the model is also valid for non-calibration points. Judging by the graph in fgure 6.19 and the data in table 6.10 the ftted model seems to be a valid representation of the localization process. Yet, the comparatively high RMSE indicates a signifcant amount of uncertainty in the model.

209 6. Experiments

100

80

60

40 calibration point calibration curve

node distance [cm] 20 verification point 0 0 0.5 1 1.5 2 2.5 3 3.5 4 time difference [ms] Figure 6.19.: Linear calibration of the localization system. The error bars indicate an interval of two standard deviations.

Table 6.10.: Calibration results for the localization system. The error intervals corre- spond to the expanded uncertainty Uk=2, as estimated from the ft residu- als.

vsound d0 RMSE f it RMSEval. [m/s][cm][cm][cm] 317.0 ± 4.3 −7.9 ± 1.0 1.9 1.9

After calibrating the localization system the time intervals measured with the WSN were used to calculate the distances between the nodes. This was done for all four distances also used during the validation of the model. Figure 6.20 shows the means and doubled standard deviations of the localization errors for each distance. It can be observed that mean localization error is in some cases sig- nifcantly diferent from zero and varies in sign and magnitude between the distances. Where the mean localization error is comparatively large, it has about the same sign and magnitude for all devices. This indicates a device independent cause. The standard deviation of the localization errors also varies with the distance. However at every dis- tance, the standard deviation of the counter measurements is the lowest and that of the WSN with active RDC the highest. Table 6.11 shows statistic values calculated over all localization errors at the distances of 30, 50, 70 and 90 cm. To investigate the infuence of the median fltering on the local- ization errors, the same statistics were also calculated for data sets that were obtained by selecting Nsamp = 20 uniformly spaced samples from the recorded data. The overall mean localization errors are always signifcantly smaller than the overall standard deviations. Thus, the RMSE is almost equal to the overall standard deviation. To separate distance dependent from distance independent errors the RMSE was split

210 6.3. Application example: acoustic localization

counter WSN WSN,sleep

5

0

−5 location error [cm] 30 50 70 90 distance [cm] Figure 6.20.: Mean localization errors obtained with fltered timestamps. The error bars indicate an interval of two standard deviations.

Table 6.11.: Overall statistics of localization errors.

Device mean std. max. abs RMSE smean sdev. [cm][cm][cm][cm][cm][cm][µs] counter -0.4 1.9 5.4 1.9 1.8 0.7 21 WSN -0.4 2.0 4.6 2.1 1.8 1.1 34

fltered WSN,sleep -0.2 2.7 8.5 2.7 1.8 2.0 63 counter -0.1 2.2 5.4 2.2 1.8 1.2 39 WSN -0.3 2.2 5.0 2.2 1.5 1.6 52 WSN,sleep 1.0 13.9 51.1 13.9 4.4 13.2 418 unfltered

up into the standard deviation smean of the mean localization errors ϵ for every distance and the standard deviation sdev of the errors ϵ for every distance with the mean error removed:

N 1 ∑samp ϵ = ϵ (6.11) i N i j samp j=1 N 1 ∑dist s2 = ϵ2 (6.12) mean N i dist i=1 N Nsamp 1 ∑dist ∑ s2 = (ϵ − ϵ )2 (6.13) dev N N i j i dist samp i=1 j=1 √ 2 2 RMSE = smean + sdev , (6.14)

211 6. Experiments with Nsamp the number of samples per distance and Ndist the number of distances. It is striking to see, that in the fltered case smean is independent of the measurement device. In contrast to this, sdev clearly increases from the frequency counter over the WSN to the WSN with active RDC. In the unfltered case the localization errors increase drastically for the WSN with active RDC, whereas in the other cases the increase is only slight. This shows, that the median fltering not only removes outliers caused by acoustic efects, but also those caused by interrupt blocking code sections (see also section 6.2).

6.3.5. Uncertainty analysis

The standard deviations of the localization error in table 6.11 match well with the lo- calization precision of about 2 cm estimated in section 6.3.2. For further analysis of the individual uncertainty contributions the measurement model (6.5) is extended with a number of error quantities:

d = vsound (Tsound + δprop + δT ) + d0 + δmodel. (6.15)

Here d0 is the localization ofset that is the result of all constant error infuences. It is compensated by the calibration processes. The error infuences that are dependent on the distance between the nodes are expressed as modeling error δmodel. Random error infuences that afect the propagation of the sound burst and its detection are summa- rized as δprop and δT is the error of the time interval measurement. Table 6.12 shows a summary of physical error infuences that contribute to the individual quantities.

Table 6.13 shows the uncertainty budget for δT of the counter. According the counter’s specifcations, the time interval measurement is afected by three error infuences: the resolution of the clock δres,counter, a system error δsys,counter and the accuracy of the internal time base δbase,counter [51]. The latter depends on the length of the time in- terval. Here it was calculated for an interval of 3.4 ms which is slightly more than the maximum interval measured during the experiments. The combined measurement un- certainty of the counter uc,T,counter is about three orders of magnitude smaller than the overall standard deviation sdev for the counter in table 6.11. Therefore, sdev,counter can be used as an estimate for the uncertainty uprop ≈ sdev,counter that is introduced by δprop. Similarly, the overall standard deviation of the mean errors smean for the counter in table 6.11 is used as an estimate for the uncertainty umodel ≈ smean,counter that is introduced by δmodel.

212 6.3. Application example: acoustic localization

Table 6.12.: Infuence quantities afecting the localization measurement. ), ) ) ) ) ) 0 0 0 0 0 sound d d d v d d ) ) ) ) ) ) ) 1.3 mm) 1 mm) ) ) ) prop prop prop prop prop model model T T T = ≤ δ δ δ δ δ δ δ δ δ δ modeled ( ect Treatment f dependent constant distance random trigger jitter x modeled ( trigger threshold x compensated by calibration ( group delay x compensated by calibration ( multipath propagation x modeled ( microphone sensitivity x compensated by calibration ( air movement x x compensated by calibration ( sound damping x modeled ( positioning error x neglected ( external noiseamplifer gain x x modeled ( compensated by calibration ( rel. position of microphone x compensated by calibration ( Category Infuenceposition yard stick accuracyacoustic sound repeatability E electric x amplifer noisetime neglected ( x interrupt latency modeled ( x modeled ( x modeled ( measure- clock resolution x modeled ( ment clock synchronization x modeled (

213 6. Experiments

Table 6.13.: Uncertainty budget for time interval measurement with frequency counter. cient f infuence estimate distribution weight standard uncertainty sensitivity coe degrees of freedom uncertainty contribution assumed uncertainty √ δ SE G u c v u √ δres,counter 10.0 ns R 1/ √3 5.8 ns 1 ∞ 5.8 ns δsys,counter 4.0 ns R 1/ √3 2.3 ns 1 ∞ 2.3 ns δbase,counter 1.7 ns R 1/ 3 1.0 ns 1 ∞ 1.0 ns

uc,T,counter 6.3 ns 1 ∞ 6.3 ns

The estimates for uprop and umodel obtained from the frequency counter measurements were used to build uncertainty budgets for the localization measurements with all three devices. The standard deviations given in table 6.7 for the nodes 31 (T1) and 41 (T2) in confgurations 3 and 7 are used as estimates for the uncertainty uT of the time interval measurement with the WSN. Tables 6.14 to 6.16 show the corresponding uncertainty budgets. The RMSE of the measured localization errors are given for comparison. The estimated uncertainty of the distance measurement matches quite well with the measured RMSE from the fltered samples in case of the frequency counter and the WSN without RDC. In case of the WSN with RDC estimated the uncertainty matches roughly the RMSE from the unfltered samples. This shows again, that the median fl- tering is also efective in removing outliers caused by synchronization or timestamping errors. It is apparent that the infuence of time interval measurement uncertainty on the overall localization uncertainty quickly decreases as it gets smaller. Consequently, the local- ization uncertainty for the frequency counter is only about 20 % smaller than that for the WSN, although the counter’s time interval measurement uncertainty is about three orders of magnitude better. Considering an idealized WSN, where only the clock reso- −14 lution of Ttick = 2 s contributes to the time interval measurement uncertainty, yields a localization uncertainty of 2.1 cm. Thus, only 0.1 cm or 4.5 % of the localization uncertainty can be attributed to synchronization or timestamping errors.

214 6.3. Application example: acoustic localization

Table 6.14.: Uncertainty budget for localization with frequency counter. cient f infuence standard uncertainty sensitivity coe degrees of freedom uncertainty contribution δ u c v u

uc,T,counter 6.3 ns 317.0 m/s ∞ 2.0 µm uprop 0.7 cm 1 76 0.7 cm umodel 1.8 cm 1 76 1.8 cm

ud 76 1.9 cm RMSE (fltered) 80 1.9 cm RMSE (unfltered) 80 2.2 cm

Table 6.15.: Uncertainty budget for localization with WSN. cient f infuence standard uncertainty sensitivity coe degrees of freedom uncertainty contribution δ u c v u

uT,WSN 36.6 µs 317.0 m/s 999 1.2 cm uprop 0.7 cm 1 76 0.7 cm umodel 1.8 cm 1 76 1.8 cm

ud 76 2.3 cm RMSE (fltered) 80 2.1 cm RMSE (unfltered) 80 2.2 cm

215 6. Experiments

Table 6.16.: Uncertainty budget for localization with WSN and active RDC. cient f standard uncertainty infuence sensitivity coe degrees of freedom uncertainty contribution δ u c v u

uT,WSN 319.8 µs 317.0 m/s 999 10.1 cm uprop 0.7 cm 1 76 0.7 cm umodel 1.8 cm 1 76 1.8 cm

ud 76 10.3 cm RMSE (fltered) 80 2.7 cm RMSE (unfltered) 80 13.9 cm

6.3.6. Conclusions

The passive acoustic localization studied is a typical example of an application that is directly infuenced by the synchronized timestamping precision of a WSN. With the help of the estimation procedure suggested in section 4.2.3 and the experimental results for the timestamping uncertainty from section 6.2 it was possible to obtain a good prediction for the localization accuracy. The same analysis has also shown which timestamping accuracy would be needed to achieve a 1 cm precision localization and that this is only feasible at an increased clock resolution. Uncertainty analysis of the measurement results revealed that the error infuences from the modeling and sound propagation alone already cause 1.9 cm of an overall localization uncertainty of 2.3 cm. Consequently, both the precision of the WSN and the sound detection would need to be optimized to achieve localizations accuracies of 1 cm or better. Finally, the experiments also show that fltering schemes introduced to suppress outliers caused by acoustic phenomena, also mitigate the efects from errors in synchronized timestamping.

216 6.4. Time synchronous waveform acquisition

6.4. Time synchronous waveform acquisition

The aim of the experiments on synchronous waveform acquisition, was to observe the infuence of the synchronization precision on the frequency, phase, SNR and THD of an acquired waveform. Furthermore, the proactive and reactive approaches to syn- chronous sampling were compared. (see also section 4.4.2). Most of this section has been previously published by the author in [Fun4].

6.4.1. Experimental setup

The test method suggested in section 4.6.2 was used for the experiments. Figure 6.21 shows the setup. Two TIMs separately acquire a sine wave from a waveform generator and wirelessly transmit the samples to the NCAP. The analog voltage sensor described in section 5.1.5.4 was run in continuous mode for the experiments. Every sample was triggered and transmitted individually, i.e. the acquisition block size was one. The rtimer triggered the samples at a fxed rate of fsample = 32 samples/s. Both, the reactive and the proactive approach were investigated in the experiments (see section 5.2.3 for their implementation). The waveform generator used in the experiments (HAMEG HM8150) had a frequency resolution of 10 mHz and a specifed frequency accuracy of 15 mHz. For a sine signal with a peak-to-peak voltage of Vpp = 1.0 V a SNR of 65 dB and a THD of -65 dB are specifed [52]. During the experiments a sine signal with a peak-to-peak amplitude of Vpp = 3.0 V and a DC component of Vdc = 1.6 V was used, in order to cover most of the ADC’s input range.

Figure 6.21.: Experimental setup to test time synchronous waveform acquisition.

An advantage of the test method is that it can equally be applied to WSNs as to con- ventional multi-channel data acquisition systems. Therefore a USB DAQ-card (Na- tional Instruments USB6009) was used as a reference. The DAQ-card contains a 16 bit

217 6. Experiments successive-approximation ADC with four multiplexed inputs, two of which were used to sample the sine wave from the generator simultaneously. As only input voltage ranges symmetrical to 0 V are supported by the DAQ-card, an input range of ±2 V was chosen for the experiments. The peak-to-peak amplitude of the waveform generator was set to Vpp = 3.8 V and its DC-component to Vdc = 0 V. Otherwise the same parameter settings as for the WSN were used.

Table 6.17 gives an overview of the confgurations that were investigated. Radio duty- cycling was deactivated in all experiments. Two sine frequencies were used: one low and one high relative to the WSN’s sampling rate. They were chosen following the recommendations outlined in section 4.6.2.

Table 6.17.: Confgurations for waveform acquisition tests. f Conf. Device MAC Sync. protocol Sampling approach f signal signal fsample [Hz][1] 1 Preon32 TDMA TDMA-timesynch proactive, hybrid 0.27 0.008 2 Preon32 TDMA TDMA-timesynch proactive, hybrid 7.11 0.222 3 Preon32 CSMA RITS reactive, none 0.27 0.008 4 Preon32 CSMA RITS reactive, none 7.11 0.222 5 USB6009 - - - 0.27 0.008 6 USB6009 - - - 7.11 0.222

For each confguration 100 waveforms of 2048 synchronously acquired samples were recorded from each node. By taking the samples recorded with the reactive approach before the resampling and discarding the timestamps a set of unsynchronized wave- forms was obtained. A set of waveforms for the hybrid approach was generated by using the timestamps recorded within the proactive approach to do a resampling of the data. During confgurations 1 and 2 the histogram of clock updates was recorded in addition to the sampled data.

6.4.2. Signal quality

f The frequency error ϵ f , the o set error ϵt0 as well as the SNR and THD of the wave- forms were calculated as described in section 4.6.2. Table 6.18 shows the means and standard deviations of the results calculated over all N = 100 waveforms for every confguration. Figure 6.22 shows the means of the estimated pairwise time ofsets. The error bars indicate and interval of two standard deviations. As all approaches to synchronized sampling show signifcantly lower ofsets than the unsynchronized case, fgure 6.23 shows the same data with a zoomed y-Axis.

218 6.4. Time synchronous waveform acquisition

f Table 6.18.: Frequency errors ϵ f and time o set errors ϵt0 calculated from the acquired waveforms.

Synch. fsignal ϵt0 ϵ f Approach TIM 1 TIM 2 mean std. mean std. mean std. [Hz][µs][µs][mHz][mHz][mHz][mHz] none 0.27 2575.1 4589.4 −3.9 2.8 −3.9 2.8 reactive 0.27 −8.1 81.3 −3.9 2.8 −3.9 2.8 proactive 0.27 −7.7 70.5 4.44390 0.00042 4.44388 0.00037 hybrid 0.27 −9.6 68.9 4.44390 0.00043 4.44388 0.00037 DAQ-card 0.27 14.1 8.8 −4.86757 0.00008 −4.86758 0.00007 none 7.11 2081.6 3121.7 −3.82316 0.0030 −3.3526 0.0068 reactive 7.11 495.8 157.6 −3.78406 0.0030 −3.678 0.013 proactive 7.11 2.2 2.6 −1.0 4.3 −1.0 4.3 hybrid 7.11 1.1 2.4 −1.0 4.3 −1.0 4.3 DAQ-card 7.11 17.7 0.3 −3.73427 0.00076 −3.73427 0.00076

10 10

5 5 [ms] [ms] 0 0 t t ǫ 0 ǫ 0

−5 −5

none none reactive hybrid reactive hybrid proactive proactive DAQ−card DAQ−card

(a) fsignal = 0.27 Hz (b) fsignal = 7.11 Hz

Figure 6.22.: Mean pairwise time shifts Tshi f t. The error bars indicate an interval of twice the standard deviation.

219 6. Experiments

0.2 0.2

0.1 0.1 [ms] [ms] 0 0 0 0 t t ǫ ǫ

−0.1 −0.1

−0.2 −0.2

none none hybrid reactive reactive hybrid proactive proactive DAQ−card DAQ−card

(a) fsignal = 0.27 Hz (b) fsignal = 7.11 Hz

Figure 6.23.: Mean pairwise time shifts Tshi f t with zoomed y-axis. The error bars indi- cate an interval of twice the standard deviation.

The ofset in the unsynchronized case is surprisingly small (ca. 2.5 ms). This is because the acquisition was started with the same broadcast message on both TIMs. This way, the nodes were implicitly synchronized to some degree. The remaining time ofset was only due to timing diferences in the process scheduling of the individual nodes. In nearly all cases, the standard deviation is smaller at the higher signal frequency compared to the lower. This is due to the time ofset estimate being less sensitive to variance in the phase estimate at higher signal frequencies (compare (4.57)). For all approaches to synchronized sampling the time ofsets are minimal at the lower signal frequency ( fsignal = 0.27 Hz). They vary only in a range of roughly two ticks of the rtimer TTick ≈ 61.0 µs. For the higher signal frequency ( fsignal = 7.11 Hz), the time ofset from the reactive approach shows a big increase. This is due to the linear interpolation used in the reactive approach being less accurate at signal frequencies close to the WSN’s Nyquist frequency ( fsample/2 = 16 Hz) (compare section 3.3.2). The time ofset of the DAQ-card is caused by its analog input multiplexer (see section 3.2.3). The mean ofset is larger than in most cases of synchronized sampling with the WSN, but the standard deviation is signifcantly smaller.

The estimates for the frequency error ϵ f , shown in table 6.18, are much smaller than the specifed frequency accuracy of the generator (15 mHz [52]). Thus, no drift error could be detected for either of the acquisition methods or the DAQ-card. To get a further insight into the performance of the sensor nodes’ clocks their average sampling rate was calculated from the acquired sample timestamps (see 6.17). The fact that the sampling rate is always exactly 32 samples/s for the resampled data (reactive and

220 6.4. Time synchronous waveform acquisition hybrid approach) just shows that the resampling algorithm wrote the correct sampling interval into the waveforms it generated. In the unsynchronized measurements it can be observed that the sampling frequency of TIM2 (node 42) was of by -1.89 mHz (- 59.1 ppm), while it was only 0.25 mHz (7.8 ppm) for TIM1 (node 26). These results correlate well with the drifts of nodes 31 and 41 relative to node 27 given in table 6.5. Thus, the observed diference in sampling rates is probably due to drift errors of the nodes’ real-time clocks. The resulting frequency error in the recorded signal would be 0.05555 mHz for TIM1 and -0.41993 mHz for TIM2 at the higher signal frequency (7.11 Hz). This matches with the observed diference in frequency errors for two TIMs in the unsynchronized case (see table 6.18). In the proactively synchronized measure- ments the error in sampling rate is signifcantly smaller, showing the efectiveness of the synchronization.

Table 6.19.: Average sampling rates calculated from sample timestamps.

Synch. fsignal fs Approach TIM 1 TIM 2 mean std. mean std. [Hz][samples/s][samples/s][samples/s][samples/s] none 0.27 32.00025 0.00014 31.99811 0.00003 reactive 0.27 32.00000 0.00000 32.00000 0.00000 proactive 0.27 31.99999 0.00003 32.00002 0.00004 hybrid 0.27 32.00000 0.00000 32.00000 0.00000 none 7.11 32.00024 0.00002 31.99811 0.00003 reactive 7.11 32.00000 0.00000 32.00000 0.00000 proactive 7.11 32.00000 0.00003 32.00003 0.00003 hybrid 7.11 32.00000 0.00000 32.00000 0.00000

The results of the SNR estimation are given in fgure 6.24. In the unsynchronized case the data acquisition is not infuenced by any synchronization algorithm. Thus, the SNR for this case indicates the general performance of the ADC and is used as a reference. It is, however, about 10 dB lower than the specifed SNR of the waveform generator and about 17 dB lower than the ideal SNR of a 12 bit ADC. This may be due to noise from the sensor nodes’ other components afecting the signal quality. Furthermore, it is observed that TIM1 generally shows a slightly lower SNR than TIM2. The SNR of the signals acquired with the DAQ-card matches well with the specifed SNR of the waveform generator (65 dB). At the lower signal frequency all approaches show a SNR close to that of the unsynchronized data. At the higher signal frequency the SNR of the reactive approach is much lower than for the other approaches. This again, is caused by a decrease in interpolation accuracy close to the Nyquist frequency.

221 6. Experiments

70 TIM1/Ch1 70 TIM2/Ch2 60 60

50 50 SNR [dB] SNR [dB]

40 40

30 30

none none hybrid reactive hybrid reactive proactive proactive DAQ−card DAQ−card

(a) fsignal = 0.27 Hz (b) fsignal = 7.11 Hz

Figure 6.24.: Signal SNR.

To investigate why the SNR of TIM2 is about 15 dB lower than that of TIM1 for the reactive approach at the higher signal frequency, two acquired waveforms, one from TIM1 and one from TIM2, were also resampled for output sampling rates other than the desired 32 samples/s. If the original sampling rate of TIM1 is chosen as the output sampling rate for the resampling, the SNR is about equal to that in the unsynchronized case (51.3 dB) and much lower for TIM2 (30.1 dB). If the original sampling rate of TIM2 is chosen for the resampling, it is the other way around (TIM1: 30.1 dB; TIM2: 54.5 dB). If the average of the original sampling rates is taken the SNR is 35.8 dB for both nodes. At resampled rates of 31.5 and 32.5 samples/s the SNR is 20.9 dB. Thus, the decrease in SNR seems to grow with increasing sampling rate change during the resampling. This again shows the poor performance of the used interpolation at signal frequencies close to the Nyquist frequency. Although the diferences are not statistically signifcant, it is also worth noting, that the SNR of the data acquired with the proactive approach is constantly slightly lower than that of the unsynchronized data. At the higher signal frequency this diference is a little bigger that at the lower. To check whether this could be related to an in- creased jitter from clock updates, the histograms of the clock updates shown in fgure 6.25 were evaluated. They show that in most synchronization intervals the clock did not need to be updated because it was still synchronized (clock correction zero). In the other cases the corrections are mostly very small (1-2 Ticks). This behavior is consis- tent with the clock update histograms obtained for the same synchronization method during the event detection experiments (see appendix E.2). Inserting the standard devi- ation calculated from the histogram data into (4.38) the SNR was calculated assuming time base jitter to be the only noise source. The results were 83.4 dB for the lower and 55.0 dB for the higher signal frequency. Comparing this to the SNR in the unsynchro-

222 6.4. Time synchronous waveform acquisition nized case shows that at the lower frequency the overall SNR is probably dominated by other noise sources, while at the higher frequency the noise from the synchronization jitter has about the same strength. Thus, the slight drop in SNR for the proactive and hybrid approach at the higher signal frequency appears indeed to be caused by synchro- nization jitter. For cases with more frequent or larger clock updates a more signifcant deterioration of the signal quality is expected.

0.6 0.6

0.4 0.4 [1] rel. f 0.2 0.2

0 0 < −5 −4 −2 0 2 4 >5 < −5 −4 −2 0 2 4 >5 ∆cT 1 [Ticks] ∆cT 2 [Ticks] (x¯ = 0.00 Ticks, s = 0.65 Ticks) (x¯ = 0.02 Ticks, s = 0.65 Ticks) Figure 6.25.: Histogram of clock updates during acquisition of all records for confgu- rations 1 and 2.

The results of the THD estimation are displayed in fgure 6.26. The THD in the un- synchronized case is representative of the ADC’s general performance, as it is not in- fuenced by any time synchronization algorithm. This THD was estimated to be about 5 dB better than the specifed THD of the generator. Signals acquired with the DAQ- card show an equally high THD. The reason for this may be the amplitude being higher than in the specifed case or a conservative specifcation by the generator’s manufac- turer. At the lower signal frequency all approaches show essentially the same THD val- ues as in the unsynchronized case. At the higher signal frequency the reactive approach shows a signifcantly worse THD, while that of the proactive and hybrid deteriorate only slightly. The diferences in THD between the two TIMs in the reactive approach, like the diferences in SNR, are caused by the slight diference in sampling rate.

223 6. Experiments

−90 −90 TIM1/Ch1 TIM1/Ch1 −80 TIM2/Ch2 −80 TIM2/Ch2

−70 −70

−60 −60 THD [dB] THD [dB]

−50 −50

−40 −40

none none hybrid reactive reactive hybrid proactive proactive DAQ−card DAQ−card

(a) fsignal = 0.27 Hz (b) fsignal = 7.11 Hz

Figure 6.26.: Signal THD.

6.4.3. Missing samples

As the output samples are obtained through linear interpolation in the reactive approach, it has the inherent capability to compensate for samples that were lost during the trans- mission. Yet, as no samples were lost in the experiments described in the previous subsection, this feature could not be evaluated there. In a later experiment, however, a waveform was acquired were about 3.8 % had been lost, probably due to interference from another wireless system. The setup for this recording matched that of confgura- tion 3 in table 6.17. Figure 6.27 shows the original and resampled data points for a section of the recording. The frequency error, the SNR and the THD of the signal before and after resampling are given in table 6.20. While the frequency error appears to be unafected by the loss of samples there is a big deterioration in the signal’s SNR and THD. After the resampling, however, both are restored to about the same levels that there observed for signals without sample loss in the previous subsection.

Table 6.20.: Quality parameters of signal with lost samples before and after resampling. before after

ϵ f [mHz] 6.1 -5.4 SNR [dB] 15.0 49.8 THD [dB] -41.6 -69.1

224 6.4. Time synchronous waveform acquisition

original resampled

3

2

1 amplitude [V]

0 5.5 6 6.5 7 7.5 time [s]

Figure 6.27.: Section of signal showing recorded and resampled data points. Intervals with missing samples are highlighted.

6.4.4. Power consumption

In later experiments, powertrace data was collected during waveform acquisition with the WSN. The network confgurations 1 to 4 shown in table 6.17 were investigated. Figure 6.28 shows the results. Like in sections 6.1.1 and 6.2.4 the average power consumption is dominated by the lis- tening consumption of the radio transceiver and the low power mode of the CPU. Also similar to section 6.2.4, the confgurations using the proactive approach show a slightly increased power consumption of the NCAP compared to those using the reactive one. The more critical power consumption of the TIMs, however, is practically the same for both approaches. The increased NCAP power consumption is caused by the send- ing of synchronization packets as well as more CPU activity. If the resampling during the reactive approach was done on the NCAP instead of the PC, this would increase the power consumption of the NCAP in the reactive case, diminishing the diference to the proactive case or even reversing the relation. If the network was to spend more time without any transmission of measurement data, the reactive approach is expected to have larger advantages over the proactive one in terms of power consumption, as it doesn’t require regular synchronization messages.

225 6. Experiments

80

70 lpm cpu 60 listen 50 tx 40

30 avg. power [mW] 20

10

0 Node: N T1 T2 N T1 T2 N T1 T2 N T1 T2 1,2 1,2 3,4 3,4 TDMA TDMA CSMA CSMA 0.27 Hz 7.11 Hz 0.27 Hz 7.11 Hz Configuration

Figure 6.28.: Mean power consumption of nodes doing synchronous waveform sam- pling.

6.4.5. Conclusions

Both approaches to synchronized sampling show comparable synchronization accura- cies close to the resolution of the underlying clock. Also the SNR and THD of the acquired signals were found to be close to those acquired without synchronization es- pecially for signals whose frequency is low compared to the sampling rate. For the reactive approach a huge decrease in SNR and THD was observed at a higher signal frequency. The reason for this is the characteristic of the linear interpolation that was used (compare section 3.3.2). More advanced interpolation techniques like cubic-spline interpolation or an approach based on nonuniform sampling are likely to ofer a better signal quality at higher frequencies, but also require more computational efort. For the proactive approach a small decrease in SNR caused by clock updates, could be detected. In the investigated settings the energy consumption for both approaches is nearly the same. However, at signifcantly larger transmission intervals the reactive approach is expected to perform better, as it does not require regular synchronization messages.

226 6.5. Synchronous angular sampling

6.5. Synchronous angular sampling

To evaluate the synchronous angular sampling algorithm presented in section 5.3 and its implementation on the WSN, several simulations and experiments were done. First the efects of diferent components in the measurement chain on signals sampled over the angle are examined during simulations in section 6.5.1. Section 6.5.2 presents sim- ulations to detect possible diferences between the diferent implementations of the al- gorithm. The performance of the algorithm running on a WSN is investigated by re- sampling signals from a waveform generator, in section 6.5.3. Finally, experiments using synchronous angular resampling with a WSN at a motor test bench are pre- sented in section 6.5.4. Most of this chapter has already been published by the author in [Fun5, Fun7].

6.5.1. Analysis of measurement chain for angular sampling

To investigate the efect of the components in the measurement chain on signals sam- pled over the angle, simulations in MATLAB/SIMULINK were done. They started with an idealized sampling model as introduced in section 2.4.1. Then step by step, components were added to model non-ideal efects found in real measurement setups. The parameters of the measurement chain were chosen in accordance with those of the WSN (compare section 5).

6.5.1.1. Simulation setup

Figure 6.29 shows the setup used for the simulations. A rotating machine is simulated, that accelerates linearly from 15 to 1500 rpm within 2 s. The rotation angle ϕ is obtained by integrating over the speed signal. A cosine function with ϕ as its argument represents a harmonic signal at the second order of rotation. The rotation angle ϕ is also used to generate sampling pulses at equidistant angular intervals of Φs = 2π/25.

Table 6.21 shows the diferent confgurations of the simulation setup that were used. The frst simulated the ideal synchronous angular sampling model introduced in sec- tion 2.4.1. Then, in confguration 2, a zero-order hold was added, that sampled the continuous input signal at equidistant time instants tn = nTs = n/ fs before the an- gular resampling. To investigate the efect of the analog sampling frequency fs it was doubled in confguration 3. In order to account for the amplitude quantization by an ADC, a 12 bit-quantizer was added in confguration 4. Finally, confgurations 5 and 6 investigated the efect of the group delay from an analog anti-aliasing flter. The flter used was a continuous 8th-order lowpass flter with a cutof-frequency of 2 kHz.

227 6. Experiments

Figure 6.29.: Setup for simulations on idealized angular sampling. Elements in dashed/dotted lines were only present starting from the confguration given as encircled number.

Table 6.21.: Confgurations of simulations on idealized angular sampling.

Conf. fs Quantizer Filter Delay [ksamples/s][bit][µs] 1 - - - - 2 20 - - - 3 40 - - - 4 20 12 - - 5 20 12 fg = 2 kHz - 6 20 12 fg = 2 kHz 290

For all confgurations the SINAD of the output signal x(lΦs) was taken as a quality indicator, as it includes the efects of both harmonic distortions and noise. The SINAD was calculated using the algorithm described in section 3.4.3.3.

6.5.1.2. Results

Figure 6.30 shows the SINAD of the output signal x(lΦs) for the diferent confgu- rations. It is obvious from fgure 6.30a that in the frst confguration the SINAD is much higher than in all others. In this confguration the value of the SINAD is prob- ably only limited by the numerical accuracy of the simulation software. Apparently, the introduction of uniform time sampling already leads to a strong decrease in the SINAD although the sampling rate of 20 ksamples/s is much higher than the maximum angular sampling frequency of 0.625 ksamples/s and both are much higher than twice the maximum signal frequency of 50 Hz.

228 6.5. Synchronous angular sampling

55 200

150 50

SINAD [dB] 100 SINAD [dB] 45 50 1 2 3 4 5 6 1 2 3 4 5 6 Configuration Configuration a) b) Figure 6.30.: SINAD of output signals synchronous to the rotation angle. Graph b) shows the same data as graph a) but with zoomed y-axis.

The reason for this is, that when sampling over time before the angular sampling, the signal value obtained for an angular sampling instant tϕ,l is equal to that of the preceding time sampling instant tn ≤ tϕ,l < tn + T0. Thus, the efect is the same as if the angular sampling instants were quantized with a resolution of T0, i.e. the time sampling period. Consequently, the resulting quantization error of the angular sampling instants causes a jitter in the angular sampling interval Φs. Assuming a uniform distribution for the quantization error the RMS-value of this jitter in the time domain is:

T0 Tϕ, j = √ . (6.16) 12 To transfer this jitter to the angle domain a frst order Taylor approximation is used: dϕ(t) ϕ (t) ≈ T = ω(t)T . (6.17) j dt ϕ, j ϕ, j

As the rotational speed ω was changing during the simulations, the speed ωavg,ϕ av- eraged over the angle was used to calculate an average jitter in angle domain. This average angle jitter was used with (4.40) to obtain a theoretical value for the SNR of the sampled signal. Figure 6.31 shows a comparison of the theoretical values for the SNR and those calculated from simulated signals at various uniform time sampling rates. The very good match between the theoretical and the simulated values shows, that the modeling is accurate. The fact that the SNR-values in fgure 6.31 are about equal to the SINAD-values in fgure 6.30, shows that no signifcant harmonic distortion occurred. The addition of amplitude quantization in confguration 4 has no signifcant efect on the signals SINAD. This is plausible, when considering that the ideal SNR of a 12 bit- quantizer is about 72 dB. Thus, its contribution to the overall signal noise is insignifcant compared to that of the sampling jitter.

229 6. Experiments

65 theoretical 60 simulation 55

50 SNR [dB] 45

40 10 20 40 60 80 100 f [kHz] 0

Figure 6.31.: Relation between analog sampling rate and SNR of angular signal.

The introduction of a continuous lowpass flter in confguration 5 causes a deteriora- tion in the signal’s SINAD of about 5 dB. This is especially remarkable, as its cutof frequency (2 kHz) is much higher than the maximum signal frequency (50 Hz). The reason for this phenomenon was found to be the group delay of the flter. The rotation angle ϕ during the simulation was: 1 ϕ(t) = α t2 + ω t, (6.18) 2 rot o with αrot the angular acceleration and ω0 the initial angular speed. The phase shift Φgrp caused by a group delay of Tgrp is: 1 ϕ(t + T ) = α (t + T )2 + ω (t + T ) (6.19) grp 2 rot grp 0 grp 1 α = α t2 + ω t + α T t + rot T 2 + ω T . (6.20) 2 rot o rot grp 2 grp 0 grp       ϕ(t) Φgrp

Thus, the phase shift of the signal was increasing linearly with time during the simula- tion, which caused an increasing error in the angular resampling positions. To compen- sate for this efect, the angle signal used for the resampling was delayed by a constant time of 290 µs, which is approximately equal to the group delay of the flter in the given frequency range. The fact, that the SINAD of the output signal for confguration 6 is about the same as for confgurations 2 and 4 shows, that this compensation was efective.

230 6.5. Synchronous angular sampling

6.5.2. Test of resampling algorithms

The performance of the diferent implementations of the resampling algorithm (see section 5.3) was evaluated in simulations using MATLAB. Table 6.22 shows the im- plementations of the algorithm that were investigated. For comparison, a simple S&H- resampler was simulated as well.

Table 6.22.: Resampling implementations that were investigated (see also section 5.3.4). Algorithm Platform Programming Number format language resampling flter PC MATLAB 64 bit-foating point resampling flter Preon32 C 32 bit-foating point (F32) resampling flter Preon32 C 16 bit-fxed point (Q15) S&H-resampling PC MATLAB 64 bit-foating point

6.5.2.1. Simulation setup

Figure 6.32 shows the block diagram of the simulation setup. As in the previous sim- ulation a harmonic signal at the second order is obtained from a linear speed ramp (n = 15 ... 1500 rpm within 2 s). The amplitude of the signal was one arbitrary unit (1 arb.).

Figure 6.32.: Setup for simulations on angular resampling.

231 6. Experiments

The signal was sampled at time instants tn distributed uniformly over time at a sampling rate of 20 ksamples/s. To simulate the infuence of the ADC the signal was quantized with a resolution of 12 bit. The rotation angle ϕ(t) was also used to sample the sys- tem clock at 25 equidistant angular intervals per revolution, generating the timestamps tϕ,l = t(lΦs). The timestamps tϕ,l were quantized with the resolution of the Preon32’s −14 rtimer: Trtc = 2 s. To check the rejection of noise, zero-mean white Gaussian noise with a standard deviation of σ = 10−2 arb. was added in a second simulation. In a third simulation, the rejection of spurious frequencies was checked by adding a constant frequency sine at fspur = 1.25 kHz with an amplitude of 1 arb. instead of the noise.

The simulated samples x(tn) and timestamps t(lΦs) were fed into the resampling flter described in section 5.3, in order to obtain the signal x(lΦs) sampled uniformly over the rotation angle. The S&H resampling can be described to as zeroth-order polyno- mial resampling (see also 3.3.2). Higher polynomial orders would not have improved performance here, because the resolution of the timestamps ∆t ≈ 61 µs was already bigger than the sampling period Tin = 50 µs. A sine ft, using the four-parameter algorithm described in 3.4.3, was performed on the resampled signals and their RMS-value, frequency and SINAD were calculated. The same simulated signals were resampled using the MATLAB implementation of the flter on a PC, as well as the two C implementations on a sensor node. For the latter the simulated input data was sent to and the resampled signal received from a sensor node via its USB-interface. The evaluation of the output signals was done in MATLAB on a PC in all cases. To measure the computational load of the algorithm on the sensor node, a sine wave signal with a constant frequency of 50 Hz and an input sampling rate of 20 ksamples/s was resampled for a speed of 1500 rpm and an angular rate of 25 samples/rev. The time needed to resample 8192 input samples (i.e. 256 output samples) was measured using the internal clock of the sensor node.

6.5.2.2. Signal quality

√The deviations of the output signals’ RMS-values from the nominal RMS-value of 1/2 arb. are shown in fgure 6.33. No error bars are given because only one input sequence was used in each case. It was exactly the same for all three implementations. No systematic diference in terms of RMS-deviation is observed between the imple- mentations. The key observation is that the deviations are very small (absolute value ≤ 2 · 10−4) in all cases.

232 6.5. Synchronous angular sampling

100

0 Q15 F32 −100 MATLAB RMS-Error [ppm] −200

only chirp with noise with spurious

Figure 6.33.: RMS-error of resampled chirp signals.

Figure 6.34 shows the deviations from the nominal order of 2. It is observed that the order error for the fxed-point implementation (Q15) is always slightly larger than for the foating-point (F32) or MATLAB-implementation. Yet, the key observation is that the deviations are very small (absolute value < 10−6) in all cases.

−1.0

−0.9

−0.8 Q15 F32 −0.7 MATLAB

Order-Error [ppm] −0.6

−0.5 only chirp with noise with spurious

Figure 6.34.: Order-error of resampled chirp signals.

The results for the SINAD of the resampled signals are shown in fgure 6.35. All implementations perform about equally well, with only a slight disadvantage for the fxed-point-implementation. The S&H-resampling always results in a lower SINAD. This is especially prominent in the simulation with a spurious component, where it drops to 0.5 dB.

233 6. Experiments

50

40 Q15 30 F32 MATLAB 20 S&H SINAD [dB]

10

0 only chirp with noise with spurious

Figure 6.35.: SINAD of resampled chirp signals.

To further illustrate the efect of the spurious component the input and output signals for this simulation as well as the corresponding spectrograms are given in fgure 6.36. The input signal with the spurious component is given in fgure 6.36 a), its spectrogram in fgure 6.36 b). As the frequency of the spurious component is much higher than the maximum output sampling frequency, it cannot be resampled correctly under the Nyquist theorem:

1500 rpm f = 25 · = 625 Hz < 2 f . (6.21) out,max 60 spur Without the resampling flter, this leads to a heavily noised signal; as the spurious component is aliased into the frequency band many times (see fgure 6.36 c) and d)). The resampling flter, by contrast, completely eliminates the spurious component, and outputs a clean constant sine wave at the order two (see fgure 6.36 e) and f)). Thus, it is efective in suppressing aliasing during resampling.

6.5.2.3. Computational load

The time needed to resample a constant frequency sine wave with 8192 input and 256 output samples on the Preon32 was measured to be 655.5 ms for the foating-point and 68.2 ms for the fxed-point implementation. In order to be suitable for real-time oper- ation in the designated measurement system, the fltering algorithm needs to process 2048 input samples within 102.4 ms and still leave enough time for radio communi- cation and bufer handling (see also section 5.3.5). Thus, it is not possible to use the foating-point implementation (expected time 163.9 ms). The fxed-point implementa- tion, however, is well suited (expected time 17.1 ms). Its causes a computational load of only about 16.7 %.

234 6.5. Synchronous angular sampling

time/angular signal time-frequency/order distribution

2 1.5

) 1 t

( 1 x 0 input f [kHz] 0.5

amplitude [arb.] −1

−2 0 0 0.5 1 1.5 2 0.5 1 1.5 a) time [s] b) time [s]

) 2 s Φ l (

x 10 1

0 5 order [1]

amplitude [arb.] −1 S&H resampling −2 0 0 5 10 2 4 6 8 10 12 14 π π c) angle [rad/2 ] d) angle [rad/2 ]

) 2 s Φ l

( 10 x 1

0 5 order [1]

amplitude [arb.] −1 resampling flter −2 0 0 5 10 2 4 6 8 10 12 14 π π e) angle [rad/2 ] f) angle [rad/2 ]

Figure 6.36.: Results of angular resampling a signal with spurious component.

235 6. Experiments

6.5.3. Acquisition of generated signals

For a frst evaluation of the WSN’s synchronous angular sampling performance it was tested on generated signals.

6.5.3.1. Experimental Setup

A two-channel waveform generator (Agilent 33500B) was used to generate both a sine wave and a pulse signal (see fgure 6.37). The frequency of the pulse signal was fxed at exactly fpulse = 30 fsine throughout the experiment. This way the sine wave signal emulates a generic machine signal at the order one, while the pulse signal emulates the output of a rotary encoder with 30 pulses per revolution.

Figure 6.37.: Setup for recording generated signals.

The sine signal was sampled with an analog sampling frequency of 20 ksamples/s on the data TIM and stored in blocks of 2048 samples. The rotation TIM transmitted a new block of timestamps every 100 ms. Thus, the block rates were about the same on both TIMs. The TDMA-MAC, described in section 5.1.3, was chosen in order to maximize data throughput and provide time synchronization.

Constant frequency sine waves at 2.5 Hz=ˆ 150 rpm and 25 Hz=ˆ 1500 rpm as well as a variable speed profle with periodically changing speed were investigated. Figure 6.38 shows one cycle of this profle. Every cycle contains 110 simulated revolutions leading to 1650 output samples. The input signal had a peak-to-peak amplitude of 3.20 V and a DC-ofset of 1.65 V in all experiments. Thus, most of the sensor node’s input voltage range was covered. The amplitude accuracy of the waveform generator is specifed as 1 mV + 1 % of amplitude at 1 kHz. Its signal purity is specifed with a THD below -70 dBc and non-harmonic noise below -75 dBc for signal frequencies below 20 kHz.

236 6.5. Synchronous angular sampling

Resampling using the resampling flter, S&H resampling and direct sampling were used to acquire the signals. In direct sampling the synchronous angular sampling is achieved for constant speeds by setting the sampling rate of the analog-to-digital converter to the required output rate. For variable speeds this method is, of course, not applicable. A total of 100 recordings with 2048 output samples were acquired for every combination of input signal and sampling method. Like in the experiments in section 6.5.2 the RMS- value, order and SINAD of the resampled signals were calculated using sine ftting.

1500 speed [rpm]

150 0 0 1 2 3 4 5 6 7 8 time [s]

Figure 6.38.: One period of the variable speed profle used in waveform generator ex- periments.

The same setup was also used to measure the average power consumption of the senor nodes during acquisition using Contiki’s powertrace mechanism. For this purpose one recording was evaluated at each constant speed: 150 rpm and 1500 rpm.

6.5.3.2. Signal quality

Figure 6.39 shows the mean RMS-values over all 100 recordings. The error bars indi- cate an interval of two standard deviations. It is observed that the measured RMS-values are about equal for all sampling methods. All values are well within the specifed accu- racy of the generators amplitude setting.

237 6. Experiments

1.140 ] RMS filter 1.130 S&H direct amplitude [V 1.120

150 rpm 1500 rpm variable

Figure 6.39.: RMS-values of acquired generator signals. The solid horizontal line indi- cates the nominal value set at the waveform generator. The dashed hori- zontal lines indicate the specifed accuracy of this setting

Figure 6.40 shows the mean order of the recorded signals. It is observed that the order of the resampled signals matches very well with the nominal setting for all speeds, regardless of whether the resampling flter or S&H-resampling was used. The order of signals recorded with direct sampling deviates by about 0.4 %. This is probably due to the limited resolution and accuracy of the sampling frequency setting of the sensor node. However, these results also show that resampling is very efective in compensating for those efects.

1.000

0.999 filter 0.998 S&H

order [1] direct 0.997

0.996

0.995 150 rpm 1500 rpm variable

Figure 6.40.: Order of acquired generator signals. The nominal order is indicated by the horizontal line.

238 6.5. Synchronous angular sampling

Figure 6.41 shows the mean SINAD of the recorded signals. The SINAD of the re- sampled signals is signifcantly higher at 150 rpm than at 1500 rpm, whereas it stays constant for directly sampled signals. This is probably due to the output sampling time intervals being larger at lower speeds, while the resolution of the angular timestamps stays constant. As a consequence the relative time base jitter is smaller at lower speeds. Furthermore, the resampling flter removes the noise energy of signal components with f > 0.25 fout. Thus, it causes a strong increase in SINAD at lower speeds. In case of the S&H resampling and direct sampling the noise energy of the higher frequency components is instead aliased to the lower bands. The SINAD from the variable speed recordings is in between that of the 150 rpm and 1500 rpm recordings for the suggested flter. For the S&H resampling it is even lower than that of the 150 rpm recordings.

65

60

55 filter 50 S&H direct

SINAD [dB] 45

40

35 150 rpm 1500 rpm variable

Figure 6.41.: SINAD of acquired generator signals.

6.5.3.3. Power consumption

An early fnding of the experiments on power consumption was that putting the CPU into low power mode caused infrequent glitches in the resampled data. The delays during by the duty-cycling of the CPU apparently cause overfows in the acquisition bufers. This points to a suboptimal behavior of the process scheduling mechanism, since the computational load calculated in section 6.5.2 as well as the powertrace data shown in fgure 6.42 indicate that the CPU is far from working at maximum load. Due to the problems with CPU duty-cycling, the results for the signal quality described above were obtained with CPU duty-cycling deactivated.

239 6. Experiments

110 100 lpm 90 cpu 80 listen 70 tx 60 50 40 avg. power [mW] 30 20 10 0

Node−ID: NCAP TIM−rot. TIM−dat. NCAP TIM−rot. TIM−dat. NCAP TIM−rot. TIM−dat. NCAP TIM−rot. TIM−dat. 150 rpm 1500 rpm 150 rpm 1500 rpm − − CPU duty−cycling CPU duty−cycling Configuration

Figure 6.42.: Average power consumption of nodes doing synchronous angular sam- pling.

The average power consumptions of the nodes displayed in fgure 6.42 show that with- out CPU duty-cycling the power consumption is about the same, i.e. 110 mW, for all nodes and speeds. Active CPU duty-cycling reduces the average power consumption by about 25 %. Furthermore, the amount of computation it performs determines a node’s power consumption in this case. Thus, the rotation TIM has the lowest average power consumption and the data TIM the highest. At 1500 rpm, the power consumption of all nodes is higher than at 150 rpm. The increase is strongest on the rotation TIM due to the highly increased number of angular timestamps transmitted per unit of time. On the data TIM the increase is only marginal, as its power consumption is mainly determined by the analog sampling rate and the output block rate, which both are inde- pendent of the rotational speed. The situation is similar for the NCAP where a slight increase in power consumption is caused by the increase in the size of transmitted data blocks.

6.5.4. Data acquisition at motor test bench

To test the synchronous angular resampling with the WSN in a more application ori- ented scenario, measurements were carried out at the motor test bench introduced in section 5.1.6. Figure 6.43 shows the setup that was used to record the voltage of one of the induction motor’s three phases.

240 6.5. Synchronous angular sampling

Figure 6.43.: Setup for experiments at motor test bench.

Like in the experiments described in the previous subsection, measurements were taken at constant speeds of 150 rpm and 1500 rpm as well as at a variable speed profle. The variable speed profle was generated by periodically changing the speed setting of the inverter between 150 rpm and 1500 rpm. The actual speed gradient was limited by the inverter’s settings and breaking capabilities, so that a ramp signal similar to that in fgure 6.38 was expected. Again, resampling with the suggested flter, S&H resampling and direct sampling were used to acquire the motor voltage. For comparison, it was also acquired with a DAQ-card (USB6009, National Instruments) at a constant sampling rate of 20 ksamples/s. A total of 10 recordings with 2048 output samples were acquired for every combination of speed setting and acquisition method. For the experiments at constant speed the RMS-value, order and SINAD were calculated using a sine ft as described in section 3.4.3. For the variable speed experiments no meaningful sine ft was possible, as the motor voltage changes its amplitude with the speed. The torque shaft of the test bench outputs an analog voltage signal that is proportional to the shaft speed. This signal was also recorded with the DAQ-card and used as a refer- ence for the speed readings. Furthermore, a frequency counter (HM8123, Hameg) was used to measure the average rotational speed and the frequency of the motor voltage.

241 6. Experiments

6.5.4.1. Constant speed

Figure 6.44 shows the mean RMS-voltage of the motor over all 10 recordings. The error bars indicate an interval of two standard deviations. It is observed that the results from all measurements recorded with the sensor node are in well agreement with those recorded with the USB data acquisition card (USB6009).

250

] 200

RMS filter 150 S&H direct 100 USB6009

amplitude [V 50

0 150 rpm 1500 rpm

Figure 6.44.: RMS-voltage of motor acquired at constant speeds.

Figure 6.45 shows the mean orders of the motor voltage. The order of the signals recorded using the suggested resampling flter and S&H resampling are always identi- cal and slightly larger than the order measured with the frequency counter. This may be explained by an inaccuracy of the timestamps used for resampling. Like in the recordings from the frequency generator given in section 6.5.3, the order of the sig- nals recorded without resampling deviates from the others due to inaccuracies of the sampling frequency. An interesting observation is that the order of the voltage is sig- nifcantly lower at 1500 rpm than at 150 rpm. This may indicate an increased slip of the induction motor at low speeds due to higher friction losses.

2.020

2.010 filter S&H 2.000 direct order [1] USB6009 1.990

1.980 150 rpm 1500 rpm

Figure 6.45.: Order motor voltage signals acquired at constant speeds.

242 6.5. Synchronous angular sampling

Figure 6.46 shows the mean SINAD of the motor voltage. The values are generally lower than those for the recordings from the frequency generator (see section 6.5.3). This indicates that at the test bench the signals were generally noisier. One reason for this is probably that the motor voltage is generated by the inverter through pulse-width- modulation of a square wave. Thus, it contains more high frequency noise.

36

34 filter 32 S&H direct USB6009 SINAD [dB] 30

28

150 rpm 1500 rpm

Figure 6.46.: SINAD motor voltage acquired at constant speeds.

Due to the good lowpass characteristic of the suggested resampling flter, the signals recorded with it always have a signifcantly higher SINAD than those recorded with S&H resampling or direct sampling. The decrease in SINAD at higher speeds that was observed in section 6.5.3 is not visible here, probably because the infuence of other noise sources is much stronger than that of the resampling jitter in this case. At 150 rpm, the signals recorded with the data acquisition card USB6009 display a SINAD higher than those recorded with the resampling flter. This may be due to the USB6009 having a higher input voltage range and resolution than the Preon32 sensor node. At 1500 rpm, however, the SINAD of the USB6009 drops well below that of the Preon32 with resampling flter. This is likely to have been caused by an increase of high frequency components in the motor voltage at higher speeds.

6.5.4.2. Variable speed

Figure 6.47 shows the speed profle measured with the torque shaft and rotation node during one cycle. Both measurements are in good agreement, but the results from the rotation node exhibit more noise due to the limited timestamp resolution (TTick = 61.0 µs). The speed cycle can be divided into four segments. In fgure 6.47 they are separated with vertical red lines and labeled with numbers. In segment one the motor is decelerating, in segment two it has a constant speed of about 150 rpm. In segment three it accelerates back to 1500 rpm and keeps this speed throughout segment four. The length of the deceleration and acceleration segments is determined by the speed change limits and breaking capabilities of the inverter.

243 6. Experiments

1500 Preon32 torque shaft

1000

speed [rpm] 500 1 2 3 4 150 0 0 1 2 3 4 5 6 7 8 time [s] Figure 6.47.: Speed profle acquired during one cycle. Vertical red lines separate the four segments of the profle.

Figure 6.48 shows the speed profle, motor voltage and order spectrogram of the same cycle as fgure 6.47 with the rotation angle instead of the time as x-axis. The order spectrogram was obtained by calculating the STFT for the resampled signal. A rect- angular window of 60 samples, i.e. two revolutions, was used. It is obvious from the spectrogram that the signal is constantly at the second order of rotation. Furthermore, the spectrogram displays hardly any signs of leakage components, which shows that resampling has worked as expected. In segment three an increased noise level can be observed. This may be due to the modulation spectra arising from the change of ampli- tude in this segment. Furthermore, also noise from the inverter power electronics may have an infuence. In segment one no such efects are visible, possibly because the speed gradient was much less there. The voltage amplitude in fgure 6.48 matches well with the RMS- values measured at constant speeds (compare fgure 6.44).

244

6.5. Synchronous angular sampling magnitude [dBV] magnitude 40 20 0

100 80 3 4 ] π 2 2 / 60 angle [rad 40 1 20

0

0 0 6 4 2 0

500 200 [1] order

1500 1000 −200

speed [rpm] speed motor voltage [V] voltage motor

Figure 6.48.: Speed, motor voltage and order spectrogram of one cycle. The green line in the motor voltage plot is the amplitude of the second order calculated from the spectrogram.

245 6. Experiments

6.5.5. Conclusions

The simulations in section 6.5.2 show that the implemented resampling flter can ef- fectively convert a linear chirp into a constant order sine signal. The SINAD of the output signal is always higher when using the resampling flter compared to a simple S&H-resampler. This advantage increases in the presence of additive white Gaussian noise and is especially high frequency spurious components. The quality of the output signal is the same for all implementations of the flter. This shows that on the targeted platform the round-of errors in the calculations are negligible in relation to those from the amplitude and time-quantization during acquisition. The fxed-point implementa- tion of the resampling flter is the only one that can be run in real-time on the targeted WSN. It is about ten times faster than the foating-point implementation, but still ofers the same signal quality. Experiments in sections 6.5.3 and 6.5.4 show that the implemented synchronous angu- lar sampling scheme can successfully be run on a WSN. The signals acquired with the resampling flter show no signifcant drawbacks in terms of signal quality compared to acquiring the signal directly without resampling. At high downsampling ratios there is even a signifcant increase in SINAD.

246 7. Conclusions and outlook

This chapter starts by summarizing the key fndings of this thesis in section 7.1. From this, conclusions are drawn in section 7.2 regarding the answers to the guiding questions formulated at the end of chapter 2. Finally, an outlook on possible directions for future research is given in section 7.3.

7.1. Summary

In chapter 4, generic models for systems doing synchronous event detection and syn- chronous waveform sampling were introduced. The key feature of these models is that they can be used to describe WSNs as well as more conventional DAQ systems. Using these models as a basis, the infuence of synchronization errors on the measurement re- sult has been modeled and compared to other error infuences, like signal noise, analog group delays or the clock resolution itself. The main result of this analysis is that the efect of synchronization errors on the measurement result is in many cases the same as that of other error infuences. It has been suggested to describe the synchronization error by a mean and a standard deviation and apply measurement uncertainty analy- sis, as defned in the GUM, to evaluate the infuence of all error infuences. Using the concept of measurement uncertainty, also a general procedure, that allows estimating the synchronization accuracy required for a given application, has been suggested in section 4.3. This method was shown to work well for practical experiments on acoustic localization in section 6.3.

Building on the developed models and error analysis, two approaches to time synchro- nized DAQ were derived in section 4.4 a proactive and a reactive one. In the proactive approach data acquisition is steered by synchronized clocks, while in the reactive one data acquisition is initially unsynchronized. The synchronization only takes place dur- ing later signal processing. Both approaches have been implemented on a WSN using state of the art commercial sensor nodes and the Contiki operating system (see chapter 5). For the data acquisition a software framework inspired by the IEEE 1451 stan- dard has been implemented, that already allows to fexibly access a number of diferent sensors through a unifed MATLAB interface. For time synchronization a simplifed version of the FTSP protocol was used.

247 7. Conclusions and outlook

Both approaches were tested for synchronous event detection and synchronous wave- form acquisition in experiments (see sections 6.2 and 6.4). No clear advantages of any approach over the other regarding synchronization precision or power consump- tion could be found. The distribution of synchronization errors during the experiments on synchronous event detection was found to be similar to a Gaussian distribution, but to signifcantly difer from it regarding the frequency of extreme values. A synchroniza- tion precision close to the clock resolution could be achieved, highlighting the discrete nature of time values in a WSN. This shows the relevance of the clock resolution for synchronized DAQ. Furthermore, it was shown that the overall timestamping precision of a WSN can be characterized by an efective clock resolution (see sections 4.2.1.6 and 6.2). Another important result of the experiments is that interrupt blocking sections in the duty-cycling code of the sensor nodes’ operating system caused signifcant errors in the synchronized data acquisition. This shows that the entire software of a wireless sensor node should show a good real-time performance in order to enable accurately synchronized DAQ.

In addition to time synchronous data acquisition, synchronous angular sampling was investigated. As discussed in section 4.5, a reactive approach is much better suited for its implementation. This way, expensive anti-aliasing flters with variable frequency response are not needed and also the real-time requirements on the sensor node soft- ware can be relaxed. Furthermore, the resampling of data acquired at a uniform time interval to a uniform angle-interval was shown to be equivalent to the problem of re- constructing a uniformly sampled waveform from nonuniform samples. A powerful reconstruction flter, which had originally been developed for communication systems, was implemented on the WSN (see section 5.3) using fxed-point arithmetic. The ex- periments presented in section 6.5 show, that the implemented flter provides a good alias-suppression over a wide range of speeds and even at fast speed changes. Fur- thermore, it was shown that it is capable of real-time data acquisition at an induction motor test bench. The described fxed-point implementation provides about the same signal quality in terms of SINAD, amplitude and frequency error as a foating point implementation, but only requires 10 % of its computation time.

7.2. Conclusions

At the end of chapter 2 four central questions were formulated, that could not satisfac- torily be answered from the current scientifc literature. The analysis and experiments presented in this thesis were aimed at these questions. Now as a conclusion, answers to them shall be attempted:

248 7.2. Conclusions

How can synchronization precision be defned and measured in a way that is meaningful for measurement applications?

Synchronization precision should be defned as a timing uncertainty characterized by a standard deviation (see section 4.2.3). This facilitates the calculation of the measure- ment uncertainty for the fnal measurement result. Furthermore, the infuence on the SNR of an acquired signal can be easily calculated this way. Finally, the timing uncer- tainty can be easily transformed into an efective clock resolution that enables easy and intuitive comparison between diferent clock systems. To measure the synchronization precision a method should be used that is as close as possible to the fnal application. This reduces the danger of accidentally neglecting signifcant efects. For synchronous event detection, applying the same digital pulse to all channels and evaluating the diference in timestamps has been found to be efective. Similarly, acquiring the same sine wave with all channels works for synchronous wave- form acquisition (see section 4.6). The major advantage of both methods is that they can equally be applied to WSN and other DAQ systems, thus enabling direct compar- isons.

Which synchronization precision is suffcient for a given application?

The synchronization precision required by an application can be calculated using mea- surement uncertainty analysis (see section 4.3). The information required for this is the acceptable uncertainty in the end result and the uncertainty contributions from other error infuences, e.g. signal noise, analog group delay, delays in multiplexed ADCs etc. Even if the exact strength of those infuences is not known, it is possible to estimate the required synchronization precision. As rule of thumb, the synchronization precision is usually sufcient, if it causes an uncertainty in the end result of less than 50 % of the overall uncertainty margin (see section 4.3). The experimental results in section 6.3 show that optimizing the synchronization precision alone may not lead to the desired result, as the infuence of other error sources may be signifcant.

Which is the best strategy for time synchronized sampling?

Two approaches to time synchronized sampling were developed: a proactive and a reactive one (see section 4.4). The proactive one directly steers the sampling times based on synchronized clocks. Thus, it requires a deep integration into the acquisition process and very good real-time properties of the underlying software. Especially at high sampling rates this may be difcult to achieve. Furthermore, corrections to the clocks during the acquisition may badly afect the SNR and THD of the signal (see section 4.2.2).

249 7. Conclusions and outlook

Under the reactive approach the data is initially acquired without synchronization. Syn- chronization takes place later during data processing. This way, there is no interference with the data acquisition of the ADC and no efort needs to be put into maintaining syn- chronized clocks all the time. However, the a posteriori synchronization of the acquired data through digital resampling only works well, if signifcant oversampling is used.

The implementations of the proactive and reactive approach for this thesis, performed about equally well in terms of power consumption and synchronization precision during the experiments. Thus, the choice of approach should be guided by the anticipated pattern of communication (see sections 6.2 and 6.4). The proactive approach matches better with regular and the reactive better with irregular communication patterns.

How can synchronous angular sampling be best implemented on a WSN?

Synchronous angular sampling is better implemented with the reactive approach. This way, the difcult direct control of the ADC is not necessary and no anti-aliasing flters with variable frequency response are required (see section 4.5). As synchronous an- gular sampling can be described as a nonuniform reconstruction problem, an efcient flter, originally developed for communication systems, could be adopted from the lit- erature (see section 5.3). An implementation of this flter in fxed-point arithmetic has been shown to enable real-time data acquisition at an induction motor test bench. Fur- thermore, the flter provides a good signal quality in terms of SINAD and efective alias-suppression.

7.3. Outlook

The analysis presented in this thesis allows for a consistent treatment of the measure- ment uncertainty that arises from synchronization errors. Furthermore, the timing un- certainty expressed as a standard deviation was identifed as the key quantity in speci- fying and assessing synchronization precision. It is to be hoped that these insights will be adopted by a wider audience and lead to a better comparability between published results. Furthermore, the direct comparison between WSNs and other DAQ systems, which is now possible, can help to establish WSNs as just another type of measurement system.

As the experimental results in chapter 6 have shown, the real-time performance of WSN software has a signifcant infuence on the synchronized data acquisition. Here, con- cepts are needed that solve the current confict between efcient duty-cycling and data acquisition. One approach might be to make better use of interrupt prioritization, which is supported by many modern microcontrollers. Also, more recent operating systems

250 7.3. Outlook for WSN like RIOT OS appear to ofer better real-time performance than Contiki. Nev- ertheless, efciently integrating the various algorithms, which have been developed for diferent tasks in WSN, into one well performing system, appears to be a major chal- lenge for the future. This could possibly be signifcantly eased through better hardware support. The timestamping operation for example, which is central to time synchro- nization and data acquisition, could be done much more accurately and efciently by dedicated hardware. A hardware coupling between a synchronized clock and an ADC might also make it possible to use the proactive approach to synchronized waveform sampling at higher sampling rates. The performance of the reactive approach at higher signal frequencies on the other hand, might be improved by using more powerful resampling algorithms like e.g. the flter suggested for synchronous angular sampling. The resampling flter itself, might also proft from a hardware implementation. Espe- cially the idea of combining it with a delta-sigma modulator and this way building a delta-sigma ADC with reactively synchronized output seems interesting. Furthermore, the flter might be extended to simultaneously resample multiple input channels. This might be done quite efciently, as the lower branch of the flter, which flters the time- stamps, could be used for all channels simultaneously. Currently, the limiting factor for the flter with regard to the supported speed range and maximum signal order at the output is the transmission bandwidth of the WSN. This might be overcome by fnding a way to encode and transmit timestamps more efciently, e.g. as spline functions. In general, more efcient encoding and compression techniques could increase the util- ity for WSN in scientifc and industrial applications. One approach might be to ex- tend the efcient compression techniques for text and image data suggested in [116] to other kinds of measurement data. Furthermore, there seems to be great potential in distributing the processing steps in a WSN such that the amount of data transmitted is minimized.

251

List of Figures

2.1. Topologies for WSNs...... 17 2.2. Protocol stacks for wireless sensor networks...... 25 2.3. Remote clock reading techniques according to [119]: a) unidirectional synchronization, b) round-trip synchronization, c) reference broadcast. . 31 2.4. Typical message delay sources according to [87]...... 33 2.5. PTP network structure [200]...... 42 2.6. PTP synchronization message exchange [200]...... 42 2.7. IEEE 1451 reference model according to [196]. Grayed out parts are out of scope for IEEE 1451...... 50 2.8. Principle of synchronous angular sampling...... 53 2.9. Principle of synchronous angular resampling...... 54 2.10. Block diagram of upsampled linear interpolation algorithm [14]. . . . . 55 2.11. Block diagram of upsampled interpolation flter [14]...... 55

3.1. Amplitude spectra of a continuous signal X, corresponding sampled signal Xs and ideal reconstruction flter Hideal...... 65 3.2. Example of an amplitude spectrum with aliasing. Dotted green lines show the individual repetition spectra. Red flled areas mark frequency intervals where a reconstructed signal would be distorted by aliasing. . . 65 3.3. Example spectrum of a nonuniform comb function [88]...... 67 3.4. Digital measurement chain [48]...... 68 3.5. Structures of multi-channel data acquisition systems [48]...... 69 3.6. Spectral efect of decimation. X: amplitude spectrum of original signal ′ sampled at ωs; Y: amplitude spectrum of signal resampled at ωs = ωs/M...... 70 3.7. Sampling rate reduction by an integer factor (decimation)...... 71 3.8. Tolerance schemes for digital anti-aliasing flters (after [93]). V is the signal amplitude spectrum after fltering and Y the signal amplitude spectrum after decimation. Red shaded areas mark the frequency bands where aliasing may occur...... 72 3.9. Spectral efect of interpolation. X: spectrum of original signal at sam- pling rate ωs...... 73 3.10. Sampling rate increase by an integer factor (interpolation)...... 73 3.11. Digital resampling with rational rate change factor...... 74 3.12. Hybrid discrete/continuous model of digital resampling [7]...... 74

253 List of Figures

3.13. FIR decimation flter...... 76 3.14. CIC decimation flter...... 77 3.15. Polynomial interpolation flters...... 79 3.16. Structure of the transposed Farrow flter [7, 82]...... 81 3.17. Example magnitude frequency response of a transposed Farrow flter. . 82

4.1. Model of a generic multi-channel event detection system applied to a WSN...... 100 4.2. Model of a generic multi-channel sampling system applied to a WSN. . 100 4.3. Data acquisition chain for event detection...... 101 4.4. Probability density distributions of clock reading errors...... 104 4.5. Efect of time ofset on an acquired sine wave...... 108 4.6. Efect of constant timing drift on an acquired sine wave...... 109 4.7. Efect of timing jitter on an acquired sine wave...... 110 4.8. Efect of a time step on an acquired sine wave...... 111 4.9. Efect of changing drift on an acquired sine wave...... 111 4.10. Sampling systems with diferent approaches to time synchronous sam- pling...... 115 4.11. Representation of the same signal in time- and angle domain. The marked positions show time, angle and signal values of a uniform sam- pling grid with spacing Ts in time domain...... 117 4.12. Setup for testing synchronous event detection...... 119 4.13. Setup for testing multi-channel waveform sampling...... 120 4.14. Setup for testing synchronous angular sampling...... 122

5.1. Preon32 on shuttle...... 124 5.2. Block diagram of Preon32...... 124 5.3. Clock sources and their distribution on the Preon32...... 125 5.4. Layers and modules of Contiki’s network stack...... 132 5.5. Structure of a TDMA frame...... 134 5.6. Structure and communication model of the data acquisition framework. 136 5.7. Sequence diagram of the transducer discovery process...... 141 5.8. Sequence diagram of the transducer confguration...... 142 5.9. Sequence diagram of one-shot acquisition...... 142 5.10. Sequence diagram of a continuous data acquisition...... 143 5.11. Maximum memory usage on a TIM...... 145 5.12. Maximum memory usage on a NCAP...... 146 5.13. Block diagram of digital event sensor...... 148 5.14. Block diagram of digital actuator...... 150 5.15. Block diagram of analog voltage sensor...... 151 5.16. Block diagram of microphone module...... 152 5.17. Block diagram of current and voltage sensor module...... 153

254 List of Figures

5.18. Three current/voltage transducer modules and signal conditioning mod- ule installed in a control cabinet...... 154 5.19. Block diagram of rotary encoder sensor...... 155 5.20. Rotary encoder sensor board with Preon32...... 156 5.21. Test bench with installed wireless sensors...... 158 5.22. Rotary encoder and TIM at the backside of the breaking engine. . . . . 158 5.23. Control cabinet with data TIM...... 158 5.24. Test bench setup...... 159 5.25. Remote clock reading technique of Contiki’s timesynch a priori syn- chronization service...... 161 5.26. Sequence diagram of a timesynch synchronization with 6LoWPAN- integration...... 163 5.27. Remote clock reading technique of the ETA-primitive for a posteriori synchronization...... 164 5.28. Sequence diagram of sending a packet with RITS-synchronization. . . . 164 5.29. Continuous event detection with a priori synchronization. Diferences to fgure 5.30 are highlighted in green...... 165 5.30. Continuous event detection with a posteriori synchronization. Difer- ences to fgure 5.29 are highlighted in red...... 166 5.31. Block diagram of upsampled linear interpolation algorithm [14]. . . . . 170 5.32. Reconstruction flter proposed in [82]...... 172 5.33. Resampling flter adapted to synchronous angular resampling...... 173 5.34. Magnitude frequency responses of individual flters...... 173 5.35. Magnitude frequency response of cascade: transposed Farrow, G and D. 174 5.36. Number formats used in implementation of resampling flter...... 175 5.37. Number formats used in the calculation of the fractional interval. . . . . 176 5.38. Number formats used in the implementation of the Farrow flter. . . . . 176 5.39. Network layout for synchronous angular resampling...... 177

6.1. Experimental setup used to measure the supply current of a node. . . . . 182 6.2. Activity diagrams of test applications used to measure a sensor node’s current consumption...... 183 6.3. Node current during transmission...... 185 6.4. Power consumption of nodes as calculated from current measurements with multimeter (DMM) and as estimated from powertrace (pwrt.). The error bars show the expanded uncertainty Uk=2...... 188 6.5. Transmission success during transmissions of one sender to one receiver. 190 6.6. Transmission success during transmissions of two senders to one receiver.191 6.7. Average power consumption during transmissions of one sender to one receiver...... 191 6.8. Average power consumption during transmission of two senders to one receiver...... 192 6.9. Experimental setup used for event timestamping tests...... 193

255 List of Figures

6.10. Recorded timestamp diferences of TIMs to NCAP without time syn- chronization. The initial clock ofset was removed to improve the visi- bility of the relative drifts...... 195 6.11. Recorded timestamp diferences with synchronization. The red lines mark the median. The blue boxes show the center 50 % and the whiskers the center 95 % of all values. Values outside these ranges are drawn as red crosses...... 197 6.12. Recorded timestamp diferences with synchronization with zoomed ver- tical axis. The red lines mark the median. The blue boxes show the cen- ter 50 % and the whiskers the center 95 % of all values. Values outside these ranges are drawn as red crosses...... 198 6.13. Histograms of recorded timestamp diferences. Fitted Gaussian proba- bility density functions are shown as red curves...... 200 6.14. First 100 s of recorded timestamp diferences and clock updates for con- fguration 5...... 202 6.15. Mean power consumption of nodes during timestamping experiments estimated from powertrace...... 203 6.16. General setup for passive acoustic localization on a straight line. . . . . 205 6.17. Setup for acoustic localization experiments...... 207 6.18. Example output of microphone amplifer and digital pin...... 209 6.19. Linear calibration of the localization system. The error bars indicate an interval of two standard deviations...... 210 6.20. Mean localization errors obtained with fltered timestamps. The error bars indicate an interval of two standard deviations...... 211 6.21. Experimental setup to test time synchronous waveform acquisition. . . . 217 6.22. Mean pairwise time shifts Tshi f t. The error bars indicate an interval of twice the standard deviation...... 219 6.23. Mean pairwise time shifts Tshi f t with zoomed y-axis. The error bars indicate an interval of twice the standard deviation...... 220 6.24. Signal SNR...... 222 6.25. Histogram of clock updates during acquisition of all records for confg- urations 1 and 2...... 223 6.26. Signal THD...... 224 6.27. Section of signal showing recorded and resampled data points. Intervals with missing samples are highlighted...... 225 6.28. Mean power consumption of nodes doing synchronous waveform sam- pling...... 226 6.29. Setup for simulations on idealized angular sampling. Elements in dashed/- dotted lines were only present starting from the confguration given as encircled number...... 228 6.30. SINAD of output signals synchronous to the rotation angle. Graph b) shows the same data as graph a) but with zoomed y-axis...... 229 6.31. Relation between analog sampling rate and SNR of angular signal. . . . 230

256 List of Figures

6.32. Setup for simulations on angular resampling...... 231 6.33. RMS-error of resampled chirp signals...... 233 6.34. Order-error of resampled chirp signals...... 233 6.35. SINAD of resampled chirp signals...... 234 6.36. Results of angular resampling a signal with spurious component. . . . . 235 6.37. Setup for recording generated signals...... 236 6.38. One period of the variable speed profle used in waveform generator experiments...... 237 6.39. RMS-values of acquired generator signals. The solid horizontal line indicates the nominal value set at the waveform generator. The dashed horizontal lines indicate the specifed accuracy of this setting ...... 238 6.40. Order of acquired generator signals. The nominal order is indicated by the horizontal line...... 238 6.41. SINAD of acquired generator signals...... 239 6.42. Average power consumption of nodes doing synchronous angular sam- pling...... 240 6.43. Setup for experiments at motor test bench...... 241 6.44. RMS-voltage of motor acquired at constant speeds...... 242 6.45. Order motor voltage signals acquired at constant speeds...... 242 6.46. SINAD motor voltage acquired at constant speeds...... 243 6.47. Speed profle acquired during one cycle. Vertical red lines separate the four segments of the profle...... 244 6.48. Speed, motor voltage and order spectrogram of one cycle. The green line in the motor voltage plot is the amplitude of the second order cal- culated from the spectrogram...... 245

B.1. Reference points for evaluation of polynomial kernel...... 292

C.1. Circuit diagram of the microphone module [Stud22]...... 294 C.2. Circuit diagram of the signal conditioning module [Stud9]...... 295 C.3. Circuit diagram of current/voltage transducer modules...... 296 C.4. Circuit diagram of rotary encoder interface circuit board...... 297

E.1. Timestamp diferences recorded with confguration 2 versus time. . . . 315 E.2. Histogram of timestamp diferences for confguration 2...... 316 E.3. Timestamp diferences recorded with confguration 3 versus time. . . . 317 E.4. Clock changes recorded with confguration 3 versus time...... 318 E.5. Histograms of timestamp diferences for confguration 3...... 318 E.6. Histograms of recorded clock updates for confguration 3...... 318 E.7. Timestamp diferences recorded with confguration 4 versus time. . . . 319 E.8. Clock updates recorded with confguration 4 versus time...... 320 E.9. Histograms of timestamp diferences for confguration 4...... 320 E.10. Histograms of recorded clock updates for confguration 4...... 320

257 List of Figures

E.11. Timestamp diferences recorded with confguration 5 versus time. . . . 321 E.12. Clock updates recorded with confguration 5 versus time...... 322 E.13. Histograms of timestamp diferences for confguration 5...... 322 E.14. Histograms of recorded clock updates for confguration 5...... 322 E.15. Timestamp diferences recorded with confguration 6 versus time. . . . 323 E.16. Histograms of timestamp diferences for confguration 6...... 323 E.17. Timestamp diferences recorded with confguration 7 versus time. . . . 324 E.18. Clock updates recorded with confguration 7 versus time...... 325 E.19. Histograms of timestamp diferences for confguration 7...... 325 E.20. Histograms of recorded clock updates for confguration 7...... 325 E.21. Timestamp diferences recorded with confguration 8 versus time. . . . 326 E.22. Clock updates recorded with confguration 8 versus time...... 327 E.23. Histograms of timestamp diferences for confguration 8...... 327 E.24. Histograms of recorded clock updates for confguration 8...... 327

258 List of Tables

2.1. Examples of basic general purpose sensor nodes...... 7 2.2. Examples of application specifc sensor nodes...... 8 2.3. Typical energy- and power densities of power supplies for wireless sen- sor nodes...... 12 2.4. Frequency bands, transmission channels and data rates in the IEEE 802.15.4 standard [194]...... 19 2.5. Canonical time synchronization services and their typical applications according to [77]...... 30 2.6. Overview of time synchronization protocols for WSN...... 37 2.7. Experimental precision of synchronization protocols...... 39 2.8. Performance of PTP implementations for WSNs...... 43 2.9. Examples of data acquisition with WSNs...... 47 2.10. Members of IEEE 1451 family of standards...... 50

3.1. Computational and memory requirements of a polyphase FIR-decimator. 77 3.2. Computational and memory requirements of a CIC-decimator...... 78 3.3. Computational and memory requirements of a polynomial interpolation. 80 3.4. Computational and memory requirements of a transposed Farrow flter. . 82 3.5. Comparison of resampling flter algorithms...... 83 3.6. Coverage factors and confdence levels for a Gaussian distribution [199]. 91 3.7. Example of an uncertainty budget...... 92

4.1. Summary of error infuences on the detection time ˆtevent ...... 105 4.2. Uncertainty margin for other infuences at given timing uncertainty. . . 114

5.1. Key features of Preon32 [179]...... 125 5.2. Key features of Preon32Shuttle [180]...... 125 5.3. Properties of clock sources on the Preon32...... 126 5.4. Major operating states and sleep modes of microcontroller and wireless transceiver on the Preon32. Values for Isupply are taken from [179]. . . . 127 5.5. Components of the software execution environment...... 128 5.6. Chosen TDMA-protocol parameters and theoretical performance. . . . 135 5.7. Transducer and TEDS commands...... 137 5.8. Types of TEDS implemented in the MSTL...... 138

259 List of Tables

5.9. Implemented user commands...... 139 5.10. Overview of commands and operation modes supported by the individ- ual application transducers...... 147 5.11. Data set of the powertrace sensor...... 149 5.12. Structure of the digital event sensor’s data set...... 149 5.13. Control values of digital actuator...... 150 5.14. Structure of analog voltage sensor’s data set...... 152 5.15. Technical data of the current/voltage transducer module...... 154 5.16. Structure of the rotary encoder sensor’s data set...... 156 5.17. Specifcation data of induction- and DC-motor...... 157

6.1. Current consumption of node 41 measured for the diferent power modes.184 6.2. Current consumption assigned to powertrace modes...... 185 6.3. Confguration of network layers investigated for data throughput. . . . . 189 6.4. Network confgurations investigated in event detection tests...... 194 6.5. Relative drifts between TIMs and NCAP. The uncertainties given are the expanded uncertainties (k = 2) calculated for the variances of the regression parameters...... 194 6.6. Theoretical maximum synchronization errors rounded to next larger in- teger number of Ticks. Exact values obtained from (2.1) are given in brackets...... 196 6.7. Estimated statistical parameters of timestamp diference distribution. . . 199 6.8. Known sections of interrupt blocking on Preon32...... 203 6.9. Maximum timing uncertainty ut,max of a single timestamp in µs for dif- ferent maximum location uncertainties ud,max and uncertainty margins for vsound = 343 m/s...... 206 6.10. Calibration results for the localization system. The error intervals cor- respond to the expanded uncertainty Uk=2, as estimated from the ft residuals...... 210 6.11. Overall statistics of localization errors...... 211 6.12. Infuence quantities afecting the localization measurement...... 213 6.13. Uncertainty budget for time interval measurement with frequency counter.214 6.14. Uncertainty budget for localization with frequency counter...... 215 6.15. Uncertainty budget for localization with WSN...... 215 6.16. Uncertainty budget for localization with WSN and active RDC...... 216 6.17. Confgurations for waveform acquisition tests...... 218 f 6.18. Frequency errors ϵ f and time o set errors ϵt0 calculated from the ac- quired waveforms...... 219 6.19. Average sampling rates calculated from sample timestamps...... 221 6.20. Quality parameters of signal with lost samples before and after resam- pling...... 224 6.21. Confgurations of simulations on idealized angular sampling...... 228

260 List of Tables

6.22. Resampling implementations that were investigated (see also section 5.3.4)...... 231

A.1. General purpose sensor nodes...... 288 A.2. General purpose sensor nodes (continued) ...... 289 A.3. General purpose sensor nodes (continued) ...... 290

261

Bibliography

[1] Abrach, H. et al.: MANTIS: System Support for multimodAl NeTworks of In-situ Sensors. In Proceedings of the 2Nd ACM International Conference on Wireless Sensor Networks and Applications, WSNA ’03, pp. 50–59, New York, NY, USA, 2003. ACM, ISBN 1-58113-764-8. DOI:10.1145/941350.941358.

[2] Abubakari, H.: IEEE 1588 Style Synchronization over a Wireless Link. Mas- ter’s thesis, University of Akron, 2008. http://etd.ohiolink.edu/view.cgi? acc_num=akron1226631636.

[3] Allan, D.W., N. Ashby, and C.C. Hodge: The Science of Timekeeping. Hewlett Packard Application Note 1289, 1997. http://literature.agilent.com/ litweb/pdf/5965-7984E.pdf, visited on 2015-05-12.

[4] Andersson, T. and P. Handel: IEEE Standard 1057, Cram´er-Rao bound and the parsimony principle. Instrumentation and Measurement, IEEE Transactions on, 55(1):44–53, Feb. 2006, ISSN 0018-9456. DOI:10.1109/TIM.2005.861497.

[5] Aoun, M., J. Catalano, and P. Stok: Distributed Task Synchronization in Wireless Sensor Networks. In Proceedings of the 6th European Conference on Wireless Sensor Networks, EWSN ’09, pp. 150–165, Berlin, Heidelberg, 2009. Springer- Verlag, ISBN 978-3-642-00223-6. DOI:10.1007/978-3-642-00224-3 10.

[6] Aoun, M., A. Schoofs, and P. van der Stok: Efcient time synchronization for wireless sensor networks in an industrial setting. In Proceedings of the 6th ACM conference on Embedded network sensor systems, SenSys ’08, pp. 419–420, New York, NY, USA, 2008. ACM, ISBN 978-1-59593-990-6. DOI:10.1145/1460412.1460482.

[7] Babic, D. and M. Renfors: Reconstruction of non-uniformly sampled signal us- ing transposed Farrow structure. In Circuits and Systems, 2004. ISCAS ’04. Pro- ceedings of the 2004 International Symposium on, vol. 3, pp. 221–224, 2004. DOI:10.1109/ISCAS.2004.1328723.

[8] Baccelli, E. et al.: RIOT OS: Towards an OS for the Internet of Things. In Computer Communications Workshops (INFOCOM WKSHPS), 2013 IEEE Conference on, pp. 79–80, Apr. 2013. DOI:10.1109/INFCOMW.2013.6970748.

263 Bibliography

[9] Badaoui, M.E. and F. Bonnardot: Impact of the non-uniform angular sampling on mechanical signals. Mechanical Systems and Signal Processing, 44(1–2):199–210, 2014, ISSN 0888-3270. DOI:10.1016/j.ymssp.2013.10.008. Special Issue on In- stantaneous Angular Speed (IAS) Processing and Angular Applications.

[10] Basaran, C. et al.: Critical evaluation of platforms commonly used in embedded wisents research. Techn. rep., Embedded WiSeNts consortium, 2006.

[11] Beard, R.L. and J.D. White: GPS Application to Time Transfer and Dissemination. GPS Solutions, 3(1):17–25, 1999, ISSN 1080-5370. DOI:10.1007/PL00012774.

[12] Benecke, S., E. Kravcenko, and R. Wirth: BMBF-Verbundprojekt ”ECoMoS” - Energieautarkes Condition Monitoring System. Abschlussbericht, Technische Uni- versitat¨ Berlin, Forschungsschwerpunkt Technologien der Mikroperipherik, 2012. DOI:10.2314/GBV:757447449.

[13] Bhatti, S. et al.: MANTIS OS: An embedded multithreaded operating system for wireless micro sensor platforms. MOBILE NETWORKS & APPLICATIONS, 10(4):563–579, Aug. 2005, ISSN 1383-469X. DOI:10.1007/s11036-005-1567-8. 2nd International Workshop on Wireless Sensor Networks and Application (WSNA 2003), San Diego, CA, SEP 19, 2003.

[14] Blough, J.: Adaptive Resampling - Transforming from the time to the Angle do- main. In 24th Conference and Exposition on Structural Dynamics 2006, IMAC- XXIV, 2006.

[15] Blough, J.R.: A survey of DSP methods for rotating machinery analysis, what is needed, what is available. Journal of Sound and Vibration, 262(3):707–720, 2003, ISSN 0022-460X. DOI:10.1016/S0022-460X(03)00118-4. 2001 India-USA Symposium on Emerging Trends in Vibration and Noise Engineering.

[16] Bomar, B.W.: Finit Wordlength Efects. In Digital signal processing fundamen- tals. CRC Press, 2009, ISBN 978-1-4200-4606-9.

[17] Bonnardot, F. et al.: Use of the acceleration signal of a gearbox in or- der to perform angular resampling (with limited speed fuctuation). Mechan- ical Systems and Signal Processing, 19(4):766–785, 2005, ISSN 0888-3270. DOI:10.1016/j.ymssp.2004.05.001.

[18] Brandt, A. et al.: Main principles and limitations of current order tracking meth- ods. Sound and Vibration, 39(3):19–22, 2005, ISSN 1541-0161.

[19] Buettner, M. et al.: X-mac: A short preamble mac protocol for duty-cycled wireless sensor networks. In in SenSys, pp. 307–320, 2006, http://www.cs. colorado.edu/˜rhan/Papers/xmac_sensys06.pdf.

264 Bibliography

[20] Caligiuri, L.M. and A. Nastro: About the conventionality of simultaneity and syn- chronization. In 20th IMEKO TC4 Symposium on Measurements of Electrical Quantities, 2014.

[21] Chen, D., M. Nixon, and A. Mok: WirelessHART. Springer, 2010, ISBN 978-1-4419-6047-4. DOI:10.1007/978-1-4419-6047-4.

[22] Cho, H., S. Son, and Y. Baek: Implementation of a precision time protocol over low rate wireless personal area networks. In Computer Systems Archi- tecture Conference, 2008. ACSAC 2008. 13th Asia-Pacifc, pp. 1–8, Aug. 2008. DOI:10.1109/APCSAC.2008.4625431.

[23] Christin, D., P.S. Mogre, and M. Hollick: Survey on Wireless Sensor Net- work Technologies for Industrial Automation: The Security and Quality of Service Perspectives. Future Internet, 2(2):96–125, 2010, ISSN 1999-5903. DOI:10.3390/f2020096.

[24] Clausen, T. et al.: The Lightweight On-demand Ad hoc Distance-vector Routing Protocol - Next Generation (LOADng), July 2012. https://tools.ietf.org/ html/draft-clausen-lln-loadng-05, DRAFT.

[25] Crochiere, R.E. and L.R. Rabiner: Multirate Digital Signal Processing. Prentice Hall, 1983, ISBN 0-13-605162-6.

[26] Dai, H. and R. Han: TSync: a lightweight bidirectional time synchronization ser- vice for wireless sensor networks. SIGMOBILE Mob. Comput. Commun. Rev., 8(1):125–139, 2004, ISSN 1559-1662. DOI:10.1145/980159.980173.

[27] Dreher, A. and D. Mohl: Pr¨azise Uhrzeitsynchronisation: Der Standard IEEE 1588. https://belden.picturepark.com/Website/Publisher. aspx?Page=Belden&AssetContainerId=1250, visited on 2015-04-21, rev. 1.2.

[28] Dunkels, A.: Rime - a lightweight layered communication stack for sensor net- works. In European Conference on Wireless Sensor Networks (EWSN), Jan. 2007, http://www.sics.se/˜adam/dunkels07rime.pdf.

[29] Dunkels, A.: The ContikiMAC Radio Duty Cycling Protocol. SICS Techni- cal Report T2011:13, 2011, ISSN 1100-3154, http://www.sics.se/˜adam/ dunkels11contikimac.pdf.

[30] Dunkels, A., B. Gronvall, and T. Voigt: Contiki - a lightweight and fexible operating system for tiny networked sensors. In Local Computer Networks, 2004. 29th Annual IEEE International Conference on, pp. 455–462, Nov. 2004. DOI:10.1109/LCN.2004.38.

265 Bibliography

[31] Dunkels, A. et al.: Software-based On-line Energy Estimation for Sen- sor Nodes. In Proceedings of the 4th Workshop on Embedded Networked Sensors, EmNets ’07, pp. 28–32. ACM, 2007, ISBN 978-1-59593-694-3. DOI:10.1145/1278972.1278979.

[32] Dunkels, A. et al.: Protothreads: Simplifying Event-driven Programming of Memory-constrained Embedded Systems. In Proceedings of the 4th International Conference on Embedded Networked Sensor Systems, Sen- Sys ’06, pp. 29–42, New York, NY, USA, 2006. ACM, ISBN 1-59593-343-3. DOI:10.1145/1182807.1182811.

[33] Duquennoy, S. et al.: Leveraging IP for Sensor Network Deployment. In Proceed- ings of the workshop on Extending the Internet to Low power and Lossy Networks (IP+SN 2011), Chicago, IL, USA, Apr. 2011.

[34] Dutta, P. and A. Dunkels: Operating systems and network protocols for wire- less sensor networks. Philosophical Transactions of the Royal Society of Lon- don A: Mathematical, Physical and Engineering Sciences, 370(1958):68–84, 2011, ISSN 1364-503X. DOI:10.1098/rsta.2011.0330.

[35] Elson, J., L. Girod, and D. Estrin: Fine-grained network time synchronization using reference broadcasts. SIGOPS Oper. Syst. Rev., 36(SI):147–163, 2002, ISSN 0163-5980. DOI:10.1145/844128.844143.

[36] Eswaran, A., A. Rowe, and R. Rajkumar: Nano-RK: an energy-aware resource-centric RTOS for sensor networks. In Real-Time Systems Sympo- sium, 2005. RTSS 2005. 26th IEEE International, pp. 256–265, Dec. 2005. DOI:10.1109/RTSS.2005.30.

[37] Ferrari, P. et al.: Time distribution in IPv6 Wireless Sensor Networks. In Precision Clock Synchronization for Measurement Control and Communica- tion (ISPCS), 2011 International IEEE Symposium on, pp. 69–74, 2011. DOI:10.1109/ISPCS.2011.6070149.

[38] Flammini, A. et al.: Wired and wireless sensor networks for industrial applica- tions. Microelectronics Journal, 40(9):1322–1336, 2009.

[39] Flammini, A. et al.: A real-time Wireless Sensor Network for temperature moni- toring. In Industrial Electronics, 2007. ISIE 2007. IEEE International Symposium on, pp. 1916–1920, June 2007. DOI:10.1109/ISIE.2007.4374900.

[40] FLUKE: 8845A/8846A Digitial Multimeter - User Manual, 3rd ed., June 2006.

[41] FLUKE: Understanding specifcations for precision multimeters, 2011. Applica- tion Note.

266 Bibliography

[42] Ganeriwal, S., R. Kumar, and M.B. Srivastava: Timing-sync protocol for sensor networks. In SenSys ’03: Proceedings of the 1st international conference on Em- bedded networked sensor systems, pp. 138–149. ACM, 2003. [43] Gnawali, O. et al.: Collection Tree Protocol. Technical Report SING-09-01, 2009, http://sing.stanford.edu/pubs/sing-09-01.pdf, visited on 2011-09-23. Stanford University. [44] Greunen, J. van and J. Rabaey: Lightweight time synchronization for sensor net- works. In Proceedings of the 2Nd ACM International Conference on Wireless Sen- sor Networks and Applications, WSNA ’03, pp. 11–19, New York, NY, USA, 2003. ACM, ISBN 1-58113-764-8. DOI:10.1145/941350.941353. [45] Guevara, J. et al.: A framework for WSN using TinyOS and the IEEE1451 stan- dard. In Communications (LATINCOM), 2011 IEEE Latin-American Conference on, pp. 1–5, Oct. 2011. DOI:10.1109/LatinCOM.2011.6107420. [46]G ockler,¨ H.G. and A. Groth: Multiratensysteme. J. Schlembach Fachverlag, 2004, ISBN 3-935340-29-X. [47]G uhmann,¨ C.: Stromanalyse zur Diagnose seriengefertigter Universalmotoren. PhD thesis, TU Berlin, 1995, ISBN 3-89574-087-X. [48]G uhmann,¨ C.: Messdatenverarbeitung. TU Berlin, lecture notes, Mar. 2011. [49]G uhmann,¨ C.: Modellbildung und Echtzeitsimulation technischer Systeme - Kapi- tel 7. TU Berlin, lecture notes, Dec. 2015. [50] Haenselmann, T.: Wireless Sensor Networks. Oldenbourg Verlag, 2011, ISBN 978-3-486-70798-4. [51] HAMEG Instruments: 3 GHz Programmable Counter HM8123, HM8123-X - User Manual. 2015-09-15. [52] HAMEG Instruments: Arbitrary Function Generator 12.5 MHz HM8150 - Datasheet. 2014-06-22. [53] Heynicke, R., D. Kruger,¨ and G. Scholl: Wireless automation. In SENSOR+TEST Conference, 2011. [54] Higuera, J. and J. Polo: Understanding the IEEE 1451 standard in 6loWPAN sen- sor networks. In Sensors Applications Symposium (SAS), 2010 IEEE, pp. 189–193, 2010. DOI:10.1109/SAS.2010.5439427. [55] Higuera, J. and J. Polo: IEEE 1451 Standard in 6LoWPAN Sensor Networks Using a Compact Physical-Layer Transducer Electronic Datasheet. Instrumentation and Measurement, IEEE Transactions on, 60(8):2751–2758, 2011, ISSN 0018-9456. DOI:10.1109/TIM.2011.2129990.

267 Bibliography

[56] Hill, J. and D. Culler: Mica: a wireless platform for deeply embed- ded networks. Micro, IEEE, 22(6):12–24, Nov. 2002, ISSN 0272-1732. DOI:10.1109/MM.2002.1134340. [57] Hofmann, J. (ed.): Taschenbuch der Messtechnik. Fachbuchverl. Leipzig im Carl- Hanser-Verl., 4th ed., 2004. ISBN 3-446-22860-8. [58] Hogenauer, E.: An economical class of digital flters for decimation and in- terpolation. Acoustics, Speech and Signal Processing, IEEE Transactions on, 29(2):155–162, Apr. 1981, ISSN 0096-3518. DOI:10.1109/TASSP.1981.1163535. [59] Hou, L. and N. Bergmann: System requirements for industrial wireless sensor networks. In Emerging Technologies and Factory Automation (ETFA), 2010 IEEE Conference on, pp. 1–8, 2010. DOI:10.1109/ETFA.2010.5641163.

[60] Hou, L. and N.W. Bergmann: Novel Industrial Wireless Sensor Networks for Machine Condition Monitoring and Fault Diagnosis. Instrumentation and Mea- surement, IEEE Transactions on, 61(10):2787–2798, 2012, ISSN 0018-9456. DOI:10.1109/TIM.2012.2200817. [61] Huang, Q., B. Tang, and L. Deng: Development of high synchronous acquisition accuracy wireless sensor network for machine vibration monitoring. Measurement, 66(0):35–44, 2015, ISSN 0263-2241. DOI:10.1016/j.measurement.2015.01.021. [62] Josefsson, S.: The Base16, Base32, and Base64 Data Encodings. RFC 4648, Oct. 2006. https://tools.ietf.org/html/rfc4648.

[63] Kagelmaker, U. and F. Hillenbrand: BMBF-Verbundprojekt ”ECoMoS”: En- ergieefziente Messdatenerfassung und -verarbeitung f¨urein energieautarkes Con- dition Monitoring System. Abschlussbericht, IMC Meßsysteme GmbH, Berlin, 2012. DOI:10.2314/GBV:742582418. [64] Karl, H. and A. Willig: Protocols and Architectures for Wireless Sensor Networks. Wiley, 2005, ISBN 978-0-470-09510-2. [65] Kester, W. (ed.): The Data Conversion Handbook. Analog Devices Inc., 2004, ISBN 0-916550-27-3. [66] Kiencke, U. and R. Eger: Messtechnik : Systemtheorie f¨urElektrotechniker. Springer, 2008, ISBN 978-3-540-78428-9. DOI:10.1007/978-3-540-78429-6.

[67] Kim, J.S. et al.: Robust clock synchronization in wireless sensor networks through noise density estimation. Signal Processing, IEEE Transactions on, 59(7):3035–3047, July 2011, ISSN 1053-587X. DOI:10.1109/TSP.2011.2141660. [68] Kinsler, L.E. et al.: Fundamentals of acoustics. Wiley, 4th ed., 2000, ISBN 0-471-84789-5.

268 Bibliography

[69] Klingler, F.M. and H.G. Gockler:¨ Conversion between arbitrary sampling rates: An implementation cost trade-of study for the family of farrow structures. In Proc. 5th Karlsruhe Workshop on Software Radios, pp. 1–8, 2008, http://www.dsv.ruhr-uni-bochum.de/imperia/md/content/ public/wsr08_klinglergoeckler.pdf. [70] Ko, J. et al.: A.: Evaluating the Performance of RPL and 6LoWPAN. In in TinyOS. In: Workshop on Extending the Internet to Low power and Lossy Networks (IP+SN 2011), 2011. [71] Kodek, D.M.: Length limit of optimal fnite wordlength FIR flters. Digital Signal Processing, 23(5):1798–1805, 2013, ISSN 1051-2004. DOI:10.1016/j.dsp.2013.07.004. [72] Kolerus, J. and J. Wassermann: Zustands¨uberwachung von Maschinen. expert- Verl., 4th ed., 2011, ISBN 978-3-8169-2597-2. [73] Kovatsch, M., S. Duquennoy, and A. Dunkels: A Low-Power CoAP for Contiki. In Mobile Adhoc and Sensor Systems (MASS), 2011 IEEE 8th International Con- ference on, pp. 855–860, Oct. 2011. DOI:10.1109/MASS.2011.100. [74] Krauße, M. and R. Konrad: Drahtlose ZigBee-Netzwerke : ein Kompendium. Springer, 2014, ISBN 978-3-658-05821-0. [75] Kreuzer, J.: Wenn mich niemand danach fragt, weiß ich es.“ – Die Re- ” alit¨at der Zeit. Hamburger Akademie der Wissenschaften, Nov. 2015. http://www.awhamburg.de/fileadmin/redakteure/Downloads/2015- 11-26_AkadVL_Kreuzer_Handout.pdf, visited on 2016-04-30, handout. [76] Kruger,¨ D., R. Heynicke, and G. Scholl: Wireless sensor/actuator-network with improved coexistence performance for 2.45 GHz ISM-band operation. In Systems, Signals and Devices (SSD), 2012 9th International Multi-Conference on, pp. 1–5, 2012. DOI:10.1109/SSD.2012.6198099. [77] Kusy, B. et al.: Elapsed time on arrival: a simple and versatile primitive for canonical time synchronisation services. International Journal of Ad Hoc and Ubiq- uitous Computing, 1(4):239–251, 2006. DOI:10.1504/IJAHUC.2006.010505. [78] Lamport, L.: Time, clocks, and the ordering of events in a dis- tributed system. Commun. ACM, 21(7):558–565, 1978, ISSN 0001-0782. DOI:http://doi.acm.org/10.1145/359545.359563. [79] Lasassmeh, S. and J. Conrad: Time synchronization in wireless sensor networks: A survey. In IEEE SoutheastCon 2010 (SoutheastCon), Proceedings of the, pp. 242–245, 2010. DOI:10.1109/SECON.2010.5453878. [80] Lee, E.A. and S.A. Seshia: Introduction to Embedded Systems - A Cyber-Physical Systems Approach. LeeSeshia.org, 2011, ISBN 978-0-557-70857-4.

269 Bibliography

[81] Lee, H.C. et al.: The Tube: A Rapidly Deployable Wireless Sensor Platform for Supervising Pollution of Emergency Work. Instrumentation and Measure- ment, IEEE Transactions on, 61(10):2776–2786, Oct. 2012, ISSN 0018-9456. DOI:10.1109/TIM.2012.2200392.

[82] Lehtinen, V. et al.: Error Spectrum Analysis of Time-Variant Recon- struction from Nonuniform Sampling. In Signal Processing Symposium, 2006. NORSIG 2006. Proceedings of the 7th Nordic, pp. 78–81, 2006. DOI:10.1109/NORSIG.2006.275281.

[83] Leng, M. and Y.C. Wu: Low-Complexity Maximum-Likelihood Estimator for Clock Synchronization of Wireless Sensor Nodes Under Exponential Delays. Sig- nal Processing, IEEE Transactions on, 59(10):4860–4870, 2011, ISSN 1053-587X. DOI:10.1109/TSP.2011.2160857.

[84] Lerch, R.: Elektrische Messtechnik. Springer, 2007.

[85] Levis, P. et al.: TinyOS: An Operating System for Sensor Networks. In Weber, W., J. Rabaey, and E. Aarts (eds.): Ambient Intelligence, pp. 115–148. Springer Berlin Heidelberg, 2005, ISBN 978-3-540-23867-6. DOI:10.1007/3-540-27139-2 7.

[86] Liu, Q. et al.: AdaSynch: A General Adaptive Clock Synchronization Scheme Based on Kalman Filter for WSNs. Wireless Personal Communications, 63(1):217–239, 2012, ISSN 0929-6212. DOI:10.1007/s11277-010-0116-3.

[87] Maroti,´ M. et al.: The fooding time synchronization protocol. In SenSys ’04: Proceedings of the 2nd international conference on Embedded networked sensor systems, pp. 39–49. ACM, 2004.

[88] Marvasti, F.: Nonuniform sampling: theory and practice. No. 1 in Information technology–transmission, processing, and storage. Kluwer Academic/Plenum Pub- lishers, 2001, ISBN 9780306464454.

[89] Marvasti, F. et al.: Reconstruction of speech signals with lost samples. Signal Processing, IEEE Transactions on, 40(12):2897–2903, 1992, ISSN 1053-587X. DOI:10.1109/78.175734.

[90] McFadden, P.: Interpolation techniques for time domain averaging of gear vibration. Mechanical Systems and Signal Processing, 3(1):87–97, 1989, ISSN 0888-3270. DOI:http://dx.doi.org/10.1016/0888-3270(89)90024-1.

[91] Medina, C., J.C. Segura, and A. de la Torre: A Synchronous TDMA Ultra- sonic TOF Measurement System for Low-Power Wireless Sensor Networks. In- strumentation and Measurement, IEEE Transactions on, 62(3):599–611, 2013, ISSN 0018-9456. DOI:10.1109/TIM.2012.2218056.

270 Bibliography

[92] Mehta, A. and K. Pister: WARPWING: A complete open source control platform for miniature robots. In Intelligent Robots and Systems (IROS), 2010 IEEE/RSJ International Conference on, pp. 5169–5174, Oct. 2010. DOI:10.1109/IROS.2010.5649382. [93] Milic, L.: Multirate Filtering for Digital Signal Processing. Information Science Reference, 2009. [94] Mills, D.: Network Time Protocol (NTP). RFC 958, Sept. 1985. https://tools. ietf.org/html/rfc958, visited on 2015-04-20, Obsoleted by RFCs 1059, 1119, 1305. [95] Mills, D. et al.: Network Time Protocol Version 4: Protocol and Algorithms Spec- ifcation. RFC 5905 (Proposed Standard), June 2010. http://www.ietf.org/ rfc/rfc5905.txt, visited on 2015-05-12. [96] Mills, D.L.: Network Time Protocol (NTP) - General Overview, 2004. https:// www.eecis.udel.edu/˜mills/database/brief/overview/overview.pdf, visited on 2015-05-12. [97] Mills, D.L.: NTP Architecture, Protocol and Algorithms, 2007. http:// www.eecis.udel.edu/˜mills/database/brief/arch/arch.pdf, visited on 2015-05-11. [98] Narendra, P., S. Duquennoy, and T. Voigt: BLE and IEEE 802.15.4 in the IoT: Evaluation and Interoperability Considerations. In International Conference on Interoperability in IoT (EAI InterIoT 2015), 2015, http://soda.swedishict. se/5923/, visited on 2016-10-03. [99] Niedermayer, M.: Methodik zum Entwurf von miniaturisierten, energieautarken, verteilten Funksensorknoten. PhD thesis, TU Berlin, 2007. [100] Niedermayer, M., H. Scholtz, and R. Wirth: BMBF-Verbundprojekt ”ECoMoS”: Miniaturisierungstechnologien f¨urEnergieautarke Condition Monitoring Systeme. Abschlussbericht, Fraunhofer-Institut fur¨ Zuverlassigkeit¨ und Mikrointegration, 2012. DOI:10.2314/GBV:757442536. [101] Nong, H. and J. Lin: Design of loosely coupled inductive power transfer systems for instrumented wheelset. In Electronic Measurement Instruments, 2009. ICEMI ’09. 9th International Conference on, pp. 1–670–1–674, 2009. DOI:10.1109/ICEMI.2009.5274779. [102] Oppenheim, A.V. and R.W. Schafer: Discrete-Time Signal Processing. Pearson Education Limited, 3rd ed., 2013, ISBN 978-1-292-02572-8. [103] Oppenheim, A.V., A.S. Willsky, and S.H. Nawab: Signals and systems. Prentice- Hall, 2nd ed., 1996, ISBN 0-13-814757-4.

271 Bibliography

[104] Outler, A.C.: Augustine: Confessions, newly translated and edited, 1955. http://www.georgetown.edu/faculty/jod/augustine/conf.pdf, visited on 2016-08-13. [105] Papoulis, A.: Error analysis in sampling theory. Proceedings of the IEEE, 54(7):947–955, July 1966, ISSN 0018-9219. DOI:10.1109/PROC.1966.4940. [106] Perkins, C., E. Belding-Royer, and S. Das: Ad hoc On-Demand Distance Vector (AODV) Routing. RFC 3561 (Experimental), July 2003. http://www.ietf.org/ rfc/rfc3561.txt. [107] Pesch, B.: Bestimmung der Messunischerheit nach GUM. Books On Demand GmbH, Norderstedt, 2004, ISBN 3-8830-1039-8. [108] Pfugradt, M. et al.: A novel pulseoximeter for bluetooth synchronized mea- surements in a body sensor network. In Education and Research Confer- ence (EDERC), 2014 6th European Embedded Design in, pp. 21–25, 2014. DOI:10.1109/EDERC.2014.6924351. [109] Pister, K. et al.: Industrial Routing Requirements in Low-Power and Lossy Net- works. RFC 5673 (Informational), Oct. 2009. http://www.ietf.org/rfc/ rfc5673.txt. [110] Pister, K.S.J. and L. Doherty: TSMP: Time Synchronized Mesh Protocol. In Proceedings of the IASTED International Symposium Distributed Sensor Networks, 2008. [111] Potter, R.: New order tracking method for rotating machinery. S V Sound and Vibration, 24(9):30–34, 1990. [112] Pottie, G.J. and W.J. Kaiser: Wireless integrated network sensors. Commun. ACM, 43(5):51–58, 2000, ISSN 0001-0782. DOI:10.1145/332833.332838. [113]P ottner,¨ W.B. et al.: WSN Evaluation in Industrial Environments First results and lessons learned. In 3rd Workshop on Performance Control in Wireless Sensor Networks 2011 (PWSN 2011) in conjuction with IEEE DCOSS 2011, pp. 1–8, 2011. [114] Raju, M.: Energy Harvesting - ULP meets energy harvesting: A game-changing combination for design engineers. Techn. rep., Texas Instruments, 2008. [115] Ramos, P.M. and A.C. Serra: A new sine-ftting algorithm for ac- curate amplitude and phase measurements in two channel acquisi- tion systems. Measurement, 41(2):135–143, 2008, ISSN 0263-2241. DOI:10.1016/j.measurement.2006.03.011. Advances in Measurements of Eelectrical Quantities. [116] Rein, S.: Low Complexity Text and Image Compression for Wireless Devices and Sensors. PhD thesis, TU Berlin, 2010. DOI:10.14279/depositonce-2484.

272 Bibliography

[117] Rein, S. and M. Reisslein: Low-Memory Wavelet Transforms for Wireless Sensor Networks: A Tutorial. Communications Surveys Tutorials, IEEE, 13(2):291–307, Feb. 2011, ISSN 1553-877X. DOI:10.1109/SURV.2011.100110.00059. [118] Ren, F., C. Lin, and F. Liu: Self-correcting time synchronization using refer- ence broadcast in wireless sensor network. Wireless Communications, IEEE, 15(4):79–85, Aug. 2008, ISSN 1536-1284. DOI:10.1109/MWC.2008.4599225. [119]R omer,¨ K., P. Blum, and L. Meier: Time Synchronization and Calibration in Wireless Sensor Networks. In Handbook of Sensor Networks: Algorithms and Ar- chitectures. Wiley, 2005, ISBN 978-0-471-68472-5. [120]R omer,¨ K. and F. Mattern: The design space of wireless sensor net- works. Wireless Communications, IEEE, 11(6):54–61, 2004, ISSN 1536-1284. DOI:10.1109/MWC.2004.1368897. [121] Roundy, S. and L. Frechette: Energy Scavenging and Nontraditional Power Sources for Wireless Sensor Networks. In Handbook of Sensor Networks: Algo- rithms and Architectures. Wiley, 2005, ISBN 978-0-471-68472-5. [122] Schafer, R. and L. Rabiner: A digital signal processing approach to inter- polation. Proceedings of the IEEE, 61(6):692–702, 1973, ISSN 0018-9219. DOI:10.1109/PROC.1973.9150. [123] Schmid, T. et al.: A case against routing-integrated time synchronization. In Proceedings of the 8th ACM Conference on Embedded Networked Sen- sor Systems, SenSys ’10, pp. 267–280, New York, NY, USA, 2010. ACM, ISBN 978-1-4503-0344-6. DOI:10.1145/1869983.1870010. [124] Schmid, T., P. Dutta, and M.B. Srivastava: High-resolution, low-power time synchronization an oxymoron no more. In IPSN ’10: Proceedings of the 9th ACM/IEEE International Conference on Information Processing in Sensor Net- works, pp. 151–161, New York, NY, USA, 2010. ACM, ISBN 978-1-60558-988-6. DOI:10.1145/1791212.1791231. [125] Scholl, G. et al.: Wireless Automation. In 16th International Conference On Sensors and Measurement Technology, 2013. [126] Schweinzer, H. and G. Kaniak: Ultrasonic device localization and its potential for wireless sensor network security. Control Engineering Practice, 18(8):852–862, Aug. 2010, ISSN 0967-0661. DOI:10.1016/j.conengprac.2008.12.007. [127] Sedlacek, M. and M. Krumpholc: Digital measurement of phase diference - a comparative study of dsp algorithms. Metrology and Measurement Systems, XII:427–448, 2005, ISSN 0860-8229. [128] Shelby, Z. and C. Bormann: 6LoWPAN: The Wireless Embedded Internet. Wiley, 2009, ISBN 978-0-470-74799-5.

273 Bibliography

[129] Shelby, Z., K. Hartke, and C. Bormann: The Constrained Application Protocol (CoAP). RFC 7252 (Proposed Standard), June 2014. http://www.ietf.org/ rfc/rfc7252.txt. [130] Shucker, B. et al.: Embedded Operating Systems for Wireless Microsensor Nodes. In Handbook of Sensor Networks: Algorithms and Architectures. Wiley, 2005, ISBN 978-0-471-68472-5. [131] Siekkinen, M. et al.: How low energy is bluetooth low energy? Compara- tive measurements with ZigBee/802.15.4. In Wireless Communications and Net- working Conference Workshops (WCNCW), 2012 IEEE, pp. 232–237, Apr. 2012. DOI:10.1109/WCNCW.2012.6215496. [132] Simon, G. et al.: Sensor network-based countersniper system. In Pro- ceedings of the 2nd International Conference on Embedded Networked Sen- sor Systems, SenSys ’04, pp. 1–12. ACM, 2004, ISBN 1-58113-879-2. DOI:10.1145/1031495.1031497. [133] Song, J. et al.: WirelessHART: Applying Wireless Technology in Real-Time Industrial Process Control. In Real-Time and Embedded Technology and Applications Symposium, 2008. RTAS ’08. IEEE, pp. 377–386, Apr. 2008. DOI:10.1109/RTAS.2008.15. [134] Souders, T. et al.: The efects of timing jitter in sampling systems. Instru- mentation and Measurement, IEEE Transactions on, 39(1):80–85, Feb. 1990, ISSN 0018-9456. DOI:10.1109/19.50421. [135] Stanislowski, D. et al.: Adaptive Synchronization in IEEE802.15.4e Net- works. Industrial Informatics, IEEE Transactions on, 10(1):795–802, 2014, ISSN 1551-3203. DOI:10.1109/TII.2013.2255062. [136] Steigmann, R. and J. Endresen: Introduction to WISA. Tech. Rep. V2.0, ABB STOTZ-KONTAKT GmbH, 2006. [137] Stojcev, M.K., L.R. Golubovic, and T.R. Nikolic: Clocks, Power and Syn- chronization in Duty-Cycled Wireless Sensor Nodes. Facta Universitatis (NIS), 24:183–208, 2011. [138] Stojmenovic, I. (ed.): Handbook of Sensor Networks: Algorithms and Architec- tures. Wiley, 2005, ISBN 978-0-471-68472-5. [139] Sun, Y.R. and S. Signell: Algorithms for nonuniform bandpass sampling in radio receiver. In Circuits and Systems, 2003. ISCAS ’03. Proceed- ings of the 2003 International Symposium on, vol. 1, pp. I–1–I–4, 2003. DOI:10.1109/ISCAS.2003.1205485. [140] Thingsquare: The World at Your Fingertips. http://www.thingsquare.com/, visited on 2015-02-27.

274 Bibliography

[141] Tian, X. et al.: Maximum likelihood estimation based on time synchronization algorithm for wireless sensor networks. In Computing, Communication, Control, and Management, 2009. CCCM 2009. ISECS International Colloquium on, vol. 4, pp. 416–420, 8-9 2009. DOI:10.1109/CCCM.2009.5267612.

[142] TinyOS: FAQ. http://tinyos.stanford.edu/tinyos-wiki/index.php/ FAQ, visited on 2015-02-27.

[143] Toma, D.M. et al.: Precision timing in TDMA-based Wireless Sensor Network through IEEE 1588 standard. In 19th Symposium IMEKO TC 4 Symposium and 17th IWADC Workshop Advances in Instrumentation and Sensors Interoperability, 2013.

[144] Tripathi, J., J.C. de Oliveira, and J. Vasseur: Proactive versus reactive rout- ing in low power and lossy networks: Performance analysis and scalabil- ity improvements. Ad Hoc Networks, 23(0):121–144, 2014, ISSN 1570-8705. DOI:10.1016/j.adhoc.2014.06.007.

[145] Vallestad, A.E.: WISA becomes WSAN - from proprietary technology to indus- try standard. In Wireless Summit, Oslo, 2012. http://www.ifea.no/wp- content/uploads/2012/04/A-Vallestad-WISA_becomes_WSAN- Wireless-Summit-2012.pdf, visited on 2015-04-18.

[146] Vesma, J. and T. Saramaki: Interpolation flters with arbitrary frequency re- sponse for all-digital receivers. In Circuits and Systems, 1996. ISCAS ’96., Con- necting the World., 1996 IEEE International Symposium on, vol. 2, pp. 568–571, 1996. DOI:10.1109/ISCAS.1996.541788.

[147] Watteyne, T. et al.: OpenWSN: a standards-based low-power wireless develop- ment environment. Transactions on Emerging Telecommunications Technologies, 23(5):480–493, 2012, ISSN 2161-3915. DOI:10.1002/ett.2558.

[148] Wehmeier, S. (ed.): Oxford Advanced Learner’s Dictionary of Current English. Oxford University Press, 7th ed., 2005, ISBN 978-0-19-4316569.

[149] Welsh, M.: Sensor networks for the sciences. Commun. ACM, 53:36–39, 2010. DOI:10.1145/1839676.1839690.

[150] Wikipedia contributors: Unix time. Wikipedia, The Free Encyclope- dia. https://en.wikipedia.org/w/index.php?title=Unix_time&oldid= 736472521, visited on 2016-08-31.

[151] Wikipedia contributors: Contiki. Wikipedia, The Free Encyclopedia, 2014. http://en.wikipedia.org/w/index.php?title=Contiki&oldid= 636293925, visited on 2015-02-27.

275 Bibliography

[152] Wikipedia contributors: Sun SPOT. Wikipedia, The Free Encyclopedia, 2014. https://en.wikipedia.org/w/index.php?title=Sun_SPOT&oldid= 619609396, visited on 2015-06-18. [153] Wikipedia contributors: Radio clock. Wikipedia, The Free Encyclope- dia, 2015. http://en.wikipedia.org/w/index.php?title=Radio_clock& oldid=655864422, visited on 2015-05-09. [154] Wikipedia contributors: TinyOS. Wikipedia, The Free Encyclopedia, 2015. http://en.wikipedia.org/w/index.php?title=TinyOS&oldid= 647685711, visited on 2015-02-27. [155] Winter, T. et al.: RPL: IPv6 Routing Protocol for Low-Power and Lossy Net- works. RFC 6550 (Proposed Standard), Mar. 2012. http://www.ietf.org/ rfc/rfc6550.txt. [156] Wirth, R. and S. Guttowski: BMBF-Verbundprojekt ”ECoMoS”: Energieau- tarkes Condition Monitoring System. Abschlussbericht, GfM Gesellschaft f. Maschinendiagnose mbH, 2012. DOI:10.2314/GBV:737579714. [157] Wobschall, D. and Y. Ma: Synchronization of wireless sensor networks using a modifed IEEE 1588 protocol. In Precision Clock Synchronization for Measurement Control and Communication (ISPCS), 2010 International IEEE Symposium on, pp. 67–70, 2010. DOI:10.1109/ISPCS.2010.5609778. [158] Yoon, S., C. Veerarittiphan, and M.L. Sichitiu: Tiny-sync: Tight time synchro- nization for wireless sensor networks. ACM Trans. Sen. Netw., 3(2):8, 2007, ISSN 1550-4859. DOI:10.1145/1240226.1240228. [159] Yuan, Y. et al.: Industrial high-speed wireless synchronous data acquisition system with real-time data compression. Measurement, 46(9):3482–3487, 2013, ISSN 0263-2241. DOI:10.1016/j.measurement.2013.06.043. [160] Zangl, H. et al.: Wireless Communication and Power Supply Strategy for Sensor Applications Within Closed Metal Walls. Instrumentation and Mea- surement, IEEE Transactions on, 59(6):1686–1692, 2010, ISSN 0018-9456. DOI:10.1109/TIM.2009.2026602. [161] A fully compliant ZigBee 2012 solution: Z-Stack. Texas Instruments. http: //www.ti.com/tool/z-stack, visited on 2015-04-17. [162] AT86RF231. Atmel. http://www.atmel.com/devices/at86rf231.aspx, visited on 2015-06-30. [163] BitCloud - ZigBee PRO. Atmel. http://www.atmel.com/tools/bitcloud- zigbeepro.aspx, visited on 2015-04-17. [164] Bluetooth Smart Technology: Powering the Internet of Things. http://www. bluetooth.com/pages/bluetooth-smart.aspx, visited on 2015-05-05.

276 Bibliography

[165] CMSIS - Cortex Microcontroller Software Interface Standard. http://www. arm.com/products/processors/cortex-m/cortex-microcontroller- software-interface-standard.php, visited on 2015-03-19. [166] Contiki Hardware. http://www.contiki-os.org/hardware.html, visited on 2015-01-31. [167] Econotag II. http://www.redwirellc.com/collections/frontpage/ products/econotag-ii, visited on 2015-02-04. [168] EmberZNet PRO ZigBee® Protocol Stack Software. Silicon Labs. https://www.silabs.com/products/wireless/zigbee/Pages/zigbee- software.aspx, visited on 2015-04-17. [169] EnOcean Dolphin – the platform for energy harvesting wireless sensor tech- nology. https://www.enocean.com/fileadmin/redaktion/pdf/press/ enocean_dolphin_EN.pdf, visited on 2015-02-04. [170] FreeRTOS™- Market leading RTOS. http://www.freertos.org/, visited on 2015-02-27. [171] INGA - Inexpensive Node for General Applications. https://www.ibr.cs. tu-bs.de/projects/inga/, visited on 2015-01-28. [172] Mica2 - Wireless Measurement System. http://www.snm.ethz.ch/snmwiki/ Projects/Mica2, visited on 2015-02-10. [173] MICAz - Wireless Measurement System. http://www.memsic.com/ userfiles/files/Datasheets/WSN/micaz_datasheet-t.pdf, visited on 2015-02-10. [174] Nano-RK: A Wireless Sensor Networking Real-Time Operating System. http: //www.nanork.org/projects/nanork/wiki, visited on 2015-02-27. [175] NI Wireless Sensor Networks. http://www.ni.com/wsn/, visited on 2015-02- 04. [176] OPENMOTE-CC2538. http://www.openmote.com/hardware/openmote- cc2538-en.html, visited on 2015-02-04. [177] OpenWSN Home. https://openwsn.atlassian.net/wiki/display/OW/ Home, visited on 2015-02-27. [178] Powercast: RF Energy Harvesting and Wireless Power for Low-Power Ap- plications. http://www.powercastco.com/PDF/powercast-overview%20% 282012%29.pdf, visited on 2015-02-04. [179] Preon32 — Innovative 2.4 GHz radio module for Preon32-Series by Virte- nio. http://www.virtenio.com/en/products/radio-module.html, visited on 2015-01-28.

277 Bibliography

[180] Preon32Shuttle — Expansion module for Preon32-Series by Virtenio. http: //www.virtenio.com/en/products/evaluation-module.html, visited on 2015-06-30. [181] Projekt Spisa - Signal Processing Sensor Applications. TU Berlin, Chair of Electronic Measurement and Diagnostic Technology. https://www.mdt.tu- berlin.de/menue/forschung/abgeschlossene_forschungsprojekte/ projekt_spisa/, visited on 2016-10-08. [182] RIOT: The friendly Operating System for the Internet of Things. http://www. -os.org/, visited on 2015-02-27. [183] The Sensor Network Museum™- Tmote Sky. http://www.snm.ethz.ch/ snmwiki/Projects/TmoteSky, visited on 2015-01-31. [184] SNM - The Sensor Network Museum™. http://www.snm.ethz.ch/, visited on 2015-01-31. [185] TELOSB Mote Platform. http://www.memsic.com/userfiles/files/ Datasheets/WSN/6020-0094-02_B_TELOSB.pdf, visited on 2015-06-18. [186] The Contiki OS (Homepage). http://www.contiki-os.org/, visited on 2015-01-28. [187] The Contiki Wiki. https://github.com/contiki-os/contiki/wiki, vis- ited on 2015-07-07. [188] The ZigBee Alliance. http://www.zigbee.org/, visited on 2015-04-11. [189] TinyOS. http://www.tinyos.net/, visited on 2015-02-27. [190] Virtenio GmbH - smart wireless devices. http://www.virtenio.com/en/, visited on 2015-02-26. [191] XBee® Multipoint RF Modules. http://www.digi.com/pdf/ds_ xbeemultipointmodules.pdf, visited on 2015-06-18. [192] Z1 Platform. http://zolertia.com/products/z1, visited on 2015-01-28. [193] ITU-T Recommendation G.810, Defnitions and terminology for synchronisation networks, Aug. 1996. [194] IEEE Standard for Information technology– Local and metropolitan area networks– Specifc requirements– Part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifcations for Low Rate Wireless Personal Area Networks (WPANs). IEEE Std 802.15.4-2006 (Revision of IEEE Std 802.15.4- 2003), pp. 1–320, Sept. 2006. DOI:10.1109/IEEESTD.2006.232110. [195] The International System of Units (SI). Bureau International des Poids et Mesures, 8th ed., 2006, ISBN 92-822-2213-6.

278 Bibliography

[196] IEEE Standard for a Smart Transducer Interface for Sensors and Actua- tors - Common Functions, Communication Protocols, and Transducer Electronic Data Sheet (TEDS) Formats. IEEE Std 1451.0-2007, pp. 1–335, Sept. 2007. DOI:10.1109/IEEESTD.2007.4338161. [197] IEEE Standard for a Smart Transducer Interface for Sensors and Ac- tuators Wireless Communication Protocols and Transducer Electronic Data Sheet (TEDS) Formats. IEEE Std 1451.5-2007, pp. C1–236, Oct. 2007. DOI:10.1109/IEEESTD.2007.4346346. [198] VDI/VDE-Richtlinie 2185: Radio based communication in industrial automa- tion, 2007. [199] Evaluation of measurement data - Guide to the expression of uncertainty in mea- surement (JCGM 100:2008), 2008. http://www.bipm.org/utils/common/ documents/jcgm/JCGM_100_2008_E.pdf, visited on 2015-08-03. [200] IEEE Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems. IEEE Std 1588-2008 (Revision of IEEE Std 1588-2002), pp. c1–269, July 2008. DOI:10.1109/IEEESTD.2008.4579760. [201] IEEE Standard for Digitizing Waveform Recorders. IEEE Std 1057-2007 (Revision of IEEE 1057-1994), pp. 1–168, Apr. 2008. DOI:10.1109/IEEESTD.2008.4494996. [202] MCKPI-G2210L-3672 (Datasheet). Multicomp, 2009. http://www.newark. com/pdfs/datasheets/spc/25R0627.pdf, visited on 2015-11-14. [203] Wireless systems for industrial automation: process control and related applica- tions. Standard ISA-100.11a-2011, 2011. [204] IEEE Standard for Local and metropolitan area networks–Part 15.4: Low-Rate Wireless Personal Area Networks (LR-WPANs) Amendment 1: MAC sublayer. IEEE Std 802.15.4e-2012 (Amendment to IEEE Std 802.15.4-2011), pp. 1–225, Apr. 2012. DOI:10.1109/IEEESTD.2012.6185525. [205] Reliable factory automation - Wireless Automation, 2012. http: //www05.abb.com/global/scot/scot397.nsf/veritydisplay/ da2ecccaededc5cdc1257c210039f241/$file/3ADR071023B0201.pdf, visited on 2015-02-04. [206] Scavenger Transceiver Module STM 300 / STM 300C / STM 300U. enO- cean, Nov. 2012. https://www.enocean.com/de/enocean_module/stm- 300-data-sheet.pdf, visited on 2015-06-15, Data Sheet. [207] STM 3xy wireless sensor transmitter module family. enOcean, June 2013. https://www.enocean.com/de/enocean_module/White_Paper_STM_ 3xy_EN_20.pdf, visited on 2015-06-09, White Paper.

279 Bibliography

[208] Motion Synchronization Using RTSI. National Instruments, Nov. 2014. http: //www.ni.com/white-paper/3522/en/, visited on 2015-06-17. [209] Sensor Transmitter Module STM 330 / STM 331 / STM 330C / STM 332U / STM 333U. EnOcean, Mar. 2015. https://www.enocean.com/de/enocean_ module/stm-330-data-sheet.pdf, visited on 2015-06-15, Data Sheet, V1.2.

280 Publications

[Fun1] Funck, J. and C. Guhmann:¨ Verfahren zur Messung von Synchro- nisationsfehlern in mehrkanaligen Messsystemen. In Schmitt, R. (ed.): XXVI. Messtechnisches Symposium des Arbeitskreises der Hochschullehrer f¨ur Messtechnik e.V. (AHMT), pp. 155–166. AHMT, 2012, ISBN 978-3-8440-1312-2. [Fun2] Funck, J., R. Knoblich, D. Scholz, S. Nowoisky, and C. Guhmann:¨ Draht- loses Messsystem f¨urTemperaturen in Kraftfahrzeugkupplungen. tm - Tech- nisches Messen, 80(3):84–91, Apr. 2013. DOI:10.1524/teme.2013.0014. [Fun3] Funck, J. and C. Guhmann:¨ Time-Synchronous Sampling in Wireless Sen- sor Networks. In 19th IMEKO TC4 Symposium Measurements of Electri- cal Quantities, 2013, ISBN 978-84-616-5438-3, http://www.imeko.org/ publications/tc4-2013/IMEKO-TC4-2013-058.pdf. [Fun4] Funck, J. and C. Guhmann:¨ Comparison of approaches to time-synchronous sampling in wireless sensor networks. Measurement, 56(0):203–214, 2014, ISSN 0263-2241. DOI:10.1016/j.measurement.2014.07.001. [Fun5] Funck, J. and C. Guhmann:¨ Design of a fexible flter for synchronous resam- pling in wireless sensor networks. In 20th IMEKO TC-4 International Sym- posium, Sept. 2014, ISBN 978-92-990073-2-7, http://www.imeko.org/ publications/tc4-2014/IMEKO-TC4-2014-196.pdf. [Fun6] Bock, A., D. Liu, J. Funck, A. Giedymin, R. Burke, and C. Guhmann:¨ Wireless Sensor for Temperature and Flux Measurements in an Axial Flux Machine. In SENSOR 2015, 17th International Conference on Sensors and Measurement Technology, 2015, ISBN 978-3-9813484-8-4. DOI:10.5162/sensor2015/C2.1. [Fun7] Funck, J. and C. Guhmann:¨ A fexible flter for synchronous angular resam- pling with a wireless sensor network. Measurement, 98:393–406, 2017, ISSN 0263-2241. DOI:10.1016/j.measurement.2016.07.062.

281

Supervised students’ theses

[Stud1] Ardanuy, X.: Design of a GUI based on the implemented IEEE1451 standard in a Wireless Sensor Network. Bachelor thesis, TU Berlin, July 2014. [Stud2] Bjorn:¨ Interpolation und Nachabtastung von Messdaten aus einem drahtlosen Sensornetzwerk. Master thesis, TU Berlin, May 2014. [Stud3] Bock: Inbetriebnahme und Plausibilisierung eines Sensors zur Messung der Rotortemperatur eines Asynchronmotors. Studienarbeit, TU Berlin, Nov. 2013. [Stud4] Bock, A.: Implementation of a Wireless Sensor System on an Axial Flux Motor. Diploma thesis, TU Berlin, Feb. 2015. [Stud5] Burisch, P.: Induktive Energieversorgung eines drahtlosen Temper- aturmesssystems. Diploma thesis, TU Berlin, Apr. 2014. [Stud6] Erik, B.: Entwurf und Charakterisierung eines Energy-Harvesting-Moduls f¨ur einen drahtlosen Sensorknoten. Diploma thesis, TU Berlin, Nov. 2011. [Stud7] Haase, P.: Implementation einer CAN-Schnittstelle f¨ureinen Intelligenten Sen- sorknoten. Bachelor thesis, TU Berlin, Jan. 2012. [Stud8] Henckell, B.: Ladezustandssch¨atzungf¨urbatteriebetriebene Sensoren. Bach- elor thesis, TU Berlin, Aug. 2013. [Stud9] Hopp, T.: Intelligenter Sensor zur Leistungsmessung im Dreiphasennetz. Mas- ter thesis, TU Berlin, May 2013. [Stud10]J ahnel,¨ A.: Fourier-basierte Ordnungsanalyse mit einem drahtlosen Sensor- knoten. Bachelor thesis, TU Berlin, July 2014. [Stud11] Kallenbach, E.: Machbarkeitsstudie bez¨uglich eines energieautarken Strom- sensors. Bachelor thesis, TU Berlin, Oct. 2013. [Stud12] Klemm, E.: Bestimmung und Korrektur dynamischer Messfehler von Temper- atursensoren. Bachelor thesis, TU Berlin, June 2014. [Stud13] Krauskopf, S.: Messdatenerfassung mit einem drahtlosen Sensornetzwerk. Bachelor thesis, TU Berlin, Jan. 2013.

283 Supervised students’ theses

[Stud14] Krauskopf, S.: Anbindung eines Android Smartphones an ein drahtloses Sen- sornetzwerk. Master thesis, TU Berlin, Sept. 2014. [Stud15] Matern, S.: Drahtloses Sensormodul zur Demonstration von Anwendungs- beispielen. Bachelor thesis, TU Berlin, Sept. 2015. [Stud16] Moksha Birk: Zeitsynchronisation in einem drahtlosen Single-Hop Sensor- netzwerk. Bachelor thesis, TU Berlin, Mar. 2013. [Stud17] Pawlikowski, J.: Energieautarker drahtloser Sensorknoten zur Raumklimaer- fassung. Diploma thesis, TU Berlin, Apr. 2015. [Stud18] Pertiller, A.: Vergleichende Untersuchung von Verfahren zur Sch¨atzungdes Signal-Rausch-Verh¨altnissesvon Analog/Digital-Umsetzern. Diploma thesis, TU Berlin, Sept. 2012. [Stud19] Peters, O.: Entwurf eines intelligenten K¨orperschallsensors. Studienarbeit, TU Berlin, Nov. 2012. [Stud20] Peters, O.: Diagnose von Unwuchten mit einem drahtlosen intelligenten K¨orperschallsensor. Diploma thesis, TU Berlin, June 2013. [Stud21] Pilgrim, B.: Integration eines drahtlosen Sensornetzwerkes in eine CAN-Bus basierte Messdatenaufnahme. Diploma thesis, TU Berlin, Feb. 2013. [Stud22] Roubal, F.: Akustische Ortung mit einem drahtlosen Sensornetzwerk. Bache- lor thesis, TU Berlin, Aug. 2013. [Stud23] Scholz, D.: Entwicklung eines drahtlosen Temperaturmesssystems f¨ureine Einscheibentrockenkupplung. Diploma thesis, TU Berlin, Mar. 2012. [Stud24] Siegmund, R.: Elektrische Steuerung einer Gleichstrommaschine als mecha- nische Last. Bachelor thesis, TU Berlin, May 2012. [Stud25] Stallenberger, B.: Aufbau eines automatisierten Testsytems f¨ur Analog/Digital-Umsetzer. Bachelor thesis, TU Berlin, Dec. 2011. [Stud26] Stallenberger, B.: Interpolation und Nachabtastung von Messdaten aus einem drahtlosen Sensornetzwerk. Master thesis, TU Berlin, May 2014.

284 Appendix

A. Sensor Nodes

287 A. Sensor Nodes n / b a c a urn osmto pcfd oe osmto a acltdasmn . upyvoltage. supply V 4.5 assuming calculated voltage. was supply consumption V 3 Power assuming specifed. calculated consumption was Current consumption Power specifed. consumption Current AAA-cells 3 by supplied = n information o oe receiving power eeec 17 5][2 11 1,1] [13, [171] unknown [92] active unknown [50] deprecated [167] active reference 2015 in status nefcsSI 2,POn I2C,GPIO SSI, interfaces auatrrrdieF elnBree TU Berkeley Berlin FU MHz 915 redwire GHz 2.4 none manufacturer GHz 802.15.4 2.4 IEEE 802.15.4 AVR w) IEEE Atmel x (l dimensions MHz 868 AVR Atmel none GHz 2.4 voltage MSP430 supply TI 802.15.4 IEEE MSP430 TI resolution ADC ARM7TDMI-S band frequency standard wireless bit CPU family CPU a.sampling-rate max. clock CPU oe active power prtn ytmCniin Contiki system operating oe sleep power RAM FLASH oe sending power a vailable [ [ kS MHz [ [ [ [ [ mW mW mW mW mm [ [ [ [ kB kB bit bit [ / V s ] ] ] ] ] ] ] ] ] ] ] ] 72 0.45 105 87x3. n 30.2 x 48.7 .–. 4.5 2.1–3.6 21 21 10 10 8 12 8 12 16 12 16 32 0 n 300 481 6n 16 16 8 24 9 cntgM1 S IAIG MANTIS INGA GINA ESB M-12 Econotag 6281 4 16 8 2 96 2 01618128 128 116 60 128 b b b b Gnrlproesno nodes. sensor purpose General A.1. : Table 54 74.25 0.036 108 / / / / PO 2,SPI, I2C, GPIO, a cm 6 a n a a a c c c c UART utmfrmware custom . .–23.0 2.5–12 3.7 n n n 90 / / / / 515 15 a n a n a n a mx power) (max. 2 b wSense Braunschweig, UART SPI, I2C, GPIO, 0x4 67x33 x 36.7 40 x 50 (TinyOS) Contiki, n / / / / 39 a 81–120 a a 120–219 a < Colorado of University UART SPI, I2C, GPIO, MOS / a 3 b b b

288 Table A.2.: General purpose sensor nodes (continued) Mica Mica2 MicaZ OpenMote- Preon32 Spisa CC2538 CPU family Atmel AVR Atmel AVR Atmel AVR ARM ARM dsPIC Cortex-M3 Cortex-M3 CPU bit [bit] 8 8 8 32 32 16 CPU clock [MHz] 4 n/a 8 ≤ 32 8 ... 72 7.37 RAM [kB] 4 n/a 4 32 64 2 FLASH [kB] 128 n/a 128 512 256 48 wireless standard none none IEEE 802.15.4 IEEE 802.15.4 IEEE 802.15.4 none frequency band 915 MHz 915 MHz 2.4 GHz 2.4 GHz 2.4 GHz 433 MHz ADC resolution [bit] 10 n/a 10 12 12 12 max. sampling-rate [kS/s] 15 n/a 15 50 1000 100 interfaces GPIO, I2C, SPI, n/a GPIO, I2C, SPI, GPIO, SPI, GPIO, UART, GPIO, UART, UART UART UART, I2C, I2C, SPi, CAN, I2C, SPI USB USB supply voltage [V] 3.0 2.7–3.3 2.7–3.3 2.0–3.6 2.7–3.6 5.6–6.6 power active [mW] 16.5 36 36 39 a 11.1–84.9a n/a power sleep [mW] 0.06 0.054 0.048 0.004a 3.9a n/a power sending [mW] 37.5 117 88.2 111a 47.9–121.8 a n/a power receiving [mW] 31.5 66 95.1 99a 53.1–126.9 a n/a dimensions (l x w) [mm] 57.2 x 31.8 n/a 58 x 22 32.9 x 22.0 27.5 x 19 70 x 74 operating system TinyOS TinyOS Contiki, TinyOS Contiki, (Contiki), Java custom FreeRTOS, OpenWSN, Riot manufacturer Berkeley Berkeley, Berkeley, OpenMote Tech. Virtenio TU Berlin Crossbow Crossbow, Memsic status in 2015 deprecated deprecated active active active deprecated reference [56] [172] [173] [176] [179] [117, 181]

289 n/a = no information available

aCurrent consumption was specifed. Power consumption was calculated assuming 3 V supply voltage. A. Sensor Nodes n / b a a urn osmto pcfdfr33V oe osmto a acltdaccordingly. calculated was consumption voltage. Power supply V. 3.3 V 3 for assuming specifed calculated consumption was Current consumption Power specifed. consumption Current = n information o a.sampling-rate max. prtn ytmJv iySCnii iySn TinyOS Contiki, TinyOS Java system operating rqec ad24Gz24Gz24Gz24Gz24GHz 2.4 Sun GHz 2.4 GHz 2.4 manufacturer 802.15.4 IEEE w) x (l dimensions 802.15.4 IEEE GHz n 2.4 802.15.4 IEEE MSP430 TI 802.15.4 IEEE GHz 2.4 voltage supply 802.15.4 IEEE MSP430 TI resolution ADC ARM920T band frequency standard wireless family CPU eeec 3,12 15 13 13 9][192] 191] [143, active active [183] deprecated [185] active 152] [37, deprecated reference 2015 in status P clock CPU P bit CPU oe active power nefcsn interfaces oe sleep power FLASH RAM oe receiving power oe sending power a vailable [ [ [ [ [ [ [ [ [ [ [ [ kS mm V bit MHz bit mW mW kB kB mW mW ] / ] ] ] ] ] s ] ] ] ] ] ] Gnrlproesno oe (continued) nodes sensor purpose General A.3. : Table Microsystems n n 3.7 n 8 8 180 21 6n 16 16 32 5–4 . . n 5.4 5.4 259–444 .1 .1 .130.033 0.0153 0.015 0.118 064 8n 48 48 4096 1 01 n 10 10 512 uSO eoBToeSyXe Z1 Xbee Sky Tmote TelosB SunSPOT n n / / / / / / n a 21 012 10 12 12 a 5x3 2x8 45c 295. 34.5 x 56.8 32.9 x cm 24.5 80 x 32 31 x 65 a POICSIGI,UART, GPIO, GPIO,I2C,SPI a 445. 181.5 58.5 74.4 a n a eklyMmi oevDigi Moteiv Berkeley,Memsic ≈ / / 0 n 200 a 54709.5 65.4 a . .–. .–. 2.7–3.6 2.8–3.4 2.1–3.6 V 3.0 I2C ≤ n 8 Inc. International POGI,IC SPI, I2C, GPIO, GPIO / / / / / / / / 16 a otk,TinyOS Contiki, a IMSP430 TI a 30 a n a 92 a 8 a 16 a b b b zolteria UART 0.008 86.4 82.2 / a a a a a

290 B. Evaluating the polynomial kernel of a transposed Farrow flter

The flter equation of a transposed Farrow flter is [7]:

M Q−1 ′ ∑ ∑ ′ y(lTs) = x(tn)ha(lTs − tn) (B.1) m=0 q=0 with

Q∑−1 ∑M ha(t) = cm[q] fm(q, t) (B.2) q=0 m=0 and

⎧ ( ′ )m ⎪ 2(t−qTs) ′ ′ ⎨⎪ ′ − 1 , qTs ≤ t < (q + 1)Ts fm(q, t) = ⎪ Ts , (B.3) ⎩⎪ 0, otherwise compare (3.53) to (3.55). The following derivation is given in [7], for the evaluation of ∗ ′ ′ ∗ ′ the polynomial kernel fm at the time t = lTs − tn with qTs ≤ t < (q + 1)Ts:

∗ ′ ′ t = lTs − tn , inserting (3.57): tn = (µn + ln)Ts (B.4) ′ ′ = lTs − (µn + ln)Ts (B.5) ′ ′ = (l − ln)Ts − µnTs (B.6) ′ = (q + 1 − µn)Ts (B.7)

Inserting (B.7) into (B.3) yields:

( ′ ′ )m ′ 2 ((q + 1 − µn)Ts − qTs) fm(q, lTs − tn) = ′ − 1 (B.8) Ts m = (2(q + 1 − µn − q) − 1) (B.9) m = (1 − 2µn) (B.10)

291 B. Evaluating the polynomial kernel of a transposed Farrow flter

′ Now, let’s consider a situation where t = qTs, i.e. an input sample is at exactly the 1 same position as an output sample . For this case follows from (3.57) that l = ln and µn = 0. When evaluating (B.10) for this situation, the result is:

′ m fm(q, qTs) = 1 (B.11) = 1, (B.12)

Yet, the result from (B.3) is:

( ′ ′ )m ′ 2(qTs − qTs) fm(q, qTs) = ′ − 1 (B.13) Ts = (−1)m (B.14)

This contradiction indicates an error in the derivation from (B.4) to (B.7). The problem appears to be in the transition from (B.6) to (B.7). Unfortunately no explanation is given in [7] as to the reasoning behind this step. However, the author assumes the following argument:

′ th th In (B.6), (l − ln)Ts is the distance between the input n input sample and the l output ′ sample rounded up to complete intervals of Ts. Considering that the flter’s impulse ′ response ha is defned piecewise over intervals of Ts, this defnes the interval of ha to ′ ′ ′ ′ evaluate, which is ((q + 1)Ts, qTs]. Thus, (q + 1)Ts = (l − ln)Ts describe the same time interval, as long as tn is not identical to any output sampling instant (see fgure B.1).

Figure B.1.: Reference points for evaluation of polynomial kernel.

1This was observed to happen occasionally on a wireless sensor node using a discrete representation of time.

292 However, if tn is identical to an output sampling instant, the fractional interval becomes ′ ′ µn = 0 and (l − ln)Ts = qTs due to (B.3). Thus, the case of µn = 0 does appear to have been overlooked in [7]. Therefore, (B.10) needs to be extended as follows, in order to always yield correct results:

{ m ′ (1 − 2µn) , µn , 0 fm(q, lTs − tn) = m . (B.15) (−1) , µn = 0

293 C. Application sensors

C.1. Microphone Mikrofon Stützkondensator für IC 1 2 GND

R1 VDD C2 100n

GND VDD 10k C1 6.8n Hochpass

GND R2 470k GND 2 3 6 5

GND VDD 11 4 MCP6004-I/PP IC1A Vorstufe IC1B MCP6004-I/PP 1 7 1

JP1 2 GND 3 1

500k TR1

TR2 500k GND VDD R41 3 R3

10k2 10k JP2 1 10 9 Impedanzwandler JP3

MCP6004-I/PP 1 IC1C 8 AUTHOR: JP4 1 Schmitt-Trigger 3 1 TR3 500k

2 13 12 MCP6004-I/PP IC1D 14 Florian Roubal

JP5 1 GND VDD GPIO15 GPIO13 GPIO11 GI2)GPIO20 (GPIO22) (GPIO21) (GPIO23) PO9GPIO18 GPIO24 GPIO32 GPIO34 GPIO36 GPIO19 GPIO25 GPIO33 GPIO35 GPIO37 GPIO9 GPIO7 GPIO0 GPIO1 P1 16 14 12 10 516 14 12 15 13 11 8 6 4 2 10 8 6 9 4 7 2 5 3 1 15 13 11 9 7 5 3 1 P2 VDD GPIO16 GPIO14 GPIO12 GPIO10 GPIO8 GPIO6 GND RESETN JP6 JP7 JP8 1 1 1

Figure C.1.: Circuit diagram of the microphone module [Stud22].

294 C.2. Current and voltage sensors

C.2. Current and voltage sensors IV IW IU 8 IC4C TL074D 14 14 14 IC2D

U_ADD_STROM 9

IC3D IC1D 10

0k20k 100k 2ADSRMR1_ADD_STROM R2_ADD_STROM R5_IV R5_IU R5_IW 100k 100k 100k 13 12 14 13 12 13 12 IC4D TL074D 7 IC4B 13 12 R4_IV R4_IU R4_IW 100k 100k 100k U_ADD_F1E 0V

6 5

8 8 8

12k 100k

IC3C IC2C IC1C TL074D TL074D TL074D TL074D TL074D TL074D

R1_ADD_F1E R2_ADD_F1E R3_IV R3_IU R3_IW 16,5k 16,5k 16,5k 9 9 9 10 10 10 0V0V 0V 0V 0V 0V ADC2 ADC4 ADC6 1 IW IC4A IU UV TL074D TL074D

U_ADD_F1C

R2_IV R2_IU R1_IU R1_IV R1_IW R2_IW 100k 100k 100k 100k 100k 100k P2 U_ADD_STROM 2P2 4P2 6P2 8P2 10P2 12P2 14P2 16P2 2 3 0V

IU_IN IV_IN IW_IN

91k 100k

PREON32

R1_ADD_F1C R2_ADD_F1C UW 1P2 3P2 5P2 7P2 9P2 11P2 13P2 15P2 UU UV

IV UW UU

4 11 7 7 7

IC2B IC1B ADC1 ADC3 ADC5 IC3B

4 11 P1 2P1 4P1 6P1 8P1 10P1 12P1 14P1 16P1 R5_UU R5_UW R5_UV 100k 100k 100k

6 5 6 5 6 5

4 11 C7 C8100n 100n C9 100n 100n C10 0V0V 0V 0V

U$1

0V

11 1P1 3P1 5P1 7P1 9P1 4 11P1 13P1 15P1 15,4k 15,4k 15,4k R4_UU R4_UW R4_UV 100k 100k 100k C1 C2 10u 10u V+ 1 1 1 L2 L3 IC2A IC1A IC3A 26,1k 26,1k TL074D TL074D 26,1k TL074D TL074D TL074D TL074D 100u 100u R3_F1E_UU R3_F1C_UV R3_F1C_UW R3_F1C_UU R3_F1E_UW R3_F1E_UV 1 2 0V JP5 2 3 2 3 2 3 14 23 C4 0V 0V 0V VDD 10 15 3 22 11 2 13 2 4 13 2 4 13 2 4

JP1 JP2 JP3 COM COM 1u 100n C5

-VOUT +VOUT

C6 R1_UV R1_UU R2_UU 0V R1_UW R2_UW R2_UV 100k 100k 100k 100k 100k 100k

1 U_ADD_SPANNUNG

O +VIN -VIN 2 CONVERTER DC/DC LP2950Z DC2 GND I 1 12 UU_IN UV_IN UW_IN IC5 3 24 13 13 2 4 JP4 L1 100u V+ C3 10u GND

12V U_ADD_F1E U_ADD_F1C

D1

1 1 0V 0V 0V 0V 0V 0V PTC Fuse PTC IU_IN IV_IN IW_IN UU_IN UV_IN UW_IN DUAL-BNC DUAL-BNC DUAL-BNC U V W X1-1 X1-2

Figure C.2.: Circuit diagram of the signal conditioning module [Stud9].

295 C. Application sensors 21.12.15 21.12.15 16:28 f=0.69 /home/jfunck/Forschung/Stro X2-2 X2-1 MKDS_5/2-9,50 MKDS_5/2-9,50 KSI1-5085MM KSI1-5085MM KSI1-5085MM F2 X1-1 12 12 12 X8-1 J2 J1 J13 47k RV3 47k RV4 47k RV1 47k RV2 MKDS_5/2-9,50 X1-2 12 12 12 X8-2 J9 12 J6 12 J3 12

I- I+ J10 12 J7 12 J4 12 LEM2 LV_25-P/SP5

J11 P10 J8 J5 P9 P8 P7 P6 P5 P4 P3 P2 P1 OUT IN -15V +15V V- M V+ LA_35-NP U$2 GND GND C210 C209 100n 100n V+

100n 100n V- M

-15V C109 C110 +15V GND GND RM203 RM201 RM103 RM101 180 180 82 82 RM204 RM202 RM104 RM102 180 180 GND 82 82 GND

100n 6 100n5 100n 6 100n5 -15V

GND +15V -15V C213 C212 GND +15V 11 4 C113 C112 11 4 IC21B TL074CDSMD TL074CDSMD IC11B 7 2 7 2 GND

R210 13 R209 GND R110 13 R109

4k7 4k7 4k7 R213 64Y-5,0k 4k7 4k7 4k7 R113 64Y-5,0k GNDPOT201 GNDPOT101 mwandler/Stromwandler_eagle/CurrentVoltageTransform 10 9 10

C211 9 4k7 R215 C111 4k7 R115 100n 100n IC21C TL074CDSMD TL074CDSMD IC11C 8 2 8 2 R216 R212 R211 4k7 4k7 13 R116 R112 13 R111 10k 10k GND 64Y-500 10k 10k GND

12 13 64Y-500

POT202 12 13 -15V +15V POT102 -15V +15V R217 R117 4k7 4k7 IC21D TL074CDSMD IC11D TL074CDSMD 14 14 k 6k8 3k9 21R202 R201 11R102 R101 k 6k8 3k9 C201 C101 6n8 6n8 GND C202 GND C102 2 3

15n 2 3 15n IC21A TL074CDSMD TL074CDSMD IC11A 1 1 23R204 R203 k 6k8 3k9 13R104 R103 k 6k8 3k9 C203 C103 6n8 6n8 GND C204 GND C104 2 3

15n 2 3

-15V 15n +15V -15V 11 4 +15V 11 4 er.sch (Sheet: 1/1)er.sch TL074CDSMD IC22A IC12A TL074CDSMD

C215 1 C214

C115 1 C114 100n 100n k 6k8 3k9 25R206 R205 100n 100n 15R106 R105 k 6k8 3k9

GND GND GND GND C205 C105 6n8 6n8 GND C206 GND C106 6 5

15n 6 5 15n 22-23-2021 TL074CDSMD IC22B IC12B TL074CDSMD 7 X4-1 X4-2 7 27R208 R207 k 6k8 3k9 k 6k8 3k9 17R108 R107 C207 C107 6n8 X9-5 X9-4 6n8 N GND GND N GND GND C208 C108 10 9 10

15n 9

15n MKDSN1,5/5-5,08 TL074CDSMD IC22C IC12C TL074CDSMD 8 X9-3 X9-2 X9-1 8

POT203 64Y-5,0k POT103 64Y-5,0k 1 3 1 3 2 2 13 12 13 12 -15V rad 470/35 rad +15V rad 470/35 rad C6 C5 TL074CDSMD IC22D IC12D TL074CDSMD + + 14 1-227161-0 1-227161-0 1-227161-0 1-227161-0 14 GND GND GND GND C8 C7 100n 100n X3 X5 X6 X7 GND

Figure C.3.: Circuit diagram of current/voltage transducer modules.

296 C.3. Rotary encoder

C.3. Rotary encoder

GND

LSP3 LSP4 +3V3 P2 GND VDD1 VDD2 F1 ADC0-9,GPIO16 ADC0-8,GPIO15 100nF C2 ADC0-15,GPIO14 ADC0-14,GPIO13 1 T1-CH1,ADC0-1,GPIO6

IC3 SPI0-MISO,ADC0-6,GPIO11 VI 2 L4940V5 GND GND UIRQ8,SPI0-MOSI,ADC0-7,GPIO12 T1-CH2,USART1-TX,ADC0-2,GPIO7 T1-CH3,USART1-RX,ADC0-3,GPIO8 VO UIRQ6,DAC0,SPI-NSS,ADC0-4,GPIO9 UIRQ7,DAC1,SPI0-SCK,ADC0-5,GPIO10 3 UIRQ1,T0-CH1,CAN0-RX,I2C0-SCL,GPIO1 UIRQ0,T0-CH0,CAN0-TX,I2C0-SDA,GPIO0

10uF C1

+ +5V

PREON32-SHUTTLE

LSP1 LSP2 tine/DrehgeberTestplatine_02.sch1/1) (Sheet:

P1 GND RESETN GPIO37,SPI2-MOSI GPIO36,SPI2-MISO,JTAG-NTRST GPIO35,SPI2-SCK,JTAG-TDO GPIO34,SPI-NSS,JTAG-TDI,UIRW14 GPIO33,JTAG-TCK,UIRQ13 GPIO32,JTAG,TMS,UIRQ12 GPIO25 GPIO24 GPIO23,SPI-RF-MOSI GPIO22,SPI-RF-MISO GPIO21-SPI-RF-SCK GPIO20,USART2-CK,SPI1-NSS,UIRQ11 GPIO19,USART2-RX,I2C-SDA,UIRQ10 GPIO18,USART2-TX,I2C-SCL,UIRQ9 GREEN

LED1 150R

516 15

R1

+5V

314 13 GND

GND

112 11 GND

10 9

YELLOW

8 7

LED2

56R

6 5

4 3

R2

+3V3

2 1 GND JP2

6 4 2

VDD VSS 4050N 4050N 4050N 1 8 IC1C IC1B IC1A

IC1P +3V3 GND 100nF C3 7 5 3

IC2EN AM26LS32AC ENABLE

N VCC GND

16 11 8 5 3 IC2C AM26LS32AC +5V IC2B AM26LS32AC IC2A AM26LS32AC IC2P GND C10 100nF 5 3 1 6 2

9 7 1

JP5 10 sationundBerichte/11_Schaltpläne/DrehgeberTestpla +5V GND 6 4 2

13 120R 120R 120R

IC2D AM26LS32AC GND GND GND

C8220pF C9 220pF C6220pF C7 220pF C4220pF C5 220pF

R3 R4 R5

516 15 14

15

314 13 UA0_P UA0_N UA1_P UA1_N UA2_P UA2_N GND

112 11

10 9

8 7 15 12 10

6 5

4 3 4050N 4050N 4050N IC1F IC1E IC1D

2 1 JP1 GND 1 9 14 11 X1 GND

9876 5 4 3 2 +5V 21.12.15 14:13 /home/jfunck/Forschung/wsn/A 14:13 21.12.15 Organi Figure C.4.: Circuit diagram of rotary encoder interface circuit board.

297 D. Angular resampling fler

D.1. Filter design

1 %% Farrow filter % Farrow coefficients 3 c o e f f F a r = [ 1 / 4 8 , 1 / 1 6 , 1 / 1 6 , 1 / 4 8 ; 2 3 / 4 8 , 5 / 1 6 , −1/16 , −1/16; 5 2 3 / 4 8 , −5/16 , −1/16 , 1 / 1 6 ; 1 / 4 8 , −1/16 , 1 / 1 6 , − 1 / 4 8 ] ; 7 M = size(coeffFar ,2) −1; 9 N = size(coeffFar ,1); %% FIR filter (G) at outputs of Farrow filters 11 wp = 0 . 5 ; % passband relative to half of output frequency [1] OSRout = 2 ; % oversampling ratio at input of output stage [1] 13 % band− specification to compensate Farrow filter passband drop 15 F1 = linspace(0,wp / OSRout,20) ; [ hfarpb , ˜ ] = freqps(coeffFar((1+N/ 2 ) : end , : ) ’ , F1 *( OSRout / 2 ) , 1 / ( OSRout ) ) ; 17 D1 = 1 . / h f a r p b ; D1(isnan(D1)) = 1 ; 19 F2 = linspace(0.4,1,100); D2 = zeros(1,length(F2)); 21 % calculate FIR filter coefficients using least −squares optimization 23 d = fdesign .arbmag( ’N,B,F,A’ ,61,2,F1,D1,F2,D2); hG = d e s i g n ( d , ’firls’ ); 25 coeffG = hG. Numerator;

27 %% Ouput decimator (D) 29 % decimation and ripple specification tSNR = 7 4 ; % target SNR [dB] 31 As = tSNR ; % stopband ripple [dB] dp = s q r t ( 2 ) *10ˆ( − tSNR / 2 0 ) ; % passband ripple [1] 33 Ap = 20* log10 ((1+ dp ) /(1 − dp ) ) ; % passband ripple [dB] d = fdesign . decimator(OSRout, ’lowpass’ , ’fp,fst,ap,ast’ ,... 35 wp / OSRout,0.5 ,Ap,As); % calculate FIR decimator coefficients using equiripple method 37 hD = equiripple(d); coeffD = hD. Numerator; Listing D.1: MATLAB code to calculate the coefcients of angular resampling flter.

298 D.1. Filter design

f u n c t i o n [ h , f ] = freqps(c,f,T) 2 % function [h,f] = freqps(c,f ,T) % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 4 % filename: freqp.m % author: Juergen Funck (juergen.funck@tu − b e r l i n . de ) 6 % organisation: TU Berlin % project: wsn 8 % date: 14.02.2014 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 10 % description: calculates the magnitude frequency response of a continuous % piecewise polynomial filter as described in 12 % Vesma1996 ”Interpolation filters with arbitrary frequency % responseforall − digital receivers” and Babic2008 14 % ”Polynomial −Based Interpolation Filters for DSP− Applications” (p. 42) % i n p u t : c − coefficient matrix 16 % f − frequency vector %T − polynomial interval length 18 % % o u t p u t h − frequency response 20 % f − frequency vector

22 % get dimensions [m, n ] = s i z e ( c ) ; 24 M = m−1; N = 2*n ; 26 h = zeros(1,length(f)); 28 f o r i =1:length(f) 30 f o r n = 0 : ( (N/ 2 ) −1) f o r m=0:M 32 h ( i ) = h ( i ) + c (m+1 , n +1) *G(n,m,f(i),T); end 34 end end 36 end 38 f u n c t i o n g = G( n ,m, f , T) 40 w = 2* p i * f *T; i f ( mod (m, 2 ) ==0) 42 % even m g = 2* cos (w*( n + 0 . 5 ) ) * ((( − 1 ) ˆ (m/ 2 ) ) * factorial(m) * P s i (m, f , T) + s i n c ( f * T)); 44 e l s e % odd m 46 g = 2*(( −1) ˆ ( (m+1) / 2 ) ) * factorial(m) * s i n (w*( n + 0 . 5 ) ) * Psi(m,f ,T); end 48 end

50 f u n c t i o n p = P s i (m, f , T) k = 0 : f l o o r ( (m−1) / 2 ) ; 52 p = sum ( ( ( p i * f *T) . ˆ ( 2 * k−m) ) . * (( −1) . ˆ k ) . / factorial(2* k ) . * ... 54 ( s i n c ( f *T) − cos ( p i * f *T). / ( 2 * k +1) ) ) ; end

Listing D.2: Function to calculate the frequency response of a piecewise polynomial flter.

299 D. Angular resampling fler

D.2. MATLAB implementation

1 [ y2 ] = resampleAngularFarrow(double(x) ,1 / param.fin ,tphi ,[] ,hFarOut);

3 % output stage y = filter (hout ,double(y2)); 5 Mout = floor((length(y)−param. Nsettle) / param. fout) * param. fout; y = reshape(y(param. Nsettle + (1:Mout)) ,[] ,1); Listing D.3: MATLAB implementation of angular resampling flter.

f u n c t i o n [y,state ,lk] = resampleAngularFarrow(x,Tin ,tphi , state ,hFarOut) 2 % function [y,state] = resampleAngularFarrow(x,tend , tphi) % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 4 % filename: resampleAngularBlock.m % author: Juergen Funck (juergen.funck@tu − b e r l i n . de ) 6 % organisation: TU Berlin % project: wsn 8 % date: 22.01.2014 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 10 % description: performes angular resampling on a block of data % i n p u t : x − input signal 12 % t e n d − time of last sample % (timeof first sampleis implicitly t0 =0) 14 % t p h i − resampling times with reference to start of block % s t a t e − structure containing the inital filter state 16 % % o u t p u t : y − resampled signal 18 % s t a t e − structure containing the final filter state % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 20 %% parameters % coefficients of farrow filter 22 % c ( n ,m) , n = 1 . . . 4 , m= 1 . . . 4 c = [ 1 / 4 8 , 1 / 1 6 , 1 / 1 6 , 1 / 4 8 ; 24 2 3 / 4 8 , 5 / 1 6 , −1/16 , −1/16; 2 3 / 4 8 , −5/16 , −1/16 , 1 / 1 6 ; 26 1 / 4 8 , −1/16 , 1 / 1 6 , − 1 / 4 8 ] ; M = s i z e ( c , 2 ) −1; 28 N = s i z e ( c , 1 ) ;

30 %% initialization % farrow buffers 32 Min = l e n g t h ( x ) ; Mout = length(tphi); 34 y = zeros(1,Mout);

36 i f (isempty(state)) s t a t e . etaX = z e r o s (M+1 ,1) ; 38 s t a t e . e t a P = z e r o s (M+1 ,1) ; state .yXbuf = zeros(N,1) ; 40 state .yPbuf = zeros(N,1) ; s t a t e . zX = zeros(1,length(hFarOut.Numerator) −1) ; 42 s t a t e . zP = zeros(1,length(hFarOut.Numerator) −1) ; end 44 l k = 1 ; 46 %% filter loop 48 % loop over all input samples f o r k =1:Min 50 % next output interval while ( ( ( k −1) * Tin ) > t p h i ( l k +1) )

300 D.2. MATLAB implementation

52 i f ( ( l k +1) < Mout ) % calculate output sample 54 f o r n = 0 : (N−1) i f ( n <(N−1) ) 56 state .yXbuf(n +1) = state .yXbuf(n +2) ; state .yPbuf(n +1) = state .yPbuf(n +2) ; 58 e l s e state .yXbuf(n +1) = 0 ; 60 state .yPbuf(n +1) = 0 ; end 62 % sum over polynomial order 64 f o r m=0:M state .yXbuf(n +1) = state .yXbuf(n +1)+c ( n +1 ,m+1) * state .etaX(m +1) ; 66 state .yPbuf(n +1) = state .yPbuf(n +1)+c ( n +1 ,m+1) * state .etaP(m +1) ; end 68 end

70 % final output sample [tempX, state .zX] = filter (hFarOut.Numerator ,1, state .yXbuf(1) ,state . zX ) ; 72 [tempP, state.zP] = filter (hFarOut.Numerator ,1, state .yPbuf(1) ,state . zP ) ;

74 y ( l k ) = tempX / tempP ;

76 % increment output index l k = l k +1; 78 % reset integrator buffer 80 s t a t e . etaX = z e r o s (M+1 ,1) ; s t a t e . e t a P = z e r o s (M+1 ,1) ; 82 e l s e break ; 84 end end 86 mu = ( ( k −1) * Tin − t p h i ( l k ) ) / ( t p h i ( l k +1)− t p h i ( l k ) ) ; f = (2* c e i l (mu) −1) *(1 −2*mu) ; 88 f o r m=0:M 90 state .etaX(m+1) = state .etaX(m+1) + x ( k ) *( f ˆm) ; state .etaP(m+1) = state .etaP(m+1) + ( f ˆm) ; 92 end end 94 %% post processing 96 % cut away surplus samples at the end y = y ( 1 : ( lk −1) ) ; 98 end Listing D.4: MATLAB implementation of the transposed Farrow flter for resampling.

301 D. Angular resampling fler

D.3. C implementations

D.3.1. C foating-point implementation

# i n c l u d e "dev/leds.h" 2 # i n c l u d e "arm_math.h"

4 # i n c l u d e "angularResampler.h" # i n c l u d e "firCoeff_f32.h" 6 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 8 static struct { UInt8 pad ; 10 angularFarrowResampler f 3 2 f a r r o w ; a r m f i r i n s t a n c e f 3 2 Gp ; 12 a r m f i r i n s t a n c e f 3 2 Gx ; a r m f i r d e c i m a t e i n s t a n c e f 3 2 D; 14 f l o a t 3 2 t saveP ; f l o a t 3 2 t saveX ; 16 f l o a t 3 2 t GpBuf [ FIR BUFFER SIZE]; f l o a t 3 2 t GxBuf [ FIR BUFFER SIZE]; 18 f l o a t 3 2 t GpState[FIR BUFFER SIZE + FARROW OUTPUT FIR TAPS − 1 ] ; f l o a t 3 2 t GxState[FIR BUFFER SIZE + FARROW OUTPUT FIR TAPS − 1 ] ; 20 f l o a t 3 2 t DState[FIR BUFFER SIZE + OUTPUT FIR TAPS −1]; } r e s a m p l e r ; 22 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / void 24 angularResampler i n i t f 3 2 ( void ) { 26 / * initialize filter D * / a r m f i r d e c i m a t e i n i t f32(&resampler .D, OUTPUT FIR TAPS , DECIMATION FACTOR, 28 outputFirCoeff , resampler.DState , FIR BUFFER SIZE);

30 / * initialize filters G * / a r m f i r i n i t f32(&resampler .Gp, FARROW OUTPUT FIR TAPS , farrowOutputFirCoeff , 32 resampler.GpState , FIR BUFFER SIZE); a r m f i r i n i t f32(&resampler .Gx, FARROW OUTPUT FIR TAPS , farrowOutputFirCoeff , 34 resampler.GxState , FIR BUFFER SIZE);

36 / * initialize farrow filter * / angularFarrowResampler i n i t f32(&resampler.farrow); 38 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 40 UInt32 angularResampler p r o c e s s f32(angularFarrowResamplerInput f 3 2 * in , f l o a t 3 2 t * out , UInt32 * l k ) 42 { / * init local variables * / 44 UInt32 blockSize = 0 ;

46 / * prepare output * / angularFarrowResamplerOutput f 3 2 f a r O u t ; 48 f a r O u t . yP = resampler .GpBuf+resampler.pad; f a r O u t . yX = resampler .GxBuf+resampler.pad; 50 / * farrow filter * / 52 * l k = angularFarrowResampler p r o c e s s f32(&resampler.farrow , in , &farOut);

54 / * reduce block length to next lower even size * /

302 D.3. C implementations

b l o c k S i z e = * l k −1 + resampler.pad; 56 i f (blockSize % 2) { b l o c k S i z e −= 1 ; 58 resampler .pad = 1 ; resampler .saveX = resampler .GxBuf[blockSize ]; 60 resampler .saveP = resampler .GpBuf[blockSize ]; } 62 e l s e { resampler .pad = 0 ; 64 }

66 / * FIRG * / a r m f i r f32(&resampler.Gp, resampler.GpBuf, resampler.GpBuf, blockSize); 68 a r m f i r f32(&resampler.Gx, resampler.GxBuf, resampler.GxBuf, blockSize);

70 / * d i v i s o r * / f o r ( i n t i =0; i

78 / * add samples that were not processed to beginning of next block * / i f (resampler.pad == 1) { 80 resampler .GpBuf[0] = resampler.saveP; resampler .GxBuf[0] = resampler .saveX; 82 }

84 return ( b l o c k S i z e / DECIMATION FACTOR) ; } Listing D.5: Floating-point C implementation of the angular resampling flter.

1 # i n c l u d e "angularFarrowResampler.h"

3 f l o a t 3 2 t farrowCoeff f 3 2 [N POLY*(M POLY+1) ] = { 1 . 0 / 4 8 . 0 , 1 . 0 / 1 6 . 0 , 1 . 0 / 1 6 . 0 , 1 . 0 / 4 8 . 0 , 2 3 . 0 / 4 8 . 0 , 5 . 0 / 1 6 . 0 , − 1 . 0 / 1 6 . 0 , − 1 . 0 / 1 6 . 0 , 5 2 3 . 0 / 4 8 . 0 , − 5 . 0 / 1 6 . 0 , − 1 . 0 / 1 6 . 0 , 1 . 0 / 1 6 . 0 , 1 . 0 / 4 8 . 0 , − 1 . 0 / 1 6 . 0 , 1 . 0 / 1 6 . 0 , − 1 . 0 / 4 8 . 0 } ; 7 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / void 9 angularFarrowResampler i n i t f32(angularFarrowResampler f 3 2 * r e s a m p l e r ) { 11 i f (resampler != NULL) { farrowFilter i n i t f32(&resampler −> f i l t e r X ) ; 13 farrowFilter i n i t f32(&resampler −> f i l t e r P ) ; } 15 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 17 s i z e t angularFarrowResampler p r o c e s s f32(angularFarrowResampler f 3 2 * r e s a m p l e r , 19 angularFarrowResamplerInput f 3 2 * in , angularFarrowResamplerOutput f 3 2 * o u t ) { 21 s i z e t k = 0 ; s i z e t l k = 1 ; 23 f l o a t 3 2 t f [M POLY+ 1 ] ;

25 f o r ( k =1; k<=in −>Min ; k++) { / * next output interval * / 27 while ( ( ( k −1) * in −>Tin ) > in −> t p h i [ l k ] ) {

303 D. Angular resampling fler

i f ( ( l k +1) < in −>Mout ) { 29 / * calculate output samples * / out −>yX[ lk −1] = farrowFilter o u t p u t f32(&resampler −> f i l t e r X ) ; 31 out −>yP [ lk −1] = farrowFilter o u t p u t f32(&resampler −> f i l t e r P ) ;

33 / * increment output index * / l k ++; 35 } e l s e { 37 / * stop producing output samples * / break ; 39 } } 41 / * calculate next fractional interval * / 43 farrowFilter f r a c I n t e r s f 3 2 ( in −>Tin , in −>tphi ,k,lk,f);

45 / * update state of farrow filters for fractional interval * / farrowFilter u p d a t e f32(&resampler −> filterX, f, in −>x [ k −1]) ; 47 farrowFilter u p d a t e f32(&resampler −> filterP , f, 1); } 49 return l k ; 51 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / Listing D.6: Floating-point C implementation of the transposed Farrow flter for resampling.

# i f n d e f FARROW FILTER H 2 # d e f i n e FARROW FILTER H

4 # i n c l u d e "arm_math.h"

6 # d e f i n e M POLY 3 / * polynomial order * / # d e f i n e N POLY 4 / * number of polynomial segments * / 8 typedef struct farrowFilterStruct f32 farrowFilter f 3 2 ; 10 extern f l o a t 3 2 t farrowCoeff f 3 2 [ ] ; 12 / ** structure to hold the coefficients and state of a farrow filter * / 14 s t r u c t farrowFilterStruct f 3 2 { f l o a t 3 2 t * c o e f f ; / * pointer to coefficients * / 16 f l o a t 3 2 t e t a [M POLY+ 1 ] ; / * eta −value buffer * / f l o a t 3 2 t ybuf [N POLY ] ; / * output value buffer * / 18 } ;

20 / ** initializes a farrow filter structure * / s t a t i c i n l i n e void 22 farrowFilter i n i t f32(farrowFilter f 3 2 * f i l t e r ) { 24 f i l t e r −> c o e f f = farrowCoeff f 3 2 ; memset( filter −>eta , 0 , (M POLY+1) * s i z e o f ( f l o a t 3 2 t ) ) ; 26 memset( filter −>ybuf , 0 , N POLY* s i z e o f ( f l o a t 3 2 t ) ) ; } 28 / ** calculates the fractional interval for angular resampling * / 30 s t a t i c i n l i n e void farrowFilter f r a c I n t e r s f32(float32 t Tin, float32 t * t p h i , s i z e t k , s i z e t lk , f l o a t 3 2 t * fm ) 32 { i n t m=0;

304 D.3. C implementations

34 f l o a t 3 2 t f =0; f l o a t 3 2 t mu = ( ( k −1) * Tin − t p h i [ lk −1]) / ( t p h i [ l k ] − t p h i [ lk −1]) ; 36 i f (mu==0) { 38 f = −1; } 40 e l s e { f = (1 −2*mu) ; 42 }

44 fm [ 0 ] = 1 ; fm [ 1 ] = f ; 46 f o r (m=2; m<(M POLY+1) ; m++) { fm [m] = fm [m−1]* f ; 48 } } 50 / ** updates the internal state of a farrow filter with a new fractional i n t e r v a l * / 52 s t a t i c i n l i n e void farrowFilter u p d a t e f32(farrowFilter f 3 2 * filter , float32 t * f , f l o a t 3 2 t x ) 54 { i n t i =0; 56 f o r ( i =0; i <(M POLY+1) ; i ++) { 58 f i l t e r −> e t a [ i ] = f i l t e r −> e t a [ i ] + x* f [ i ] ; } 60 }

62 / ** calculates a new output sample from a farrow filter * / s t a t i c inline float32 t 64 farrowFilter o u t p u t f32(farrowFilter f 3 2 * f i l t e r ) { 66 i n t n =0; i n t m=0; 68 f o r ( n =0; nybuf [ n ] = f i l t e r −>ybuf [ n + 1 ] ; 72 } e l s e { 74 f i l t e r −>ybuf [ n ] = 0 ; } 76 / * sum over polynomial order * / 78 f o r (m=0; m<(M POLY+1) ; m++) { f i l t e r −>ybuf [ n ] = f i l t e r −>ybuf [ n ] + f i l t e r −> c o e f f [ ( N POLY*n )+m]* f i l t e r −> e t a [m] ; 80 } } 82 / * reset integator buffer * / 84 f o r (m=0; m<(M POLY+1) ; m++) { f i l t e r −> e t a [m] = 0 ; 86 }

88 / * return final output sample * / return f i l t e r −>ybuf [ 0 ] ; 90 }

92 # e n d i f / * FARROW FILTER H * / Listing D.7: Helper functions for the transposed Farrow flter (C foating-point).

305 D. Angular resampling fler

D.3.2. C fxed-point implementation

# i n c l u d e "dev/leds.h" 2 # i n c l u d e "arm_math.h" # i n c l u d e "lib/list.h" 4 # i n c l u d e "lib/memb.h"

6 # i n c l u d e "angularResampler.h" # i n c l u d e "firCoeff_q15.h" 8 # d e f i n e DEBUG DEBUG NONE 10 # i n c l u d e "net/ip/uip-debug.h"

12 # d e f i n e BLOCK SIZE 2048 # d e f i n e MAX BUFFER BLOCKS 2 14 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / s t r u c t inputDataBlock { 16 s t r u c t inputDataBlock * n e x t ; UInt32 readInd; 18 angularFarrowResamplerInput q 1 5 i n ; int16 data[BLOCK SIZE]; 20 } ; / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 22 static struct { UInt8 pad ; 24 angularFarrowResampler q 1 5 f a r r o w ; a r m f i r i n s t a n c e q 3 1 Gp ; 26 a r m f i r i n s t a n c e q 3 1 Gx ; a r m f i r d e c i m a t e i n s t a n c e q 3 1 D; 28 q 3 1 t saveP ; q 3 1 t saveX ; 30 q 3 1 t GpBuf [ FIR BUFFER SIZE]; q 3 1 t GxBuf [ FIR BUFFER SIZE]; 32 q 3 1 t DBuf [ FIR BUFFER SIZE / 2 ] ; q 3 1 t GpState[FIR BUFFER SIZE + FARROW OUTPUT FIR TAPS − 1 ] ; 34 q 3 1 t GxState[FIR BUFFER SIZE + FARROW OUTPUT FIR TAPS − 1 ] ; q 3 1 t DState[FIR BUFFER SIZE + OUTPUT FIR TAPS −1]; 36 } r e s a m p l e r ; / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 38 void angularResampler i n i t q15(timestampFunc t popTimestamp) 40 { / * initialize filter D * / 42 a r m f i r d e c i m a t e i n i t q31(&resampler .D, OUTPUT FIR TAPS , DECIMATION FACTOR, outputFirCoeff q31 , resampler.DState, FIR BUFFER SIZE); 44 / * initialize filters G * / 46 a r m f i r i n i t q31(&resampler .Gp, FARROW OUTPUT FIR TAPS , farrowOutputFirCoeff q 3 1 , resampler.GpState , FIR BUFFER SIZE); 48 a r m f i r i n i t q31(&resampler .Gx, FARROW OUTPUT FIR TAPS , farrowOutputFirCoeff q 3 1 , resampler.GxState , FIR BUFFER SIZE); 50 / * initialize farrow filter * / 52 angularFarrowResampler i n i t q15(&resampler .farrow ,popTimestamp);

54 / * initialize resampler * / resampler .pad = 0 ; 56 resampler .saveP = 0 ; resampler .saveX = 0 ; 58 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * /

306 D.3. C implementations

60 UInt8 angularResampler p r o c e s s q15(angularFarrowResamplerInput q 1 5 * in , x d c r D a t a B l o c k * o u t ) 62 { / * init local variables * / 64 UInt32 blockSize = 0 ; UInt8 blockDone = 0 ; 66 UInt32 l k = 0 ;

68 / * prepare output * / angularFarrowResamplerOutput q 1 5 f a r O u t ; 70 farOut.phi0 = 0 ; farOut.dphi = 0 ; 72 f a r O u t . yP = resampler .GpBuf+resampler.pad; f a r O u t . yX = resampler .GxBuf+resampler.pad; 74 / * farrow filter * / 76 l k = angularFarrowResampler p r o c e s s q15(&resampler.farrow , in , &farOut , & blockDone) ;

78 / * set output angle information * / i f (resampler .pad >0) { 80 farOut.phi0 −= (resampler.pad * farOut.dphi) >>16; } 82 out −>timestamp = farOut.phi0; out −>s a m p l e p e r i o d = DECIMATION FACTOR* farOut.dphi; 84 / * reduce block length to next lower even size * / 86 b l o c k S i z e = l k −1 + resampler.pad; i f (blockSize % 2) { 88 b l o c k S i z e −= 1 ; resampler .pad = 1 ; 90 resampler .saveX = resampler .GxBuf[blockSize ]; resampler .saveP = resampler .GpBuf[blockSize ]; 92 } e l s e { 94 resampler .pad = 0 ; } 96 / * FIRG * / 98 a r m f i r q31(&resampler.Gp, resampler.GpBuf, resampler.GpBuf, blockSize); a r m f i r q31(&resampler.Gx, resampler.GxBuf, resampler.GxBuf, blockSize); 100 / * d i v i s o r * / 102 f o r ( i n t i =0; i

114 / * fir decimator * / a r m f i r d e c i m a t e q31(&resampler.D, resampler.GxBuf, resampler.DBuf, blockSize); 116 / * convert to q15 and copy to output * / 118 f o r ( i n t i =0; i <( b l o c k S i z e / DECIMATION FACTOR) ; i ++) { out −>samples [ i ] = ( q 1 5 t)resampler.DBuf[i ]; 120 }

307 D. Angular resampling fler

122 / * add samples that were not processed to beginning of next block * / i f (resampler.pad == 1) { 124 resampler .GpBuf[0] = resampler.saveP; resampler .GxBuf[0] = resampler .saveX; 126 }

128 / * set number of output samples * / out −>repCount = ( b l o c k S i z e / DECIMATION FACTOR) ; 130 return blockDone ; 132 } Listing D.8: Fixed-point C implementation of the angular resampling flter.

# i n c l u d e "angularFarrowResampler.h" 2 # i n c l u d e "lib/timestampBuffer_64.h"

4 # d e f i n e DEBUG DEBUG NONE # i n c l u d e "net/ip/uip-debug.h" 6 q 1 5 t farrowCoeff q 1 5 [N POLY*(M POLY+1) ] = { 683, 2048, 2048, 683, 8 15701, 10240, −2048 , −2048 , 15701 , −10240 , −2048 , 2048 , 10 683 , −2048 , 2048 , −683}; / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 12 s t a t i c inline uint8 t getInitialResamplingInstants(q63 t tstart , q63 t t r e f , angularFarrowResampler q 1 5 * resampler); s t a t i c inline uint8 t updateResamplingInstants(q63 t t r e f , angularFarrowResampler q 1 5 * resampler); 14 s t a t i c i n l i n e q 6 3 t nextTimeStamp(angularFarrowResampler q 1 5 * r e s a m p l e r , u i n t 3 2 t * phi , u i n t 3 2 t * dphi ) ; / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 16 void angularFarrowResampler i n i t q15(angularFarrowResampler q 1 5 * r e s a m p l e r , timestampFunc t popTimestamp) 18 { i f (resampler != NULL) { 20 farrowFilter i n i t q15(&resampler −> f i l t e r X ) ; farrowFilter i n i t q15(&resampler −> f i l t e r P ) ; 22 r e s a m p l e r −> t p h i l S t a t e = −1; r e s a m p l e r −> tphilnextState = −1; 24 r e s a m p l e r −> d e l t a T p h i = 0 ; r e s a m p l e r −>popTimestamp = popTimestamp ; 26 r e s a m p l e r −>p h i = 0 ; r e s a m p l e r −>dphi = 0 ; 28 } } 30 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / s t a t i c i n l i n e q 6 3 t 32 nextTimeStamp(angularFarrowResampler q 1 5 * resampler , uint32 t * phi , u i n t 3 2 t * dphi ) { 34 i n t 6 4 t new = 0 ; u i n t 8 t v a l i d = r e s a m p l e r −>popTimestamp(&new, phi , dphi); 36 i f ( v a l i d ) { 38 return new ; } 40 e l s e { return −1; 42 } }

308 D.3. C implementations

44 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / s t a t i c inline uint8 t 46 getInitialResamplingInstants(q63 t tstart , q63 t t r e f , angularFarrowResampler q 1 5 * r e s a m p l e r ) { 48 while (( resampler −> t p h i l S t a t e < 0) | | ( r e s a m p l e r −> tphilnextState < 0) | | 50 ( r e s a m p l e r −> tphilnextState <= t s t a r t ) ) { / * try updating timestamps * / 52 i f (!updateResamplingInstants(tref , resampler)) { / * update not possible * / 54 return 0 ; } 56 }

58 / * ensure update to new t0 in any case * / r e s a m p l e r −> t p h i l = r e s a m p l e r −> t p h i l S t a t e − t r e f ; 60 r e s a m p l e r −> t p h i l n e x t = r e s a m p l e r −> tphilnextState − t r e f ; r e s a m p l e r −> d e l t a T p h i = ( r e s a m p l e r −> t p h i l n e x t − r e s a m p l e r −> t p h i l ) >>EXP Q; 62 return 1 ; 64 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 66 s t a t i c inline uint8 t updateResamplingInstants(q63 t tref , angularFarrowResampler q 1 5 * r e s a m p l e r ) 68 { u i n t 3 2 t tempPhi =0 , tempDphi = 0 ; 70 q 6 3 t temp = nextTimeStamp(resampler , &tempPhi , &tempDphi);

72 i f ( temp < 0) { / * no valid timestamp in buffer * / 74 return 0 ; } 76 e l s e { / * update timestamp state * / 78 r e s a m p l e r −> t p h i l S t a t e = r e s a m p l e r −> tphilnextState; r e s a m p l e r −> tphilnextState = temp ; 80 r e s a m p l e r −> t p h i l = r e s a m p l e r −> t p h i l S t a t e − t r e f ; 82 r e s a m p l e r −> t p h i l n e x t = r e s a m p l e r −> tphilnextState − t r e f ; r e s a m p l e r −> d e l t a T p h i = ( r e s a m p l e r −> t p h i l n e x t − r e s a m p l e r −> t p h i l )>>EXP Q ; 84 r e s a m p l e r −>p h i = tempPhi ; 86 r e s a m p l e r −>dphi = tempDphi ;

88 return 1 ; } 90 } / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / 92 s i z e t angularFarrowResampler p r o c e s s q15(angularFarrowResampler q 1 5 * r e s a m p l e r , 94 angularFarrowResamplerInput q 1 5 * in , angularFarrowResamplerOutput q 1 5 * out , u i n t 8 t * blockDone ) { 96 s i z e t l k = 1 ; q 1 5 t f [M POLY+ 1 ] ; 98 u i n t 1 6 t s c a l e O u t = 0 x8000 ;

100 PRINTF( "angularFarrowResampler_process_q15... x=%i,%i,%i,...\n" , in −>x [ 0 ] , in −>x [ 1 ] , in −>x [ 2 ] ) ;

102 * blockDone = 0 ;

309 D. Angular resampling fler

104 / * get initial timestamps * / i f (! getInitialResamplingInstants(in −>t 0 +( in −>k +1) * in −>Tin , in −>t0 , resampler)) { 106 return l k ; } 108 / * prepare output * / 110 out −>phi0 = r e s a m p l e r −>p h i ; out −>dphi = r e s a m p l e r −>dphi ; 112 / * f i l t e r loop * / 114 f o r ( ; in −>kMin ; in −>k++) { / * next output interval * / 116 while ( ( ( in −>k +1) * in −>Tin ) >= r e s a m p l e r −> t p h i l n e x t ) { i f ( l k < in −>Mout ) { 118 / * calculate output samples * / out −>yX[ lk −1] = (farrowFilter o u t p u t q15(&resampler −> f i l t e r X ) ) ; 120 out −>yP [ lk −1] = 2*(farrowFilter o u t p u t q15(&resampler −> f i l t e r P ) );

122 / * increment output index * / l k ++; 124 i f (! updateResamplingInstants(in −>t0, resampler)) { return l k ; 126 } } 128 e l s e { / * stop producing output samples * / 130 return l k ; } 132 }

134 / * calculate next fractional interval * / farrowFilter f r a c I n t e r s q 1 5 ( in −>Tin ,resampler −> tphil ,resampler −> deltaTphi ,in −>k , f ) ; 136 / * update state of farrow filters for fractional interval * / 138 farrowFilter u p d a t e q15(&resampler −> filterX, f, in −>x [ in −>k ] ) ; farrowFilter u p d a t e q15(&resampler −> filterP , f, scaleOut / 2 ) ; 140 }

142 / * reset input index * / * blockDone = 1 ; 144 return l k ; } 146 / * −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− * / Listing D.9: Fixed-point C implementation of the transposed Farrow flter for resampling.

# i f n d e f FARROW FILTER Q15 H 2 # d e f i n e FARROW FILTER Q15 H

4 # i n c l u d e "arm_math.h" # i n c l u d e "dev/leds.h" 6 / * exponent of choosen Q format * / 8 # d e f i n e EXP Q ( 1 4 )

10 / * representation of unit (1) in choosen Q format * / # d e f i n e UNIT Q (1<

310 D.3. C implementations

14 # d e f i n e N POLY 4 / * number of polynomial segments * /

16 typedef struct farrowFilterStruct q15 farrowFilter q 1 5 ;

18 extern q 1 5 t farrowCoeff q 1 5 [ ] ;

20 / ** structure to hold the coefficients and state of a farrow filter * / s t r u c t farrowFilterStruct q 1 5 { 22 q 1 5 t * c o e f f ; / * pointer to coefficients * / q 3 1 t e t a [M POLY+ 1 ] ; / * eta −value buffer * / 24 q 6 3 t ybuf [N POLY ] ; / * output value buffer * / } ; 26 / ** initializes a farrow filter structure * / 28 s t a t i c i n l i n e void farrowFilter i n i t q15(farrowFilter q 1 5 * f i l t e r ) 30 { f i l t e r −> c o e f f = farrowCoeff q 1 5 ; 32 memset( filter −>eta , 0 , (M POLY+1) * s i z e o f ( q 3 1 t ) ) ; memset( filter −>ybuf , 0 , N POLY* s i z e o f ( q 6 3 t ) ) ; 34 }

36 / ** calculates the fractional interval for angular resampling * / s t a t i c i n l i n e void 38 farrowFilter f r a c I n t e r s q 1 5 ( q 6 3 t Tin , q 6 3 t t p h i l , q 3 1 t deltaTphi, size t k , q 1 5 t * fm ) { 40 i n t m=0; q 3 1 t f = 0 ; 42 q 3 1 t mu = 0 ; 44 q 3 1 t num = ( k +1) * Tin − t p h i l ; // q 3 1 t num = k* Tin − t p h i l ; 46 i f (deltaTphi!=0) { 48 mu = num / d e l t a T p h i ; } 50 e l s e { l e d s o n (LEDS RED) ; 52 }

54 i f (mu==0) { f = −UNIT Q; / * = −1 in Q17.14 format * / 56 } e l s e { 58 f = (UNIT Q−2*mu) ; } 60 fm [ 0 ] = UNIT Q; / * = 1 in Q1.14 format * / 62 fm [ 1 ] = f ; f o r (m=2; m<(M POLY+1) ; m++) { 64 fm [m] = ( ( q 3 1 t ) fm [m−1]* f )>>EXP Q; } 66 }

68 / ** updates the internal state of a farrow filter with a new fractional i n t e r v a l * / s t a t i c i n l i n e void 70 farrowFilter u p d a t e q15(farrowFilter q 1 5 * f i l t e r , q 1 5 t * f , q 1 5 t x ) { 72 i n t i =0;

74 f i l t e r −> e t a [ 0 ] = f i l t e r −> e t a [ 0 ] + x ;

311 D. Angular resampling fler

76 f o r ( i =1; i <(M POLY+1) ; i ++) { q 3 1 t temp = ( q 3 1 t ) x* f [ i ] ; 78 f i l t e r −> e t a [ i ] = f i l t e r −> e t a [ i ] + ( temp>>EXP Q); } 80 }

82 / ** calculates a new output sample from a farrow filter * / s t a t i c i n l i n e q 3 1 t 84 farrowFilter o u t p u t q15(farrowFilter q 1 5 * f i l t e r ) { 86 i n t n =0; i n t m=0; 88 f o r ( n =0; nybuf [ n ] = f i l t e r −>ybuf [ n + 1 ] ; 92 } e l s e { 94 f i l t e r −>ybuf [ n ] = 0 ; } 96 / * sum over polynomial order * / 98 f o r (m=0; m<(M POLY+1) ; m++) { q 6 3 t temp = ( q 6 3 t ) f i l t e r −> c o e f f [ ( N POLY*n )+m]* f i l t e r −> e t a [m ]; 100 f i l t e r −>ybuf [ n ] = f i l t e r −>ybuf [ n ] + temp ; } 102 }

104 / * reset integrator buffer * / f o r (m=0; m<(M POLY+1) ; m++) { 106 f i l t e r −> e t a [m] = 0 ; } 108 / * return final output sample * / 110 return ( f i l t e r −>ybuf [0] > >15) ; } 112 # e n d i f / * FARROW FILTER H * / Listing D.10: Helper functions for the transposed Farrow flter (C fxed-point).

312 D.3. C implementations

D.3.3. C header fles for foating- and fxed-point

1 # i n c l u d e "mstl/mstl.h" # i n c l u d e "angularFarrowResampler.h" 3 / ** buffer size if filters G * / 5 # d e f i n e FIR BUFFER SIZE 160

7 / ** * \ brief initializes the angular resampler 9 * / void angularResampler i n i t f 3 2 ( void ); 11 void angularResampler i n i t q15(timestampFunc t popTimestamp);

13 / ** * \ brief process a block of input samples 15 * \ param in input structure * \ param out output structure 17 * \ return number of output samples processed * / 19 UInt32 angularResampler p r o c e s s f32(angularFarrowResamplerInput f 3 2 * in , f l o a t 3 2 t * out , UInt32 * l k ) ; UInt8 angularResampler p r o c e s s q15(angularFarrowResamplerInput q 1 5 * in , x d c r D a t a B l o c k * o u t ) ; Listing D.11: Common header for C implementations of the angular resampling flter.

1 # i f n d e f ANGULAR FARROW RESAMPLER H # d e f i n e ANGULAR FARROW RESAMPLER H 3 # i n c l u d e "farrowFilter_f32.h" 5 # i n c l u d e "farrowFilter_q15.h" # i n c l u d e "arm_math.h" 7 ty pede f u i n t 8 t (* timestampFunc t ) ( i n t 6 4 t * timestamp , uint32 t * phi0 , u i n t 3 2 t * dphi ) ; 9 typedef struct resamplerStateStruct f32 angularFarrowResampler f 3 2 ; 11 typedef struct resamplerStateStruct q15 angularFarrowResampler q 1 5 ; typedef struct angularFarrowResamplerInStruct f 3 2 angularFarrowResamplerInput f 3 2 ; 13 typedef struct angularFarrowResamplerInStruct q 1 5 angularFarrowResamplerInput q 1 5 ; typedef struct angularFarrowResamplerOutStruct f 3 2 angularFarrowResamplerOutput f 3 2 ; 15 typedef struct angularFarrowResamplerOutStruct q 1 5 angularFarrowResamplerOutput q 1 5 ;

17 s t r u c t angularFarrowResamplerInStruct f 3 2 { f l o a t 3 2 t * x ; / * array of input signal values * / 19 f l o a t 3 2 t Tin ; / * input sampling interval * / f l o a t 3 2 t * t p h i ; / * array of output sampling instants * / 21 s i z e t Min ; / * number of input samples * / s i z e t Mout ; / * number of output sampling instants * / 23 } ; s t r u c t angularFarrowResamplerInStruct q 1 5 { 25 q 1 5 t * x ; / * array of input signal values * / q 6 3 t Tin ; / * input sampling interval * / 27 q 6 3 t t 0 ; / * timestamp of first sample * / s i z e t Min ; / * number of input samples * / 29 s i z e t Mout ; / * number of output sampling instants * /

313 D. Angular resampling fler

s i z e t k ; / * index to read * / 31 } ;

33 s t r u c t angularFarrowResamplerOutStruct f 3 2 { f l o a t 3 2 t * yX ; 35 f l o a t 3 2 t * yP ; } ; 37 s t r u c t angularFarrowResamplerOutStruct q 1 5 { u i n t 3 2 t phi0 ; 39 u i n t 3 2 t dphi ; q 3 1 t * yX ; 41 q 3 1 t * yP ; } ; 43 s t r u c t resamplerStateStruct f 3 2 { 45 farrowFilter f32 filterX; / * filter for time signal * / farrowFilter f32 filterP; / * filter for pulse signal * / 47 } ; s t r u c t resamplerStateStruct q 1 5 { 49 farrowFilter q15 filterX; / * filter for time signal * / farrowFilter q15 filterP; / * filter for pulse signal * / 51 q 6 3 t tphilState; q 6 3 t tphilnextState; 53 q 6 3 t t p h i l ; q 6 3 t tphilnext; 55 q 3 1 t deltaTphi; u i n t 3 2 t p h i ; 57 u i n t 3 2 t dphi ; timestampFunc t popTimestamp; 59 } ;

61 / ** initialize resampler with default values * / void angularFarrowResampler i n i t f32(angularFarrowResampler f 3 2 * resampler); 63 void angularFarrowResampler i n i t q15(angularFarrowResampler q 1 5 * r e s a m p l e r , timestampFunc t popTimestamp); s i z e t angularFarrowResampler p r o c e s s q15(angularFarrowResampler q 1 5 * r e s a m p l e r , 65 angularFarrowResamplerInput q 1 5 * in , angularFarrowResamplerOutput q 1 5 * out , u i n t 8 t * blockDone) ;

67 / ** processes a block of data * / s i z e t angularFarrowResampler p r o c e s s f32(angularFarrowResampler f 3 2 * r e s a m p l e r , 69 angularFarrowResamplerInput f 3 2 * in , angularFarrowResamplerOutput f 3 2 * o u t ) ;

71 # e n d i f / * ANGULAR FARROW RESAMPLER H * / Listing D.12: Common header for C implementations of the transposed Farrow flter for resampling.

314 E. Results of event timestamping experiments

This section shows the recordings of timestamp diferences and clock updates for all experiments describes in section 6.2. Refer to table 6.4 for information on the individual network confgurations.

E.1. Network confguration 2

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.1.: Timestamp diferences recorded with confguration 2 versus time.

315 E. Results of event timestamping experiments

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.2.: Histogram of timestamp diferences for confguration 2.

316 E.2. Network confguration 3

E.2. Network confguration 3

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.3.: Timestamp diferences recorded with confguration 3 versus time.

317 E. Results of event timestamping experiments

40 20 [Ticks] 1

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000

40 20 [Ticks] 2

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s] Figure E.4.: Clock changes recorded with confguration 3 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.5.: Histograms of timestamp diferences for confguration 3.

100 100 80 80 60 60 40 40 20 20

rel. frequency [%] 0 0 −40 −20 0 20 40 −40 −20 0 20 40 ∆c 31 [Ticks] ∆c41 [Ticks]

Figure E.6.: Histograms of recorded clock updates for confguration 3.

318 E.3. Network confguration 4

E.3. Network confguration 4

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.7.: Timestamp diferences recorded with confguration 4 versus time.

319 E. Results of event timestamping experiments

40 20 [Ticks] 1

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000

40 20 [Ticks] 2

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s] Figure E.8.: Clock updates recorded with confguration 4 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.9.: Histograms of timestamp diferences for confguration 4.

100 100 80 80 60 60 40 40 20 20

rel. frequency [%] 0 0 −40 −20 0 20 40 −40 −20 0 20 40 ∆c 31 [Ticks] ∆c41 [Ticks]

Figure E.10.: Histograms of recorded clock updates for confguration 4.

320 E.4. Network confguration 5

E.4. Network confguration 5

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.11.: Timestamp diferences recorded with confguration 5 versus time.

321 E. Results of event timestamping experiments

40 20 [Ticks] 1

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000

40 20 [Ticks] 2

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s] Figure E.12.: Clock updates recorded with confguration 5 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.13.: Histograms of timestamp diferences for confguration 5.

100 100 80 80 60 60 40 40 20 20

rel. frequency [%] 0 0 −40 −20 0 20 40 −40 −20 0 20 40 ∆c 31 [Ticks] ∆c41 [Ticks]

Figure E.14.: Histograms of recorded clock updates for confguration 5.

322 E.5. Network confguration 6

E.5. Network confguration 6

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.15.: Timestamp diferences recorded with confguration 6 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.16.: Histograms of timestamp diferences for confguration 6.

323 E. Results of event timestamping experiments

E.6. Network confguration 7

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.17.: Timestamp diferences recorded with confguration 7 versus time.

324 E.6. Network confguration 7

40 20 [Ticks] 1

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000

40 20 [Ticks] 2

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s] Figure E.18.: Clock updates recorded with confguration 7 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.19.: Histograms of timestamp diferences for confguration 7.

100 100 80 80 60 60 40 40 20 20

rel. frequency [%] 0 0 −40 −20 0 20 40 −40 −20 0 20 40 ∆c 31 [Ticks] ∆c41 [Ticks]

Figure E.20.: Histograms of recorded clock updates for confguration 7.

325 E. Results of event timestamping experiments

E.7. Network confguration 8

40 20 [Ticks]

1 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 N,T

t −20

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 40 20 [Ticks]

2 0 ,T 1

T −20 t

∆ −40 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s]

Figure E.21.: Timestamp diferences recorded with confguration 8 versus time.

326 E.7. Network confguration 8

40 20 [Ticks] 1

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000

40 20 [Ticks] 2

T 0 c

∆ −20 0 200 400 600 800 1000 1200 1400 1600 1800 2000 t [s] Figure E.22.: Clock updates recorded with confguration 8 versus time.

60

[%] 40 rel. f 20 0 −20 −10 0 10 20 −20 −10 0 10 20 −20 −10 0 10 20 ∆tN,T1 [Ticks] ∆tN,T2 [Ticks] ∆tT 1,T2 [Ticks]

Figure E.23.: Histograms of timestamp diferences for confguration 8.

100 100 80 80 60 60 40 40 20 20

rel. frequency [%] 0 0 −40 −20 0 20 40 −40 −20 0 20 40 ∆c 31 [Ticks] ∆c41 [Ticks]

Figure E.24.: Histograms of recorded clock updates for confguration 8.

327

Advances in Automation Engineering Hrsg.: Prof. Dr.-Ing. Clemens Gühmann ISSN 2509-8950 (print) ISSN 2509-8969 (online)

1. Nowoisky, Sebastian: Verfahren zur Identifkation nichtlinearer dynami- scher Getriebemodelle. - 2016. - VIII, 224 S. ISBN 978-3-7983-2854-9 (print) 15,00 EUR ISBN 978-3-7983-2855-6 (online) DOI 10.14279/depositonce-5420

2. Huang, Hua: Model-based calibra- tion of automated transmissions. - 2016. - XXIV, 134 S. ISBN 978-3-7983-2858-7 (print) 14,00 EUR ISBN 978-3-7983-2859-4 (online) DOI 10.14279/depositonce-5461

3. Röper, Jan: Entwicklung eines virtuellen Getriebeprüfstands. - 2017. - xxvi, 133 S. ISBN 978-3-7983-2951-5 (print) 14,00 EUR ISBN 978-3-7983-2592-2 (online) DOI 10.14279/depositonce-6073 9 ISBN 978-3-7983-2980-5 Universitätsverlag derTUBerlin ISBN 978-3-7983-2981-2(online) ISBN 978-3-7983-2980-5(print) 783798 329805 Synchronous data acquisitonwithwireless sensor networks tracking at aninductonmotor test bench. order simple a and line straight a on nodes sensor two of localizatonacoustc the siton: Twoapplicatonimplementedexamplesdataillustrate the to acqui areof used utlity the is described,onwhichthedeveloped data acquisitonmethods have beenimplemented. practcalmachine‘sWSNrotatonsynchronous realizatonThe a a shaf.the siton toof of reactveapproachfacilitatesthe that shown data is acqui It reactveone. a proactve and can a developed: applicatonare acquisiton data synchronousan to approaches for distnctTwo estmated. requiredbe accuracy synchronizaton the also but assessed, be can uncertainty measurementoverall the synchronizatonto the of contributon the only not way,This informaton. tming the of uncertainty as expressed be should accuracy zaton synchroni that shown, is it model this of help the system.With acquisiton data channel mult- generic a as modeled is WSN A results. measurement of quality and accuracy ton synchroniza- between relaton investgatesthe thesis This nodes. diferent of acquisiton developments.One ofthebiggest challenges,WSN, when using synchronizing is the data Wireless sensornetworks (WSN) are predicted to play a key rolefuture in technological htp://verlag.tu-berlin.de - - -

Jürgen Helmut Funck Synchronous data acquisiton with wireless sensor networks 4 with Synchronous data acquisiton Jürgen HelmutFunck Universitätsverlag derTUBerlin Editor: ClemensGühmann Advances inAutomaton Engineering wireless sensornetworks

Band4