# A Novel Low-Cost Real-Time Power Measurement Platform for LoWPAN IoT Devices

Authors: Yang Liu; Yubing Wang; Weiwei Gao; Wuxiong Zhang; Hua Qian; Yang Yang
Journal: Mobile Information Systems
 (2017)

---

## Abstract

With the rapid development of technology and application for Internet of Things (IoT), Low-Power Wireless Personal Area Network (LoWPAN) devices are more popularly applied. Evaluation of power efficiency is important to LoWPAN applications. Conventional method to evaluate the power efficiency of different LoWPAN devices is as follows: first measure the current of the devices under working/idle/sleep state and then make an average and estimation of the lifetime of batteries, which deeply relied on the accuracy of testing equipment and is not that accurate and with high cost. In this work, a low-cost, real-time power measurement platform called PTone is proposed, which can be used to detect the real-time power of LoWPAN devices (above 99.63%) and be able to determine the state of each module of DUT system. Based on the PTone, a novel abnormal status diagnosis mechanism is proposed. The mechanism can not only judge abnormal status but also find accurate abnormal status locating and classify abnormal status accurately. According to the method, each state of Device Under Test (DUT) during wireless transmission is estimated, different abnormal status can be classified, and thus specific location of abnormal module can be found, which will significantly shorten the development process for LoWPAN devices and thus reduce costs.


---

## Body

## 1. Introduction

The rapid development of information technology, for example, 3G/4G mobile communication technology and the Internet of Things (IoT), have largely changed our everyday lives. LoWPAN devices are more popularly developed for embedded applications in biomedical electronics, wireless sensor networks, and environment monitoring [1–6]. LoWPAN devices are indispensable for modern electronic applications, and numerous hardware/software techniques have been developed for drastically reducing functional power dissipation [7–9].In order to reduce the amount of unused power from existing devices, engineers engaged in the development of battery power-supply device are facing huge pressure to reduce the consumption of power. Many methods for reducing power consumption of the system have been proposed [10–12]. They are therefore exploring component level dynamic power consumption, which is difficult to measure, especially for low-power devices used in IoT enabled products, because of the limited dynamic range, large measurement noise, and limited bandwidth. For example, most of the battery-powered devices have low-power sleep mode that consumes very little supply current such as less than 1 μA, while the active mode usually requires more than 10 mA current. It is difficult to measure such a wide dynamic range of currents with a single measurement. Otherwise, the testing of these low-cost, low-power devices is a daunting task; since such devices are cost-sensitive, test cost is a major consideration [13, 14].For the development of low-power devices and applications, power (or current) measurement is important. Thus, in order to fulfill the requirements for power consumption reduction, precise dynamic current waveform measurement and debug are required. In this paper, a low-cost, real-time current measurement system is proposed which is capable of digitizing a wide range of current, classifying different abnormal status, and providing specific location of abnormal module and significantly shortening the development process. The system consists of a power measurement platform called PTone and a novel abnormal status diagnosis mechanism which is proposed based on PTone.A power measurement platform called PTone can be used to detect the real-time power of LoWPAN devices and be able to determine the state of each module of DUT system which is meaningful to the R&D on LoWPAN devices/applications. By comparing the power consumption of well-performance device and DUT in corresponding state of the device system, the abnormal status can be estimated and detected. Our hardware implementation approach would be described in detail in Section3.In traditional abnormal status detection, the usual practice is just judging abnormal status or not. No approaches are developed to find accurate abnormal status locating and abnormal status classification for IoT devices. In order to classify different abnormal status, a novel abnormal status diagnosis mechanism based on sliding-window feature extraction (SWFE) is proposed based on PTone.Although much research has been done in designing systems for the detection of abnormal status to perform feature selection, to the best of our knowledge, no specific approaches have been developed for IoT devices. The work in [15, 16] developed a grained approach to perform feature selection, but enormously increasing computational complexity. A few attempts have been proposed. Wang et al. [17] developed a system to implement Bloom filters which avoids some of the computational complexity. Despite the improvement in complexity, effective Bloom filter implementation may not be possible on resource constrained embedded devices [18]. Additional approaches at improving computational complexity have been explored. McPAD [19] measures features using a sliding window to analyze pairs of bytes. References [20, 21] also use a sliding-window approach to extract features from the payload. Although these improvements obtain reliable detection results, their approaches are not able to reduce computational complexity.First, we design a work state detection algorithm (WSDA), which is able to approximate start and end points of active time in work state by continuously moving a sliding window on the observed waveform. According to the start and end points of active time in work state, we can extract the waveform series in the work state for further analysis instead of using the whole waveform. PTone chooses features based on unique features of each active period in work state of LoWPAN devices, which allow us to extract the features of power waveform more accurately. Then the Support Vector Machine (SVM) is used to compare the profiles of measured waveform data series for classifying different abnormal status. Finally, we investigate whether PTone can accurately classify DUT system status based on the waveform features extracted above and verify classification accuracy through some experiments. The system considers different aspects of testing low-power device, which cannot be measured by the previous measurement due to the fact that they cannot detect the broadband low level of current waveform.The remainder of this paper is organized as follows. Section2 provides an overview of system description. Section 3 describes our hardware implementation approach for PTone in detail. Section 4 describes our abnormal status classification algorithm in detail and provides evaluation of the performance of our approach. Section 5 concludes the paper.


## 2. System Description

### 2.1. Overview

Nowadays, there is strong request to design a real-time power measurement platform for LoWPAN devices, with applications to sensing in environments where it is difficult or impossible to change batteries and where the exact position of the devices might not be known.We propose a power measurement platform called PTone which can be used to detect the real-time power of LoWPAN devices and be able to determine the state of each module of DUT system which is meaningful to the R&D on LoWPAN devices/applications. By comparing the power consumption of well-performance device and DUT in corresponding state of the device system, the abnormal module can be estimated and detected.PTone consists of a low-cost power detection hardware platform and a service (such as a laptop), as shown in Figure1.Figure 1
System composition.In order to reduce the power consumption, LoWPAN devices’ wireless communication is typically divided into work state and sleep state. In work state, LoWPAN devices have several periods of active time: receiving beacon signal from a device, replying Acknowledgement (ACK) of the beacon signal, sending data packet to the devices, and receiving ACK of the transmitted data packet. In sleep state, LoWPAN devices enter low-power status to extend battery life.When a LoWPAN device receives a wireless connection request from source device, LoWPAN device takes step into work state to send ACK and then keeps quiet for a short time to wait for the preparation of source device. Work states and sleep states constitute a period of wireless communication, as shown in Figure2. We can evaluate the status of LoWPAN devices system according to the impact of power consumption on the power waveforms change because different components in the devices have unique power consumption.Figure 2
Typical working process of LoWPAN devices.However, there are three key technical challenges. The first technical challenge is to segment the power waveforms to identify start time and end time of the active period in work state. We studied the characteristics of typical power waveforms of different kind of LoWPAN devices. We observed that the power waveforms are periodic and power consumption has obvious significant increase which causes power pulses during each active time in work state. We also observed that the period of DUT system is stable, and the intervals and amplitude of power pulses also are regular. Based on this observation, we design a power waveform feature extraction algorithm which is able to approximate start and end points of active time in work state by continuously moving a sliding window on the observed waveforms.The second technical challenge is to extract the feature of power waveforms for generating classification model for each status of the DUT system. As the power consumption of components is similar, it is hard to distinguish the noise signal in the waveforms which is introduced by various factors, such as circuit noise of the DUT and measuring platform. Some conventional features such as maximum peak power, RMS deviation, the intervals between power pulses, entropy, and the number of power pluses cannot be directly used for the classification. To address this challenge, we apply aHampel filter on the power consumption waveforms to extract the valuable signals which contain the power change caused by system perform and detect and remove the outlier signal caused by digital circuit noise.Hampel filter computes the median value of the sample and its surrounding samples. It also estimates the standard deviation of each sample about its window median using the median absolute deviation which can used to remove abnormal point in the waveform series.The third technical challenge is to compare the profiles of filtered waveforms, which is hard to realize in real-time based on Commercial-Off-The-Shelf (COTS) power detection platform which usually just provides real-time display or records of the power consumption, so a kind of low complexity algorithm for feature comparison needs to be designed. The mean values of power in each work state align with each other because the estimated value of start and end points are different from the true value which would lead to much higher errors in mean value. Moreover, the interval time of different work state is fluctuant over time, and there may be different interval time of work state in the same system status. Therefore, mean value of power and interval time of work state are not enough to identify the system statues. We need to combine them with more waveform features to classify system statuses.To address this challenge, PTone uses extracted features to train a Support Vector Machine (SVM) and achieves the classification of multiple system status and uses maximum posterior probability (MAP) obtained by the SVM to estimate the system status. MAP can be used to obtain a point estimate of an unobserved quantity based on measured data.The key novelty of this paper is on proposing the first low-cost power measure platform and an effective status detection method for LoWPAN DUT system. In this paper, we have shown that fine grained status detection method is possible by analyzing and processing measured power waveforms properly. We also have taken some experiments to prove that the techniques proposed in this paper can be used for the proposed low-cost power measure platform. Examples include the detection of two common faults of microcomputer control unit and two often encounter problems in radio frequency module in different type of LoWPAN DUTs. Our PTone techniques can be potentially used to detect a wider range of system status by building a more complete component power consumption model in the future.


## 2.1. Overview

Nowadays, there is strong request to design a real-time power measurement platform for LoWPAN devices, with applications to sensing in environments where it is difficult or impossible to change batteries and where the exact position of the devices might not be known.We propose a power measurement platform called PTone which can be used to detect the real-time power of LoWPAN devices and be able to determine the state of each module of DUT system which is meaningful to the R&D on LoWPAN devices/applications. By comparing the power consumption of well-performance device and DUT in corresponding state of the device system, the abnormal module can be estimated and detected.PTone consists of a low-cost power detection hardware platform and a service (such as a laptop), as shown in Figure1.Figure 1
System composition.In order to reduce the power consumption, LoWPAN devices’ wireless communication is typically divided into work state and sleep state. In work state, LoWPAN devices have several periods of active time: receiving beacon signal from a device, replying Acknowledgement (ACK) of the beacon signal, sending data packet to the devices, and receiving ACK of the transmitted data packet. In sleep state, LoWPAN devices enter low-power status to extend battery life.When a LoWPAN device receives a wireless connection request from source device, LoWPAN device takes step into work state to send ACK and then keeps quiet for a short time to wait for the preparation of source device. Work states and sleep states constitute a period of wireless communication, as shown in Figure2. We can evaluate the status of LoWPAN devices system according to the impact of power consumption on the power waveforms change because different components in the devices have unique power consumption.Figure 2
Typical working process of LoWPAN devices.However, there are three key technical challenges. The first technical challenge is to segment the power waveforms to identify start time and end time of the active period in work state. We studied the characteristics of typical power waveforms of different kind of LoWPAN devices. We observed that the power waveforms are periodic and power consumption has obvious significant increase which causes power pulses during each active time in work state. We also observed that the period of DUT system is stable, and the intervals and amplitude of power pulses also are regular. Based on this observation, we design a power waveform feature extraction algorithm which is able to approximate start and end points of active time in work state by continuously moving a sliding window on the observed waveforms.The second technical challenge is to extract the feature of power waveforms for generating classification model for each status of the DUT system. As the power consumption of components is similar, it is hard to distinguish the noise signal in the waveforms which is introduced by various factors, such as circuit noise of the DUT and measuring platform. Some conventional features such as maximum peak power, RMS deviation, the intervals between power pulses, entropy, and the number of power pluses cannot be directly used for the classification. To address this challenge, we apply aHampel filter on the power consumption waveforms to extract the valuable signals which contain the power change caused by system perform and detect and remove the outlier signal caused by digital circuit noise.Hampel filter computes the median value of the sample and its surrounding samples. It also estimates the standard deviation of each sample about its window median using the median absolute deviation which can used to remove abnormal point in the waveform series.The third technical challenge is to compare the profiles of filtered waveforms, which is hard to realize in real-time based on Commercial-Off-The-Shelf (COTS) power detection platform which usually just provides real-time display or records of the power consumption, so a kind of low complexity algorithm for feature comparison needs to be designed. The mean values of power in each work state align with each other because the estimated value of start and end points are different from the true value which would lead to much higher errors in mean value. Moreover, the interval time of different work state is fluctuant over time, and there may be different interval time of work state in the same system status. Therefore, mean value of power and interval time of work state are not enough to identify the system statues. We need to combine them with more waveform features to classify system statuses.To address this challenge, PTone uses extracted features to train a Support Vector Machine (SVM) and achieves the classification of multiple system status and uses maximum posterior probability (MAP) obtained by the SVM to estimate the system status. MAP can be used to obtain a point estimate of an unobserved quantity based on measured data.The key novelty of this paper is on proposing the first low-cost power measure platform and an effective status detection method for LoWPAN DUT system. In this paper, we have shown that fine grained status detection method is possible by analyzing and processing measured power waveforms properly. We also have taken some experiments to prove that the techniques proposed in this paper can be used for the proposed low-cost power measure platform. Examples include the detection of two common faults of microcomputer control unit and two often encounter problems in radio frequency module in different type of LoWPAN DUTs. Our PTone techniques can be potentially used to detect a wider range of system status by building a more complete component power consumption model in the future.


## 3. Hardware Implementation

### 3.1. Hardware Overview

The block diagram of the proposed current measurement platform is shown in Figure3. As seen from the figure, the block diagram mainly consists of five parts:(1)
Analog signal detection circuit(2)
Programmable-gain instrumentation amplifier (PGA)(3)
Analog-to-digital converter circuit (ADC)(4)
Microcontroller unit (MCU)(5)
Power-supply moduleFigure 3
Block diagram for implementation.Signal detection sensor in this figure represents a sensitive resistor with very small resistance value. According to the voltage across this sensor, the power consumption of DUT can be calculated accurately. However, the instantaneous current of LoWPAN devices is usually very small, which makes it hard to measure the current directly.Therefore, a controllable gain amplifier is required to amplify the low voltage at the signal detection sensor output, which is represented by PGA in Figure3. Then the analog signal amplified by PGA needs to be sampled and converts to digital signal by analog-to-digital converter circuit, which is represented by ADC in the figure.In order to achieve wide dynamic range of gain, wide bandwidth, and low noise and high linearity and digitize a wide range of signals, it is necessary to set the value of reference voltage and input gain of PGA and output data rate of ADC to reasonable values by system control module represented by MCU in the figure. The functional characteristics of proposed system are shown in Table1.Table 1
Functional characteristics.
Key features Specification Current measurement range 0.5 uA to 200 mA Power measurement range 1.65 uW to 10 W Output data rates 10 to 14 kSPS Maximum CMRR 140 dB Operating temperature −40°C to 105°C


### 3.2. Programmable-Gain Instrumentation Amplifier (PGA)

In order to obtain suitable output voltage that can be digitized directly, PGA281 is used as the instrumentation amplifier with digital gain control in Figure3. PGA281 offers excellent DC precision and long-term stability using modern technology with internal filters that minimize noise. The output stage connects to the low-voltage supply. The PGA is carried out by improved parallel feedback based Flipped Voltage Follower (FLV) to achieve wide dynamic range of gain, wide bandwidth, and low noise and high linearity.The input voltage gain of PGA281 is in the range of 0.125 to 128 in binary steps. The output stage has a gain adjustment factor, 1 or 1.37, to adjust gain to the optimal value. Desired gain can be selected by controlling digital input G4:G0 and the gain of PGA is set toAPGA.In the hardware interface circuit of the proposed system, we use a resistor with resistanceR, which is very small and sensitive to the change of current. The voltage at the resistor is represented by UR, and the current across the resistor is given by(1)IR=UR×1R.R P G A i n stands for the input impedance of PGA. And RDUTin stands for the input impedance of DUT. Similarly, the current across the DUT is given by(2)IDUTin=UR×R+RPGAinR×RPGAin.The output voltage of UADCin the PGA is given by(3)UPGAout=APGA×UR=APGAIDUTinR×RPGAinR+RPGAin.APGA stands for the gain of PGA.


### 3.3. Analog-to-Digital Converter (ADC)

Analog-to-digital converter circuit used ADS1259 to digitize the signals at PGA281 output. ADS1259 outputs 24 bits of conversion data in binary format. Combined with a signal amplifier, a high-resolution, high-accuracy measurement system is formed that is capable of digitizing a wide range of signals.Depending on different input values, the ADS1259 has corresponding output codeNADC, a 24-bit hexadecimal number. If the voltage of input signal UADCin is larger than positive full-scale input VREF, the output code of ADC is set to 7FFFFFh. UADCin is provided by the PGA and equal to the output voltage of PGA; namely, UPGAout=UADCin. If the input voltage of ADC is less than -VREF223/223-1, the output code of ADC is set to 800000H. And if the input voltage is in the interval of -VREF223/223-1,VREF, the input signal can be digitized to a dynamic output code, which can be expressed as(4)NADC=UADCin223-1VREF.According to Nyquist Theorem, the input analog signal can be recovered without distortion; thus voltage of input analog signalUADCin can be measured based on the value of NADC.


### 3.4. Microcontroller Unit (MCU)

In order to configure the value of reference voltage and input gain of PGA and output data rate of ADC and calculate the data obtained from ADC outputs, a low-power and high-speed MCU, namely, STM32L151, is used in the system control module of the proposed system. STM32L151 device has high-performance ARM core operating at a 32 MHz frequency, as well as high-speed embedded memories having up to 128 Kbytes of flash memory and up to 16 Kbytes of RAM. Moreover, the STM32L151 device contains standard and advanced communication interfaces, such as USARTs and USBs, which can transmit measured data to computer for record and further analysis. Due to the good performance and low-cost of STM32L151 device, the proposed system is well represented in the configuration of a variety of parameters of the system and data processing.


### 3.5. Power-Supply Module

A power-supply module has been elaborated in order to satisfy the power requirement of PGA, ADC, and MCU.The PGA281 requires three supply voltages: the high-voltage analog supply, the low-voltage output amplifier supplies, and the digital I/O supply. The high-voltage analog supplies, which include negative high-voltage supply (VSN) and positive high-voltage supply (VSP), power the high-voltage input stage section and are set to±12 V in the proposed system. The voltage of USB is 5 V, which cannot provide ±12 V power supply, so that a DC-DC boosting circuit based on MC34063 which is a DC/DC converter is proposed. The power-supply module can provide stable power which improve the stability of the system.


### 3.6. Parameter Measured by the Proposed System

The proposed system is developed as a low-cost, high-resolution, high-accuracy, real-time measurement system for the power LoWPAN devices. It can measure and estimate instantaneous current, average current, average power, and instantaneous power.The instantaneous current of the DUT is measured in a sampling interval, which is given by(5)IDUTinn=NADCnVREF/223-1R+RPGAinAPGAR×RPGAin.I D U T i n n stands for the current value in nth sampling interval.The average current valueIaverage is computed once per cycle Ns, which can be calculated by (6)Iaverage=1Ns∑n=1NsIDUTinn=1Ns∑n=1NsNADCnVREF/223-1R+RPGAinAPGAR×RPGAin.The input impedance of PGA is very large and the impedance ofR is very small, which is usually set to 10 Ω; that is, RPGAin≫R. Therefore, the instantaneous current of DUT can be simplified to the following:(7)IDUTinn≈URR=NADCnVREF/223-1APGA×R.Similarly, the average current value can be expressed as follows:(8)Iaverage=1Ns∑n=1NsNADCnVREF/223-1APGA×R.Assuming the batteryE of DUT is ideal, and the voltage of the battery is not time-varying; that is, UE is a constant. The average power of the DUT is calculated once per cycle Ns, which is shown as follows:(9)Paverage=IaverageUE-Iaverage2R×RPGAinR+RPGAin.Due to the fact thatRPGAin≫R and R→0, the equation can be expressed as(10)Paverage=IaverageUE=UE×1Ns∑n=1NsIDUTinn.The instantaneous power is the power consumption of DUT in each sampling slot, which is given by(11)Pn=UE×IDUTinn.The measured instantaneous power can be set to computer through Universal Asynchronous Receiver/Transmitter (UART) for further research.In all equations,VREF is the difference between the voltage values of positive reference absolute input and negative reference absolute input of ADC. Ns, R, and APGA are known parameters. NADCn is a value measured by ADC in a sample interval, and according to NADCn, we can measure and calculate the value of the instantaneous current, average current, average power, and instantaneous power of DUT. The description of the symbols in the equations above is summarized in Table 2.Table 2
Symbols description.
Symbols Meaning U R Analog voltage of signal detection senor R D U T i n Input impedance of DUT R P G A i n Input impedance of PGA A P G A Gain of PGA U A D C i n Analog input voltage of ADC U P G A o u t Analog output voltage of PGA N A D C Digital output of ADC I D U T i n n Digital current value innth sampling interval provided by MCU V R E F Reference voltage of PGA controlled by MCUAs shown in Figure4, DUT is a kind of LoWPAN device, which periodically builds a wireless connection with another LoWPAN device. The proposed system is connected to the DUT via an interface reserved for power measurement. The measured data will be calculated and transmitted to computer for record and further analysis via USB cable. The battery can supply the power of DUT.Figure 4
Hardware setup.


## 3.1. Hardware Overview

The block diagram of the proposed current measurement platform is shown in Figure3. As seen from the figure, the block diagram mainly consists of five parts:(1)
Analog signal detection circuit(2)
Programmable-gain instrumentation amplifier (PGA)(3)
Analog-to-digital converter circuit (ADC)(4)
Microcontroller unit (MCU)(5)
Power-supply moduleFigure 3
Block diagram for implementation.Signal detection sensor in this figure represents a sensitive resistor with very small resistance value. According to the voltage across this sensor, the power consumption of DUT can be calculated accurately. However, the instantaneous current of LoWPAN devices is usually very small, which makes it hard to measure the current directly.Therefore, a controllable gain amplifier is required to amplify the low voltage at the signal detection sensor output, which is represented by PGA in Figure3. Then the analog signal amplified by PGA needs to be sampled and converts to digital signal by analog-to-digital converter circuit, which is represented by ADC in the figure.In order to achieve wide dynamic range of gain, wide bandwidth, and low noise and high linearity and digitize a wide range of signals, it is necessary to set the value of reference voltage and input gain of PGA and output data rate of ADC to reasonable values by system control module represented by MCU in the figure. The functional characteristics of proposed system are shown in Table1.Table 1
Functional characteristics.
Key features Specification Current measurement range 0.5 uA to 200 mA Power measurement range 1.65 uW to 10 W Output data rates 10 to 14 kSPS Maximum CMRR 140 dB Operating temperature −40°C to 105°C


## 3.2. Programmable-Gain Instrumentation Amplifier (PGA)

In order to obtain suitable output voltage that can be digitized directly, PGA281 is used as the instrumentation amplifier with digital gain control in Figure3. PGA281 offers excellent DC precision and long-term stability using modern technology with internal filters that minimize noise. The output stage connects to the low-voltage supply. The PGA is carried out by improved parallel feedback based Flipped Voltage Follower (FLV) to achieve wide dynamic range of gain, wide bandwidth, and low noise and high linearity.The input voltage gain of PGA281 is in the range of 0.125 to 128 in binary steps. The output stage has a gain adjustment factor, 1 or 1.37, to adjust gain to the optimal value. Desired gain can be selected by controlling digital input G4:G0 and the gain of PGA is set toAPGA.In the hardware interface circuit of the proposed system, we use a resistor with resistanceR, which is very small and sensitive to the change of current. The voltage at the resistor is represented by UR, and the current across the resistor is given by(1)IR=UR×1R.R P G A i n stands for the input impedance of PGA. And RDUTin stands for the input impedance of DUT. Similarly, the current across the DUT is given by(2)IDUTin=UR×R+RPGAinR×RPGAin.The output voltage of UADCin the PGA is given by(3)UPGAout=APGA×UR=APGAIDUTinR×RPGAinR+RPGAin.APGA stands for the gain of PGA.


## 3.3. Analog-to-Digital Converter (ADC)

Analog-to-digital converter circuit used ADS1259 to digitize the signals at PGA281 output. ADS1259 outputs 24 bits of conversion data in binary format. Combined with a signal amplifier, a high-resolution, high-accuracy measurement system is formed that is capable of digitizing a wide range of signals.Depending on different input values, the ADS1259 has corresponding output codeNADC, a 24-bit hexadecimal number. If the voltage of input signal UADCin is larger than positive full-scale input VREF, the output code of ADC is set to 7FFFFFh. UADCin is provided by the PGA and equal to the output voltage of PGA; namely, UPGAout=UADCin. If the input voltage of ADC is less than -VREF223/223-1, the output code of ADC is set to 800000H. And if the input voltage is in the interval of -VREF223/223-1,VREF, the input signal can be digitized to a dynamic output code, which can be expressed as(4)NADC=UADCin223-1VREF.According to Nyquist Theorem, the input analog signal can be recovered without distortion; thus voltage of input analog signalUADCin can be measured based on the value of NADC.


## 3.4. Microcontroller Unit (MCU)

In order to configure the value of reference voltage and input gain of PGA and output data rate of ADC and calculate the data obtained from ADC outputs, a low-power and high-speed MCU, namely, STM32L151, is used in the system control module of the proposed system. STM32L151 device has high-performance ARM core operating at a 32 MHz frequency, as well as high-speed embedded memories having up to 128 Kbytes of flash memory and up to 16 Kbytes of RAM. Moreover, the STM32L151 device contains standard and advanced communication interfaces, such as USARTs and USBs, which can transmit measured data to computer for record and further analysis. Due to the good performance and low-cost of STM32L151 device, the proposed system is well represented in the configuration of a variety of parameters of the system and data processing.


## 3.5. Power-Supply Module

A power-supply module has been elaborated in order to satisfy the power requirement of PGA, ADC, and MCU.The PGA281 requires three supply voltages: the high-voltage analog supply, the low-voltage output amplifier supplies, and the digital I/O supply. The high-voltage analog supplies, which include negative high-voltage supply (VSN) and positive high-voltage supply (VSP), power the high-voltage input stage section and are set to±12 V in the proposed system. The voltage of USB is 5 V, which cannot provide ±12 V power supply, so that a DC-DC boosting circuit based on MC34063 which is a DC/DC converter is proposed. The power-supply module can provide stable power which improve the stability of the system.


## 3.6. Parameter Measured by the Proposed System

The proposed system is developed as a low-cost, high-resolution, high-accuracy, real-time measurement system for the power LoWPAN devices. It can measure and estimate instantaneous current, average current, average power, and instantaneous power.The instantaneous current of the DUT is measured in a sampling interval, which is given by(5)IDUTinn=NADCnVREF/223-1R+RPGAinAPGAR×RPGAin.I D U T i n n stands for the current value in nth sampling interval.The average current valueIaverage is computed once per cycle Ns, which can be calculated by (6)Iaverage=1Ns∑n=1NsIDUTinn=1Ns∑n=1NsNADCnVREF/223-1R+RPGAinAPGAR×RPGAin.The input impedance of PGA is very large and the impedance ofR is very small, which is usually set to 10 Ω; that is, RPGAin≫R. Therefore, the instantaneous current of DUT can be simplified to the following:(7)IDUTinn≈URR=NADCnVREF/223-1APGA×R.Similarly, the average current value can be expressed as follows:(8)Iaverage=1Ns∑n=1NsNADCnVREF/223-1APGA×R.Assuming the batteryE of DUT is ideal, and the voltage of the battery is not time-varying; that is, UE is a constant. The average power of the DUT is calculated once per cycle Ns, which is shown as follows:(9)Paverage=IaverageUE-Iaverage2R×RPGAinR+RPGAin.Due to the fact thatRPGAin≫R and R→0, the equation can be expressed as(10)Paverage=IaverageUE=UE×1Ns∑n=1NsIDUTinn.The instantaneous power is the power consumption of DUT in each sampling slot, which is given by(11)Pn=UE×IDUTinn.The measured instantaneous power can be set to computer through Universal Asynchronous Receiver/Transmitter (UART) for further research.In all equations,VREF is the difference between the voltage values of positive reference absolute input and negative reference absolute input of ADC. Ns, R, and APGA are known parameters. NADCn is a value measured by ADC in a sample interval, and according to NADCn, we can measure and calculate the value of the instantaneous current, average current, average power, and instantaneous power of DUT. The description of the symbols in the equations above is summarized in Table 2.Table 2
Symbols description.
Symbols Meaning U R Analog voltage of signal detection senor R D U T i n Input impedance of DUT R P G A i n Input impedance of PGA A P G A Gain of PGA U A D C i n Analog input voltage of ADC U P G A o u t Analog output voltage of PGA N A D C Digital output of ADC I D U T i n n Digital current value innth sampling interval provided by MCU V R E F Reference voltage of PGA controlled by MCUAs shown in Figure4, DUT is a kind of LoWPAN device, which periodically builds a wireless connection with another LoWPAN device. The proposed system is connected to the DUT via an interface reserved for power measurement. The measured data will be calculated and transmitted to computer for record and further analysis via USB cable. The battery can supply the power of DUT.Figure 4
Hardware setup.


## 4. Status Detection and Classification

### 4.1. Measurement Accuracy

We compare our measured waveforms with Keysight 34465A millimeter. Keysight 34465A millimeter has high sensitivity and accuracy, so that it can be used as the ground-truth of the measured waveforms and the qualification standard of the accuracy of our measured data. We can see that these values measured by our platform are close to 34465A millimeter. The result is shown in Figure5(a).Figure 5
Power waveform measured by Keysight 34465A and PTone and CDF of error in power measurements.
(a)
Comparison of measured waveforms (b)
CDF of errorWe quantitatively evaluate the errors in Figure5(b), which shows a cumulative distribution function (CDF) of the difference between PTone’s measurement and the Keysight 34465A millimeter’s measurement.The CDF shows that the 90th percentile error is 4 mw. Our results further show that PTone’s mean power measurement error is 0.37 mw. Since the average power in our experiments is 100 mw, on average, PTone estimates power to within 0.37% of its correct value.We confirm the performance of our system through this experiment. Besides we can ensure the evident effectiveness of the proposed system to make it easier to measure instantaneous current, average current, instantaneous power, and average power of DUT, as well as checking for system status during the period of development of LoWPAN devices.


### 4.2. Power Consumption Waveforms Information

LoWPAN devices contain a variety of components, such low-power MCU, RF circuits, power management module, and sensor module. In a real-world application, the sensor module often adopts COTS sensors, which have mature and stable power consumption model and have little interfere to the detection of DUT system status. MCU and RF circuits consume most of the power offered by power supply [22, 23]. Each LoWPAN DUT uses the power in maintenance of system configuration and sends ACK or data packet during the work state. After this period, the DUT system reduces the workload of MCU and shuts down RF circuits and then enters the sleep state which has almost no electric energy loss.The PTone continually monitors the power waveforms of the DUT in real time, and the information of the waveforms can be represented by the following equation:(12)Pi=PMi+PRi+Nii∈0,T.In the equation above,PM(i) represents power consumption of MCU module and i stands for the ith sample point. PR(i) represents power consumption of RF module. PM(i) and PR(i) make up a large proportion of the total power P(i) and the noise N(i) comes from random measurement noise and the power consumption of sensors and components in peripheral circuit and so on.This section is organized as follows. First, we remove the noise in the measured waveform. Second, we detect the work state in the waveform which includes the start time and end time of active time. Third, we select and extract features based on the character of LoWPAN devices’ power consumption. Finally, we use the extracted features to train a multiple classifier, which can detect and classify the status of LoWPAN devices accurately.


### 4.3. Noise Removal

Even though the proportion of system noise in the total measured power waveform is not large, the noise cannot be ignored due to amplitude excitations of noise with large dynamic range, as shown in Figure6(a). The goal of this preprocessing step is to dampen the noise signal and improve the signal-to-interference-and-noise ratio (SINR) of the PM(i) and PR(i) signal.Figure 6
Power waveform before and after filtering.
(a)
Power waveform before filtering (b)
Power waveform after filteringThe frequency of system noise is not regular and occurs in a random fashion. In order to minimize the influence of system noise to the following feature extraction and classification, we use an appropriate filter to remove noise in such a situation.If we use a Butterworth low pass filter, a type of signal processing filter widely used to remove high frequency noise, the large amplitude noise would make the power waveform distortion, because the noise signal in the waveforms is introduced by various factors, such as test environment, circuit noise of the DUT, and measuring platform, and is not all of high frequency. To address this challenge, PTone applies aHampel filter to the measured power waveforms, to detect and remove outliers.Hampel filter computes the median value of the sample and its surrounding samples by using a slipping window. It also estimates the standard deviation of each sample about its window median using the median absolute deviation. If a sample differs from the median by more than three standard deviations, it is replaced with the media, which can eliminate the outliers caused by noise [24, 25].The result shows thatHampel filter can remove the outliers effectively under the premise of retaining the valid data.


### 4.4. Work State Detection

In order to detect work state and distinguish the active time and quiet time in work state, we need to detect the start points and end points of the active time work state of DUT system. We process the measured data in a causal system, which is different from traditional mean absolute deviation (MAD) algorithm. MAD algorithm is a kind of edge detection algorithm widely used in the digital image processing and not suitable for the time signals processing in this paper. To address this challenge, we propose a work state detection algorithm (WSDA).First, the algorithm calculates weighted mean absolute value in the latestW sample points. The weighted coefficients of each point in the window width of W are set according to the distance to the current point. The weighted mean absolute value (WMAV) is calculated using the following equation:(13)mi=∑j=0W-1ωjP′i-j,i∈0,T′.In the equation,j represents the distance to the current point in the slipping window, P′(i-j) represents the filtered data of P waveforms processed by aHampel filter, ω(j) represents the weighted coefficients of each point in the window and decreases with the increase of distance j, and m(i) represents WMAV of the current point, which can be used to detect the start and end points of work state.Second, after calculating the WMAV of each point in the measured power consumption waveforms, WSDA compares the WMAVs with a thresholdθth. Let Δm(i)=m(i)-m(i-1) and δi=Δmi-θth; if Δm(i)>0 and δ(i)>0, it indicates that the WMAV has a significant increase in interval i-W,i and current point can be regarded as a candidate of state point.IfΔm(i)<0 and δ(i)>0, it indicates an obvious decrease in the interval, which can be regarded as a candidate of end point. If δ(i)≤0, it shows that the variation of WMAVs does not exceed the threshold θth and power consumption waveforms do not change obviously in the interval.Third, in a real-world measurement, there may be more than one state point candidate on the rising edge of power waveforms, so we need to choose an appropriate candidate as the start point in each work state. Due to the requirement of the complete work state waveforms for feature extraction, it is inappropriate to use the mid-value of those candidates which is commonly used in statistics, and we chose the state points according to the following ways. Letsws1,sws2,sws3,…,swsNws represent the set of start point candidates obtained from stat point detection algorithm. sws(1) represents the first start point candidate in chronological order. Nws represents number of candidates in the set.WSDA compares theΔm(i) values of each point in sws1,sws2,sws3,…,swsNws on the same rising edge. If the mean value of Δm(i) from point sws(k) to point sws(Nws) is larger than threshold θth, we define that point sws(k) has stable growth subsequent waveforms as shown in the following equation: (14)1swsNws-swsk∑j=swskswsNwsΔmj>θth,k∈1,Nws.Then, we choose the minimum value insws(1),sws(2),sws(3),…,sws(Nws) which satisfies the above equation as the start point of the active period of work state and set the work state flag sf=1 to capture the increasing and decreasing trends. The end points ew of each work state are obtained in a similar way. The pseudocode of our algorithm is presented in  Algorithm 1.Algorithm 1:Work state detection algorithm (WSDA).
Input: Sequence P′ ofT′ points Output: Start points sw of each work state (1)Assertsf==0 (2)sws←FINDCANDIDATES (P′) (3)Fork←0 to Nwsdo (4)If1/sws(Nws)-sws(k)∑j=sws(k)sws(Nws)Δmj>θthdo (5)sf←1 (6)    setkth point as the start pointsw. (7)returnsw (8)procedure FINDCANDIDATES (P′) (9)Fori←0 to T′do (10)m(i)←∑j=0W-1ω(j)P′(i-j) (11)Δm(i)←m(i)-m(i-1) (12)δ(i)←|Δm(i)|-θth (13)Ifδ(i)>0 and Δm(i)>0do (14)   addith point into start point candidate set {sws(1),sws(2),sws(3),…,sws(Nws)} sequentially (15)return{sws(1),sws(2),sws(3),…,sws(Nws)}Lastly, our algorithm detects the start point and end point candidates in the whole waveform and chose appropriate ones as start or end points to confirm the presence of a complete active time of work state within that interval, as shown in Figure7.Figure 7
Work state detection.The figure shows that even though the filtered waveform has some outliers, our algorithm can detect the start point accurately in different work state.


### 4.5. Feature Selection and Extraction

In order to differentiate between statuses of the DUT system based on the real power consumption, we need to extract some unique features that can classify different system status. And according to the start and end points of active time in work state, we can extract the waveform series in the work state for further analysis instead of using the whole waveform, which allows us to extract the features of power waveform more accurately. Feature selection techniques are important to select features for good classification results. Previous works on feature selection were based on filter or wrapper methods [26–28]. However, the methods need to process a large number of data to find out appropriate features, which is hard to achieve in real-time and low-cost platform.Instead, PTone chooses the features based on unique features of each active period in work state of LoWPAN devices.As shown in Figure8, S1, S2, S3, and S4 represent the active time of receiving beacon for source node, sending ACK, sending data, and receiving ACK from source node, respectively. Work state includes S1, S2, S3, and S4 section and the quiet time between them.Figure 8
Active time and quiet time in work state.T w represents the duration time of work state. Ts represents the period of DUT system which includes one work state and one sleep state. And we observed that Tw is fluctuant and increases with the increase of transmission data. We also observed that Ts is stable even though it is controlled by MCU of the DUT system and in real-world application, Ts is far greater than Tw, and the change of Tw has no great effect on Ts. In the same experimental condition, if outliers are presented within Ts in each DUT period, that is, the measured value of power consumption is either too large or too small, we usually may consider that abnormal configuration of DUT’s MCU exists in the wake-up time control module or system clock of the MCU. Therefore, Ts can be selected as a feature to evaluate the MCU performance of the DUT.We also observed that the power waveforms in S2 and S3 have similar amplitude in each work state. If the DUTs do not perform well in radio frequency module, the amplitude of S2 and S3 may be different and not stable. So the difference of maximum value of S2 and S3 can be used to evaluate the status of radio frequency (module of DUT devices).After many experiments and analysis, we carefully selected some distinctive features of LoWPAN devices to classify the system status of DUT as follows:Waveform Features Mean amplitude of S2 and S3 Root mean square deviation of S2 and S3 Mean amplitude of S1 and S4 Quiet time in work state System periodTsPTone can detect and classify the abnormal system status of LoWPAN devices based on the features proposed above. Note that we only detect the abnormity which affects the performance of low-power wireless communication, and the abnormity is inconvenient and hard to be detected in traditional ways. The labeled features are collected in the following ways. We connect a LoWPAN DUT into our hardware platform. Then, we start a source device which could search the LoWPAN DUT and build wireless communication. Then, the LoWPAN device enters work state and sleep state periodically. Meanwhile, the real-time power waveform sequences will be measured by PTone. The work state, the start time, and end time of S1, S2, S3, and S4 and sleep state in the sequences can be detected by the work state detection algorithm (WSDA) proposed above. Then, PTone extracts the labeled features from the measured power waveform sequences based on the start and end point of each active time. Then, the features could be trained for the further analysis and classification of system status.


### 4.6. Classification and Evaluation

In this section, we investigate whether PTone can accurately classify DUT system status based on the waveform features extracted above. Based on our experience in the R&D process of LoWPAN devices, we divided system abnormal status into several groups: two kinds of RF module abnormal cases and two kinds of MCU control system abnormal cases.RF module abnormal cases include the case of abnormal power control and the case of insufficient RF power in certain active period of work state. MCU control system abnormal cases include the case of irregular interval of each active time in work state and the case of inappropriate DUT’s system period, which is caused by crystal deviation, synchronization strategy bugs, and so on.The existence of abnormal power control, which is represented by RF-1, undermines the network connectivity and even may lead to the failure of data transmission. A typical waveform of this status is shown in Figure9(a). The amplitude of S2 is not smooth, which should be stable during the active period to have better performance according to the design of the devices. The power waveform indicates that the power control in the S2 period during work state is abnormal.Figure 9
Typical power waveform of abnormal power control status (RF-1) and insufficient RF power status (RF-2).
(a)
Typical power waveform of RF-1 status (b)
Typical power waveform of RF-2 statusThe insufficient RF power, which is represented by RF-2, may reduce the coverage of wireless network and influence the use of LoWPAN devices. A typical waveform of this status is shown in Figure9(b). Even though the amplitudes of S2 and S3 are smooth in each active time, the amplitudes have obvious difference, which should be similar during sending packet and sending ACK period according to our design. The insufficient RF power in S3 causes this kind of abnormal power waveform.The unstable interval of active time may be caused by inaccurate configuration in MCU, incomprehensive estimation of time-delay in DUT system, and so on, which is represented by M-1. In LoWPAN, every device takes a time slot to receive beacon and send ACK or data package. Unstable interval of the active time can result in communication conflicts with other devices. A typical waveform of this status is shown in Figure10(a).Figure 10
Typical power waveform of unstable interval of active time status (M-1) and abnormal system period status (M-2).
(a)
Typical power waveform of M-1 status (b)
Typical power waveform of M-2 statusThe figure shows that the interval between S2 and S3 is much larger than that of well-performed devices. S3 is repeated two times in the same work state, which means that the excessive interval between S2 and S3 leads to unnecessary retransmission of packet data (S3). This phenomenon is difficult to be directly observed in the traditional test method.Time synchronization is a key issue for any distributed system and is widely used in distributed wireless sensor networks, especially LoWPAN. So, if the system period is not stable and accurate, not only would power consumption be improved, but also the device would have a bad effect on the communication of other devices in the area with high node density. The case of abnormal system period is represented by M-2. A typical waveform of this status is shown in Figure10(b). The figure shows that the system in M-2 does not have a suitable sleep state between each work state, and the device receives beacon and sends data all the time, which is not in accordance with the design of the devices.The extracted features are used to train Support Vector Machine (SVM) and achieve the classification of multiple system status. We use maximum posterior probability (MAP) obtained by the SVM to estimate the system status. MAP can be used to obtain a point estimate of an unobserved quantity based on measured data. It is closely related to Fisher’s method of maximum likelihood (ML) estimation but employs an augmented optimization objective which incorporates a prior distribution (that quantifies the additional information available through prior knowledge of a related event) over the quantity one wants to estimate [29–32].We visualize the output of the classification as follows: we choose two of the features and calculate the maximum posterior probability (MAP) of each status in a 2D plane. The axes are the two features or combinations of the two features.In Figure11(a), the MAP of M-1 and M-2 status are estimated on the basis of two features, that is, the quiet time between S2 and S3 and system period. Due to the limit of using only two features, the SVM only can classify the system status into 3 kinds of cases, M-1, M-2, and uncertain status. The uncertain status includes RF-1, RF-2, normal status, and other unknown statuses. Every point in Figure 10 has a posterior probability of each system status. And the color of point is the MAP value of a system with those two features. If the MAP of system in certain status is larger than in others, we can classify the system in that status.Figure 11
Classification of two statuses based on two features.
(a)
Classification of M-1 and M-2 (b)
Classification of RF-1 and RF-2 (c)
Classification of M-2 and RF-1For example, if a DUT’s quiet time between S2 and S3 is 60 ms, and system period is 700 ms, we can classify that the system status is in M-2 status, because the MAP of that point in M-2 status is more than 90%.We also visualize the output of the classification by calculating the MAP based on different features to estimate system status. We classify RF-1 and RF-2 (Figure11(b)) and M-2 and RF-1 (Figure 11(c)) by using mean value of S2, quiet time between S2 and S3, and system period.Note that we can accurately classify two system statuses by using two only two features.In the actual course of application, we use more than two features to train the multiple classifier, which can detect different system status at the same time.Our method in the real-world application is composed of offline step and online step. In the offline step, we collect waveform data of DUT in known statuses, extract the features, and train classifier. In the online step, we connect the DUT (in unknown status) into our platform. Then, the real-time power waveform of the DUT can be transmitted into a server, which is a Lenovo laptop with a Core i5 desktop CPU and 4 GB RAM. Then, the server calculates the MAP of each status based on the well-trained classifier and classifies the real-time system status based on the following rules.PN,PM-1,PM-2,PRF-1, and PRF-2 represent the MAP of normal, M-1, M-2, RF-1, and RF-2 status, respectively. If the difference between the two largest values of PN,PM-1,PM-2,PRF-1, and PRF-2 is more than a certain threshold θMAP, the system is assigned to the status with largest MAP. If there are no such values, PTone classifies the system into uncertain status and waits for further data to calculate the MAP of each status. The threshold θMAP depends on the number of detected statuses and the resolution of distinguishing different statuses. The larger θMAP reduces the probability of wrong classification, but, at the same time, it also increases the number of data collected from the DUT and the time consumption of analyzing data. According to our measurements, θMAP is set to 20% in our experiments.To evaluate PTone’s system status classification accuracy, we collect 200 power waveform sequences (with the same length) from different statuses (40 sequences in each status). We train a type of system status classifier based on some features proposed and extracted above. The average accuracy of classification and some typical multiple classification of system status are shown in Figure12.Figure 12
Multiple classification of system status based on multiple features.
(a)
Multiple Classification Average Accuracy (b)
Typical measurementsIn Figure12(a), the figure shows that the average accuracy of multiple classification is 89.5%. The classification of abnormal system period status (M-2) has higher accuracy (95%) because the time of sleep state between each work state, as the main feature of M-2, is longer than that of work state and can be easily distinguished. Meanwhile, the classification accuracy of RF-2 is relatively low (82.5%), because the amplitude difference between S2 and S3 in work states, which is one of the main features of RF-2, is usually very small and easily affected by noise. Even though there is some noise in the measured sequences and limited performance of PTone’s server, our platform can still achieve an accuracy of 89.5%.In Figure12(b), the figure shows that the multiple classifier can calculate the MAP of each status. In the 1st measurement, the MAP of system in normal status is 85%, which is higher than that of M-1 (2%), M-2 (3%), RF-1 (3%), and RF-2 status (7%). According to the classification rule proposed above, PN-PRF-2>θMAP, we can classify the DUT system in the 1st measurement into normal status. Similarly, the DUT system in the 2nd, 3rd, 4th, and 5th measurement can be classified into M-1, M-2, RF-1, and RF-2 status, respectively.The results of the experiment show that PTone can detect and classify typical system at high classification rate by using different features extracted from power waveforms.


## 4.1. Measurement Accuracy

We compare our measured waveforms with Keysight 34465A millimeter. Keysight 34465A millimeter has high sensitivity and accuracy, so that it can be used as the ground-truth of the measured waveforms and the qualification standard of the accuracy of our measured data. We can see that these values measured by our platform are close to 34465A millimeter. The result is shown in Figure5(a).Figure 5
Power waveform measured by Keysight 34465A and PTone and CDF of error in power measurements.
(a)
Comparison of measured waveforms (b)
CDF of errorWe quantitatively evaluate the errors in Figure5(b), which shows a cumulative distribution function (CDF) of the difference between PTone’s measurement and the Keysight 34465A millimeter’s measurement.The CDF shows that the 90th percentile error is 4 mw. Our results further show that PTone’s mean power measurement error is 0.37 mw. Since the average power in our experiments is 100 mw, on average, PTone estimates power to within 0.37% of its correct value.We confirm the performance of our system through this experiment. Besides we can ensure the evident effectiveness of the proposed system to make it easier to measure instantaneous current, average current, instantaneous power, and average power of DUT, as well as checking for system status during the period of development of LoWPAN devices.


## 4.2. Power Consumption Waveforms Information

LoWPAN devices contain a variety of components, such low-power MCU, RF circuits, power management module, and sensor module. In a real-world application, the sensor module often adopts COTS sensors, which have mature and stable power consumption model and have little interfere to the detection of DUT system status. MCU and RF circuits consume most of the power offered by power supply [22, 23]. Each LoWPAN DUT uses the power in maintenance of system configuration and sends ACK or data packet during the work state. After this period, the DUT system reduces the workload of MCU and shuts down RF circuits and then enters the sleep state which has almost no electric energy loss.The PTone continually monitors the power waveforms of the DUT in real time, and the information of the waveforms can be represented by the following equation:(12)Pi=PMi+PRi+Nii∈0,T.In the equation above,PM(i) represents power consumption of MCU module and i stands for the ith sample point. PR(i) represents power consumption of RF module. PM(i) and PR(i) make up a large proportion of the total power P(i) and the noise N(i) comes from random measurement noise and the power consumption of sensors and components in peripheral circuit and so on.This section is organized as follows. First, we remove the noise in the measured waveform. Second, we detect the work state in the waveform which includes the start time and end time of active time. Third, we select and extract features based on the character of LoWPAN devices’ power consumption. Finally, we use the extracted features to train a multiple classifier, which can detect and classify the status of LoWPAN devices accurately.


## 4.3. Noise Removal

Even though the proportion of system noise in the total measured power waveform is not large, the noise cannot be ignored due to amplitude excitations of noise with large dynamic range, as shown in Figure6(a). The goal of this preprocessing step is to dampen the noise signal and improve the signal-to-interference-and-noise ratio (SINR) of the PM(i) and PR(i) signal.Figure 6
Power waveform before and after filtering.
(a)
Power waveform before filtering (b)
Power waveform after filteringThe frequency of system noise is not regular and occurs in a random fashion. In order to minimize the influence of system noise to the following feature extraction and classification, we use an appropriate filter to remove noise in such a situation.If we use a Butterworth low pass filter, a type of signal processing filter widely used to remove high frequency noise, the large amplitude noise would make the power waveform distortion, because the noise signal in the waveforms is introduced by various factors, such as test environment, circuit noise of the DUT, and measuring platform, and is not all of high frequency. To address this challenge, PTone applies aHampel filter to the measured power waveforms, to detect and remove outliers.Hampel filter computes the median value of the sample and its surrounding samples by using a slipping window. It also estimates the standard deviation of each sample about its window median using the median absolute deviation. If a sample differs from the median by more than three standard deviations, it is replaced with the media, which can eliminate the outliers caused by noise [24, 25].The result shows thatHampel filter can remove the outliers effectively under the premise of retaining the valid data.


## 4.4. Work State Detection

In order to detect work state and distinguish the active time and quiet time in work state, we need to detect the start points and end points of the active time work state of DUT system. We process the measured data in a causal system, which is different from traditional mean absolute deviation (MAD) algorithm. MAD algorithm is a kind of edge detection algorithm widely used in the digital image processing and not suitable for the time signals processing in this paper. To address this challenge, we propose a work state detection algorithm (WSDA).First, the algorithm calculates weighted mean absolute value in the latestW sample points. The weighted coefficients of each point in the window width of W are set according to the distance to the current point. The weighted mean absolute value (WMAV) is calculated using the following equation:(13)mi=∑j=0W-1ωjP′i-j,i∈0,T′.In the equation,j represents the distance to the current point in the slipping window, P′(i-j) represents the filtered data of P waveforms processed by aHampel filter, ω(j) represents the weighted coefficients of each point in the window and decreases with the increase of distance j, and m(i) represents WMAV of the current point, which can be used to detect the start and end points of work state.Second, after calculating the WMAV of each point in the measured power consumption waveforms, WSDA compares the WMAVs with a thresholdθth. Let Δm(i)=m(i)-m(i-1) and δi=Δmi-θth; if Δm(i)>0 and δ(i)>0, it indicates that the WMAV has a significant increase in interval i-W,i and current point can be regarded as a candidate of state point.IfΔm(i)<0 and δ(i)>0, it indicates an obvious decrease in the interval, which can be regarded as a candidate of end point. If δ(i)≤0, it shows that the variation of WMAVs does not exceed the threshold θth and power consumption waveforms do not change obviously in the interval.Third, in a real-world measurement, there may be more than one state point candidate on the rising edge of power waveforms, so we need to choose an appropriate candidate as the start point in each work state. Due to the requirement of the complete work state waveforms for feature extraction, it is inappropriate to use the mid-value of those candidates which is commonly used in statistics, and we chose the state points according to the following ways. Letsws1,sws2,sws3,…,swsNws represent the set of start point candidates obtained from stat point detection algorithm. sws(1) represents the first start point candidate in chronological order. Nws represents number of candidates in the set.WSDA compares theΔm(i) values of each point in sws1,sws2,sws3,…,swsNws on the same rising edge. If the mean value of Δm(i) from point sws(k) to point sws(Nws) is larger than threshold θth, we define that point sws(k) has stable growth subsequent waveforms as shown in the following equation: (14)1swsNws-swsk∑j=swskswsNwsΔmj>θth,k∈1,Nws.Then, we choose the minimum value insws(1),sws(2),sws(3),…,sws(Nws) which satisfies the above equation as the start point of the active period of work state and set the work state flag sf=1 to capture the increasing and decreasing trends. The end points ew of each work state are obtained in a similar way. The pseudocode of our algorithm is presented in  Algorithm 1.Algorithm 1:Work state detection algorithm (WSDA).
Input: Sequence P′ ofT′ points Output: Start points sw of each work state (1)Assertsf==0 (2)sws←FINDCANDIDATES (P′) (3)Fork←0 to Nwsdo (4)If1/sws(Nws)-sws(k)∑j=sws(k)sws(Nws)Δmj>θthdo (5)sf←1 (6)    setkth point as the start pointsw. (7)returnsw (8)procedure FINDCANDIDATES (P′) (9)Fori←0 to T′do (10)m(i)←∑j=0W-1ω(j)P′(i-j) (11)Δm(i)←m(i)-m(i-1) (12)δ(i)←|Δm(i)|-θth (13)Ifδ(i)>0 and Δm(i)>0do (14)   addith point into start point candidate set {sws(1),sws(2),sws(3),…,sws(Nws)} sequentially (15)return{sws(1),sws(2),sws(3),…,sws(Nws)}Lastly, our algorithm detects the start point and end point candidates in the whole waveform and chose appropriate ones as start or end points to confirm the presence of a complete active time of work state within that interval, as shown in Figure7.Figure 7
Work state detection.The figure shows that even though the filtered waveform has some outliers, our algorithm can detect the start point accurately in different work state.


## 4.5. Feature Selection and Extraction

In order to differentiate between statuses of the DUT system based on the real power consumption, we need to extract some unique features that can classify different system status. And according to the start and end points of active time in work state, we can extract the waveform series in the work state for further analysis instead of using the whole waveform, which allows us to extract the features of power waveform more accurately. Feature selection techniques are important to select features for good classification results. Previous works on feature selection were based on filter or wrapper methods [26–28]. However, the methods need to process a large number of data to find out appropriate features, which is hard to achieve in real-time and low-cost platform.Instead, PTone chooses the features based on unique features of each active period in work state of LoWPAN devices.As shown in Figure8, S1, S2, S3, and S4 represent the active time of receiving beacon for source node, sending ACK, sending data, and receiving ACK from source node, respectively. Work state includes S1, S2, S3, and S4 section and the quiet time between them.Figure 8
Active time and quiet time in work state.T w represents the duration time of work state. Ts represents the period of DUT system which includes one work state and one sleep state. And we observed that Tw is fluctuant and increases with the increase of transmission data. We also observed that Ts is stable even though it is controlled by MCU of the DUT system and in real-world application, Ts is far greater than Tw, and the change of Tw has no great effect on Ts. In the same experimental condition, if outliers are presented within Ts in each DUT period, that is, the measured value of power consumption is either too large or too small, we usually may consider that abnormal configuration of DUT’s MCU exists in the wake-up time control module or system clock of the MCU. Therefore, Ts can be selected as a feature to evaluate the MCU performance of the DUT.We also observed that the power waveforms in S2 and S3 have similar amplitude in each work state. If the DUTs do not perform well in radio frequency module, the amplitude of S2 and S3 may be different and not stable. So the difference of maximum value of S2 and S3 can be used to evaluate the status of radio frequency (module of DUT devices).After many experiments and analysis, we carefully selected some distinctive features of LoWPAN devices to classify the system status of DUT as follows:Waveform Features Mean amplitude of S2 and S3 Root mean square deviation of S2 and S3 Mean amplitude of S1 and S4 Quiet time in work state System periodTsPTone can detect and classify the abnormal system status of LoWPAN devices based on the features proposed above. Note that we only detect the abnormity which affects the performance of low-power wireless communication, and the abnormity is inconvenient and hard to be detected in traditional ways. The labeled features are collected in the following ways. We connect a LoWPAN DUT into our hardware platform. Then, we start a source device which could search the LoWPAN DUT and build wireless communication. Then, the LoWPAN device enters work state and sleep state periodically. Meanwhile, the real-time power waveform sequences will be measured by PTone. The work state, the start time, and end time of S1, S2, S3, and S4 and sleep state in the sequences can be detected by the work state detection algorithm (WSDA) proposed above. Then, PTone extracts the labeled features from the measured power waveform sequences based on the start and end point of each active time. Then, the features could be trained for the further analysis and classification of system status.


## 4.6. Classification and Evaluation

In this section, we investigate whether PTone can accurately classify DUT system status based on the waveform features extracted above. Based on our experience in the R&D process of LoWPAN devices, we divided system abnormal status into several groups: two kinds of RF module abnormal cases and two kinds of MCU control system abnormal cases.RF module abnormal cases include the case of abnormal power control and the case of insufficient RF power in certain active period of work state. MCU control system abnormal cases include the case of irregular interval of each active time in work state and the case of inappropriate DUT’s system period, which is caused by crystal deviation, synchronization strategy bugs, and so on.The existence of abnormal power control, which is represented by RF-1, undermines the network connectivity and even may lead to the failure of data transmission. A typical waveform of this status is shown in Figure9(a). The amplitude of S2 is not smooth, which should be stable during the active period to have better performance according to the design of the devices. The power waveform indicates that the power control in the S2 period during work state is abnormal.Figure 9
Typical power waveform of abnormal power control status (RF-1) and insufficient RF power status (RF-2).
(a)
Typical power waveform of RF-1 status (b)
Typical power waveform of RF-2 statusThe insufficient RF power, which is represented by RF-2, may reduce the coverage of wireless network and influence the use of LoWPAN devices. A typical waveform of this status is shown in Figure9(b). Even though the amplitudes of S2 and S3 are smooth in each active time, the amplitudes have obvious difference, which should be similar during sending packet and sending ACK period according to our design. The insufficient RF power in S3 causes this kind of abnormal power waveform.The unstable interval of active time may be caused by inaccurate configuration in MCU, incomprehensive estimation of time-delay in DUT system, and so on, which is represented by M-1. In LoWPAN, every device takes a time slot to receive beacon and send ACK or data package. Unstable interval of the active time can result in communication conflicts with other devices. A typical waveform of this status is shown in Figure10(a).Figure 10
Typical power waveform of unstable interval of active time status (M-1) and abnormal system period status (M-2).
(a)
Typical power waveform of M-1 status (b)
Typical power waveform of M-2 statusThe figure shows that the interval between S2 and S3 is much larger than that of well-performed devices. S3 is repeated two times in the same work state, which means that the excessive interval between S2 and S3 leads to unnecessary retransmission of packet data (S3). This phenomenon is difficult to be directly observed in the traditional test method.Time synchronization is a key issue for any distributed system and is widely used in distributed wireless sensor networks, especially LoWPAN. So, if the system period is not stable and accurate, not only would power consumption be improved, but also the device would have a bad effect on the communication of other devices in the area with high node density. The case of abnormal system period is represented by M-2. A typical waveform of this status is shown in Figure10(b). The figure shows that the system in M-2 does not have a suitable sleep state between each work state, and the device receives beacon and sends data all the time, which is not in accordance with the design of the devices.The extracted features are used to train Support Vector Machine (SVM) and achieve the classification of multiple system status. We use maximum posterior probability (MAP) obtained by the SVM to estimate the system status. MAP can be used to obtain a point estimate of an unobserved quantity based on measured data. It is closely related to Fisher’s method of maximum likelihood (ML) estimation but employs an augmented optimization objective which incorporates a prior distribution (that quantifies the additional information available through prior knowledge of a related event) over the quantity one wants to estimate [29–32].We visualize the output of the classification as follows: we choose two of the features and calculate the maximum posterior probability (MAP) of each status in a 2D plane. The axes are the two features or combinations of the two features.In Figure11(a), the MAP of M-1 and M-2 status are estimated on the basis of two features, that is, the quiet time between S2 and S3 and system period. Due to the limit of using only two features, the SVM only can classify the system status into 3 kinds of cases, M-1, M-2, and uncertain status. The uncertain status includes RF-1, RF-2, normal status, and other unknown statuses. Every point in Figure 10 has a posterior probability of each system status. And the color of point is the MAP value of a system with those two features. If the MAP of system in certain status is larger than in others, we can classify the system in that status.Figure 11
Classification of two statuses based on two features.
(a)
Classification of M-1 and M-2 (b)
Classification of RF-1 and RF-2 (c)
Classification of M-2 and RF-1For example, if a DUT’s quiet time between S2 and S3 is 60 ms, and system period is 700 ms, we can classify that the system status is in M-2 status, because the MAP of that point in M-2 status is more than 90%.We also visualize the output of the classification by calculating the MAP based on different features to estimate system status. We classify RF-1 and RF-2 (Figure11(b)) and M-2 and RF-1 (Figure 11(c)) by using mean value of S2, quiet time between S2 and S3, and system period.Note that we can accurately classify two system statuses by using two only two features.In the actual course of application, we use more than two features to train the multiple classifier, which can detect different system status at the same time.Our method in the real-world application is composed of offline step and online step. In the offline step, we collect waveform data of DUT in known statuses, extract the features, and train classifier. In the online step, we connect the DUT (in unknown status) into our platform. Then, the real-time power waveform of the DUT can be transmitted into a server, which is a Lenovo laptop with a Core i5 desktop CPU and 4 GB RAM. Then, the server calculates the MAP of each status based on the well-trained classifier and classifies the real-time system status based on the following rules.PN,PM-1,PM-2,PRF-1, and PRF-2 represent the MAP of normal, M-1, M-2, RF-1, and RF-2 status, respectively. If the difference between the two largest values of PN,PM-1,PM-2,PRF-1, and PRF-2 is more than a certain threshold θMAP, the system is assigned to the status with largest MAP. If there are no such values, PTone classifies the system into uncertain status and waits for further data to calculate the MAP of each status. The threshold θMAP depends on the number of detected statuses and the resolution of distinguishing different statuses. The larger θMAP reduces the probability of wrong classification, but, at the same time, it also increases the number of data collected from the DUT and the time consumption of analyzing data. According to our measurements, θMAP is set to 20% in our experiments.To evaluate PTone’s system status classification accuracy, we collect 200 power waveform sequences (with the same length) from different statuses (40 sequences in each status). We train a type of system status classifier based on some features proposed and extracted above. The average accuracy of classification and some typical multiple classification of system status are shown in Figure12.Figure 12
Multiple classification of system status based on multiple features.
(a)
Multiple Classification Average Accuracy (b)
Typical measurementsIn Figure12(a), the figure shows that the average accuracy of multiple classification is 89.5%. The classification of abnormal system period status (M-2) has higher accuracy (95%) because the time of sleep state between each work state, as the main feature of M-2, is longer than that of work state and can be easily distinguished. Meanwhile, the classification accuracy of RF-2 is relatively low (82.5%), because the amplitude difference between S2 and S3 in work states, which is one of the main features of RF-2, is usually very small and easily affected by noise. Even though there is some noise in the measured sequences and limited performance of PTone’s server, our platform can still achieve an accuracy of 89.5%.In Figure12(b), the figure shows that the multiple classifier can calculate the MAP of each status. In the 1st measurement, the MAP of system in normal status is 85%, which is higher than that of M-1 (2%), M-2 (3%), RF-1 (3%), and RF-2 status (7%). According to the classification rule proposed above, PN-PRF-2>θMAP, we can classify the DUT system in the 1st measurement into normal status. Similarly, the DUT system in the 2nd, 3rd, 4th, and 5th measurement can be classified into M-1, M-2, RF-1, and RF-2 status, respectively.The results of the experiment show that PTone can detect and classify typical system at high classification rate by using different features extracted from power waveforms.


## 5. Conclusions

In this paper, a low-cost, instantaneous current/power waveform detection platform with desirable resolution and accuracy is proposed. Some power definitions, for example, average current, instantaneous current, average power, and instantaneous power, can be measured and calculated precisely. A novel and convenient testing method based on this system has been demonstrated for LoWPAN devices. The platform can be designed as a hermetically sealed module with economical components with small volume, which can be used in a variety of scenes whenever a wide range of small DC current is to be measured.



---

*Source: 8713873-2017-02-22.xml*