Artificial Neural Network Active Power Filter with Immunity in Distributed Generation

With an electrical grid shifting toward Distributed Generation (DG), the emerging use of renewable energy resources is continuously creating challenges to maintain an acceptable electrical power quality thought-out the grid; Therefore, in an energy market where loads are becoming more and more sensitive in a distributed generation filled with polluting nonlinear loads, power quality improvement devices such Active Power Filters (APFs) have to evolve to meet the new standards, since theirs conventional control strategies can't properly operate when multiple power quality problems happens at once, even the one using AI based control as it will be proven in this paper. In this paper a neural network based Active Power Filter will be tested in a DG environment where both current and voltage harmonics, along with fast frequency variation occurs, we will see how the PLL can downgrade its performances enormously under such hostile conditions, We propose to solve this problem by replacing the conventional PLL with a nonlinear least square (NLS) frequency estimator, this novel NLS-ADALINE SAPF is immune in high DG penetration environment, as it will be tested and validated experimentally on an Opal-RT OP5600 FPGA based real-time simulator.


Introduction
The increasing number of population and widespread of technology devices all over the world is creating a rising demand of electrical power. This growth is triggering the need for more power generation, and because conventional energy sources like coal and oil are decaying and causing climatic pollution, the need to develop renewable and sustainable alternatives has arisen [1]. Nevertheless, while electrical centralized plants are economic and easily scalable, this scalability comes at a price: their long transmission lines always require additional power to compensate the transmission and distribution losses. Unfortunately, this kind of loss is not affordable in renewable energies, so energy generation needs to be as close as possible to the point of consumption, preferably in the same building or facility, this major requirement drove energy provider to think about a novel generation paradigm: Distributed Generation DG (also called on-site generation or decentralized generation) [2].
Despite the economic, environmental and energy benefits of DG, such system faces technical barriers, and all these generators distributed all throughout the power system pose new challenges and problems to the network operators as these can have a significant impact on different aspect of power quality [3].
It was already challenging to maintain power quality in centralize generation systems due to the increasing use of variety of nonlinear loads in industrial, domestic sectors; such as Computers, UPS, Battery and phone chargers, variable speed drives, PLCs, and medical equipment. All those devices cause power quality problems, such as degrading power factor, and unbalancement in the power supply, and especially the injection of harmonics back into the grid, causing waveform distortion [4]; this will have side effects like disturbance within proximity communication devices and electromagnetic interference, increasing power losses and stability concerns, magnetic saturation in transformers, audible noise and heat rising in machinery, all those side effect can lead to an improper operation of proximity sensitive devices and shortening their life expectancy [5]. Thus, harmonic mitigation had been a major concern since the beginning of the power grid evolution. Throughout the years, many solutions had been proposed, but the most reliable one to this day remains Active Power Filters (APF).
APF technology saw the day in the 1970's [6] as special electronic converters based devices developed to reduce harmonic pollution; they immediately attracted engineers and researches attention. Moreover, deeper interest was spurred with rising performances of semi-conductors and computational power. Today, APFs can perform harmonic mitigation, reactive power control, power factor correction, load balancing, voltage regulation, and flicker reduction [7].
However, a chronological survey of active compensation technologies in the literature [8][9][10] shows that attention to those devices during the last decade has risen again, due to the new challenges caused by DG. Indeed, conventional Active Power Filters were primarily designed to compensate harmonics caused by nonlinear load within the client side in a centralized generation system (i.e. under the assumption that the grid is already a stable electrical power source with good quality, where the worst-case scenario is unbalanced phases) [8]. However, with the DG rising to be one of the most actively developed sectors of energy. Daily, RES like PV, wind and fuel cell power plants are connected to the grid, and while they seem as a the key to a cutting edge society, their interconnection to the grid postures significant challenges due to their non-dispatchibility and high fluctuating nature inherited from their nature resources (wind speed, solar illumination), and as DG penetration arise, serious power quality concerns arise with it [11]. Indeed, during the survey [12], data from 1200 locations where DG was interconnected at low, medium and high voltages, were collected during 3 years in different countries, and all those data pointed that DG can cause power quality problems, such as dips, flickers, voltage harmonics and rapid frequency fluctuation. Conditions that heavily affect the performance of conventional APFs, since their traditional control algorithms were not conceived for such hostile operating conditions, which pushed researchers to think about a new a generation of APFs, that can overcome those adverse grid conditions as reviewed in [9].
Motivated by this argument, in this paper we rise the concern of APF performances under high DG penetration where frequency variation along with voltage harmonic happens continuously as shown in [13], and how those conditions can heavily impact APFs performances, especially those with a control algorithm relying on synchronization devices to estimate the phase or frequency of the grid to properly operate. One of those control technique is the Adaptive Linear Neuron (ADALINE) strategy for harmonic extraction.
When using ADALINE as a harmonic extraction algorithm in APFs, a PLL is necessary to estimating the grid frequency and generating the correct input data [14]. Moreover, because the performances of the SAPF are directly related to the performances of the extraction algorithm, so are they to the PLL's. Nevertheless, conventional PLL performances decay enormously when the input signal is infected with harmonics [15], which is the case of the grid voltage in DG. Therefore, a more suited frequency estimation tool is required for the ADALINE to obtain optimal performances. In this paper, a novel nonlinear least square frequency estimator [16] is embedded into the ADALINE of a SAPF to give it immunity in DG environment; Since its proposal, this frequency estimator showed promising results and had been improved and used in multiple APF application such as: [17] where it was combined with the instantaneous power theory control, and in [18] with the Synchronous Reference Frame algorithm, But so far no reported work shows its application with ADALINE. This paper is organized as following. In Section 2, ADALINE as a harmonic extraction tool for APF is described. In Section 3, the NLS frequency estimator mathematical problem and its computational model are explained. In Section 4, the proposed integration of the NLS estimator to the ADALINE and its implementation inside a SAPF is showed. In Section 5, the proposed architecture is validated in an experimental setup build-in the Opal-RT OP5600 FPGA based real time simulator. Finally, a conclusion is stated in Section 6.

ADALINE based Shunt Active Power Filter
SAPF operates by generating a compensation current with the same amplitude as the harmonic component but phase shifted at 180°. The two current will cancel each other when merging at the PCC giving back to the current its initial sinusoidal waveform, this process is called active compensation [6]. The compensation current is generated using a VSI connected from the AC side to the PCC through a passive filter and from the DC side to a capacitor, where the voltage is measure and maintained constant using a regulator (usually a PI). The amount of compensation current required is controlled using an extraction algorithm that separate the harmonic component from the fundamental one. The general architecture of a SAPF is showed in Fig. 1.
APFs are a mature technology that received considerable attention from research and many proposals had been made to enhance the different parts of the APF, a detailed review on APF technology is discussed in [19]. However, the scope of this paper focus on a specific extraction algorithm that is the Adaptive Linear Neural (ADALINE), which is according to [20] the most widely used type of neural network in APF control.
ADALINE was proposed for the first time by Widrow and Hoff in their attempt to develop their learning algorithm: the Least Mean Square "LMS" [21]. It was an adaptive linear combiner cascaded with a quantizer and one of the earliest neuronal models. The adaptive weights were analogous to synapses. The input vector components related to the dendritic inputs. The quantized output was analogous to the axonal output. The output decision was determined by a weighted sum of the inputs, in much the same way real neurons were believed to behave, the general schema of an ADALINE is shown in Fig. 2.
The first step of the harmonic extraction process using ADALINE is to generate the input vector x i of the ADALINE; this vector is constituted of a combination of Sine and Cosine waves at the frequency of the fundamental and the most dominant harmonics. Then, sensing the waveform of the signal to process (in this case the load's current) and feeding it as a target result. Later, random widths vector w i is initiated, and the ADALINE is lunched. During every iteration the ADALINE force its output to converge toward the target signal by constantly updating the widths vector using the LMS algorithm. Eventually, after sufficient number of iteration, the ADALINE will converge with a minimum acceptable error and the widths vector w i will represent the FFT coefficients of the signal. Thus, it is possible to separate the fundamental signal from the rest and by subtraction generate the reference signals.
The mathematic application of this process previously described is as following, the load current can be wrote using FFT as it is shown in Eq.
where f 0 is the fundamental frequency of the grid; a k n and b k n are the amplitudes of the k th harmonic's sin and cos components respectively, i n being the n th sample of the load's currents and the targeted signal, k is the index of the harmonic. Naturally, due to the half-wave symmetry nature of the wave and the three-phase power system architecture both even and triple harmonic are inexistent.
with H being the highest rank of k. So far, the estimated load's current i es n at the n th sample can be written as following in Eq. (2): where w i n being the widths vector of the sine and cosine components of the current's harmonic respectively at the time of the n th sample, as shown in Eq. (3):  Also x x t n n = ( ) would be the input vector at the moment t n coinciding with the n th sample, extracted from the x input matrix, which is a combination of x n cos and x n sin , who would be the matrixes of both cosine and sine component for the set of harmonics as shown in Eq. (4): LMS algorithm use gradient descent to minimize the mean square of the error between the estimated value i es n and the measured one i me n . Then it calculates the amount of update required to each width. The error is calculated using Eq. (5): The gradient ∇ of the error E is shown in the Eq. (6): So that the value of the width in the next iteration is calculated using the Eq. (7): where η is the learning rate of the ADALINE. Investigations showed that some papers studying the application of ADALINE as an extraction algorithm in SAPF such [22][23][24] use inputs generated in form of sine and cosine waves at a frequency multiple of conventional one (50 Hz or 60 Hz), taking for granted that the frequency will not fluctuate. This approach can have dramatic impacts on compensation performances in case the frequency shifts as it will be shown later in this study. To avoid this problem, other papers like [25][26][27] suggest the use of a PLL to continuously estimating the grid frequency, so that the ADALINE's inputs are generated based the measured value of the frequency. Nevertheless, most of those paper use conventional PLL. Thus, they may give good estimation results during steady state and voltage harmonic free scenarios, but as soon as distortions and noise are introduced to the signal processed by the PLL, important delay and estimation errors happens, especially during transient phases. All this will result in a performances decline of the APF. Therefore, an important question should rise about the selection of the most suited PLL to use in the ADALINE harmonic extraction algorithm. However, so far, no such investigation was carried in the literature, and this was the main motivation behind this paper.

Frequency estimation using NLS approach
Several methods of frequency estimation have been reported in literature [15], such Zero-Crossing detection, Kalman filter, Discrete Fourier Transform, Adaptive Notch Filter, Delayed Signal Cancellation with Frequency-locked loop. But among them, Phase-locked loops (PLL) remain the most commonly used technologies at a commercial level [15], due to their appreciable response during transients, a delay in the estimation process. But those performances decline dramatically in presence of harmonics and fast frequency variation, making it unsuitable for devices deployed in DG cases. Therefore, many efforts had been made to build a more robust frequency estimator that operate properly under such conditions such [28]. In [29] a promising algorithm based on the least-square-error was proposed, where the goal is to minimize the error between a modeled and measured signal so that grid frequency can be estimated, this algorithm showed harmonic immunity and fast response compared to the aforementioned estimators.

Mathematical formulation
Since voltage waveform is usually less distorted than the load current, the former is more suited for frequency estimation. In addition, by following the mathematical logic showed in Section 2 to the voltage waveform, Eq. (2) can be applied to estimated voltage v es n , as shown in Eq. (8): ing with the n th sample. Nevertheless, from Section 2, we proved that the estimation of harmonic widths is a linear problem that is solvable using an ADALINE as long as the frequency f 0 is known. But the moment f 0 fluctuated to an unknown value (as in the case of DG) the problem loses its linearity and become a nonlinear least square one [30]. Solving this problem requires solving the Eq. (9): Unfortunately, the matrix x computed using the Eq. (8) is not square unless M H = * 2 which is not always the case. Thus, it cannot be inverted, so this problem cannot be solved directly. Therefore, we need to compute the pseudoinverse matrix of x and transform the Eq. (9) to the following form (Eq. (10)): Substituting w v from Eq. (8) in Eq. (10) will result in Eq. (11): Therefore, the error will be equal to: According to [30], NLS optimization shows that the right estimation of the frequency is the one minimizing the second norm R of the error e, with R e = 2 2 , and since e is function f 0 only. A lookup table needs to be build linking a set of possible candidate frequencies and theirs second norms, and then perform a search for the smallest second norm value and recover its corresponding frequency. Candidate frequencies will be equally spread through a search range starting from a minimum to a maximum frequency with a step search (example f es = 48 0 01 52 : . : ).

Computational model
Since the NLS estimation algorithm is window based, the analysis window needs to be continuously shifted and the frequency re-estimated. The accuracy of this estimation depends on two parameters: the length of the analysis window, and the number of harmonic taken under consideration. In [17] a general behavior of the estimated frequency as a function of both parameters was made to determine the optimal configuration, results showed that the best estimation came from a window length of 20 ms and a 13 harmonics analysis {1, 5, 7…}, this configuration will be used throughout this study. The algorithm is computationally intensive but it is possible to save computational time by precomputation constant variable and save them in the ROM of the processor, since the error is computed using the Eq. (let's denote it by δ) is a function of f 0 only, and since all candidate values of f 0 are predefine before execution, it is possible to compute every δ for every candidate f 0 and save it internally and accessed during execution.
The first step of the algorithm is to go through some parameters initialization, such as frequency search range and resolution (ex: from 48 Hz to 52 Hz with a step of 0.01 Hz). Then, compute δ for every possible f 0 inside that search range and save them internally. Third step is to run the experiment and start with buffering M samples to build up the first y vector. Then, go thought a loop of every candidate f 0 and compute its error vector e using Eq. (12). Next, calculate the second norm of every error vector e and saved in a look-up table right next to its corresponding f 0 ; afterwards, a 1D search will locate the minimum value inside the second norm vector and recover its corresponding f 0 and output it as the estimated frequency. Once this cycle terminated, a new sample is pushed into the vector y in FILO mode (First In Last Out) so that the analysis window slides forward. So that the same process happens again. The algorithm diagram is shown in Fig. 3.

The proposed NLS-ADALINE SAPF
To design a SAPF that can operate in an optimal state even under high DG penetration as shown in Fig. 1, we had to overcome the limitations of conventional PLL occurring during distorted voltage and fast frequency variation, and based [17], the NLS frequency estimator showed that it is able to estimate the grid frequency in less than one cycle, even during such conditions, those promising result made it the perfect candidate for our work. In the proposed approach, sensed harmonically distorted voltage signal will go through the NLS algorithm so that this one estimate the frequency of the grid, this value will be used to generate the input template signals (cosine/sine) for the ADALINE; those inputs will be combined with the sensed harmonically distorted current. Thus, the ADALINE will be on possession of both correct data which will fasten its convergence, as well as the generation of the compensation reference signals provided to VSI hysteresis controllers to inject the compensation currents into the PCC. The DC side of the VSI is connected to capacitors, and the DC voltage is regulated using PI controller, the proposed architecture is shown in Fig. 4.

Experimental results
To test the proposed architecture, and validate the hypothesis of using the NLS algorithm for real time estimation of the grid frequency in an ADALINE based Active Power Filter destined for high DG penetration causing fast frequency variation along with voltage harmonics, those working condition had to be recreated in laboratory so that the proposed strategy can be tested.
In that purpose, we simulated a grid power quality degradation scenario caused in a DG, where we created sinusoidal signal with two rapid frequency variation, the first occurring at t = 1.2 sec where the frequency drops from 50 Hz to 49 Hz and the second at t = 1.6 sec where it rises from 49 Hz to 51 Hz. This signal is then harmonically distorted, rising its THD to 10 %. Finally, the resulting signal is fed to a Trek programmable power source to be amplified to a 100 V. By doing so, we would have simulated two power quality problems: frequency shifting and voltage harmonics; the waveform of the generated signal is shown in Fig. 5.
Next, this voltage source will go through a three phase diode rectifier to feed a DC motor. The nonlinear nature of this load will additionally cause current harmonics at the PCC; the sensed load current waveform is plotted along with the frequency variation pattern of the simulated grid voltage in Fig. 6 (a), while Fig. 6 (b) and (c) shows a zoomed portion on the moment the frequency changed (i.e. t = 1.2 and t = 1.6 respectively).
The first step of the comparative study is to test the frequency estimation using both conventional PLL (VCO based one) and the proposed NLS one. Therefore, both estimation algorithms were implemented on the Xilinx FPGA based real time simulator Opal-RT OP5600. Fig. 7 displays the frequency variation reference along with the estimation results of both algorithms. We notice that both estimators eventually settle on the correct frequency, but the difference is noticeable during transient state: while the conventional PLL require a faire long amount of time to estimate the frequency due to the presence  In the second part of the experiment, the impact of the estimation delay on the compensation performances of an ADALINE SAPF is studied, during this comparative study both frequency estimators (conventional and NLS) are implemented in a hardware-in-loop mode simulation on the Opal-RT OP560. Technical data of the APF are also shown in Table 1. Fig. 8 shows the spectrum of current during steady state compensation, after the PLL settles on the correct value of the grid frequency. Fig. 9 (a) shows the extraction of the fundamental component from the sensed current waveform, Fig. 10 (a) shows the compensation current generated by the APFs to compensate the harmonic content, and finally Fig. 11 (a) shows the load current at the PCC after compensations, all this using the conventional PLL.   Similarly, Fig. 9 (b) shows the extraction of the fundamental component from the current waveform, Fig. 10 (b) shows the compensation current generated by the APFs and finally the load current after compensation is shown in Fig. 11 (b), while using the NLS based frequency estimator.
The first conclusion from Fig. 11 (a) and (b) is that ADALINE based SAPF gives considerable good compensation results during the steady state despite the used  frequency estimation tool, with a THD equal to 2.6 % as shown in the harmonic spectrum in Fig. 8. Nevertheless, during transient caused by frequency variation we face poor compensation performances relative to the delay of estimation, which shows that the ADALINE algorithm rely heavily on knowing the exact value of the frequency to properly operate, which validate the motivation behind this study.
A comparative analysis in Fig. 9 (a) and (b) shows that the extraction of the fundamental component from the current waveform when using the conventional PLL took far more time than the one using NLS algorithm. In addition, it is noticeable that those durations are in direct relationship with the delays of both estimation algorithms seen previously in Fig. 7. This is due to the fact that during the transient frequency estimation, wrong input data are still fed to the ADALINE, preventing it from converging to a minimum least square error. Thus, the extraction process of the fundamental waveform won't be optimum until the estimation of frequency is correct, and since NLS algorithm is faster than conventional PLL, its fundamental component extraction is faster, as well as compensation current generation as shown by comparing Fig. 10 (a) and (b). As result, NLS based APF compensated currents harmonic in 0.06 sec after the moment the frequency variation occurred, compared to conventional PLL that took 0.32 sec, as shown in Fig. 11 (a) and (b). Thus, making it five time faster during transients.
Therefore, according to the data provided by the comparative study carried out on the experimental setup showed in Fig. 12, it is safe to say that the use of NLS estimator improved dramatically the transient response of an ADALINE based SAPF compared to the usage of conventional PLL but at the expense of more computational power. In a traditional centralized generation system, frequency variation occurs rarely, but in a modern decentralized system this phenomena can happen more often, and the optimization proposed in this paper can become very useful.

Conclusion
This paper contributes to a new generation of Active Power Filters designed for high DG penetration environment. It points out the hostility of such environment and the challenges those devices are facing to maintain power quality. This study shows the limitation of an AI based Active Power Filter that uses ADALINE as a harmonic extraction algorithm in a DG environment, where fast frequency variation along with harmonic distortion happens frequently, those limitations are due to the heavy dependency of the ADALINE on its PLL and how conventional PLLs suffers during frequency estimation in the presence of voltage harmonics. Thus, we proposed an alternative using a Nonlinear Least Square (NLS) based frequency estimator, its fast response and unconditional stability due to its open loop nature gives the SAPF immunity in DG environment, The proposed architecture is discussed and then experimentally validated in a comparative study with the conventional one, Results show the dominance of the proposed NLS-ADALINE SAPF making it a perfect candidate for high DG penetration cases.