SOGI-FLL Grid Frequency Monitoring with an Error-Based Algorithm for a Better Response in Face of Voltage Sag and Swell Faults

The SOGI-FLL (second-order generalized-integrator frequency-locked-loop) is a wellknown and simple adaptive filter that allows estimation of the parameters of the grid voltage with a small computational burden. However, this structure has shown to be sensitive to the events of voltage sags and swell faults, especially to voltage sags that deeply distort the estimated frequency. In this paper an algorithm is proposed to face the fault that modifies the SOGI-FLLs gains in order to achieve a better transient response with a reduced perturbation in the estimated frequency. The algorithm uses the SOGI’s instantaneous and absolute error to detect the fault and change the SOGIFLL gains during the fault. Moreover, the average of the absolute error is used for returning to normal operating conditions. The average value is obtained by means of a single low pass filter (LPF). The approach is easy to implement and represents a low computational burden for being implemented into a digital processor. The performance is evaluated by using simulations and real-time Typhoon Hardware in the Loop (HIL) results.


Introduction
Phase, amplitude, and frequency of the utility voltage are critical information for the operation of inverter-based distributed generators (DG), due to synchronization requirements with the grid network [1][2][3][4]. DG can use different grid monitoring techniques for obtaining online estimates of the grid parameters and stay synchronized with the grid. However, the performance of these estimators is perturbed by faults in the grid, such as voltage sags and swells, which in turn implies a worse DG performance of DG when injecting power to the grid [5][6][7][8][9][10][11][12][13][14][15]. Therefore, during grid faults, a fast and accurate detection of the grid voltage parameters is essential to keep a high quality in the DG's operation [6]. Additionally, the grid monitoring used by the power converters should be able to perform a fast detection of the fault event while minimizing the distortion impact that faults cause on the estimated grid parameters and in the DG injected currents. This impact is particularly strong for the case of voltage sags in the estimated frequency, which is considered here, including also the case of voltage swells [6,15].
Voltage sags and swells are defined by the IEEE 1159 as short-time reductions and increases in the grid voltage amplitude. Voltage sags are produced by faults in the line due to short-circuits, overloads, or starting of large motors [2,3]. Voltage sags can have a duration ranging from of 0.5 cycles to 1 min and can go from 0.9 per-unit (pu) to 0.1 pu in voltage magnitude. According to their duration, voltage sags are classified into three categories: instantaneous sags lasting from 0.5 cycles to 30 cycles, momentary sags from 30 cycles to 3 s, and temporary sags from 3 s to 1 min. Additionally, they are classified as an undervoltage when they exceed more than 1 min. In the same way, voltage swells are defined as a short-time increase in the grid voltage amplitude due to a single line-toground fault or by the de-energization of huge loads, among other causes. Voltage swells are also classified into the same three categories as for voltage sags. Voltage swells can be instantaneous, from 0.5 cycles to 30 cycles and from 1.1 pu to 1.8 pu; momentary, from 30 cycles to 3 s and from 1.1 pu to 1.4 pu; and temporary, from 3 s to 1 min and from 1.1 pu to 1.2 pu. The impact of strong voltage swells such as 1.8 pu in the SOGI-FLL estimated frequency is also high but with less magnitude than the case of 0.2 pu voltage sags [32,33].
In [32] the response of the SOGI-FLL to voltage sags and swells was studied. In this paper a saturation of ±1 Hz around the estimated frequency was used to limit the size of the perturbation and a Finite State Machine (FSM) algorithm was defined to minimize the transient response. The FSM used the pattern produced at the estimated frequency transient response for defining a set of five states that correspond to each relevant part of the pattern. The gains of the SOGI-FLL were adjusted by the FSM at each part of the pattern according to the voltage sag/swell depth/height level to minimize the size of the perturbation in the estimated frequency. However, the reaction to the fault with this approach presents some drawbacks as: an inherent slow response that is difficult to overcome due to the method's definition around the integrator-block of the FLL; the necessity of measuring the depth/height of the voltage sag/swell; and the use of a set linear and nonlinear equations to obtain the SOGI-FLL gains, which made complex the proposal implementation.
In this paper, a different approach is presented for facing this problem by means of an algorithm that uses the SOGI's instantaneous, absolute and averaged error signal. The approach is easier to implement than [32] since it doesn't need to measure the depth or height of the voltage sag or swell, it uses a simpler algorithm employing less states and uses constant gains for the SOGI-FLL for dealing with the fault. In this algorithm, the use of the SOGI's error allows a faster transient response to the fault event, since the error is directly affected by it, with no-delay, and allows differentiating voltage sags from voltage swells. The absolute value of the error allows determining a fast detection of the fault, which can be applied to both, sags and swells. The detection is made using a given threshold that triggers the algorithm when is surpassed by the absolute error value. The threshold is designed to preserve the capability of the SOGI-FLL to respond to step changes in the grid frequency of ±2 Hz and, also, to harmonic distortions till 3% amplitude regarding nominal voltage. The algorithm works with nominal gains at normal conditions and changes to reduced gains when a fault happens. The average of the error is used as a means to detect when the perturbation induced by the fault ends. Another threshold is also used for returning to normal operating conditions when the average is below it. This threshold is designed to cover all the possible depths or heights that voltage sags and swells could have. The algorithm is simple and easy to implement, representing a low computational burden for being implemented in a digital processor. The response of the proposed algorithm is better than the reported in [32], which is assessed using simulations and HIL test using MATLAB/Simulink and Typhoon HIL 402 platforms.

SOGI-FLL Response to Voltage Sags and Swells
The structure of the SOGI-FLL is shown in Figure 1, where v g is the grid voltage, ω o is the center frequency of the SOGI filter, v d and v q are the in-phase and quadraturephase outputs and ω is the FLL estimated grid frequency acting as center frequency of the SOGI filter. The SOGI has a second-order band-pass filter (BPF) and a low-pass filter (LPF) behavior for v d and v q [23], with the following transfer functions The FLL is a gradient descent estimator [20,23], defined as where A is the estimate of the grid voltage amplitude, The linearized model of the SOGI-FLL in a quasi-locked operating point regarding the voltage amplitude and frequency is defined in [24,26,33], as (4) and (5), depicted in Figure 2.
where ω g and A g are the frequency and amplitude of the grid voltage, respectively, and ω n is the nominal value of the grid frequency, ω n = 2π50 rad/s. The linearized models of (4) and (5) allow obtainment of the transient response of A and ω for a sudden change in A g and ω g , respectively, for a given value of ξ and λ.
The model of (4) is of a first-order system with constant time τ = 1/ξω n and, from linear control theory, it is well known that using ξ = 1/ √ 2 an optimal relationship is achieved in the transient response of the system [1]. The model of (5) corresponds to a second-order system, whose transient response comes determined by the roots of (6): In (6), it can be seen that ξω n and λ/2 are related to the damping factor, ξ , and natural undamped frequency, ω , respectively, in the standard definition of a second-order system, i.e., a system with roots s 2 + 2ξ ω · s + (ω ) 2 = 0. Then, by identifying ξω n = 2ξ ω and λ/2 = (ω ) 2 , it can be inferred that: and extracting ω from the other identification: and, putting (8) in (7) leads to: Which choosing the optimal ξ = ξ = 1/ √ 2 leads to a transient response that only relies on λ: Then, by inserting these gains, ξ and λ, in (6) gives roots located at s 1,2 = −111.07 ± 111.07 j, which corresponds to a transient response in ω that achieves an overshoot of Mp = 4.32% and settling time t s1 = 4τ = 4/111.07 = 36 ms, depicted in blue as the pair of gains (ξ 1 , λ 1 ) in Figure 3. By choosing this pair of gains, the transient response is optimal for the second-order system regarding achieved overshoot and settling time [1]. This, from the harmonic rejection point of view, it implies that a 3rd harmonic with a 3% amplitude voltage regarding nominal produces a ripple distortion around ω of 0.435 Hz, measured peak-to-peak. However, another interesting design point can be chosen instead for λ = 0.25ω 2 n that corresponds to double real roots at s 1,2 = −111.07, i.e., a transient response without overshoot, Mp = 0%, since there are no imaginary parts in s 1,2 , see depicted in red as the pair (ξ 2 , λ 2 ) in Figure 3. In this case, as the gain has been reduced by half, an extra attenuation to harmonics has been achieved and the ripple is reduced also by half, to 0.217 Hz. Notice that for λ = 0.25ω 2 n the settling time is identical than for λ = 0.5ω 2 n , since the real part of the roots for both gains are identical, i.e., t s2 = t s1 = 4/111.07. Therefore, we can consider λ = 0.25ω 2 n as an optimal gain regarding harmonic-attenuation and t s . Additionally, this gain could be an interesting choice for those designers that are more interested in keeping the same t s but with an extra harmonic attenuation. From now on, in this paper, λ 1 and λ 2 are considered as two reference optimal gains for facing the perturbation induced by voltage sags and swells in the estimated frequency. The first one is better for achieving a faster transient response and the second one achieves a response with the same settling time but with better harmonic rejection capability.
Regarding the impact of voltage sags in the SOGI-FLL, the model in (4) can be used to obtain the transient response to the fault in the estimated grid voltage amplitude. But the model in (5) can provide the transient response of ω to a perturbation in the grid frequency, ω g , but not to changes in A g since there are no-crossing terms between (4) and (5). Therefore, the impact in ω should be assessed using the real model depicted in Figure 1. Additionally, it is well known that the impact of voltage sags in the estimated ω g is really high. Moreover, the transient response induced by the fault is nonlinear, and its magnitude size depends nonlinearly on the voltage sag's depth, being worst for the deepest voltage sags. Figure 4 provides an idea about the high impact of the perturbation induced in the estimated frequency by a voltage sag. Figure 4a depicts the estimated frequency for a series of voltage sags ranging from 0.8 pu to 0.2 pu for the optimal pair (ξ 1 = 0.707, λ 1 = 0.5 ω 2 n ). Figure 4b depicts the measured peak-to-peak value of the perturbation for each case. In this figure, the two pair of optimal gains, (ξ 1 = 0.707, λ 1 = 0.5 ω 2 n ) and (ξ 2 = 0.707, λ 2 = 0.25 ω 2 n ) had been considered. Notice that the size of the perturbation for λ 1 can arrive to 15 Hz for the pair (ξ 1 , λ 1 ) and of 6 Hz for (ξ 2 , λ 2 ). A similar impact, but with less peak-to-peak size, can be observed for a voltage swell in Figure 5a for voltage swells ranging from 1.2 to 1.8 pu and for the pair (ξ 1 , λ 1 ). Additionally, Figure 5b depicts the measured peak-to-peak magnitude for the two pair of optimal gains, (ξ 1 , λ 1 ) in blue and (ξ 2 , λ 2 ) in red.

Reducing the Perturbation Impact by Means of a SOGI's Error-Based Algorithm
The most effective approach for reducing the perturbation in the FLL estimated frequency is by means of using directly the error signal of the SOGI filter, because it receives directly the impact of the fault through the input voltage, i.e., e = v g − v d . In this paper, a proposal is made using the error signal, the absolute value of the error signal, |e|, and a low-pass filtering of |e|, noted as LPF(|e|) and also as avg(|e|). The proposal consists in an algorithm that uses these variables as inputs and that provides a proper value of ξ and λ to the SOGI-FLL for facing the fault and reduce the impact of the perturbation. This proposal is defined first for voltage sags and after is also applied to voltage swells. The block diagram that schematizes this proposal can be seen in Figure 6. The algorithm is depicted in Figure 7 and is defined using only three states, named as S1, S2 and S3. From now on, the proposal will be named as SOGI-FLL "Error-based Algorithm", SOGI-FLL-EbA. In the algorithm, S1 means normal operation. In this case, the SOGI-FLL-EbA operates with nominal gains (ξ N , λ N ). This gains can be the pair (ξ 1 , λ 1 ) or (ξ 2 , λ 2 ), but the pair (ξ 1 , λ 1 ) are used mainly in this paper. Then, at a fault event, |e| spikes such as a sharp impulsive transient response. The error |e| is compared to a given threshold e γ and, if |e| > e γ , the algorithm goes to state S2 were the SOGI-FLL-EbA runs with different gains named as (ξ F , λ F ). These gains had been designed by a series of trial-and-error simulations for achieving a proper transient response and reduce the impact of the perturbation. The threshold e γ is designed to be able respond to a frequency step change of ±2 Hz and to pass a harmonic distortion that can reach a 3% THD. The main objective had consisted into reducing the perturbation size to less than 2 Hz for the case of 0.2 pu, i.e., an 80% depth. To this purpose, the FLL gain, λ F , has been strongly reduced. At this stage, the average input, avg(|e|) is used for transitioning to S3. This average is obtained by using a LPF with a suitable cutoff frequency, ω c , with the aim of filtering |e| and generate an energy-like function for giving an indication of when the perturbation has passed over. The transitory of avg(|e|) will consists in an impulsive function, see Figure 7 in red, that exponentially decays to zero, which, when is close to zero, means that the perturbation is over. Therefore, the algorithm goes to S3 only when avg(|e|) is a given threshold, avg(|e|) < e o . Finally, a counter timer T c is started for giving a specific exit-time, t exit . This counter helps to set a specific time delay to be performed before returning to state S1, in order to ensure a smooth returning to normal state. The exit-time is designed to cover all the different voltage sag depths. When the condition T c > t exit meets, the algorithm returns back to state S1 and the SOGI-FLL-EbA operates again with (ξ N , λ N ).
Additionally, the same algorithm can be applied to voltage swells using e to identify a swell from a voltage sag. As e = v g − v d , at the event of a fault, if e < 0 means that the fault consists in a voltage sag and e > 0 in a voltage swell. The gains (ξ F , λ F ), threshold e o and exit time t exit are different for voltage sags and swells and the values are depicted in Table 1.

Simulation and HIL Results
The SOGI-FLL-EbA proposal of Figure 6 has been discretized and simulated with Matlab/Simulink software. The SOGI-FLL-EbA gains during S1, S2 and S3 states and the thresholds e γ , e o and exit-time t exit are shown in Table 1. A third-order Adam-Bashforth method has been adopted, (11), for discretizing the SOGI filter following the discretization analysis performed in [34]. This method provides an exact −90 • phase delay at the SOGI quadrature output and doesn't have the drawbacks reported with backward, forward and trusting related methods, especially for low sampling frequencies.
and, the integrator of the FLL has been discretized using the backward Euler method: Ts being the sample time of 100 µs, consistent with the 10 kHz frequency. Figure 8a,b depicts the transient response of the SOGI-FLL and SOGI-FLL-EbA for a 0.2 pu voltage sag and 1.8 pu voltage swell, respectively. The faults happen at time 0.205 s. Notice how the perturbation in both cases had been reduced considerably, above 1 Hz peak-to-peak. The value chosen for the threshold e γ has been designed to be able to accommodate a frequency step change of ±2 Hz and including a 3% THD harmonic distortion. Figure 9a depicts the transient response of the SOGI-FLL-EbA for a 2 Hz frequency step change at 0.2 s. Figure 9b shows the same transient response with a 3rd harmonic with 3% amplitude from nominal. Notice how the threshold allows the SOGI-FLL-EbA to respond to these perturbations, which do not trigger the proposed algorithm. It is important to remark that, since the "EbA" algorithm has not been triggered, these transient responses are identical to the achieved by a traditional SOGI-FLL, so they are not depicted in the figure.   Additionally, the grid voltage and the SOGI-FLL and SOGI-FLL-EbA had been implemented in a real-time HIL Typhoon 402 and HIL DSP100 platforms and the responses being captured in the typhoon SCADA panel [35]. Figure 12 shows the HIL results for the SOGI-FLL and SOGI-FLL-EbA to a periodic voltage sag fault transient that goes from 1 pu to 0.2 pu and then return back to 1 pu., the voltage sags go down to 0.2 pu and then return to 1 pu. In a similar way, Figure 13 depicts the transient results for a voltage swell that goes from 1 pu to 1.8 pu and back to 1 pu. As in the Simulink simulations, these HIL results show how the SOGI-FLL-EbA noticeably reduces the impact of the perturbation, allowing a faster response and respond to shorter duration transient faults.  Moreover, the peak-to-peak size of the perturbation had been measured for different depth and height sizes to assess the reduction in the perturbation achieved by the proposal using MATLAB/Simulink. Figure 14 depicts these measurements that show that the algorithm functions effectively in all the ranges defined for sags and swells.

Conclusions
This paper tried to improve the response of the SOGI-FLL to voltage sags and swells, since it is highly sensitive to these kinds of faults, especially to voltage sags. The paper first showed the scope of this problem for a given set of optimal SOGI-FLL gain parameters considered from the point of view of the SOGI-FLL's optimal speed response to frequency step changes in the grid and of optimal capability rejection to harmonics. Then, it proposes an algorithm using the SOGI's error signal and its absolute and average values for facing voltage sags and swells faults, reducing the impact in the estimated frequency. The MATLAB/Simulink simulations and real-time Typhoon HIL results showed the feasibility of this approach, which improved the response to these faults and reduced the recovery time involved in the transient perturbation.