analytical study of a smart energy meter

50
1 School of Engineering Department of Electrical Engineering Towards the Design of a Smart Energy Meter: Feature Extraction and Classification EENG 495 – Senior Project Spring 2011-2012 Mohammad Tfaily Tarek kamar Supervisor: Dr. Khaled Chahine

Upload: tariq-qamar

Post on 22-Jan-2018

262 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Analytical study of a smart energy meter

1

School of Engineering

Department of Electrical Engineering

Towards the Design of a Smart Energy Meter:

Feature Extraction and Classification

EENG 495 – Senior Project

Spring 2011-2012

Mohammad Tfaily

Tarek kamar

Supervisor: Dr. Khaled Chahine

Page 2: Analytical study of a smart energy meter

2

Abstract

Improving energy efficiency by monitoring household electrical consumption is of

significant importance with the climate change concerns of the present time. In this

project, it is proposed to implement a non-intrusive appliance load monitoring system

(NIALM). This system captures the signals from the aggregate consumption, extracts the

features from these signals and classifies the extracted features in order to identify the

switched on appliances .We use ESPRIT as a feature extraction method; ESPRIT extracts

the complex poles and the residues of the individual load.

We build a database of current signature of nine different appliances. By comparing

its poles and residues with those obtained from the theoretical expressions of elementary

loads, we obtain exact values. Then we obtain an almost perfect reconstructed current for

the elementary load and linear loads, and a good reconstructed current for the nonlinear

load. Then, the K-NN method allows us to identify a moderate sample of data and

assigning a label for it.

Page 3: Analytical study of a smart energy meter

3

TABLE OF CONTENTS

1. Introduction ………………………………………………………………..1

1.1 Problem statement……………………………………………………......1

1.2 Project objectives………………………………………………………....2

1.3 Document structure……………………………………………….............4

2. Literature review……………………………………………………………5

2.1Introduction…………………………………………………………………5

2.2 Data aggregated energy meter……………………………………………...5

2.3 Smart Energy meter system………………………………………………...7

2.3.1 Energy tracker for home ………………………………………………....7

2.3.2 Entacker hardware and theory of operation……………………………...7

2.3.3 Evaluation and current limitation………………………………………...8

2.4 Non Intrusive Appliance load monitoring history………………………….9

2.4.1 United States of America…………………………………………………9

2.4.2 France……………………………………………………………………..9

2.4.3 Other Countries…………………………………………………………..10

2.4.4 Disaggregated End- Use Energy sensing………………………………....11

2.5 Conclusion………………………………………………………………….13

3. Methodology ……………………………………………………………....14

3.1 Introduction………………………………………………………………14

3.2 Signal Model……………………………………………………………...14

3.3 Feature Extraction………………………………………………………...15

3.3.1 The covariance matrix………………………………………………….15

3.3.2 Estimation Signal Parameter via rotational invariant technique………..16

3.4 Classification……………………………………………………………..19

3.4.1 Database of signature…………………………………………………..19

3.4.2 K-Nearest Neighbor…………………………………………………….20

3.5 Conclusion………………………………………………………………..20

4. Results and discussion……………………………………………21

Page 4: Analytical study of a smart energy meter

4

4.1 Introduction…………………………………………………………….21

4.2 Elementary Load…………………………………………………....21

4.2.1 Series RC load……………………………………………………21

4.2.2 Series RL Load…………………………………………………...23

4.2.3 Parallel RL load…………………………………………………..24

4.2.4 Series RLC load…………………………………………………..26

4.2.5 Nonlinear load……………………………………………………27

4.3 Real Signals………………………………………………………...28

4.4 Feature Space……………………………………………………….32

5. Conclusion……………………………………………………………….34

Bibliography……………………………………………………………………...35

Appendix A……………………………………………………………………….36

Appendix B……………………………………………………………………….42

Page 5: Analytical study of a smart energy meter

5

LIST OF FIGURES1: NIALM scheme……………………………………………………………….....3

2: Schematic block diagram of Entacker prototype……………………………....7

3: Event recording system………………………………………………………..10

4: Single-point disaggregated energy sensing system………………………………..12

5: The analytic and reconstructed currents of the series RC circuit……………...22

6: The analytic and reconstructed currents of the series RL circuit……………...24

7: The analytic and reconstructed currents of the parallel RL circuit……………25

8: The analytic and reconstructed currents of the series RLC circuit…………….27

9: The analytic and the reconstructed current of a nonlinear load………………..28

10: The measured and reconstructed currents of the economy lamp……………..29

11: The measured and reconstructed currents of the Incandescent Lamp………..29

12: The measured and reconstructed currents of the Halogen Lamp…………….29

13: The measured and reconstructed currents of the Electric Convector………...30

14: The measured and reconstructed currents of the vacuum cleaner…………....30

15: The measured and reconstructed currents of the television………………….30

16: The measured and reconstructed currents of the computer…………………..31

17: The measured and reconstructed currents of the water heater………………..31

18: The measured and reconstructed currents of the fridge………………………31

19: The training matrix…………………………………………………………..32

20: The feature space……………………………………………………………..33

21: The feature space showing one sample data appliance………………………33

Page 6: Analytical study of a smart energy meter

6

LIST OF TABLES

1: Summary of results: Shows the correct % of device transitions detected ……8

2: The residues, attenuation factor, and frequencies of the series RC load……....21

3: The estimated characteristics of a series RC load extracted by ESPRIT……...22

4: The residues,attenuation factor, and frequencies of the series RL load………..23

5: The estimated characteristics of a series RL load extracted by ESPRIT……....23

6: The residues, attenuation factor, and frequencies of the parallel RL load….…25

7: The estimated characteristics of a parallel RL load extracted by ESPRIT…….25

8: The residues, attenuation factor, and frequencies of the series RLC load……..26

9: The estimated characteristics of a series RLC load extracted by ESPRIT…….27

10: Current composition of a nonlinear load…………………………………....28

Page 7: Analytical study of a smart energy meter

7

CHAPTER 1

INTRODUCTION

1.1 Problem statement

Improving energy efficiency by monitoring household electrical consumption is of

significant importance with the climate change concerns of the present time.

Home owners are sometimes unaware of how older appliances, newly installed

appliances and changes in occupant behavior affect the energy consumption of their

house. For example, installing a more efficient furnace will not necessarily reduce energy

bills if the occupants stop turning down the thermostat at night [1].

Utilities installed energy meters have advanced tariffs based on load data and in building

automation systems the state of appliances can be used for fault diagnostics and

calculation of energy consumption. They report only the aggregate electrical energy

consumption of a home over intervals as long as a month. Consequently, they cannot tell

the consumers which devices are responsible for their energy consumption. In contrast,

disaggregated energy data broken down by individual appliances offers a much plentiful

dataset that has the potential to authorize a wide variety of energy stakeholders from

homeowner's operators to utilities. In other words, disaggregated energy data enables

the utilities and the policymakers to understand how energy is consumed in the home.

The method of extraction of the constituent parts of the overall load is called

“Load Disaggregation “. It produces more accurate information about the electrical

energy consumption of end uses without measuring the end uses directly for long periods

of time; therefore, fewer sensors are needed, and less data is collected.

Page 8: Analytical study of a smart energy meter

8

Notice that the disaggregated data presents for households to better understand their

consumption practices, determine cost-effective measures to increase their energy

efficiency, and finally reduce their overall consumption. Even a 10-15% reduction in

electricity consumption use across the United States of America homes would be

substantial, representing nearly 200 billion kWh of electricity per year. This is equivalent

to the yearly power output of 16 nuclear power plants or 81.3 million tons of coal. Such

statistics have led a growing body of scientists, utilities, and regulators to view energy

efficiency as the most accessible and cost effective form of alternative energy [2].

There are two classes of appliance signature: nonintrusive and intrusive. An electrically

intrusive signature is generated at the electricity meter by injecting a signal such as a

voltage harmonic. A nonintrusive signature is one that can be measured by passively

observing the operation of a load. There are two types of nonintrusive signature: steady

state and transient. A steady state signature is derived from the difference between the

steady state properties of an appliance's operating states. Transient signatures, on the

other hand, are more difficult to detect and provide less information than steady state

signatures [3].

1.2 Project Objectives

In this project, it is proposed to implement a non-intrusive appliance load monitoring

system (NIALM). It can determine the operating schedule of whole electrical loads in a

target system from measurements made at a centralized location. In addition it can

identify the operation of electromechanical devices from other kinds of power

distribution net and distinguish loads even when many are operating at one time.

This system captures the signals from the aggregate consumption, extracts the features

from these signals and classifies the extracted features in order to identify the switched on

appliances (see figure 1). We will employ for feature extraction the estimation signal

parameter via a rotational invariant technique method (ESPRIT), a well known

parametric estimation technique. ESPRIT is based on theorems that make the extension to

higher spatial dimension and to signal containing multiple frequencies possible.

Page 9: Analytical study of a smart energy meter

9

NIALM can monitor the operation of the electrical distribution system itself, identifying

situations where two or more otherwise healthy loads interfere with each other’s

operation through voltage waveform distortion or power quality problems. We will also

study a classification method. The classification module has the task of identifying an

appliance by comparing it with labeled signatures in a database.. The main software that

we will use is MATLAB® which is a high-level language and interactive environment

that enables user to perform computationally intensive tasks faster than with traditional

programming languages such as C, C++, and FORTRAN.

The result of the feature extraction phase is a compact representation of the signal in

terms of complex numbers referred to as poles and residues. We will use these complex

numbers to determine a feature vector consisting of the contribution of the fundamental,

the third and the fifth harmonic currents to the maximum of the total load current. Once a

signature is extracted, we will store it in a database of signatures which is used by a

classification method to identify the appliance. Results obtained will be evaluated in

terms of the success rate.

Electric Appliance

Current Identification

Figure 1: NIALM scheme

Data

Acquisition

Event

Detection

Feature

Extraction Classification

Page 10: Analytical study of a smart energy meter

10

1.3 Document structure

This document is divided into 5 chapters; an overview about each chapter is given

below:

Chapter1

This chapter presents the problem statement and the project objectives in extended

way.

Chapter 2

This chapter presents a survey of literature and historical background on NIALM

system

Chapter 3

This chapter presents the methodology of the project. It shows the data analysis of

different kinds of electrical loads operation.

Chapter 4

This chapter presents the results of the project. It shows the current signature of

different kind of electrical load.

Chapter 5

This final chapter summarizes the main achievements of the work, discusses the

obtained results, and provides suggestions for future work.

Page 11: Analytical study of a smart energy meter

11

CHAPTER 2

LITERATURE REVIEW

2.1 Introduction

There is a stark contrast between the grid as it exists today and the grids of other

sectors, such as telecommunications. Power systems grids are not much different than

they were a hundred years ago. On the other hand, the information and communications

technology that is starting to be applied in the grid is, to a great extent, similar to what

was done 30 years ago in the telecom infrastructure.

Machine learning techniques can be applied to sensor data collected from smart

homes to reveal activity patterns of the residents, which can then be correlated with

measured energy consumption. Improving energy efficiency and reducing expenses need

intelligent systems that can be devised to automatically control home environments by

associating activities with energy usage and costs.

To make informed decisions, residents need to know current energy consumption in

real time and ideally would need to be alerted when appliances are being activated at

unfavourable times. Without installing additional sensors, Non-intrusive Appliance Load

Monitoring (NIALM) techniques can be designed to detect switch events at individual

appliances on a single electrical circuit and communicate those events to a home energy

management system.

This chapter will present a brief summary on data aggregated energy meter benefits

and disadvantages, show similar systems to NIALM and represents the historical

background of NIALM in different countries.

2.2 Data aggregated energy meter

Utility Company programs aims to reduce demand for electricity have been in existence

since the late1970s. But beyond that, consumption information must be under customers’

Page 12: Analytical study of a smart energy meter

12

control, as any sharing must be with their explicit authorization. This is standard practice

in Commercial & Industry; particularly in manufacturing and process industries, where

some companies view their consumption profiles as competition-sensitive and protect this

information carefully.

While the development of the power grid promises many social profits, the data collected

by advanced metering systems (AMI) introduce fundamental issues for electricity

consumers, including personal privacy. Electricity consumption is collected frequently on

a large scale; however, because sensing is passive, consumers have little awareness of

their exposure. The accurate electricity load data will prevent electricity deceive attacks

against the electricity distribution infrastructure.

Handling energy-use data is at the core of many privacy use cases, including data

aggregation. Data aggregation of AMI data can be used to avoid "fingerprinting"

consumer behaviour being able to associate specific consumption patterns with specific

individuals by storing aggregate behavior. While utilities require singular consumer data

for billing, that data can be collected over long intervals (several hours); data that needs

to be accessed more frequently than that data needed for operational purposes such as

demand-response can be aggregated across customers at intervals of less than an hour

before being processed and used[4].

By eliminating unnecessary information from transmitted data streams, data aggregation

can achieve two fundamental objectives. First, aggregation can strongly reduce network

traffic, thus improving the efficiency of the AMI network. Second, since only the

necessary information is kept, aggregation improves the privacy of customers from not

only entities outside the network but also, to a lesser extent, even entities within the

network.

The disadvantage of this system is the lack of accountability. A node that is captured by

an adversary can report arbitrary values as its aggregation result; the opponent thereby

corrupts the measurements of all the nodes in its entire aggregation sub-tree. In this kind

of powerful cost-effective integrity attack, an opponent can control the measurements of a

large portion of the network by compromising a selected number of well-positioned

aggregating nodes.

Page 13: Analytical study of a smart energy meter

13

2.3 Smart energy meter system

2.3.1 Energy Tracker for Homes (Entacker)

This system was implemented by Sunil Mallya a Computer Science Student at Brown

University in Spring Semester 2011. The aim of Mallya was building a system that can

provide real time estimate of the power breakdown per device in a house given a power

meter that records the total power consumption of the entire house and a device that

determines the binary state of devices in the house [5].

2.3.2 Entacker hardware and theory of operation

The system contains two modules: the signal processing unit and the power meter. The

signal processing unit (see Figure 2) is Data acquisition (DAQ) which records the analog

noise signal through a power line interface circuit, which in turn is plugged into any

electrical socket.

Figure 2: Schematic block diagram of Entacker prototype [5]

Each appliance has a characteristic noise pattern which is produced when it turns on, the

systems collects these characteristics and uses machine learning to predict later when

these devices are switched again. His first step was to detect the transient noise in the

electrical line. Signal data is sampled by the DAQ and his software module converts this

Page 14: Analytical study of a smart energy meter

14

signal from time domain to frequency domain by performing a real Fast Fourier

Transform (FFT). The FFT results in a vector which contains amplitudes for frequencies

ranging from 0 to 100 KHz. It was further observed that over several instances of device

actuations the Euclidean transient value was stable.

2.3.3 Evaluation and current limitation

The result was that Entacker was able to classify around 70% of the device actuations

correctly. It had a higher accuracy of around 80% for detecting the on transitions. The

accuracy is lower for all events including off transitions because Mallya pays double

penalty for every wrong on classification he makes. Every misclassification of on

transition results in misclassification of the off transition too. It was also observed that he

missed a few transitions due to the fact that we had a static threshold for detecting the

Euclidean transients.

Table 1: Summary of results: Shows the correct % of device transitions detected [5]

As shown in table 1 the percentage of accuracy reaches 81 % on detecting an on

transition. On the other hand, it reaches no more than 63 % on detecting an off transition.

Mallya concluded that instead of analyzing a big slice of the frequency spectrum, it is

efficient to extract dominant features from the device signature and use these features to

classify a potential signature. Mallya disregarded the phase component and he observed

that the noise signatures for the same device could vary depending upon the phase of all

the components, not just that of the device but also the other devices. He tried to

incorporate phase into his model and failed at his attempt to do so.

Page 15: Analytical study of a smart energy meter

15

2.4 Non- Intrusive Appliance Load Monitoring History

2.4.1 United States of America

Due to increasing electricity prices, concerns about the continued reliability of

electricity supply, and growing interest in limiting emissions of greenhouse gases that

contribute to climate change, utilities, policymakers, and environmental groups have

shown renewed interest in policies and programs to promote energy efficiency .

Non-intrusive Appliance Load Monitor (NIALM) was developed by George W. Hart in

1982 at the Massachusetts Institute of Technology (MIT).NIALM is designed to monitor

an electrical circuit that contains a number of appliances which switch on and off

independently. By a sophisticated analysis of the current and voltage waveforms of the

whole load, the NIALM estimates the number and nature of the individual loads, their

individual energy consumption, and other relevant statistics such as time-of-day

variations [6].

Electric Power Research Institute (EPRI) sponsor has accomplished the basic research

and development of Hart. Hart designed and implemented the first two prototypes and

specified the algorithms for the third prototype. The hardware prototype was a unit

housed as a module separate from the meter, with signals being captured through a meter

extender to the service entrance. The result was an Automatic-Setup NIALM for

households, which set it up as it measures the load. This desirable goal took more than 10

years to commercialize this system. The system was commercialized in 1998 by Telog

Instruments Inc.

2.4.2 France

Electricite’ de France (EDF) has engaged in some studies since 1990 with the aim of

distinguishing among domestic electrical uses (Sultanem 1991). A digital prototype of a

recorder named ACNI was built during 1989 – 1992 in collaboration with Schlumberger

industries. This device fed by the currents and voltages of a single phase customer

records dP and dQ each time a variation of the load is detected.

Page 16: Analytical study of a smart energy meter

16

Another model consists of a Hidden Markov Model (HMM) which attempts to

recognize the logical and chronological switch-on and switch-off of different loads (Bons

et al. 1994) is investigated.

2.4.3 Other Countries

Fuzzy Logic method to recognize household appliances was chosen as a research

project in Denmark during 1990-1992. The lack of suitable 3-phase load registration

equipment led to unsuccessful results. The households that have a 3-phase power supply

are the dominant in Denmark as in Finland.

In Finland, at VTT Energy, a group of researcher developed a project on NIALM. The

NIALM-concept was based on a 3-phase, power quality monitoring kWh-meter and

unique load identification algorithms.

As shown in figure 3 below the prototype event recording system consists of the power

quality kWh meter and a laptop personal computer. The meter is connected to power

supply lines via current transformers in the electric distribution board of a building and to

a laptop IBM-compatible personal computer via an RS-232 link. The meter sends, once

per second, through the data link, registered measurement values to the PC and these

values are processed and stored into the files of a hard disk [7].

Figure 3: Event recording system [7]

Page 17: Analytical study of a smart energy meter

17

The software of load identification algorithms which runs in an off-line personal

computer was the principal part of the developed NIALM-system prototype. Both two-

state and multi-state appliances were identified accurately. This prototype requires

manual-setup in which the naming of appliances is performed.

The results of this prototype field testing in a real private house were verified by parallel

measurements in the case of main appliances. The loads in the test house, in addition to

being common household appliances, also contained one big multi-state load (hot water

boiler for accumulating electrical heating). The average error of this NIALM in

estimating daily energy consumption including nine main appliances was about 12.1 %

and the average error of energy over a week period was about -6.2 %.

2.4.4 Disaggregated End-Use Energy Sensing

Recently research has explored methods to infer disaggregated energy usage via a single

sensor. The building of databases of the signatures for the NIALM architecture was

investigated by Berges et al. and Roberts and Kuhn .In the ideal case, these signatures

would be similar across homes and thus could be pre-loaded on the sensing device or

uploaded and tested in the cloud. In the worst case, however, a training example of each

appliance must be produced per home, which would greatly increase installation

complexity [2].

The group of researchers used transient voltage noise to implement a prototype system

which consists of a single custom power line interface plug-in module that can be

plugged into any electrical outlet in the home .The output of the plug-in module is

connected to a high speed data acquisition system that digitizes the analog signal and

streams it over a USB connection to data collection software running on the PC. The PC

then samples and conditions the incoming signal (see Figure 4).

Page 18: Analytical study of a smart energy meter

18

Figure 4: Single-point disaggregated energy sensing system [2]

To detect and classify the transient voltage noise, they employed a simple sliding window

algorithm (1-microsecond in length) to look for substantial changes in the input line noise

(both beginning and end). To detect and classify steady-state noise, they also employed a

frequency-based analysis. The incoming time domain signal stream from the data

acquisition hardware was buffered into 4 ms windows. Their feature extraction algorithm

used finds new resonant peaks using the difference vector and extracts quantities related

to center frequency, magnitude, and bandwidth of the resonances. To evaluate the

accuracy of their approach, they had conducted a number of staged experiments over a

total of 14 homes of varying styles, ages, sizes and locations.

For transient voltage noise analysis they tested their system in one home for six weeks

and in five homes for one week each to evaluate the system performance over time and in

different types of homes. Results indicate that they could classify various electrical events

with accuracies ranging from 80-90% with recalibration being unnecessary even after 6

weeks of installation.

They tested the steady-state voltage signatures approach in one home for a period of six

months, and in six other homes using staged experiments in a fixed setting. Results

Page 19: Analytical study of a smart energy meter

19

indicate that devices can be classified with accuracies ranging from 89-97% within

individual homes.

2.5 Conclusion

This chapter shows a literature review on NIALM system and brief evaluation of

similar systems around world. We conclude that the main objective of NIALM is to

automatically identify appliance-specific characteristics. The process of NIALM consists

of four basic steps:

(1) Data acquisition and preprocessing

(2) Event detection

(3) Feature extraction

(4) Classification.

Our project will emphasize on the last two steps Feature extraction and classification.

We will use the Estimation Signal Parameter via Rotational Invariant Technique

(ESPRIT) method which is a signal parameter estimation method to extract the features

from the aggregate signal in order to decompose it into multiple signals In addition we

will use the k nearest neighbor classification method that has the task of assigning a label

to each extracted signature.

Page 20: Analytical study of a smart energy meter

20

CHAPTER 3

METHODOLOGY

3.1 Introduction

This chapter will present the methods used to achieve the objectives of the project.

It shows the electric current signal model, explain the feature extraction method ESPRIT,

and the classification method (k-NN) chosen to identify the appliance.

3.2 Signal Model

For a sinusoidal driving voltage of the form the drawn electric ( ) 2 sin ( )v t V wt

current can be modeled as a linear combination of d cisoids (complex-valued sinusoidal

signals) weighted by complex residues according to the following signal model:

(1) 1

( ) exp 2 ( )d

m m mm

i t r j f t b t

where is the residue of the cisoid, is its attenuation factor, is its frequencymr thm m mf

and b(t) is additive white Gaussian noise. After sampling the time variable t is replaced

by

, where is the chosen sampling period.k st kt st 46.25 10

The discrete current signal becomes:

(2)

1( ) ( )

dk

m mm

i k r z b k

1,2,......,k N

where

Page 21: Analytical study of a smart energy meter

21

(3) exp 2m m m sz j f t 1, 2,.....,m d

is the complex pole. Under matrix form, the signal model is expressed by:thm

(4)i Ar b

with the following notational definitions:

current data vector (5) [ (1), (2),....., ( )]Ti i i i N 1N

Vandermonde matrix (6) 1 2[ , ,......., ]dA a a a N d

mode vector (7) 2[ , ,......, ]N Tm m m ma z z z 1N

vector of complex amplitudes (8) 1 2[ , ,....., ]Tdr r r r 1d

noise vector (9) [ (1), (2),...., ( )]Tb b b b N 1N

The superscript T denotes the transpose operator.

The problem the feature extraction problem can be stated as follows:

Given the electric current data sequence we use a feature extraction method 1

N

ki k

which is known as ESPRIT to extract the complex poles and residues 1

dm m

z

of the appliance. 1

dm m

r

3.3 Feature Extraction

3.3.1 The covariance matrix

The covariance matrix of the electric current data vector is defined by:N N i

(10) [ ]HR E ii

where E and H are the expectation and the conjugate-transpose operators, respectively.

Using equation (1) and developing, R can be written as

Page 22: Analytical study of a smart energy meter

22

(11)22HiR AR A I

where and denote the covariance matrices of the echoes and noise, iR 22 I

respectively. Practically R is estimated from M independent snapshots of the current data

vector which is termed the sample covariance matrixi

(12)1

1ˆM

Hx x

xR i i

M

The covariance matrix is Hermitian and positive semi-definite. All eigenvalues of R are

real and, due to its positive semi-definiteness, nonnegative. Notice that eigenvectors with

distinct Eigen values are orthogonal. This fundamental property of orthogonality forms

the basis of subspace-based estimation methods. Being Hermitian R admits the following

eigenvalue Decomposition (EVD):

(13) 1,....., 1[ ] ,..., [ ]H H

N i n N i nR Udiag U U U diag U U

Where U is the unitary matrix of eigenvectors, 21 2 1... ... 2d d N

,and

and contain the eigenvectors associated with the 1[ ...... ]i dU u u 1[ ... ]n d NU u u

signal(largest d) and noise (smallest N-d) eigenvalues, respectively. Indeed, the subspace

spanned by the eigenvector of is termed the electric current signal subspace, whereas iU

the subspace spanned by the eigenvectors of is termed the noise subspace [8].nU

3.3.2 Estimation Signal Parameter via Rotational Invariant Technique (ESPRIT)

In many practical signal processing problems, the objective is to estimate from

measurements a set of constant parameters upon which the received signals depends.

There have been several approaches to such problems including the so-called maximum

likelihood (ML) method of Capon and Burg’s maximum entropy (ME) method. Although

often successful and widely used, these methods have certain fundamental limitations

because they use an incorrect model of the measurements [9].

Page 23: Analytical study of a smart energy meter

23

Schmidt exploited correctly the measurement model in the case of sensor arrays of

arbitrary form, the resulting algorithm was called MUliple SIgnal Classification (MUSIC)

that was a leading candidate for an actual hardware implementation, but it requires a

search over array manifold which is computationally expensive. Resembling to the same

subspace-based algorithm family ESPRIT algorithm proposed by Richard Roy and

Thomas Kailath dramatically reduces these computations.

The main idea behind ESPRIT is to exploit the rotational invariance of the

underlying signal subspace induced by the Vandermode structure of the mode matrix A

without having to know . In particular, this rotational invariance can be established by A

partitioning into two adjacent frequency sub band, preferably with maximum A

overlapping for maintaining the resolution capability of the algorithm.

According to the damped exponential models, it is justified that the following

relation carries:

(14)2 1S S

Where and are dimensional matrices obtained from by removing its 1S 2S ( 1)N d A

last and first rows, respectively:

(15)1

2

SSA

And is a full rank diagonal matrix that gathers the electric current signal poles: d d

(16) 1 2, ..., ddiag z z z

For the damped exponential case, the complex numbers on the diagonal of have

modulo less than one and becomes a contractive operator. The objective of ESPRIT is

to estimate the diagonal elements of from electric current data samples.

Because the subspace spanned by the mode vectors of is equal to the subspace A

spanned by the eigenvectors of (the electric current signal subspace) defined in section iU

(3.3.1), there must exist a unique nonsingular dimensional matrix such thatd d j

(17) iU Aj

Partitioning in same way as done for gives:iU A

Page 24: Analytical study of a smart energy meter

24

(18)1

2

i

i

Ui UU

Using equation (17) allows us to express and as1iU 2iU

(19)1 1iU S j

(20) 2 2 1iU S j S j

Equation (19) implies

(21)1

1 1iS U j

Replacing the above equation in equation (19) yields

(22)1

2 1i iU U j j

This equation can also be expressed as

(23)2 1i iU U

Where (24)1 -j j

Therefore, and are similar matrices and the sought diagonal elements of are the

eigenvalues of . The estimation problem leads to estimating from and iU

computing its eigenvalues. Equation (24) is the key relationship in the development of

ESPRIT and its properties[8].

Recall that the covariance matrix is estimated from a finite number of noisy snapshots

as described in section (3.3.1) .The result is that the subspace spanned by the eigenvectors

of is only an estimate of the signal subspace and different from the subspace spanned iU

by the mode vector of A. We encounter a problem due to the difference between the spans

of the eigenvectors of and .Least Square criterion (LS) can solve this problem 1iU

2iU

that yields the following approximate solution for :

(26) 1

2 2 2 1H Hi i i iU U U U

Page 25: Analytical study of a smart energy meter

25

Knowing that both and contain errors, estimating using the the Total Least 1iU

2iU

Square criterion (TLS) is more appropriate.The TLS solution is given by:

(27) 1

12 22W W

Where the dimensional matrices and are determined from a matrix W that d d 12W 22W

results from the Singular Value Decomposition (SVD) of an dimensional ( 1) 2N d

matrix as follows:2 1i iV U U [ ]

(28)HV E W

(29)

11 12

21 22

W WW

W W

As a result ESPRIT allows us to obtain a reconstructed current y (t):

(30) 1

( ) exp 2 ( )d

m m mm

y t r j f t b t

Where y(t) can indicates the accuracy of the characteristic complex numbers extracted by ESPRIT (see Appendix A ).

3.4 Classification

3.4.1 Database of signature

Supervised multi-class classification algorithms aim at assigning a class label for

each input example. Given an electric current training data set of the form ( , , , )x x x xa b c d

where compose a feature vector consisting of the contribution of the , ,x x xa b c nA

fundamental, the third and the fifth harmonic currents respectively to the maximum of the

total appliance current, and is the class label, the algorithms aim at thx xd {1,..., }K thx

finding a learning model such that for new unseen appliances. ( , , )x x x xa b c d

The problem is simply formulated in the two-class case, where the labels are justxd

Page 26: Analytical study of a smart energy meter

26

+1 or -1 for the two classes involved. Several algorithms have been proposed to solve this

problem in the two-class case, some of which can be naturally extended to the multi-class

case, and some that need special formulations to be able to solve the latter case. The first

category of algorithms includes decision trees, neural networks, k-Nearest Neighbor,

Naive Bayes classifiers, and Support Vector Machines. The second category includes

approaches for converting the multi-class classification problem into a set of binary

classification problems that are efficiently solved using binary classifiers.

3.4.2 K-Nearest Neighbor (K-NN)

K-Nearest Neighbor is considered among the oldest non-parametric classification

algorithms. To classify an unknown appliance, the distance (using some distance

measure, e.g. Euclidean) from that appliance to every other training appliance is

measured. The k smallest distances are identified, and the most represented class in these

k classes is considered the output class label. The value of k is generally determined

using a validation set or using cross-validation. That method we use it to classify the

electric current sample data. Results obtained will be evaluated in terms of success rate.

3.5 Conclusion

Up to these approaches we conclude that ESPRIT extracts the complex poles and

the residues of the individual load. So, we need to validate it as a feature extraction

method this can be achieved by first comparing its poles and residues with those obtained

from the theoretical expressions of elementary loads. Then we must validate ESPRIT on

currents of real appliances .This can be done by observing the current drawn by the

appliances and its reconstruction based on the pole-residue estimates of ESPRIT. After

doing this part well we can move to the K-Nearest Neighbor method to identify the

switched on appliance.

Page 27: Analytical study of a smart energy meter

27

CHAPTER 4

RESULTS AND DISCUSSION

4.1 Introduction

This chapter will present the evaluation of ESPRIT on the following elementary

loads: series RC, series RL, parallel RL, and series RLC, give numerical results of the

complex characteristics. Then it presents the validation of ESPRIT on nine real signals.

Finally it presents an example on the K-NN method on an electric current sample data.

4.2 Elementary Loads

4.2.1 Series RC Load

The RC circuits lead to first order differential equations. Numerical results will be

given for a load of values R=100 and C=0.1mF. The theoretical analysis of the circuit

allows writing the current i(t) in the following form:

(31) 0

0 01 22

2

j wt j wtt t

cV e ei t v V wt e

R R j

( ) sin cos cos

The load is initiated at the moment =0, and .0t t 0 0cv

Table 2: The residues, attenuation factor, and frequencies of the series RC load.

mmr m mf Hz

1 2

2cos jV e

jR

0 50

2 2

2cos jV e

jR

0 -50

3

0

0 01 2

t

cv V wt eR

sin cos1

0

Page 28: Analytical study of a smart energy meter

28

As shown Table 2, thus a RC series load is characterized by three couples’ pole-

residues, two pure imaginary conjugate poles representing their forced response and one

real pole representing their natural response.

Table 3: The estimated characteristics of a series RC load extracted by ESPRIT

mmr m mf

1 0.4701 - 1.4767i 0.0000 50.0000

2 0.4701 + 1.4767i 0.0000

-50.0000

3 -0.9401 -100.00

0

Table 3 confirms that the estimated characteristics by ESPRIT are exactly equal to the theoretical values.

Figure 5: The analytic and reconstructed currents of the series RC circuit

Figure 5 shows the analytic and reconstructed currents of the series RC circuit

obtained by the poles and residues extracted by ESPRIT.

Page 29: Analytical study of a smart energy meter

29

4.2.2 Series RL load

The RL circuits lead also to first order differential equations. Numerical results

will be given for a load of values R=10 and L=100mH. The theoretical analysis of the

circuit allows writing the current i(t) in the following form:

(32) 0

0 02 2

2

j wt j wtt t

LV V e ei t i wt e

R R j

( )( ) cos sin cos

The load is initiated at the moment =0, and .0t t 0 0Li

As shown Table 4, thus a RL series load also is characterized by three couples’ pole-

residues, two pure imaginary conjugate poles representing their forced response and one

real pole representing their natural response.

Table 4: The residues, attenuation factor, and frequencies of the series RL load.

mmr m mf Hz

1 2

2cos jV e

jR

0 50

2 2

2cos jV e

jR

0 -50

3

0

0 02 t

LVi wt e

R cos sin

1

0

Table 5: The estimated characteristics of a series RL load extracted by ESPRIT

mmr m mf

1 -4.7006 - 1.4962i 0.0000 50.0000

2 -4.7006 + 1.4962i 0.0000

-50.0000

Page 30: Analytical study of a smart energy meter

30

3 9.4011 -100.00

0

Table 5 represents that the estimated characteristics by ESPRIT are exactly equal to the theoretical values.

Figure 6: The analytic and reconstructed currents of the series RL circuit

Figure 6 shows the analytic and reconstructed currents of the series RL circuit

obtained by the poles and residues extracted by ESPRIT.

4.2.3 Parallel RL load

The parallel RL circuits lead also to first order differential equations. Numerical

results will be given for a load of values R=10 and L=100mH. The theoretical analysis

of the circuit allows writing the current i(t) in the following form:

(33)

0 02 2

2( ) sin

cos cos( )

j wt j wt

L

e eV Vi t i wtR R j

The load is initiated at the moment =0, and .0t t 0 0Li

Page 31: Analytical study of a smart energy meter

31

Table 6: The residues, attenuation factor, and frequencies of the parallel RL load.

mmr m mf Hz

1

2

2 cosjV e

jR

0 50

2

2

2 cosjV e

jR

0 -50

3

0 02 sin

cosLVi wt

R

0 0

As shown Table 6, parallel RL load is characterized by two pure imaginary conjugate

poles representing its forced response and one real pole representing its natural response.

Table 7: The estimated characteristics of a parallel RL load extracted by ESPRIT

mmr m mf

1 -5.1768 -16.2635i 0.0000 50.0000

2 -5.1768 +16.2635i 0.0000

-50.0000

3 10.3536 0.0000 0

Table 7 represents that the estimated characteristics by ESPRIT are exactly equal to the theoretical values.

Page 32: Analytical study of a smart energy meter

32

Figure 7: The analytic and reconstructed currents of the parallel RL circuit

Figure 7 shows the analytic and reconstructed currents of the parallel RL circuit obtained

by the poles and residues extracted by ESPRIT.

4.2.4 Series RLC Load

The RLC circuit leads to a second order differential equation. Numerical results

will be given for a load of values R=1 , L=20mH and C=20 mF. The theoretical analysis

of the circuit allows writing the current i(t) in the following form:

(34)

1 0 0 2 0 02

2( ) cos

j wt j wtK w t t K w t tV e ei t Ae Be

R j

The load is initiated at the moment =0.0t t

Table 8: The residues, attenuation factor, and frequencies of the series RLC load.

mmr m mf Hz

1 2

2cos jV e

jR

0 50

2 2

2cos jV e

jR

0 -50

3 1 0 0k w tAe1 0k w 0

4 2 0 0k w tBe2 0k w 0

Page 33: Analytical study of a smart energy meter

33

As shown table 8, the RLC Load has, beside the two pure imaginary conjugate poles of

its forced response, two conjugate complex poles related to its natural response. The

expressions of the dependent parameters are given in the appendix B.

Page 34: Analytical study of a smart energy meter

34

Table 9: The estimated characteristics of a series RLC load extracted by ESPRIT

mmr m mf

1 -25.4489 - 4.0848i 0.0000 50.0000

2 -25.4489 + 4.0848i 0.0000

-50.0000

3 25.4489 +44.8294i -25.0 0

4 25.4489 -44.8294i -25.0 0

Table 9 represents that the estimated characteristics by ESPRIT are exactly equal to the

theoretical values.

Figure 8: The analytic and reconstructed currents of the series RLC circuit

Figure 8 shows the analytic and reconstructed currents of the series RLC circuit obtained

by the poles and residues extracted by ESPRIT.

4.2.5 Nonlinear Loads

A nonlinear load is one for which the relationship between the current through the

load and the voltage across the load is a nonlinear function. So for a nonlinear load, the

resistance varies. When AC power is supplied to a nonlinear load, the result is the

creation of currents that do not oscillate at the fundamental frequency. These currents are

Page 35: Analytical study of a smart energy meter

35

called harmonics. Harmonics occur at multiples of the fundamental frequency. For

instance, if the fundamental frequency is 50 Hz, the third harmonic is 150 Hz, and so on.

To evaluate the performance of ESPRIT on nonlinear loads, we considered the current

shown in Table 10. It consists of a fundamental and four harmonics and hence can be

represented by ten pair wise complex conjugate pole-residue couples. We then used

ESPRIT to extract these ten couples which served to reconstruct the current as shown in

Figure 9. As can be seen, ESPRIT is successful in estimating the pole-residue couples of

the load.

Table 10: Current composition of a nonlinear load

1I 5I 7I 11I 13I100% 18.9% 11% 5.9% 4.8%

Figure 9: The analytic and the reconstructed current of a nonlinear load

4.3 Real Signals

In this section, the validation of ESPRIT is carried out on currents of nine

representative loads [10]: Incandescent Lamp, economy Lamp, Halogen Lamp, Electric

Convector, Vacuum cleaner, Television, Computer, Water Heater, and Fridge.

Figures 10-18 show the measured current drawn by the appliances and its reconstruction

based on the pole-residue estimates of ESPRIT.

Page 36: Analytical study of a smart energy meter

36

Figure10: The measured and reconstructed currents of the Incandescent Lamp

Figure11: The measured and reconstructed currents of the economy lamp

Figure12: The measured and reconstructed currents of the Halogen Lamp

Page 37: Analytical study of a smart energy meter

37

Figure13: The measured and reconstructed currents of the Electric Convector

Figure14: The measured and reconstructed currents of the vacuum cleaner

Figure15: The measured and reconstructed currents of the television

Page 38: Analytical study of a smart energy meter

38

Figure16: The measured and reconstructed currents of the computer

Figure17: The measured and reconstructed currents of the water heater

Figure18: The measured and reconstructed currents of the fridge

The current of the incandescent lamp, Halogen lamp, Electric Convector, Vacuum

cleaner, Water Heater, and Fridge could be accurately reconstructed from two pole-

residue couples. The current of the economy lamp needs thirteen pole-residues couples.

The current of the television needs eight pole-residues couples. The current of the

computer needs four pole-residues couples. As we can see from the figures, ESPRIT is

Page 39: Analytical study of a smart energy meter

39

good in estimating the pole-residue couples of the incandescent lamp, television, and

computer, as well as in estimating the pole-residue couples of the other linear loads.

4.4 Feature Space

0 4442 0 0 1 00000 3623 0 2980 0 1761 2 00002 8770 0 0 3 00007 9911 0 0 4 00005 2069 0 0 5 00000 5269 0 5103 0 3756 6 00000 2314 0 1359 0 7 0000

15 8281 0 0 8 00000 9719 0 0 9 0000

. .

. . . .

. .

. .

. .

. . . .

. . .. .. .

Figure 19: The training matrix

Figure 19 shows the electric current training matrix where columns 1, 2, and 3 compose a

feature vector consisting of the contribution of the fundamental, the third and the fifth

harmonic respectively to the maximum of each individual total appliance load (see

Appendix A).Notice that even harmonics didn’t exist in the real signals that we studied.

Whereas the fourth column represents the label for each appliance, the labels are assigned

to the following appliance:

1- Incandescent lamp

2- Economy Lamp

3- Halogen Lamp

4- Electric Convector

5- Vacuum Cleaner

6- Television

7- computer

8- water heater

9- fridge

Page 40: Analytical study of a smart energy meter

40

Figure 20: The feature space

Figure 20 represents the disaggregated contribution of the fundamental and harmonic

currents to the maximum of the total current for the nine appliances.

Figure 21: The feature space showing one sample data appliance

Figure 21 represents the electric current sample data [0.5369 0.5303 0.3856] used

to evaluate the K-NN method, so we observe that the classification method assigned label

6 to this sample data because it is the nearest one to the training data [0.5269 0.5103

0.3756] (Television) so we remark that the television is the switched on appliance.

Page 41: Analytical study of a smart energy meter

41

CHAPTER 5

CONCLUSION

In summary, NIALM allow us to switching from aggregate to disaggregate

consumption. By using ESPRIT as a feature extraction method, we obtain a database of

signature of nine different loads. We obtain an almost perfect reconstructed current for

the elementary load and linear loads, and a good reconstructed current for the nonlinear

loads.

Then, the K-NN method allows us to identify a moderate sample of data and

assigning a label for it.

In the future, it is recommended to enrich the database of signatures by a largest

number of appliances that covers the most developed technologies. Then using other

classification method like Support Vector Machine allows obtaining a more accurate

classification. Finally the challenge will be writing a C code that performs the same

algorithm of the MATLAB code that we write; here we can talk about a real hardware

implementation without the absence of a microcontroller having a high sampling

frequency.

Page 42: Analytical study of a smart energy meter

42

Bibliography [1] Zmeureanu.R ,Marceau.M, (September 1999); Evaluating the energy impact of people's behaviour in a house: a case study. Journal of Architectural Engineering: 1999.

[2] Froehich.J,Larson.E,Gupta.S,Cohn.G,(April 2011); Disaggregated End-Use Energy Sensing for the Smart Grid,computer science & Engineering,Electrical Engineering,University of washigton seattle,IEEE:2011

[3] Zmeureanu.R ,Marceau.M,(October 1999); Nonintrusive load disaggregation computer program to estimate the energy consumption of major end uses in residential buildings, Department of building.Concordia university,Canada:1999

[4] Taban.G and Alvaro.A,(March 2012);Data Aggregation as a Method of Protecting Privacy in Smart Grid Networks ;IEEE:2012

[5] Mallay.S, ( spring 2011); Entracker: Energy Tracker for Homes, Department of Computer Science, Brown University:2011

[6] George hart ,website : http://www.georgehart.com/

[7] Hannu.P (May 1998) Non-intrusive appliance load monitoring system based on a modern kWh-meter, VTT Energy:1998

[8] Chahine.K (2010) ; Méthodes d’estimation paramétriques appliquées à la caractérisation de milieux dispersifs du génie civil, THÈSE DE DOCTORAT: 2010

[9]Roy.R,(July 1989) ;ESPRIT-Estimation of signal parameters via rotational invariance techniques.IEEE :1989

[10] By courtesy of the French COPUS research project

Page 43: Analytical study of a smart energy meter

43

Appendix A

% MATLAB m filefunction [Sing_Value_appliance_name]=Feature_Extraction clc;close allrange=32*1-1; %%% % %%%%%%%%%%Loading data %%%%%%%%%%%

load appliance_name.csv % load Microsoft excel comma separated values file containing the %current data sequence Appliance_voltage=[];Appliance_current=[]; [row_appliance,col_appliance]=size(appliance_name); for i=1:2:row_appliance Appliance_voltage=[Appliance_voltage appliance_name(i,:)]; Appliance_current=[Appliance_current appliance_name(i+1,:)]; end for index=1:100 %100 % take a specific (32x1) data vector from the whole appliance current graph % Economy_lamp_current=Economy_lamp_current(29411+(range+1)*(index-%1):29411+(range+1)*(index-1)+range); % Economy_lamp_current=Economy_lamp_current(:)/100; % halogenlamp_current=halogenlamp_current(8321+(range+1)*(index-%1):8321+(range+1)*(index-1)+range); % Electric_convector_current=Electric_convector_current(35585+(range+1)*(index-%1):35585+(range+1)*(index-1)+range); % Vacuum_cleaner_current=Vacuum_cleaner_current(23780+(range+1)*(index-%1):23780+(range+1)*(index-1)+range); % Television_current=Television_current(28581+(range+1)*(index-%1):28581+(range+1)*(index-1)+range); % Incandescent_lamp_current=Incandescent_lamp_current(242331+(range+1)*(index-%1):242331+(range+1)*(index-1)+range)/100; % Computer_current=Computer_current(8926+(range+1)*(index-1):8926+(range+1)*(index-%1)+range); % Water_heater_current=Water_heater_current(33+(range+1)*(index-1):33+(range+1)*(index-%1)+range)/100; % Fridge_current=Fridge_current(188507+(range+1)*(index-1):188507+(range+1)*(index-%1)+range); Time=(0:length(Appliance_voltage)-1)*(1/1600); fs=1600;% Sampling frequency % sampling period ts= 6.25 *10^-4 second time=Time(1:length(Appliance_current));% create an array (1x32) [poles1,residus1, SingVal]=ESPRIT(Appliance_current,1600,time);% call ESPRIT function to %obtain the estimated % poles residues and singular value of the appliance

Page 44: Analytical study of a smart energy meter

44

[poles_1,residus_1, Har_1]=arrange_poles(poles1,residus1);% call arrange_poles function to %obtain the contribution of the fundamental, the third and the fifth harmonic %currents respectively to the maximum of the total appliance current SIGH_1(index,:)=[Har_1 1]; % take the electric current training data and assign a label number %for it for kk=1:length(Appliance_current) Reconstructed_current(kk) = real(sum ( residus1.* exp(poles1/(fs)*(kk-1)) )); % calculate the reconstructed current from the extracted % poles-residues from ESPRIT end% draw the measured and the reconstructed current figure(1); plot(Appliance_current,'r--'); grid on; hold on; plot(Reconstructed_current,'b-o'); xlabel({'K'},'FontSize',20); ylabel({'Current (A)'},'FontSize',20); legend({'Measured I','Reconstructed I'},'FontSize',18); end

%%%%%%%%%%% Feature Extraction%%%%%%% function [poles, residus, SingVal]=ESPRIT(I,fs,time) I=I(:);% load the electric current data sequenceN=length(I); % data lengthm=floor(N/2); % Let m be the order of covariance matrix % compute the sample covariance matrix R=zeros(m,m); for i = m : N, R=R+I(i:-1:i-m+1)*I(i:-1:i-m+1)'/(N-m+1); end%R is estimated from N-m+1 independent snapshots of the current data [U,D,V]=svd(R);% perform the singular value decomposition of R where U is unitary % D is diagonal matrix Diagonal=diag(D);% take the diagonal element of DSingVal=Diagonal(1);% take the first element of Diagonal

Energy=sum(Diagonal.^2);% calculate the energy of the signal kkk=1;M=1; while sum(Diagonal(1:kkk).^2)/Energy<0.98 %Keep first singular values which constitute 90% of %energy M=M+1; kkk=kkk+1; end n=M;%n -> the model order

Page 45: Analytical study of a smart energy meter

45

disp(['The value of n is: ', num2str(M)]);S=U(:,1:n);% Create a submatrix S contain elements from C#1 till C#n from U S1=S(1:m-1,:);S2=S(2:m,:);% Remove the last and the first row of S and place it into S1 and S2 %respectivelyphi = S2\S1; % calculate phi = inverse (S2)*(S1) phi_LS= inv(S2'*S2)*S2'*S1; % apply least square solution represented by phi_LSW=[S2 S1];% create matrix W contain S1 and S2 [Uv,Dv,Wv]=svd(W);% perform singular value decomposition of W% column of Wv are called right singular vector and these are the% eigenvector of W' *W% take 4 submatrices from Wv Wv11=Wv(1:n,1:n);Wv12=Wv(1:n,n+1:2*n);Wv21=Wv(n+1:2*n,1:n);Wv22=Wv(n+1:2*n,n+1:2*n);phi_TLS=-Wv12*inv(Wv22);% apply total least square solution given by phi_TLSGG=eig(phi);%let GG be the eigenvalues of phi GG_LS=eig(phi_LS);%let GG_LS be the eigenvalues of phi_LSGG_TLS=eig(phi_TLS);%let GG_TLS be the eigenvalues of phi_TLSzeta_ESPRIT=real(log(GG_TLS));% Let zeta_ESPRIT and gamma_ESPRIT be the real part % and the imaginary part of the natural logarithm of phi_TLS respectivelygamma_ESPRIT=imag(log(GG_TLS)); poles=log(GG_TLS(1:n))*fs;% calculate polesESPRIT_Frequencies=gamma_ESPRIT/2/pi*fs;%calculate frequenciesESPRIT_Damping=zeta_ESPRIT*fs;% calculate damping factor z=GG_TLS(1:n);for i=1:n EXPO(:,i)=z(i).^(time*fs); % Take elements from row # i from z and do an array powering by % (time*fs) and place the result into a column # i of EXPO endresidus=inv(EXPO'*EXPO)*EXPO'*I;% calculate residus %%%%%%%%%%%%%%%% Arrange pole function %%%%%%%%%%%%%%%function [polesa,residusa,Har]=arrange_poles(poles,residus) fs=1600; [bpc,npc]=sort(abs(imag(poles)));%Sort the absolute imaginary part of poles vector in ascending %order poles=poles(npc); residus=residus(npc); M=length(poles); coun=0; Remove_Entry=[]; for kj=1:M if isreal(poles(kj))==1% Determine whether poles vector entries are reals coun=coun+1; Remove_Entry(coun)=kj; end end if isempty(Remove_Entry)==0 % Determine whether Remove_Entry vector is empty

Page 46: Analytical study of a smart energy meter

46

poles(Remove_Entry)=[]; residus(Remove_Entry)=[]; end % find the contribution of the fundamental harmonic loc50p = find( imag(poles)>(2*pi*50-0.15*2*pi*50) & imag(poles)< (2*pi*50+0.15*2*pi*50) ; if length(loc50p)==1 polesa(1)=poles(loc50p); residusa(1)=residus(loc50p); else polesa(1)=0;residusa(1)=0; display('ZERO PADDING...') end loc50n = find( imag(poles)>-(2*pi*50+0.15*2*pi*50) & imag(poles) < -(2*pi*50-15*2*pi*50); if length(loc50n)==1 polesa(2)=poles(loc50n); residusa(2)=residus(loc50n); else display('ZERO PADDING...') polesa(2)=0;residusa(2)=0; end %find the contribution of the third harmonic loc150p = find( imag(poles)>(3*2*pi*50-0.15*3*2*pi*50) & imag(poles) < (3*2*pi*50+0.15*3*2*pi*50) ) ; if length(loc150p)==1 polesa(3)=poles(loc150p); residusa(3)=residus(loc150p); else polesa(3)=0;residusa(3)=0; display('ZERO PADDING...') end loc150n = find( imag(poles)>-(3*2*pi*50+0.15*3*2*pi*50) & imag(poles) < -(3*2*pi*50-0.15*3*2*pi*50) ) ; if length(loc150n)==1 polesa(4)=poles(loc150n); residusa(4)=residus(loc150n); else display('ZERO PADDING...') polesa(4)=0;residusa(4)=0; end %find the contribution of the fifth harmonic loc250p = find( imag(poles)>(5*2*pi*50-0.15*5*2*pi*50) & imag(poles) < (5*2*pi*50+0.15*5*2*pi*50) ) ; if length(loc250p)==1 polesa(5)=poles(loc250p); residusa(5)=residus(loc250p); else polesa(5)=0;residusa(5)=0; display('ZERO PADDING...') end loc250n = find( imag(poles)>-(5*2*pi*50+0.15*5*2*pi*50) & imag(poles) < -(5*2*pi*50-0.15*5*2*pi*50) ) ; if length(loc250n)==1 polesa(6)=poles(loc250n); residusa(6)=residus(loc250n); else display('ZERO PADDING...') polesa(6)=0;residusa(6)=0;

Page 47: Analytical study of a smart energy meter

47

end polesa=polesa(:); residusa=residusa(:); for kk=1:32 I_recon(kk) = real(sum ( residusa.* exp(polesa/(fs)*(kk-1)) )); % do an array multiplication of residusa by the whole exp term % take the real part of the summation place it into I_reconend [loc,val] = pickpeak(I_recon,1,5);% call pickpeak function to find the location of the K at which % the maximum peak of the reconstructed current occur Product=residusa(1:6).*exp(polesa(1:6)/(fs)*(loc-1));% determine the final electric current signature of the appliance Har=real([Product(1)+Product(2) Product(3)+Product(4) Product(5)+Product(6)]); %%%%%%% PICKPEAK function %%%%%%%%%%%%%%%%%%%%%%%%%%function [loc,val] = pickpeak(spec,npicks,rdiff) % [loc,val] = pickpeak(spec,npicks,rdiff)% spec - data vector or matrix % npicks - number of peaks desired [default = 2]% rdiff - minimum spacing between picked peaks [default = 5]% loc - vector of locations (indices) of the picked peaks% val - vector corresponding values % A 0 in location (i,j) of array loc (or a NaN in array val)% indicates that the j-th data vector has less than i peaks% with a separation of rdiff or more. % ---- parameter checks ------------------------------------------- if (exist('rdiff') ~= 1) rdiff = 5; end if (exist('npicks') ~= 1) npicks = 2; end % ---- convert row vectors to col vectors ------------------------- [mrows,ncols] = size(spec);if (mrows==1) mrows=ncols; ncols=1; spec = spec(:); end % ---- edit out NaNs and Infs --------------------------------------- good = find (finite(spec)); rmin = min(spec(good)) - 1; bad = find(~finite(spec));if (~isempty(bad)) spec(bad) = ones(size(bad)) * rmin; end

Page 48: Analytical study of a smart energy meter

48

% ---- find a peak, zero out the data around the peak, and repeat val = ones(npicks,ncols) * NaN ; loc = zeros(npicks,ncols) ; for k=1:ncols % Find all local peaks: dx = diff([rmin; spec(:,k); rmin]); % for a local peak at either end lp = find(dx(1:mrows) >= 0 ... & dx(2:mrows+1) <=0); % peak locations vp = spec(lp,k); % peak values for p=1:npicks [v,l] = max(vp); % find current maximum val(p,k) = v; loc(p,k) = lp(l); % save value and location ind = find(abs(lp(l)-lp) > rdiff); % find peaks which are far away if (isempty(ind)) break % no more local peaks to pick end vp = vp(ind); % shrink peak value array lp = lp(ind); % shrink peak location array endend

%%%%%% Classification %%%%% load electric current training matrix training=[0.4443 0 0;0.3623 0.2980 0.1761;2.877 0 0;7.99911 0 0;5.2069 0 0; 0.5269 0.5103 0.3756;0.2314 0.1359 0;15.8281 0 0;0.9719 0 0]; group=[1;2;3;4;5;6;7;8;9]; % assign a group number for each appliance scatter3(training(:,1),training(:,2),training(:,3),'r','o'), view(-60,30); hold on; sample=[0.5369 0.5303 0.3856];% take a sample data class=knnclassify(sample,training,group,1);% perform the knn method display('class'); display(class);scatter3(sample(:,1),sample(:,2),sample(:,3),class(:)), view(-60,30);hold on; xlabel({'fundamental harmonic'},'FontSize',16); ylabel('third harmonic','FontSize',16); zlabel('fifth harmonic','FontSize',16); hold off; % 1 Economy Lamp,2 Incandescent Lamp, 3 Halogen Lamp, 4 Electric Convector, 5 Vacuum cleaner, 6 Television, 7 Computer, 8 Water Heater, and 9 Fridge.

Page 49: Analytical study of a smart energy meter

49

Appendix B

Load s rad

Series RC RC 1arctanRCw

Series RL /L Rarctan Lw

R

Parallel RL -arctan R

Lw

Series RLC coefficients:

2 0 02 cos sinL

VA i wtR

1 1arctan LwR Cw

01wLC

2R C

L

21 1k

22 1k

12 2 1

1 2

kA A k Ak k

Page 50: Analytical study of a smart energy meter

50

22 2 1

2 1

kA A k Ak k

01 0 0

2 cos coscwC VA v wt

L R w