Adaptive Neural Network for a Stabilizing Shunt Active Power Filter in Distorted Weak Grids

: Harmonics destructively impact the performance and stability of power systems. This paper proposes the development of a stable shunt active power ﬁlter (SAPF) for harmonics mitigation. The proper and stable operation of the SAPF control system requires the determination of the current reference, phase angle synchronization, and DC-link voltage regulation. This paper uses an artiﬁcial neural network (ANN) and one of its sub-methods, the adaptive linear neuron (ADALINE), to determine the current reference. However, determining the current reference requires providing a stable phase angle, which is a fundamental challenge in distorted grids because harmonics created in the grid cause phase angle synchronization problems, due to malfunction of the conventional phase-locked loop (PLL). These things considered, the weak grid connection imposes an instability issue due to the poor performance of the conventional PLL when the grid impedance is high. In this paper, a robust synchronous ﬁlter (RSF) is adopted, which separates the harmonic from the main component to provide harmonics-free signals for the PLL. Using RSF, a robust synchronizer quasi-static ﬁlter (RSQSF) PLL model is designed, which is effective in dealing with harmonics in weak-grid conditions. MATLAB Simulink was used to check the validation and effectiveness of the proposed control structure. The results show a reduction in harmonics generated in the grid by 86.7% for nonlinear load with a balanced source, 84% for nonlinear load with an unbalanced source under grid impedance, and 80.46% for the nonlinear load with an unbalanced source under weak-grid conditions.


Introduction
In recent years, power electronics equipment has seen significant use in modern power systems. Despite its benefits, it has harmful consequences on the power system. Harmonics created by tools such as arc furnaces, switching power supplies, and fluorescent lamps, due to the nature of having a non-sinusoidal current, lead to increased heating in equipment and conductors, misfiring in variable speed drives, torque pulsations in motors, reduced efficiency, and ultimately reduced power quality in the grid [1]. Filters are used to reduce the created harmonics, which are divided into two categories: active and passive filters [2,3]. The control system of the active filter has three steps, including harmonic identification, DC-link voltage regulation, and current reference generation. In general, the following classification can be considered for the control structure of filters.
(1) Determining the current reference: In order to have a proper and correct operation of the control system of filters, it is very important to determine the current reference. There are various methods to specify the current reference, such as the d − q synchronous reference frame (SRF) and abc natural reference frame [4], instantaneous power theory (PQ) [5], and Fourier transform [6]. The artificial neural network (ANN) is a promising technique to extract harmonics and obtain the current reference for SAPFs. ANN is becoming an attractive estimation and regression technique in many control applications due to its parallel computing nature and high learning capability [7]. There are several methods of the neural network to identify the harmonic and fundamental parts of nonlinear currents, such as an adaptive neuro-fuzzy interference system (ANFIS) [8], adaptive linear neuron (ADALINE) [9], the recurrent neural network (RNN) [10], and the radial-basis-function neural network (RBFNN) [11]. Among these methods, ADALINE is an early single-layer ANN and the most commonly used ANN technique to identify fundamental or harmonic components present in nonlinear currents and voltages. The ADALINE network makes the extraction of harmonics faster, increases the speed of convergence and adaptability, and is very flexible against nonlinear load changes. In the ADALINE network, the weights are updated using the Least Mean Square (LMS) method [12]. The use of the LMS algorithm in the control circuit, in addition to improving the filter performance when injecting sinusoidal current, also reduces the total harmonic distortion, which ensures the improvement of the power quality and the correction of the power factor.
(2) Synchronization: The active filter needs a synchronization unit, commonly the phase-locked loop (PLL), because matching the phase angle of the generated current reference signal with the phase angle of the operating grid is the main issue. Yet, the use of PLL, in addition to its advantage in frequency detection, comes with disadvantages, such as: permeability to grid disturbances due to noise, nonlinear loads, unbalance, harmonics, and weak-grid (with high inductive impedance) connection [13]. In recent studies, pre-filtering and/or in-loop filtering have been used to improve distorted waveforms, which affect the dynamic stability of the PLL and limit its stability margin [14]. In [15], PLL and a zero-crossing detector (ZCD) were used to synchronize. In this method, if the grid voltage were unbalanced/distorted, the voltage angle would not be well estimated and would cause the active filter to malfunction.
(3) DC-link voltage regulation: The DC-link capacitor voltage must be monitored continuously, as the capacitor must momentarily inject current into the line. The current injection causes the capacitor voltage to drop, which must be controlled by the capacitor voltage control algorithm. In [16], a low-pass filter (LPF) was used to filter ripples. In [17], the authors proposed a method to minimize DC-link capacitance through direct current control, while [18] proposed a predictive scheme for DC-link voltage control of back-to-back converters based on energy-balance modeling.
Summarizing according to the classification of filter control system issues, the significant shortcomings observed in existing works can be mentioned as follows: In [19], a passive filter was used to remove existing harmonics. Among the weaknesses of the inherent structure of this method is that it does not deal with a wide range of harmonics. In addition, one of the basic defects of the passive filter is the possibility of resonance and a sharp rise in the passing current. The SAPF used in [20] was inconsistent in dealing with nonlinear current, and in this paper, it was not possible to detect and remove harmonics completely in the control structure of the filter. Removing a major part of the harmonics created in the grid by the method mentioned in [21,22] involves the complexity of calculations, which increases the cost and inefficiency of the system. The most critical point noted in these studies is the failure to design and adjust PLL control gains in weak-grid connections. This is because the performance of conventional PLLs in the direction of detecting the phase angle is inefficient in weak-grid conditions. It may cause instability in the system due to the adverse interaction of the PLL for phase angle detection with the current controller to adjust the phase angle for delivering the reference current. Since the grid impedance is high, there would be a significant phase angle shift in the voltage (caused by the current controller), which affects the PLL performance for detecting the stable phase angle of the voltage [23].
In addition, one of the main parts of the SAPF control structure is the regulation of the DC-link voltage. In [24,25], reducing the transient response of the DC-bus voltage and unwanted changes in the DC-link voltage in the mode transient also had relatively complex control blocks and methods, and during large transient changes, the DC-link voltage changed dramatically and the protective mechanism was likely to be activated.
In this paper, the active filter was used to deal with the harmonics created by power electronics tools in the grid. To determine the current reference in the first part of the filter control structure, ADALINE was used. In the second part of the control structure, to synchronize the phase angle of voltage and current, an approach that has two modes was used. First, the synchronization was performed by considering the conventional PLL, and in the second case, it used the RSF and RSQSF PLL model, which led to the matching of voltage and current phase angles. Finally, in the third part of the control structure, a proportional-integral (PI) controller was used, which is responsible for tracking the voltage error signal and comparing it with the reference voltage and which leads to setting the DC voltage level of the capacitor at any desired level.
The methodology proposed in the paper can be summarized as follows: (1) In this paper, an active filter is used to reduce the harmonics created in the grid, which is easier to install and has a lower operating cost compared to passive filters.
(2) In the control structure of the filters, the ADALINE network is used to determine the current reference, which has a better performance than other methods due to good prediction and a reduction in response delay. Additionally, it provides a fast, advanced and accurate model for extracting harmonics in nonlinear models.
(3) From the grid synchronization perspective, the paper analyzes three cases to check different conditions. At first, the ADALINE performance is studied under ideal grid conditions, where the PLL does not have a problem determining the phase angle. Second, a distorted grid condition, where the PLL shows poor performance in determining the phase angle due to the harmonic nature of the grid, uses RSF to remove harmonics and provide a signal without distortion to the PLL to solve this problem. Finally, the case related to a weak-grid connection mode that requires a stable PLL considering the impact of grid impedance is analyzed. As a result, the main idea of this paper is to present the RSQSF PLL model for improving the SAPF performance in weak-grid conditions.
(4) The DC capacitor is responsible for injecting instantaneous current and adjusting the line voltage. In this paper, a PI controller is used to regulate the voltage, which results in the correct operation of the control structure and voltage regulation at any desired level.
The remainder of this paper is organized as follows: Section 2 describes the system configuration. The effectiveness of the proposed approach is evaluated in Section 3. Finally, conclusions are drawn in Section 4.

System Configuration
The structure of the adopted control scheme is illustrated in Section 2.1. In Section 2.2, an equivalent single-phase diagram of the SAPF is illustrated, and the governing mathematical relations that describe the current load are given from [26]. The filter control structure includes three sections shown in Section 2.3, that are used to determine the current reference and weight coefficients from the ANN-ADALINE method and the mathematical relationships deduced from [27][28][29]. Additionally, in Sections 2.4 and 2.5, equations and functional structures related to RSF, conventional PLL, and RSQSF are explained [30,31]. Finally, Section 2.6 covers the subject of DC-link voltage regulation, which uses the PI controller to improve the DC-link voltage, and mathematical relationships are proposed to confirm the efficiency of this method [32].

The SAPF Structure
The overall scheme of SAPF as a three-phase, three-wire system is shown in Figure 1. A nonlinear load and three-phase grid Vs abc are connected to the three-phase SAPF connection bus. Reference signal for the grid current is produced by the ADALINE. Determining the control target is used to compensate the load's harmonics and quadratic (reactive) components by the SAPF so that the grid current is sinusoidal. In order to analyze grid synchronization in different grid conditions, PLL and RSF along with RSQSF PLL models have been used to synchronize the signal produced by ADALINE with the grid in different conditions. To maintain the DC value of the capacitor voltage V dc , at the V dcre f level, V dc is measured and fed back to a PI controller, so that it can compute the peak value of charge current I dc required from the supply side. In addition, a hysteresis band current control (HBC) technique is adopted to convert the current reference signal into gate-switching pulses.

Application of the SAPF in the Grid
The installation of a SAPF in an electrical circuit with a voltage source (v) and nonlinear load (i L ) is shown in Figure 2. According to Figure 2, we have where i s is supply current, i L is harmonic nonlinear load current, and i inj is the injection current of the shunt active power filter. The i L can be represented as: where I L f is the peak value of the fundamental load current, I Lh is the peak value of the harmonic nonlinear load current, i L f ,p is the load instantaneous fundamental phase current, i L f ,q is the load instantaneous fundamental quadrature current, and ϕ Lh and ϕ L f are the phase angle of the harmonic and fundamental component of the nonlinear load current, respectively. The SAPF must be able to inject harmonic currents and the quadrature current into the system to achieve sinusoidal grid current, so According to Equations (4) and (5), the current equation is obtained as follows:

The ADALINE Neural Network
ANN-ADALINE is used to estimate harmonic components, and one of the critical features of this method is the direct estimation of Fourier coefficients of nonlinear currents distorted by random/intentional noise. One of the important features of ANN-ADALINE, which is more efficient than other methods in identifying harmonics in the control structure of SAPF, is the use of the LMS algorithm in updating the current reference weights. The ANN-ADALINE output is compared with the harmonic current and generates a modulation signal to generate a PWM pulse to the filter. Figure 3 shows that ADALINE comprises an input vector, a weighting vector, and a weight updating algorithm. According to the structure of the ADALINE neural network, the following equations are obtained.
X = sin(ωt) cos(ωt) where X is the input vector for the extraction circuit, W T is the weight matrix, and e is the error between i L and y. LMS is given by Equation (11).
In each iteration, the error signal e is found by subtracting y from i Lk . This e is used in (11) to compute the weights for the next iteration W(k), which minimizes e. After a few iteration processes, y will converge to i Lk . The initial weights are random values in this paper, where γ is the learning rate. To obtain i L f ,p , first the difference between the i Lh and y is minimized online, then, by multiplying the w 1 on sin(ωt), i L f ,p is obtained, and finally, the sum of i Lh and i Lq is achieved as the following equations.

Robust Synchronizer Filter (RSF)
Synchronization of the SAPF reference signal with the grid voltage is necessary for grid connection. RSF can separate the harmonic component from the main component of the voltage signal in unbalanced conditions and apply a without-harmonic signal to the PLL. First, by using the Clarke transform matrix, the voltage v s in the abc domain is the transformed αβ domain according to the following equations.
In the αβ domain, the following equation holds for the transformed source voltage signal v αβ due to harmonics distortion: where v α, f und and v β, f und are the fundamental and v α,har and v β,har are harmonic components in the αβ domain. In this step, RSF is used to remove the harmonic parts and separate fundamental components from harmonic components according to the following equations. v where K is a constant gain parameter and f c is the cut-off frequency. Then, by using the inverse Clarke transform matrix, the fundamental component in the αβ domain is transformed to the abc domain according to the following equation.
By using (18), the obtained v Sabc, f und is converted into its unity form, which serves as the synchronization signal sin(ωt + θ).

Robust Synchronizer Quasi-Static Filter (RSQSF) PLL Model for WEAK-GRID Conditions
This section is divided into three sub-sections. Section 2.5.1 discusses the operation of a conventional PLL in balanced grid mode for determining the phase angle and control structure and mathematical relationships governing them. In Sections 2.5.2 and 2.5.3, first, the stiff-grid connection mode is adopted, and its relations to arrive at the weak-grid connection mode and the idea of the RSQSF PLL method is inspired. Figure 4 shows the conventional PLL, which consists of three parts: a phase detector (PD), a loop filter (LF), and a digitally controlled oscillator. It is known as the 3-phase RSF-PLL. Using the Clarke transform matrix as the PD, the voltage v s given in (20) and in the abc domain is transformed to the dq domain. The q channel signal v q is the phase-error signal. The PD gain K PD , shown in (21), is equal to the input voltage amplitude. θ C and θ s are the phase reference for the current loop and grid voltage phase, respectively.

Conventional PLL
The linearized PLL is shown in Figure 5. This PLL is widely used but it is unable and will not work well under weak-grid conditions.

PLL Model Considering the Grid Impedance
According to Figure 1, which shows the three-phase SAPF, Z S represents the grid impedance under stiff-grid conditions (Z S = 0) and θ C is equal to θ s . Considering Figure 2, and based on the superposition principle, V C is the combination of three voltage responses v C1 , v C2 , and v C3 : V s e j(θ s +θ 1 ) + Z sh Z s Z sh + Z s I L e j(θ L +θ 2 ) + Z s Z s + Z sh i inj e j(θ C +θ 3 ) (23) (24) where θ 1 , θ 2 and θ 3 are the phase shift angles at line frequency due to the presence of the reactive components in Z s and Z L . Figure 6 shows the PLL structure considering the interaction between the grid and SAPF. The parameters in Figure 6 are shown in Equation (25). Figure 7 shows a small signal model of the PLL with added grid synchronization and self-synchronization signals by considering the interaction between the grid and SAPF (θ SS = θ S + θ 1 ). v According to (26), it is observed that the intensity of the disturbance is determined by I inj , K 3 and θ 3 . The higher voltage of SAPF, bigger grid impedance, and bigger reactive components or bigger θ 3 give a stronger disturbance to the PLL or give a stronger selfsynchronization loop effect. Because of the presence of LF in the PLL structure, the PLL is stable only when v q = 0; therefore, the absolute value of the difference between the output of the synchronization loop and the output of the self-synchronization loop must be equal. The synchronization loop achieves this goal by automatically adjusting the error signal between the θ SS and θ C . Due to the presence of the PD, the output of the synchronization loop v − is limited by K 1 and V S , according to (27).
When v + is larger than the maximum amount of v − , according to Figure 7, v q cannot be zero and it makes the PLL unstable. Therefore, the large-signal stability requirement can be derived in (28).
The result of (28) shows that a higher grid voltage level, a lower SAPF voltage, a higher load current level, a smaller grid input impedance, a higher SAPF impedance, and a smaller reactive component result in a more stable operation of PLL. Figure 7. Small signal model of the PLL including synchronization signals by considering the interaction between the grid and SAPF. In addition to the grid-synchronization loop, another "selfsynchronization" loop appears in the proposed model, representing the injection current effect. The output of the self-synchronization loop v + can be considered as a disturbance to the PLL loop, which prevents θ C and θ S from synchronizing.

Stable PLL under Weak-Grid Conditions
One of the critical conditions is the weak-grid connection, which makes the phase angle synchronization unstable. In this section, PLL is designed to improve the phase angle synchronization performance under these conditions. As such, the parameters in Figure 7 would be (29) under the weak-grid condition.
Based on Z sh , the characteristics of K 3 and θ 3 can be simply derived as:

DC-Link Voltage Regulation
For regulating the DC-side voltage of SAPF, I dc is needed and approximated by using a simple PI controller that helps to minimize the voltage difference between reference DC-side voltage v dc,re f and e dc according to the following equations.
where k p and k i are the constant gains of the PI controller. The bandwidth of the DC-link voltage controller is tuned to be higher than the bandwidth of the PLL to avoid instability due to the interaction between the PLL and DC-link controller. The reference signal I S,re f can be generated according to the following equation.
Hysteresis current controller is used for generating gate pulses to SAPF. The hysteresis current controller will take the difference between I S,re f and I S , where I S is the supply current. Considering the difference between I S,re f and I S , the hysteresis current controller will switch the IGBTs of the voltage source inverter according to the following equation.
where g is the status of the IGBT, "1" symbolizes on and "0" symbolizes off, and band denotes the hysteresis band. The switching status of each IGBT in a branch is complementary to one another. Hence, when g = 0, g = 1, or contrariwise.

Simulation Results
The proposed control system is simulated in the Matlab/Simulink (2016b) Simscape power systems toolbox. A time-domain Simulink model is used within which all nonlinear characteristics of the system, such as the switching process, as well as electromagnetic transients of the electric parts, are modeled to produce accurate results. The results show the performance of the proposed control system for improving power quality, harmonics reduction, and DC-link voltage control, as well as synchronizing performance. The system parameter values are shown in Table 1. Voltage and frequency V s = 400 v f s = 50 Hz Line impedance L s = 1 mH Three-phase diode rectifiers parameters L l = 50 mH R l = 20 ohm Shunt active power filter parameters L c = 3 mH C dc = 3300 µF R c = 16 ohm Voltage loop controller parameters k p = 0.3 k i = 2 DC-Link Voltage 800 V

Nonlinear Load with a Balanced Voltage Source
In this scenario, the load is nonlinear and the voltage source is sinusoidal and balanced; see Figure 8. In the proposed control scheme, harmonic and square currents are obtained by ADALINE, and then the extracted currents are synchronized by the conventional PLL, and the required SAPF signal is produced by a hysteresis band controller. The results show that this control scheme works well and the harmonic rate is reduced from 17.51% to 2.33%.

Nonlinear Load and Unbalanced Voltage Source under Grid Impedance
In this scenario, a nonlinear load and a sinusoidal (but unbalanced) voltage source are considered. ANN-ADALINE is used to determine the current reference, and due to the harmonic created under the unbalanced grid, before synchronizing the phase angle, the harmonic component is separated by RSF and the pure signal is applied to the PLL. In Figure 9b,c, the harmonic value has been significantly reduced by the proposed control structure so that the harmonic value has decreased from 19.52% to 3.11%. Figure 9d,e shows the power factor and the DC-link capacitor voltage, where the power factor is almost one and the capacitor voltage is constant at its initial value.

Nonlinear Load and Unbalanced Voltage Source under Weak-Grid Conditions
In this scenario, the load is nonlinear, the voltage source is unbalanced, and the waveform of each phase is a nonsinusoidal voltage. In this scenario, due to the inefficiency of conventional PLLs for phase angle synchronization, a PLL designed under a weak-grid connection has been used. Figure 10 presents the simulation results of the third scenario. In Figure 10a, the voltage is unbalanced and the current is disturbed due to the nonlinear load. The current extracted from the control method in Figure 10c is displayed. According to the obtained results, the effectiveness of the presented method can be seen, so that the harmonic rate decreases from 24.37% to 4.76%.

Conclusions
The SAPF performance in harmonics mitigation in different grid conditions was studied. The ANN-ADALINE method was used for determining the reference current for harmonic elimination. The conventional PLL was used to determine the phase angle in the balanced grid condition with the nonlinear load. Additionally, the RSF was designed to remove the harmonic components for rendering pure sinusoidal signals for the PLL in distorted unbalanced conditions with nonlinear loads. In the case of weak-grid connection and under unbalanced and nonlinear load conditions, an RSQSF PLL model was designed that revealed stable performance in determining the phase angle. For the case of the balanced voltage source and nonlinear load, the harmonic value was reduced by 86.7%, and for the unbalanced voltage source and nonlinear load under grid impedance, the harmonic value was reduced by 84%. In the case of nonlinear load and unbalanced voltage source, under weak-grid conditions, the harmonic value was reduced by 80.46%. As a result, the effectiveness of the proposed control structure in harmonic reduction can be observed. The performance of the ADALINE is questionable in fault-ride through and current limiting conditions, which is left for future works. Funding: This research received no external funding.

Conflicts of Interest:
The authors declare no conflict of interest.