PQ and Harmonic Assessment Issues on Low-Cost Smart Metering Platforms: A Case Study

This paper presents a feasibility study on how to implement power quality (PQ) metrics in a low-cost smart metering platform. The study is aimed at verifying the possibility of implementing PQ monitoring in distribution networks without replacing existing smart metering devices or adding new modules for PQ measurements, thus zeroing the installation costs. To this aim, an electronic board, currently used for remote energy metering, was chosen as a case study, specifically the STCOMET platform. Starting from the specifications of this device, the possibility of implementing power quality metrics is investigated in order to verify if compliance with standard requirements for PQ instruments can be obtained. Issues related to device features constraints are discussed; possible solutions and correction algorithms are presented and experimentally verified for different PQ metrics with a particular focus on harmonic analysis. The feasibility study takes into account both the use of on-board voltage and current transducers for low voltage applications and also the impact of external instrument transformers on measurement results.


Introduction
Nowadays smart metering devices have widespread use in many countries around the world to enable automatic meter reading (AMR) and other smart grid functionalities. Typical features include the measurement of different quantities, such as energy consumptions, supply voltages, frequency, absorbed currents and powers, as well as communication functionalities for enabling meter interaction with the grid and information exchange between customers and utilities. In this framework, several studies and proposals can be found in literature concerning both AMR, enhanced smart grid applications, and related measurement and communication issues. For example, in [1] and [2] main smart metering and communications technologies are surveyed, in the viewpoint of their integration in smart grid and industrial contexts; main features of metering and communication equipment and methods are analyzed, putting in evidence the advantages and open issues concerning advanced measurement and communication features. In [3], an overview is given of the enabling technologies and standards for communication, sensing, and monitoring purposes, also from the viewpoint of the full integration of distributed generation and storage systems at the customer level. In [4], a study is made on the possible integration of AMR with further sensing and IoT functionalities. of a device and related metering algorithms for PQ monitoring, based on the Arduino NANO V3 ATmega328 microprocessor; the proposed device is integrated into a system for power supply reliability and power quality monitoring at both sides of switching devices.
It should be noticed that, in the viewpoint of widespread diffusion of PQ measurements at the user level, the installation of sophisticated and expensive instrumentation is not economically feasible. On the other hand, low-cost devices have been proposed to implement PQ measurement tasks; in this case, such additional instrumentation should be installed alongside the currently employed energy meters or new integrated platforms should replace those already used in distribution networks. In [35], the authors have investigated an alternative approach to the problem, i.e., the possibility of implementing PQ metrics on existing smart metering platforms; thus, exploiting current installed instrumentation and hardware architectures, by only modifying firmware and implemented metrics. This allows for the zeroing of the installation costs. The integration of PQ metrics into existing smart meters could open new market opportunities for both energy traders and manufacturers; moreover, this can allow users to easily monitor the quality of supplied power, without the need to handle different metering devices.
PQ phenomena measurements and limits are covered by specific standards [36][37][38][39][40]. The main reference is the IEC 61000-4-30, which defines the methods for PQ parameter measurement and the related accuracy requirements; as regards, harmonics (and interharmonics) measurements, it refers to IEC 61000-4-7. The instrument's compliance with such standards is crucial to enable their use for monitoring or even billing purposes. In more detail, IEC 61000-4-30 defines two classes of measurements, i.e., classes A and S (correspondent to classes I and II of IEC 61000-4-7, respectively). Class A instruments are meant to be used for contractual applications or compliance verification with allowed disturbances limits; class S instruments are allowed for statistical applications such as surveys or power quality assessment and they obviously entail processing requirements lower than those of class A.
When dealing with PQ and harmonics measurements, another important issue to be considered is the influence of measurement transducers on the metrological accuracy of the whole measurement chain (i.e., transducers plus instrument) [41][42][43][44][45][46][47]. In fact, it is known that transducers can introduce relevant uncertainty contributions, especially when measured signals are not purely sinusoidal, because of transducer nonlinearities, frequency response, and bandwidth. In this viewpoint, PQ standards do not cover the presence of measurement transducers external to the instrument, and accuracy requirements do not include the transducers contribution. This problem is considered in the technical report IEC TR 61869-103 [38], which specifically deals with the use of instrument transformers (both inductive and electronic) for power quality measurements.
Starting from the aforesaid standard requirements for PQ and harmonic measurements, this paper investigates the issues related to the integration of PQ metrics on commercial platforms for smart metering. The device used as a case study is the STCOMET by STMicroelectronics [48], which is currently used in different countries for energy meter deployment. In detail, this paper is an extension of a previous author's work [35], where a first implementation of some PQ metrics was presented. STCOMET already implements some PQ parameter metrics, such as frequency, RMS, dips, and swells. In [35], the compliance of on-board metrics with IEC 61000-4-30 was evaluated and some correction metrics were implemented and experimentally tested. In this way, the STCOMET measurement performances of the above-mentioned PQ parameters were found compatible with the accuracy class S requirements (in some cases even class A requirements were met). This paper investigates the possibility of implementing further metrics for harmonics measurement. Taking into account the constraints due to STCOMET technical specifications, a harmonic analysis algorithm was designed and implemented. Experimental tests were performed using the reference calibrator Fluke 6100A [49], in order to evaluate the compatibility between measurement errors and standard limits, according to IEC 61000-4-7. Furthermore, the impact of external measurement transducers on the whole measurement Sensors 2020, 20, 6361 4 of 27 system accuracy is also analyzed; harmonics amplitude and phase errors were evaluated with and without external current transducers, to distinguish their contribution to measurement accuracy.
The paper is organized as follows. In Section 2, STCOMET specifications are analyzed from the viewpoint of obtaining measurement compliance with standard prescriptions, highlighting the main measurement issues to be considered for each accuracy class. Section 3 describes the implementation of the different PQ metric on STCOMET, the required correction algorithms, with a special focus on harmonic analysis. Section 4 reports the experimental characterization results for voltage and current measurements, both in sinusoidal and distorted conditions; tests were carried out both with and without an external current transformer, to evaluate its influence on the final measurement accuracy.

STCOMET Specifications and Standards Requirements
The evaluation kit for the STCOMET platform, named EVLKSTCOMET10-1 [48], was used as a case study to demonstrate the feasibility of the PQ measurement capability of an electronic board currently used for remote energy metering. EVLKSTCOMET10-1 includes a Cortex ™ -M4 microcontroller, a metrology section, and a power line communication (PLC) transceiver in a single device. The embedded PLC coupling circuit allows the STCOMET device to transmit and receive communication signals on the low voltage mains. More in detail, single carriers or OFDM (orthogonal frequency-division multiplexing) multi-carrier signals up to 500 kHz can be selected, enabling automatic meter reading (AMR) applications. The device functional block diagram is shown in Figure 1. The paper is organized as follows. In Section 2, STCOMET specifications are analyzed from the viewpoint of obtaining measurement compliance with standard prescriptions, highlighting the main measurement issues to be considered for each accuracy class. Section 3 describes the implementation of the different PQ metric on STCOMET, the required correction algorithms, with a special focus on harmonic analysis. Section 4 reports the experimental characterization results for voltage and current measurements, both in sinusoidal and distorted conditions; tests were carried out both with and without an external current transformer, to evaluate its influence on the final measurement accuracy.

STCOMET Specifications and Standards Requirements
The evaluation kit for the STCOMET platform, named EVLKSTCOMET10-1 [48], was used as a case study to demonstrate the feasibility of the PQ measurement capability of an electronic board currently used for remote energy metering. EVLKSTCOMET10-1 includes a Cortex ™ -M4 microcontroller, a metrology section, and a power line communication (PLC) transceiver in a single device. The embedded PLC coupling circuit allows the STCOMET device to transmit and receive communication signals on the low voltage mains. More in detail, single carriers or OFDM (orthogonal frequency-division multiplexing) multi-carrier signals up to 500 kHz can be selected, enabling automatic meter reading (AMR) applications. The device functional block diagram is shown in Figure 1.
As regards the measurement transducers, a resistive divider is used as a voltage sensor (Figure 2), while a shunt and a current transformer are available for current measurements (the shunt was used in experimental tests).  As regards the measurement transducers, a resistive divider is used as a voltage sensor (Figure 2), while a shunt and a current transformer are available for current measurements (the shunt was used in experimental tests). The metrology section includes a three-channel analog front end (AFE) with 24-bit sigma-delta converters and a dedicated digital signal processor (DSP). Available memories are: 640 kB or 1 MB of embedded Flash; 128 kB of embedded SRAM (static RAM); 8 kB of embedded shared RAM. EVLKSTCOMET10-1 metrological specifications are summarized in Table 1. As mentioned in the introduction, IEC 61000-4-30 and IEC 61000-4-7 are the reference standards for PQ and harmonic measurements: IEC 61000-4-30 covers PQ measurement methods [36], referring to IEC 61000-4-7 for harmonics measurements [37]. Among the PQ parameters covered by the aforesaid standards, STCOMET base firmware already embeds metrics for power system frequency, voltage and current rms, and dips and swells. For those metrics, compatibility with standard requirements was analyzed in the paper, eventually suggesting correcting algorithms. The harmonic measurement metric is not available in the original firmware, thus it was developed, implemented, and tested.
According to IEC 61000-4-30, two possible classes are defined for measuring instruments: named A and S (corresponding to class I and II of IEC 61000-4-7, respectively). Class A is used when precise measurements are required (for example, in the case of billing applications that may require the resolution of disputes, detection of possible fraud, attribution of economical penalties for exceeding the standard limits, etc.) and class S is used for statistical applications (such as investigations of the origin of power quality disturbances, even with a limited subset of parameters PQ). For both classes, the base time interval (t.i.) for many measurements (voltage and current rms, harmonics, interharmonics, and unbalance) is 10/12 cycles for 50/60 Hz systems (i.e., 200 ms in the 50 Hz case). The 10/12 cycle values are then aggregated over three additional time intervals: 150/180 cycles, 10 min, and two hours.
As regards harmonic measurements, the IEC 61000-4-7 standard defines measurement requirements for harmonic distortion assessment both in terms of single harmonic component The metrology section includes a three-channel analog front end (AFE) with 24-bit sigma-delta converters and a dedicated digital signal processor (DSP). Available memories are: 640 kB or 1 MB of embedded Flash; 128 kB of embedded SRAM (static RAM); 8 kB of embedded shared RAM. EVLKSTCOMET10-1 metrological specifications are summarized in Table 1. As mentioned in the introduction, IEC 61000-4-30 and IEC 61000-4-7 are the reference standards for PQ and harmonic measurements: IEC 61000-4-30 covers PQ measurement methods [36], referring to IEC 61000-4-7 for harmonics measurements [37]. Among the PQ parameters covered by the aforesaid standards, STCOMET base firmware already embeds metrics for power system frequency, voltage and current rms, and dips and swells. For those metrics, compatibility with standard requirements was analyzed in the paper, eventually suggesting correcting algorithms. The harmonic measurement metric is not available in the original firmware, thus it was developed, implemented, and tested.
According to IEC 61000-4-30, two possible classes are defined for measuring instruments: named A and S (corresponding to class I and II of IEC 61000-4-7, respectively). Class A is used when precise measurements are required (for example, in the case of billing applications that may require the resolution of disputes, detection of possible fraud, attribution of economical penalties for exceeding the standard limits, etc.) and class S is used for statistical applications (such as investigations of the origin of power quality disturbances, even with a limited subset of parameters PQ). For both classes, the base time interval (t.i.) for many measurements (voltage and current rms, harmonics, interharmonics, and unbalance) is 10/12 cycles for 50/60 Hz systems (i.e., 200 ms in the 50 Hz case). The 10/12 cycle values are then aggregated over three additional time intervals: 150/180 cycles, 10 min, and two hours.
As regards harmonic measurements, the IEC 61000-4-7 standard defines measurement requirements for harmonic distortion assessment both in terms of single harmonic component amplitudes and global parameters, such as the total harmonic distortion (THD) factor. The standard also provides indications regarding the general structure of measurement instruments, which is preferably based on the use of the discrete Fourier transform (DFT) and implemented by means of the fast Fourier transform (FFT) algorithm for shorter computation time (see Figure 3).
Sensors 2020, 20, x FOR PEER REVIEW 6 of 25 amplitudes and global parameters, such as the total harmonic distortion (THD) factor. The standard also provides indications regarding the general structure of measurement instruments, which is preferably based on the use of the discrete Fourier transform (DFT) and implemented by means of the fast Fourier transform (FFT) algorithm for shorter computation time (see Figure 3). According to IEC 61000-4-7, the base time interval window must be synchronized to the fundamental power system frequency; the time between the leading edges of the first and the (N + 1)th sampling pulses (where N is the number of samples acquired in the observation window) shall be equal to the duration of the specified number of cycles, with a maximum allowable error of ±0.03% for class A instruments. Phase-locked loop or other synchronization systems are needed to properly generate the sampling frequency, in order to meet the aforesaid synchronization requirements. Hanning weighting is allowed only in the case of the loss of synchronization, even if in such occurrence the data shall be flagged and not used for the purpose of determining compliance with standard PQ limits.
On STCOMET, the input signal period is obtained by means of a zero-crossing method. Frequency is obtained from the period measurement. Using this method, it is necessary to filter harmonics and inter-harmonics, in order to minimize the effects of multiple zero crossings. This is in accordance with IEC 61000-4-30, which requires attenuating harmonics and inter-harmonics before measuring frequency. The STCOMET DSP calculates the period using the zero-crossing signal (ZRC) of the fundamental harmonic voltage, which is measured through a low-pass filter connected at the voltage channel. The resolution of the zero-crossing signal is 8 μs (given by the internal clock at 125 MHz); period measurement is updated every eight cycles of the input signal.
Even if the period is continuously measured, STCOMET sampling frequency cannot be synchronized to input signal frequency. In fact, as typically happens for many low-cost commercial platforms, STCOMET has a fixed sampling frequency. Thus, the synchronous sampling condition can be obtained only by properly choosing the number of acquired samples (N) in order to acquire an integer number of cycles of the input signal (10/12 cycles for the base time interval for power quality and harmonic measurements). In more detail, the STCOMET board has a fixed frequency sampling equal to fs = 7812.5 Hz (see Table 1), corresponding to a sampling period Ts = 128 μs. Considering a power system frequency of 50 Hz and the 10 cycles observation window Tw = 200 ms, the number of acquired samples is: FFT spectral resolution is: The synchronization error, corresponding to 0.5 samples, is of E = 0.5 × Ts = 64 μs, which in percentage terms can be calculated as follows: According to IEC 61000-4-7, the base time interval window must be synchronized to the fundamental power system frequency; the time between the leading edges of the first and the (N + 1)th sampling pulses (where N is the number of samples acquired in the observation window) shall be equal to the duration of the specified number of cycles, with a maximum allowable error of ±0.03% for class A instruments. Phase-locked loop or other synchronization systems are needed to properly generate the sampling frequency, in order to meet the aforesaid synchronization requirements.
Hanning weighting is allowed only in the case of the loss of synchronization, even if in such occurrence the data shall be flagged and not used for the purpose of determining compliance with standard PQ limits.
On STCOMET, the input signal period is obtained by means of a zero-crossing method. Frequency is obtained from the period measurement. Using this method, it is necessary to filter harmonics and inter-harmonics, in order to minimize the effects of multiple zero crossings. This is in accordance with IEC 61000-4-30, which requires attenuating harmonics and inter-harmonics before measuring frequency. The STCOMET DSP calculates the period using the zero-crossing signal (ZRC) of the fundamental harmonic voltage, which is measured through a low-pass filter connected at the voltage channel. The resolution of the zero-crossing signal is 8 µs (given by the internal clock at 125 MHz); period measurement is updated every eight cycles of the input signal.
Even if the period is continuously measured, STCOMET sampling frequency cannot be synchronized to input signal frequency. In fact, as typically happens for many low-cost commercial platforms, STCOMET has a fixed sampling frequency. Thus, the synchronous sampling condition can be obtained only by properly choosing the number of acquired samples (N) in order to acquire an integer number of cycles of the input signal (10/12 cycles for the base time interval for power quality and harmonic measurements). In more detail, the STCOMET board has a fixed frequency sampling equal to fs = 7812.5 Hz (see Table 1), corresponding to a sampling period Ts = 128 µs. Considering a power system frequency of 50 Hz and the 10 cycles observation window Tw = 200 ms, the number of acquired samples is: FFT spectral resolution is: Sensors 2020, 20, 6361 The synchronization error, corresponding to 0.5 samples, is of E = 0.5 × Ts = 64 µs, which in percentage terms can be calculated as follows: Therefore, the instrument based on STCOMET cannot be classified in class A; thus, in the performed feasibility study class S requirements have been considered as a target for the implementation and verification of PQ and harmonics measurement metrics.
As regards the data aggregation over additional intervals, class S requirements are depicted in Figures 4 and 5. In more detail, the data for the 150/180-cycles (i.e., 3 s) time interval shall be aggregated from fifteen contiguous 10/12-cycles (200 ms) base time intervals (see Figure 4). The aggregated data are calculated as the square root of the arithmetic mean of the squared input values measured in the base time intervals. For example, this is the case of RMS measurements. On the other hand, gaps are permitted for harmonics, inter-harmonics, mains signaling voltage, and unbalance (see Figure 5); in this case, a minimum of three 10/12-cycles values shall be used every 150/180-cycle time interval, i.e., at least one 10/12-cycles value shall be used every 50/60 cycles (1 s). This allows for the exploiting of the permitted gaps to reduce both the number of data to be aggregated (a minimum of one 10/12 cycles t.i. of every 50/60 cycles, for a total of three to mediate) and the computational time requirements. Slightly different aggregation intervals are defined in [38]; for example, 1 min aggregation intervals are considered for the assessment of voltage variations. In this framework, in [50] some comparative analyses have been made on the application of 1 and 10 min aggregation t.i., showing how the different t.i. and the requirements to have 100% of the measured data in the permissible range can pose some issues for the event assessment sensitivity, i.e., a single 1 min value can cause a negative assessment of voltage variation. Therefore, the instrument based on STCOMET cannot be classified in class A; thus, in the performed feasibility study class S requirements have been considered as a target for the implementation and verification of PQ and harmonics measurement metrics.
As regards the data aggregation over additional intervals, class S requirements are depicted in Figures 4 and 5. In more detail, the data for the 150/180-cycles (i.e., 3 s) time interval shall be aggregated from fifteen contiguous 10/12-cycles (200 ms) base time intervals (see Figure 4). The aggregated data are calculated as the square root of the arithmetic mean of the squared input values measured in the base time intervals. For example, this is the case of RMS measurements. On the other hand, gaps are permitted for harmonics, inter-harmonics, mains signaling voltage, and unbalance (see Figure 5); in this case, a minimum of three 10/12-cycles values shall be used every 150/180-cycle time interval, i.e., at least one 10/12-cycles value shall be used every 50/60 cycles (1 s). This allows for the exploiting of the permitted gaps to reduce both the number of data to be aggregated (a minimum of one 10/12 cycles t.i. of every 50/60 cycles, for a total of three to mediate) and the computational time requirements. Slightly different aggregation intervals are defined in [38]; for example, 1 min aggregation intervals are considered for the assessment of voltage variations. In this framework, in [50] some comparative analyses have been made on the application of 1 and 10 min aggregation t.i., showing how the different t.i. and the requirements to have 100% of the measured data in the permissible range can pose some issues for the event assessment sensitivity, i.e., a single 1 min value can cause a negative assessment of voltage variation.  IEC 61000-4-7 accuracy requirements are reported in Table 2 for class I and class II instruments; the maximum allowable errors refer to single-frequency and steady-state signals, in the operating frequency range and under rated operating conditions indicated by the manufacturer (temperature and/or humidity ranges, rated supply voltage, etc.). No specific accuracy requirements are given for phase angle measurement.
Another important aspect to be addressed when dealing with power quality and harmonic measurements is the impact of measurement transducers. In fact, it is known that they are a key component of the measurement chain, which has a great impact on the overall measurement accuracy. Therefore, the instrument based on STCOMET cannot be classified in class A; thus, in the performed feasibility study class S requirements have been considered as a target for the implementation and verification of PQ and harmonics measurement metrics.
As regards the data aggregation over additional intervals, class S requirements are depicted in Figures 4 and 5. In more detail, the data for the 150/180-cycles (i.e., 3 s) time interval shall be aggregated from fifteen contiguous 10/12-cycles (200 ms) base time intervals (see Figure 4). The aggregated data are calculated as the square root of the arithmetic mean of the squared input values measured in the base time intervals. For example, this is the case of RMS measurements. On the other hand, gaps are permitted for harmonics, inter-harmonics, mains signaling voltage, and unbalance (see Figure 5); in this case, a minimum of three 10/12-cycles values shall be used every 150/180-cycle time interval, i.e., at least one 10/12-cycles value shall be used every 50/60 cycles (1 s). This allows for the exploiting of the permitted gaps to reduce both the number of data to be aggregated (a minimum of one 10/12 cycles t.i. of every 50/60 cycles, for a total of three to mediate) and the computational time requirements. Slightly different aggregation intervals are defined in [38]; for example, 1 min aggregation intervals are considered for the assessment of voltage variations. In this framework, in [50] some comparative analyses have been made on the application of 1 and 10 min aggregation t.i., showing how the different t.i. and the requirements to have 100% of the measured data in the permissible range can pose some issues for the event assessment sensitivity, i.e., a single 1 min value can cause a negative assessment of voltage variation.  IEC 61000-4-7 accuracy requirements are reported in Table 2 for class I and class II instruments; the maximum allowable errors refer to single-frequency and steady-state signals, in the operating frequency range and under rated operating conditions indicated by the manufacturer (temperature and/or humidity ranges, rated supply voltage, etc.). No specific accuracy requirements are given for phase angle measurement.
Another important aspect to be addressed when dealing with power quality and harmonic measurements is the impact of measurement transducers. In fact, it is known that they are a key component of the measurement chain, which has a great impact on the overall measurement accuracy. IEC 61000-4-7 accuracy requirements are reported in Table 2 for class I and class II instruments; the maximum allowable errors refer to single-frequency and steady-state signals, in the operating frequency range and under rated operating conditions indicated by the manufacturer (temperature and/or humidity ranges, rated supply voltage, etc.). No specific accuracy requirements are given for phase angle measurement. Another important aspect to be addressed when dealing with power quality and harmonic measurements is the impact of measurement transducers. In fact, it is known that they are a key component of the measurement chain, which has a great impact on the overall measurement accuracy. In IEC 61000-4-30 the effect of transducers is acknowledged but not addressed in detail and external transducers and their associated uncertainty is not included in the accuracy requirements. The nature of this problem is better addressed in IEC TR 61869-103 [38], which specifically deals with the use of instrument transformers (both inductive and electronic) for power quality measurements. As detailed in [38], to evaluate transducer influence on the overall uncertainty on the measurement of a given power quality parameters, it is necessary to simultaneously consider the behavior of the transducer for a given disturbance and the related measurement method. Typically, the nonlinearity of the transducer can determine a worsening of the measurement uncertainty when the input signal (voltage or current) is not sinusoidal. The transducer impact on the overall uncertainty can be quantified as an added uncertainty that combines with the uncertainty of the measuring system. In this viewpoint, harmonic measurements can be negatively affected by the transducer presence, because of its frequency response (and bandwidth).
In this framework, the issues related to the implementation of harmonic analysis on STCOMET are analyzed in Section 3.2 with the aim of investigating the possibility of developing an instrument for harmonic measurements compliant with IEC 61000-4-7 accuracy requirements (class II). For phase angles measurements, quality metering specifications of IEC TR 61869-103 have [38] been used for reference; according to quality metering requirements of [38], phase errors at harmonics should be below 1 • for 1st and 2nd harmonic and below 5 • for other harmonics.

On-Board Metrics Compliance Verification and Correction Algorithms
As mentioned in the previous section, STCOMET already implements the measurement of: power system frequency; voltage and current RMS; and voltage dips and swells. The comparison between the IEC 61000-4-30 requirements for class S instruments and the STCOMET on-board metrics is reported in Table 3. To meet IEC 61000-4-30 requirements for on-board metrics, some correction algorithms have been implemented, as described in [35]. In brief: − For frequency measurement, the main difference between IEC 61000-4-30 requirements and STCOMET on-board metric is the measurement time (10 s vs. 8 µs, i.e., STCOMET measurements are updated every 8 µs); thus the measurement over 10 s has been obtained as the mean of the frequency values (updated at every 8 µs) over the time interval of 10 s.
− For voltage/current RMS measurement, the main difference between the IEC 61000-4-30 requirements and STCOMET on-board metric is the observation window in subsequent measurements. In fact, IEC 61000-4-30 requires that the measurements shall be obtained over the base time interval (e.g., 10 cycles at 50 Hz); subsequent time intervals shall be contiguous, and not overlapping. STCOMET calculates RMS over the aforesaid base time interval; however, the RMS measurement is updated every 128 µs, i.e., once a new signal sample is available from the analog to digital converter (ADC). Thus, in the correction algorithm, the measurement reading update has been modified in order to obtain one RMS reading every 10 cycles. − Main on-board metrics modifications were made for swells, dips, and interruptions.
In fact, for swells and dips, IEC 61000-4-30 requires the measurement of a pair of data, i.e., the maximum/residual/voltage (i.e., the maximum/minimum voltage value recorded during the swell/dip) and the event duration, which is the difference between start and end times of the swell/dip (i.e., the time when the voltage RMS rises above/falls below the swell/dip threshold, and the time when the voltage RMS equals or goes back below/above the threshold); in this case, the RMS shall be measured over half a cycle or one cycle (Urms(1/2) or Urms(1), respectively). For interruptions, only event duration shall be measured. The STCOMET on-board metric was very different from the IEC 61000-4-30 one. Thus, a new algorithm was implemented, based on the measurement of Urms(1), as summarized in Table 3.
The aforesaid metrics were experimentally validated in [35]. In the following, further results are reported for frequency and RMS measurements, in both sinusoidal and distorted conditions which confirm the class S requirements compliance.
As regards the metrics not already on-board on STCOMET, in this study, voltage and current harmonics measurements have been implemented and tested, as described in the next sections.

Harmonics Analysis Implementation on STCOMET
As already mentioned, the EVLKSTCOMET10-1 uses a zero-crossing method for measuring the signal period/frequency, therefore this value can be used for the synchronization of the observation window Tw of 10/12 cycles of the 50/60 Hz input signal, i.e., 200 ms. If the frequency is not 50 Hz, the window would be greater or less than 200 ms. In accordance with [37], DFT/FFT algorithms have been evaluated for harmonic analysis. DFT can be performed with any number of samples N, but it has a higher computational cost (O(N 2 )); on the other hand, the FFT has a much lower computational cost (O(NlogN)), however, it needs a number of samples equal to a power of two to be performed (i.e., N = 1024, 2048, etc). An analysis of the computational time required for the algorithm executions with STCOMET leads to choose FFT (DFT execution time was not compatible with timing requirements for harmonic analysis even considering gaps).
To use the FFT, the closest values for N should be 2048. On the other hand, the STCOMET has a fixed sampling frequency of 7812.5 Hz, then the acquisition of 2048 samples would lead to a not synchronous observation window (i.e., Tw = 2048 × 128 µs ≈ 262 ms 200 ms). Thus, a time-domain interpolation algorithm has been implemented to obtain N = 2048 samples over the time interval of 10 cycles. Figure 6 shows a flow chart representing the operations of the algorithm implemented on STCOMET.   In this way, whatever the input signal period is, the algorithm is able to virtually synchronize the observation window, in order to minimize the synchronization error. In addition, the "virtual re-sampling" of the signal allows for the calculation of the FFT on 2048 samples in the observation window of 10 signal periods, thus minimizing leakage and scallop loss errors. The adoption of a simple linear interpolation algorithm allows for the limiting of the computational cost of the harmonic calculation (FFT + interpolation). To demonstrate this, the FFT computation time was experimentally measured, both with and without the interpolation; as shown in Figure 7, the overall time needed for FFT with interpolation is 11.4 ms (a time of 9.6 ms was measured in the case of FFT calculation without interpolation). It should be noted that while executing the interpolation and FFT algorithms, the device continues acquiring the samples of the subsequent observation window, which are stored in memory for the next FFT calculation. As regards the memory requirements, in the case of f = 50 Hz, Tw = 200 ms, and fs = 7812.5 Hz, the number of samples acquired is M = Tw/fs = 1563, so the number of bytes allocated in the STCOMET memory for samples storage is: K = 1563 × 32 = 6.252 kB (5) Considering that for the FFT calculation it is necessary to store 2048 samples (with both real and imaginary part), memory occupation is equal to 2048 × 32 × 2 = 16 kB. Furthermore, to allow the acquisition of samples of the subsequent observation window while performing the FFT calculation, it is necessary to instantiate a second register of 16 kB size. This was made in order to investigate the possibility of harmonic measurements without gaps between the observation windows. In summary, 32 kB are needed for samples storage and the FFT calculation algorithm; this requirement is compliant with STCOMET features, since the device has a RAM of 128 kB.
In this way, whatever the input signal period is, the algorithm is able to virtually synchronize the observation window, in order to minimize the synchronization error. In addition, the "virtual re-sampling" of the signal allows for the calculation of the FFT on 2048 samples in the observation window of 10 signal periods, thus minimizing leakage and scallop loss errors. The adoption of a simple linear interpolation algorithm allows for the limiting of the computational cost of the harmonic calculation (FFT + interpolation). To demonstrate this, the FFT computation time was experimentally measured, both with and without the interpolation; as shown in Figure 7, the overall time needed for FFT with interpolation is 11.4 ms (a time of 9.6 ms was measured in the case of FFT calculation without interpolation). It should be noted that while executing the interpolation and FFT algorithms, the device continues acquiring the samples of the subsequent observation window, which are stored in memory for the next FFT calculation.

Test System
A measuring test bench was been set up as shown in Figure 9. To evaluate the PQ measurement performances, a calibrator was used as a reference for both voltage and current. The calibrator model used for experimental tests was the Fluke 6100A. Full accuracy specifications of the calibrator for PQ parameters are reported in the instrument manual [48]. Main accuracy specifications for the tests herein presented are the following: 50 ppm for frequency (setting the resolution to 0.1 Hz); up to ± (190 ppm of output + 33 mV) for fundamental and harmonic voltage amplitudes in the range from 70 to 1008 V for frequencies from 16 to 850 Hz and ± (524 ppm of output + 33 mV) for frequencies from 850 Hz to 6 kHz; up to ± (267 ppm of output + 720 µA) for fundamental and harmonic current amplitudes in the range from 2 to 21 A for frequencies from 16 to 850 Hz; up to 0.080 • for current to voltage phase shift, for frequencies from 16 to 850 Hz and amplitudes from 0.5% to 40% of range. For the feasibility study presented in this work, the calibrator was assumed as a reference for the STCOMET characterization; for each measured quantity, the measurement system error was calculated as the difference between the value set on the calibrator and that measured with STCOMET. harmonic analysis algorithm using the IAR Embedded Workbench.
Tests were carried out reproducing different PQ phenomena (harmonics, dips, and swell interruptions) and for different frequencies of the test signal (in the range of 42.5 ÷ 57.5 Hz). Some results for dips, swells, and interruptions can be found in [35]. In the following sections, some results for frequency and voltage/current RMS and harmonics measurements are presented. For current measurements, both amplitudes and phase errors are shown. Figure 9. Test bench. Figure 9. Test bench.
Voltage measurements were directly acquired by STCOMET. To investigate the impact of external measurement transducers, current measurements were carried out with and without an external current transformer (CT); in both cases, the STCOMET current channel with internal shunt was used. The external current transformer is an open window CT used by Italian utilities to connect energy meters to low voltage distribution networks. The CT-rated data are summarized in Table 4. The window diameter is 3 cm. The EVLKSTCOMET10-1 has been connected to a PC via USB JTAG J-linkOB. STCOMET firmware was updated with both the corrected on-board metrics and the harmonic analysis algorithm using the IAR Embedded Workbench. Tests were carried out reproducing different PQ phenomena (harmonics, dips, and swell interruptions) and for different frequencies of the test signal (in the range of 42.5 ÷ 57.5 Hz). Some results for dips, swells, and interruptions can be found in [35]. In the following sections, some results for frequency and voltage/current RMS and harmonics measurements are presented. For current measurements, both amplitudes and phase errors are shown.

Voltage Measurements
Tests have been made in both sinusoidal and distorted conditions. Results obtained with the FFT algorithm are shown, together with RMS and frequency measurements; as already mentioned, errors between values generated by the calibrator and those measured by STCOMET are calculated and compared with IEC 61000-4-30 and IEC 61000-4-7 accuracy requirements. In more detail, calculated errors are listed in Table 5. where: • f_FFT e V_FFT are frequency and amplitude (in RMS) measured by STCOMET (fundamental and harmonics); • f_gen e V_gen are frequency and amplitude (in RMS) generated by the calibrator (fundamental and harmonics).
Some results of tests with sinusoidal voltage are reported in Table 6, for different frequency values (50, 42.5, and 57.5 Hz). Figures 10-12 show the spectra obtained at the three frequencies 50, 42.5, and 57.5 Hz, respectively. The obtained errors are compatible with the limits set by IEC 61000-4-30 for class S instruments (equal to ±50 mHz and ±0.5% for frequency and RMS measurements, respectively).           Further tests were performed with distorted voltage signals, with 25 harmonics, choosing the harmonic amplitudes equal to the limit values for electrical networks reported in CEI EN 50160 [40] and shown in Table 7. The voltage of the fundamental harmonic generated by the calibrator was V1 = 230 V and the RMS voltage was V = 231.47 V. The tests were carried out for different frequency values.
In Table 8, the results of the first test performed at a fundamental frequency f 1 = 50 Hz are reported. As can be seen, the measurement results are within the class S requirements (for frequency also class A requirements are met). The measured errors for each harmonic are reported in Table 9. Comparing these values with that of the limits reported in Table 2, it is possible to observe that the measuring system is compatible with the class II requirements (in some cases measurement results comply also with class I limits).
• f_gen is the frequency generated by the calibrator; • V_gen is the voltage generated by the calibrator; • f_FFT is the frequency measured using the FFT algorithm; • E is the absolute error between f_FFT and f_gen expressed in mHz; • V_FFT is the measured voltage; • Em is the error on the measured value calculated (see Table 2); • En is the error on the nominal value (see Table 2).
The same test with 25 harmonics was repeated for different signal frequencies. Some results are reported in the following tables for 42.5 Hz (see Tables 10 and 11) and 57.5 Hz (see Tables 12 and 13). Even in these cases, measurement results are within the class S maximum allowable errors for RMS and frequency and they are compatible with the class II requirements for harmonic measurements (for frequency also class A requirements are met and in many cases errors on harmonics are within class I limits).   Further tests were carried out by changing the phase shift between harmonic and fundamental components of the voltage test signal. This allowed for the investigation of the influence of harmonic phase shift, which can negatively affect the measurement accuracy, especially in the presence of measurement transducers. Tests herein presented were performed with a distorted voltage with fundamental frequency f 1 = 50 Hz, fundamental amplitude V 1 = 230 V, and four harmonics, i.e., the II, III, VI, and XI order harmonics. Each harmonic has an amplitude equal to 10% of the fundamental. For each harmonic, phase shift with respect to the fundamental harmonic was changed from −180 • to +180 • , with steps of 30 • . Tables 14 and 15 show amplitude and phase errors in harmonic voltage measurements, respectively. It can be seen that the proposed measurement system complies with class I requirements.

Current Measurements
The tests made for voltage were repeated also for currents. As regards RMS and FFT measurements, the results obtained were similar to those obtained for voltage measurements.
The tests with harmonics at different phase-shifts were carried out with and without the external CT, in order to investigate not only the STCOMET behavior in current measurements but also the external CT influence on the measurement results. Tests herein presented were carried out at 50 Hz, with fundamental current amplitude I 1 = 5A; II, III, VI, and XI order harmonics have been considered, with an amplitude equal to the 10% of fundamental current and variable phase shift from −180 • to +180 • , with steps of 30 • . Tables 16 and 17 show amplitude and phase errors in harmonic current measurements, respectively, for the tests without the external CT. Also, in this case, the proposed measurement system complies with class I requirements. The aforesaid tests were repeated with the external CT, whose secondary winding was connected to the on-board shunt (see test bench of Figure 9). To obtain the rated current (125 A), a 10-turns primary winding was set up. Each turn had a very large diameter compared to the CT window diameter. Moreover, the 10 loops of the winding were wound in a compact group, with a small section compared to the CT window area. In this way, the current generated by the calibrator was 12.5 A and it had the same magnetic effects as a 125 A equivalent current flowing in a single cable. Tables 18 and 19 show amplitude and phase errors in current measurements, respectively. It can be seen that the measured errors are higher in comparison to those of Tables 16 and 17 because they are strongly influenced by the CT behavior. Moreover, they have a large variability with the harmonic phase shift with respect to fundamental. This behavior is in agreement with what was found in previous works on the CT metrological performances in distorted conditions [47].

Conclusions
The paper has verified the possibility to implement PQ metrics into smart meters used for remote energy metering purposes. The aim of this feasibility study was to demonstrate that PQ distributed monitoring can be performed in a distribution network without replacing already installed smart meters or adding new PQ modules. In fact, the proposed solution entails a firmware upgrade, which implements the power quality metrics using the available calculation capabilities. Moreover, using the metering infrastructure already installed and the power line communication capabilities of the smart meters, PQ measurements can be collected, and statistical analysis can be performed all over distribution networks.
The feasibility of PQ metrics implementation in smart meters was demonstrated by choosing the real case study of STCOMET, an electronic board widely used for remote energy metering purposes in different countries. Starting from an analysis of the electronic board specifications, it was verified that the fixed sampling frequency value results in a synchronization error outside class A requirements. Thus, class S instrument prescriptions were considered as a reference both for PQ metrics and for data aggregation over additional intervals. Different correction algorithms of on-board metrics were implemented in order to comply with standard requirements for each parameter to be measured, i.e., frequency, voltage, and current RMS; voltage dips and swells. As regards harmonic measurements, the considered board has no predefined metrics. Thus, different solutions were considered for harmonic analysis implementation. The analysis led to the choice of the FFT algorithm with interpolation. In this way, the signal is "virtually re-sampled" minimizing leakage and scallop loss errors. The adoption of a simple linear interpolation algorithm allows for the limiting of the computational cost of the harmonic calculation (FFT + interpolation), which is compatible with the board capabilities. Moreover, the calculation times were measured and found to be compatible with standard requirements, thus confirming the feasibility of the proposed solution. The compliance with accuracy standard requirements was then verified with experimental tests. Different distorted conditions were tested, varying the frequency of the signal and the harmonic content, in terms of both harmonic component amplitudes and phase shifts. Summarizing the results of all the tested cases, the study has shown that correction algorithms applied to on-board metrics allowed for the meeting of IEC 61000-4-30 requirements for class S instruments for the following measurement quantities: frequency; voltage and current, RMS; interruptions, voltage dips, and swells. Moreover, thanks to the developed harmonic measurement algorithm, the smart meter fulfills the class II requirements for harmonic measurements according to IEC 61000-4-7. In many cases, errors on harmonics were even found within class I limits. However, the compatibility with class S and class II requirements grants that smart meters enhanced with the developed firmware can be correctly used for statistical applications, such as surveys or power quality assessment all over an LV network. In this viewpoint, future work will be focused on using these new measurement capabilities in a distributed measurement architecture, developing and testing new algorithms for fault detection and fault diagnosis, extensive power quality surveys, and harmonic distortion assessment.
Finally, some tests were performed to study the effect on harmonic measurements of additional external transducers, specifically a current transformer used to couple energy meters to LV networks. As expected, larger errors were found which have a larger variability with harmonic phase shift with respect to fundamental. Future work will be focused on implementing on-board correction techniques of CT errors in distorted condition, thus reducing the total uncertainty associated with the whole measurement chain.