Recursive Pyramid Algorithm-based Discrete Wavelet Transform for Reactive Power Measurement in Smart Meters

Measurement of the active, reactive, and apparent power is one of the most fundamental tasks of smart meters in energy systems. Recently, a number of studies have employed the discrete wavelet transform (DWT) for power measurement in smart meters. The most common way to implement DWT is the pyramid algorithm; however, this is not feasible for practical DWT computation because it requires either a log N cascaded filter or O (N) word size memory storage for an input signal of the N-point. Both solutions are too expensive for practical applications of smart meters. It is proposed that the recursive pyramid algorithm is more suitable for smart meter implementation because it requires only word size storage of L × Log (N-L), where L is the length of filter. We also investigated the effect of varying different system parameters, such as the sampling rate, dc offset, phase offset, linearity error in current and voltage sensors, analog to digital converter resolution, and number of harmonics in a non-sinusoidal system, on the reactive energy measurement using DWT. The error analysis is depicted in the form of the absolute difference between the measured and the true value of the reactive energy.


Introduction
Energy conservation is currently a highly important and much-discussed field of research.The increase in global energy demand has resulted in almost daily increases in energy prices; therefore, energy conservation is important for both consumers and service providers [1].Energy conservation can save money for consumers by reducing tariffs; on the other hand, supplying more consumers with lower energy production reduces installation costs for service providers [2].
In this context, the smart grid is one of the most interesting fields of research for next-generation power systems.This type of grid uses a bidirectional flow of electricity and information to create a widely distributed power delivery network.The smart grid offers several advantages, such as renewable energy usage, reduced greenhouse gas emissions, increased energy efficiency due to better balance of supply and demand, improved security and reliability, and fast and effective responses to energy generation, consumption fluctuations, and catastrophic events [3].The catastrophic events are sudden incidents, which occur due to the occasional failure of the power system component.The achievement of energy conservation in a smart grid, either at the consumer level or at the utility level, requires analysis of the energy provided by the utility, the effectiveness of energy use by the consumer, and the losses.This type of analysis requires energy consumption to be measured at various levels in the smart grid.
Smart meters represent one of the major components of smart grids.Smart meters can be used to measure energy consumption at various points in the smart grid [4].The smart grid concept has been put into full use by utility companies throughout the World through the installation of smart meters in homes and commercial buildings; by 2015, approximately 60 million smart meters will be installed in the US [5].The smart meter is an advanced energy meter that measures a consumer's energy consumption and provides additional information for the utility company not typically available with a regular energy meter.The smart meter can read real-time energy consumption data and securely send those data to the company [6].The ultimate objective of these meters is to set real-time pricing and establish demand-side management [7].
The functional requirement of electricity for smart meters, in terms of power measurement, is the measurement of active, reactive, and apparent power.Broadly speaking, reactive power is the difference between the power used for real working (active power) and the total consumed power (apparent power).However, some electrical equipment used in industrial and commercial building-especially transformers and motors-requires an amount of reactive power in addition to active power.The reactive power in such equipment is used to generate a magnetic field, which is essential for the inductive elements in these pieces of equipment to operate [8].Although reactive power is required to operate several pieces of equipment, if supplied in excess, it can also make harmful effects on appliances and installed electrical infrastructure [1].
Power factor is another term associated with power measurement in power systems.Power factor is the relationship between the active and reactive power.It indicates how effectively the electrical power is used.In other words, power factor is the ratio of active power to the apparent power.Typically, homes have power factors in the range of 70%-85%, depending on the appliances being used.However, a power factor correction mechanism can be employed to increase the power factor above 90%.Power factor correction has several benefits.It can: save money by reducing tariff; prevent electric losses; reduce peak energy demand and reduce risk of harm being done to the installed electrical infrastructure [9].
The tremendous increase in the amount and complexity of electrical equipment has provided welcome additions to modern homes, such as electronic ballast lighting, computer monitors, and air conditioners, but these impose an additional energy burden.This has resulted in an electric distribution profile that is completely different from what was observed 50 years ago [10].This change in the end-user load profile is a disadvantage for the service provider, which generates tariffs based only on active power.The addition of these nonlinear loads to the power lines means that active energy no longer represents the total energy delivered.Therefore, from the above discussion it can be concluded that the reactive power measurement is necessary to bill consumers, design the compensator, power factor correction and monitor power usage.
The aim of this study is to devise a method for practical measurement of reactive power.A reactive power measurement is essential to determine the reactive power demand and to assist in improving the voltage profile introducing power factor correction mechanism.It also enables the service provider to take the proper steps to reduce revenue losses, peak energy demand and increase power generation capacity to serve more consumers [11].Reactive power overloads the power lines and produces excessive thermal stress on the conductors, and it is also undesirable from the service provider's perspective.A decrease in the reactive power leads to lower expenses; once the reactive power has been measured, it can be compensated with the help of a suitable capacitor or a number of capacitors [2].
In this paper, we propose a more suitable implementation of the discrete wavelet transform (DWT) that uses a recursive pyramid algorithm (RPA) for reactive energy measurement in smart meters.This paper also investigates the effect of varying different system parameters such as the sampling rate, dc offset, phase offset, linearity error in current and voltage sensors, analog to digital converter resolution, and number of harmonics in a non-sinusoidal system on the reactive energy measurement using DWT.The error analysis is depicted in the form of the absolute difference between the measured and the true value of the reactive energy.
The rest of the paper is organized as follows: Section 2 discusses some of the related work.Section 3 discusses the different methods for measuring reactive power, their categorization, and the challenges involved with each of them.Section 4 describes reactive power measurement using the DWT and Section 5 suggests DWT implementation.Section 6 presents the results for different case studies and shows the impact of various kinds of errors.Section 7 provides some concluding remarks.

Related Work
Definitions and approaches for measuring reactive power have been developed in the time domain [12,13], Fourier (frequency domain) [14][15][16], and the wavelet domain (time-frequency domain) [17][18][19].The limitation of time domain definitions is that they cannot measure the reactive power for a specific frequency component and they also result in loss of temporal insights.Therefore, time-frequency (wavelet domain) analysis emerges as the most appropriate solution for measurements in power systems, because it preserves both temporal and spectral relationships associated with the resulting power [17].A comprehensive survey of the categories shown in Figure 1 has been presented in [20].The present paper focuses on wavelet-based power measurement in the smart meter.

Time-frequency domain
The advantage offered by wavelet domain analysis has been exploited by many studies on power measurement reported in the literature.For example, Yoon and Devaney [21] introduced the concept of power measurement using the DWT.In [2], the same authors proposed a calculation for reactive power using the DWT.That wavelet-based reactive power measurement system requires the phase shift of the input voltage or current signal.In [22], Vatansever and Ozdemir proposed a method for power measurement using the discrete wavelet packet transform and the Hilbert transform.In [2], Morsi summarized the approaches made to power measurement in the wavelet domain by comparing them.In [20], Morsi et al., investigated the usefulness of bio-orthogonal and reverse bio-orthogonal wavelets to measure reactive power.In [19], Morsi et al., proposed a method for measuring reactive power using the wavelet packet transform.In [23], Morsi presented a modified version of reactive power measurement using the DWT, which reduced the computational complexity when compared to the wavelet packet transform.
In this paper, we propose a more suitable implementation of the DWT for reactive power measurement in smart meters.General purpose computers can be used to implement DWT in an efficient algorithm using the pyramid algorithm (PA) proposed by Mallat [24,25].However, for real time or running implementations of DWT, the PA requires either O(N) storage or N cascade filters together in order to compute the N-point DWT.Both of these alternatives [that is, O (N) memory storage cells and N cascaded filters] are expensive.Hence, a more efficient method for measuring reactive power using DWT is desired for smart meters because real-time reactive power measurement must be computed.In the present study, we present a reformulation of the (PA), called the pyramid recursive algorithm (RPA), for use in reactive power measurement in smart meters.The RPA, first introduced by Vishwanarth [26], computes the N-point DWT using just L × log (N-L) storage cells, where L is the length of the filter and generally L << N. It takes the same number of operations as that required by the PA.

Reactive Power Measurement
The notations used in the paper are listed in Table 1.Reactive power calculation methods of commercially available smart meters can be divided into two types: a time shift approach and a power triangle approach [2].The following is a brief description of each method, along with its physical interpretation.

Time Shift Approach
A time delay is introduced to shift one of the waveforms by 90° at the fundamental frequency and to multiply the voltage and current waveforms, as shown in Figure 2. In [4], the reactive energy using time shift approach is mathematically expressed as: (1) where T is the time period of the fundamental frequency component of the voltage waveform.If the voltage and current waveforms contain harmonic distortion, the time shift approach loses its physical meaning because it is only valid when applied to the fundamental frequency component.Therefore, in the case of non-sinusoidal waveforms, reactive power measured by an electronic energy meter based on the time-shift approach will give a measurement that differs from the actual reactive energy.

Power Triangle Approach
The block diagram for calculating reactive power is shown in Figure 3.The power triangle method is based on the assumption that apparent, active, and reactive powers form a right angle triangle, as shown in Figure 3.In [4], the reactive power is mathematically expressed as: (2) where apparent power is the product of total root mean squared (rms) voltage and rms current: (3) Active power can be written as: (4) where T represents the time of interest or the observation time, or for periodic signals, the time period.
In an ideal power system, the voltage and currents are purely sinusoidal with a frequency of 50 Hz or 60 Hz, but in real power systems, current and voltage waveforms are no longer sinusoidal and contain harmonics due to existence of inductive, capacitive components and occurrence of distortions [27].
Unlike the time shift approach, the triangle approach is capable of calculating reactive power under most of the conditions that contribute to the degradation of the electric power quality-such as disturbances, harmonics distortion or losses, etc.However, it is unable to provide reactive power at the fundamental frequency under a non-sinusoidal condition.
Reactive power measurement using the power triangle method first needs to compute active and apparent power.Active power measurement is accurate for most energy meters, but the accuracy of the apparent power is bounded by the accuracy of the rms measurements.Therefore, in this paper, we also investigated the usefulness of the DWT for computing reactive power using the power triangle method under sinusoidal as well as non-sinusoidal cases, and by varying different operating parameters such as sampling rate, dc offset, phase offset, linearity error in current and voltage sensors, analog to digital converter resolution and a number of harmonics in the non-sinusoidal system.

Reactive Power Measurement Using the DWT
This section covers the operating principles of the reactive energy meters using the power triangle method and the DWT.Let v(t) and i(t) be the time domain signal of the voltage and the current waveform, respectively.In the time domain, the rms value can be calculated as follows: (5) (6) where n is the total number of samples in one period of the waveform; m is the current sample number; and v m and i m are the voltage and current values, respectively, defined in the samples.
Using DWT, the rms value of the voltage and current waveforms can be expressed as follows: where the c's and d's represent the scaling/approximation and detail wavelet coefficients; which quantify how closely the wavelet function matches the original waveform at sample time k and frequency sub-band j, with j o as the lowest frequency sub-band; Subscripts j and k refer to the wavelet level/frequency sub-band and the sample time; respectively, while the superscripts v and i represent the voltage and current coefficients, respectively, in the wavelet domain.The apparent power at the approximation level (lowest frequency band) j o , S jo , and the total apparent power S DWT are as follows: The reactive power in the wavelet can be calculated as: (11) where P DWT , total active power, is the sum of approximations and detail active power and can be written as: The reactive power Q contains all the non-active power due to harmonics and any oscillating power that does not contribute to the power transmission.When considering the apparent power at the lowest wavelet decomposition, the reactive power becomes: (13)

Implementation of the DWT
The wavelet theory was first applied to digital signal processing application following derivation of the PA for the DWT by Mallat [24,25].Since then, many applications of the DWT have been explored.In recent years, DWT has become a powerful tool for analyzing and measuring power in energy meters.The DWT can be viewed as a multi-resolution decomposition of a sequence.The large-scale study of wavelets for power measurement in energy meters has pointed to the importance of practical implementation of power measurement using the DWT. Figure 4 shows the block diagram of a smart meter in a smart grid, along with a schematic of the energy calculation algorithm using wavelet transform.For N points of input sequence x(n), DWT generates a sequence of length N as the output y(n).The output has N/2 values at the highest resolution and N/4 values at next to the highest resolution level, and so on.This mean time resolution is high at high frequency and low at low frequency, whereas frequency resolution is low at high frequency and high at low frequency.Let N = 2 J , where J is the number of frequencies.Therefore, the frequency index varies as 1, 2,…, J corresponding to the scales 2 1 , 2 2 ,…, 2 J .The scaling and detailed wavelet coefficients can be computed as follows: , , (15) where: k th approximation and detail coefficient at level j; Low pass and high pass L-tap filters obtained from chosen wavelet transform; N-sample input signal x(n); Number of wavelet coefficients in level j.

The Pyramid Algorithm (PA)
The pseudo code for the Pyramid algorithm can be written as: f s ← sampling rate a.TW ← observation interval for voltage or current waveform b.N = f s × TW 3. J = log 2 N 4. for (j = 1 to J) 5. for (k = 1 to 2 J − j ) 6.

7.
8. end for 9. end for 10. end for where J is the number of octaves; N = 2 J is the length of sequence x; L is the length of the wavelet filter; and w( ) and h( ) are the low pass and high pass filters; respectively, derived from the wavelet.The output for the j th octave is contained in d j (k).The PA algorithm can be implemented using either filter bank architecture or folded architecture, as shown in Figures 5 and 6, respectively.

Recursive Pyramid Algorithm (RPA)
The RPA proposed by Vishwanth is a reformulation of the PA proposed by Mallat for real-time computation of the DWT coefficients.The core aim of the RPA is to make the memory size independent of the input length.The basic idea behind the RPA is to rearrange the computation order of the DWT coefficient.In the RPA, each coefficient computation is scheduled at the earliest possible instance.This schedule for computing the DWT coefficients is based on the precedence rule; i.e., if the earliest instance of the i th octave clashes with the (I + 1) th octave, then the i th octave output is computed first.For the sake of understanding, the scheduling mechanism of the RPA considers a grid of the DWT coefficients as shown in Figure 7.This is now pushed in a way that makes all horizontal lines line up in the form of a single line (RPA output sequence).The order of the output gives the output schedule.The advantages offered by the RPA are:  Because each output of the j th octave is scheduled at the earliest instance, only the latest L words (L is the length of filter) need to be stored.Thus, the total memory size needed for DWT using RPA is L(J − 1), where J is the number of decomposition levels;  The memory size can be small because each output of the different decomposition level is computed at the earliest possible instance.This removes the need to store the whole result of the j th octave for (j + 1) th octave computations;  The input number of samples fed for each subsequent stage is equal to the length of the filter; therefore, it achieves a uniform rate; i.e., a practical rate.
6. else 7. recursive_dwt (i/2, j + 1) 8. end if 9. end The RPA algorithm architecture is shown in Figure 8.The routing network has to keep track of the latest Llog (N-L) blocks of output.The main disadvantage of implementing the RPA on general purpose computers is that the efforts required by the routing network to keep track of the latest Llog (N-L) block of output might prevail over the reduction in the memory storage because searching for data from a huge memory requires longer access time.Hence, smart meters can be implemented more practically using the DWT with the RPA, which requires fewer memory cells than the PA does.
Although, computing the DWT using the RPA reduces memory requirements quite remarkably, however, still it requires heavy arithmetic computation because it is essentially a two channel filter bank.This arithmetic complexity can be reduced by using lifting scheme implementation of the DWT [28].Implementation of lifting wavelet transform with an efficient RPA can be realized as an interesting future work for power measurement in smart meters.

Results and Discussion
This section first presents a comparison of the PA and the RPA in terms of the required numbers of memory cells and then provides an error analysis for power measurement using the DWT.Table 2 shows the memory required for the PA and the RPA for an input sequence having different samples, with a filter having 20 and 40 samples.Two case studies are introduced for error analysis, considering sinusoidal (linear load) and non-sinusoidal (non-linear load) operating conditions to show the performance of power measurement using the DWT under varying parameters.The overall block diagram of the simulated system is shown in Figure 9.
True values of the measurable quantities, such as P, Q, and S, are already predetermined because the input voltage and current waveform are synthesized by known parameters.The true value of Q is computed using the Hilbert transform.However, computing Q using the Hilbert transform at reasonable cost is not practically feasible because it requires a dedicated processor to process the Hilbert transform necessary to compute a constant phase shift of 90° at each harmonic frequency [29].Hence, the value of Q computed using the Hilbert transform approach is taken as the reference point and compared with the value of Q computed using the DWT and the absolute error is presented in the results.The input voltage or current waveforms are defined with parameters such as amplitude, fundamental frequency, and number of harmonics, phase offset, and (direct current) dc component.
The generalized form of sinusoidal voltage and current waveforms for case study 1 is defined as: where V max represents the peak voltage and I max is the peak current; α is the amplitude scaling; β is the dc offset; γ is the phase offset and t is the running time.
For the case study 2, the non-sinusoidal voltage waveform contains n harmonics and can be expressed as: (18) These input waveforms pass through an analog to digital converter (ADC); two things are defined here: i.e., sampling rate and the ADC resolution, meaning how many bits a sample represents.These sample sequences are fed to the processing unit where the power calculation is performed using DWT.The mother wavelet chosen for the DWT is Daubechies 10 (db10) and Daubechies 20 (db20).The simulation is conducted in Matlab and the developed GUI interface is shown in Figure 10.The time window (TW) in the figure indicates the observation time of the input waveform and is in multiple of the fundamental time period T.
The impact of sensor linearity error is shown by varying α in Equation ( 16), the impact of DC offset is shown by varying β, the impact of phase offset is shown by varying γ, the impact of nonlinear load is shown by varying the number of harmonics, the effect of ADC resolution is shown by varying the number of bits used to store a sample, and the impact of sampling rate is shown by varying the sampling frequency f s .The sampling frequency f s is taken as 1.92 kHz and a 64 bit floating point numbering system is used.Various values obtained for α, β and γ are shown in Table 3.The values of α, β, and γ for which the error value (ERR Q ) is lowest are highlighted.
Case study 2: Let v(t) be a waveform comprising three frequency components; i.e., fundamental frequency, third, and fifth harmonic.Current i(t) contains just the fundamental frequency component.These are given as: , The sampling frequency f s is taken as 1.92 kHz and a 64 bit (double) floating point numbering system is used.The results of varying values of α, β and γ are shown in Table 4.The values of α, β, and γ for which the error value (ERR Q ) is lowest are highlighted.The impact of ADC resolution on the power measurement is shown by conducting measurements under different data types; i.e., double, int32, int16, and int8 for both the sinusoidal and non-sinusoidal cases under Daubechies 10 (db10).Let values of α, β, and γ be 1, 0 and 2, respectively.Table 5 shows the results for both case study 1 and case study 2. The impact of sampling frequency f s on the power measurement is shown by conducting measurements under different sampling rates.Table 6 shows the results for both case study 1 and case study 2.

Conclusions
This paper presents an investigation of efficient implementation of power measurement using the DWT for practical smart meters.RPA-based DWT computation ideally suits power measurement in smart meters because it requires just L × log (N-L) words of storage for computation of the N-point DWT.The problems associated with the power measurement using the DWT are also discussed in terms of error analysis by varying the number of system parameters.The error in power measurement is investigated for different types of environments; i.e., for both linear and nonlinear loads.These studies have been conducted for a single-phase load, but extending this study to a three-phase system would be a worthwhile future task.

Figure 1 .
Figure 1.Categories of reactive power measurement definitions and approaches.

Figure 2 .
Figure 2. Time shift approach for reactive power calculation.

Figure 3 .
Figure 3. Power triangle approach for reactive power calculation.

Figure 4 .
Figure 4. Block diagram of an energy meter using wavelet transform in a smart grid.

Figure 7 .
Figure 7. Scheduling diagram for the RPA.

Figure 9 .
Figure 9. Block diagram of the power measurement system.

Figure 10 .
Figure 10.GUI for power measurement system.

Table 2 .
Comparison of required numbers of memory cells for the pyramid algorithm (PA) and the recursive pyramid algorithm (RPA).

Table 3 .
Results for case study 1.

Table 4 .
Results for case study 2.

Table 5 .
Effect of ADC resolution on the power measurement.

Table 6 .
Effect of sampling frequency on power measurement.