Comparative Analysis of Lattice-based All-Pass Filter and Second Order Generalized Integrator as Orthogonal System Generator of a PLL

This paper presents a steady-state comparison of two methods that generate an orthogonal voltage system for a single-phase Phase-Locked Loop (PLL) structure: a widely accepted one based on a Second Order Generalized Integrator (SOGI) and a new one based on a All-Pass Filter (APF) with Lattice structure. Both methods are very attractive because of their simple digital implementation, low computational load and good performance under harmonically distorted grid conditions and variable frequency, so they are a good alternative to other known methods. The paper derives and analyzes the full state space models of the two methods. It is shown that these two methods are equivalent in the most common operation conditions of distributed energy resources, although the APF structure is clearly better than the SOGI one because it maintains its orthogonal generation ability for any higher notch frequencies and any lower sampling frequencies. The comparative analysis were validated by simulation using MATLAB/Simulink and experimental results using a fixed-point DSP.


Introduction
The use, development and deployment of Distributed Energy Resources (DERs), especially renewable resources, has increased dramatically in the last decade. This is changing the paradigm of electric generation [1], [2], [3], and [4]. Single-phase grid-connected inverters are found in many DERs, such as photovoltaic inverters and energy storage devices [5] and [6].
Inverter system control must ensure that the power generation system is synchronized with the grid, and that phase angle jumps are detected for reliable power delivery [7] and [8]. Moreover, it must ensure that gridconnected system performance complies with operation requirements under the most common distortions, such as line harmonics, notches, voltage dips, rises and falls, and frequency variations.
Phase, frequency and amplitude characterize the single-phase grid voltage signal and knowledge of these parameters is fundamental in the design of gridconnected inverter systems [9], like the one in Fig. 1. In order to meet the new requirements of network codes and optimize inverter performance, a PLL is used for rapid synchronization with the grid.
The main task of the PLL is to accurately detect the actual voltage phase angle at the Point of Common Coupling (PCC), even in the presence of voltage harmonics and unbalance [10] and [11]. This structure, for example, should be used to provide any unity power factor operation which involves synchronization of the inverter output current with the grid voltage and to give a clean sinusoidal current reference, among other functions.
For three-phase applications, some of the recent and most popular grid synchronization techniques for detecting the phase and frequency of the mains voltage signal using PLL are presented in [12], where a complete study was carried out on the control strategies of Indeed, the single-phase structure of PLLs limits the use of some well-known three-phase control strategies [13] and [14]. In single-phase systems, less is known about the network operating conditions than in threephase systems. That is why the most advanced methods used to overcome this limitation must create an orthogonal voltage system [15] and then exploit the existing three-phase control methods. In this line of research, several advanced PLL techniques, have been proposed for single-phase applications [16], [17], [18], and [19]. General structure of a single-phase PLL algorithm based on Orthogonal Signal Generator (OSG), also called Quadrature Signal Generator (QSG), for grid synchronization is presented in [15], [16], [20], [21], [22], [23], and [24]. This structure can use the Park Trans-formation, as shown in Fig. 2 or the arc-tangent function depicted in Fig. 3. The main difference between OSG-based single-phase PLLs lies in the way orthogonal voltage systems are generated.

Frequency and Phase Estimator Orthogonal
System Generator Fig. 3: PLL using the arctangent function.
The OSG-based single-phase PLL structures, Fig. 2 and Fig. 3, found in the state-of-the-art methods are basically formed by two blocks. In the first, an orthogonal system in phase with the above signal is generated from a single reference sinusoidal signal. The second block uses either a feedback loop through the αβ to dq transformation or the arc-tangent function to determine the phase angle of the reference signal.
The methods for OSG of a single-phase PLL must be easy to apply in practice. Moreover, the OSG must deliver the filtered output without any delay, because of its resonance at the fundamental frequency, not to be affected by frequency changes. The most common methods used in the literature to generate the orthogonal voltage are presented in [15], [19], [20], [21], [25], [26], [27], [28], [29], [30], [31], and [33]. One using a block of a Transport Delay function is shown in Fig. 4. It introduces a 90 degree phase shift with respect to the input signal [21] and [28]. Another method uses the Hilbert Transformation [29], depicted in Fig. 5, and the Inverse Park Transformation [19], [30], and [31], shown in Fig. 6. However, these methods have one or more of the following deficiencies: frequency dependence, high complexity, non-linearity, and poor or no filtration. To improve the deficiencies mentioned in the OSG methods, an improved Average Filter (AF) is proposed in [32], with a simple structure and implementation, which, integrated into OSG, attenuates the negative effect of voltage harmonics and unbalances on orthogonal  d-q signals for PLL. Providing fast phase detection and fast dynamic response without using the second order filters, which reduce the dynamic response time and the detection of the synchronization unit.

V Vb
In [34], a Frequency Lock Loop (FLL) with a Generalized Integrator (GI) was proposed. In the GI-FLL, the GI part is a OSG, while the FLL part uses the signals generated for unknown frequency estimation purposes. The GI works as an adaptive bandpass filter using coordinate transformation, which allows to improve the dynamic tuning range, with an excellent balance between the convergence speed and the maximum acceptable peak estimation error, but with some computational cost additional to that needed for accuracy and the FLL has to add the normalization of the gain that the GI does not have.
The technique using the grid voltage demodulation to obtain a OSG is proposed in [35], in a Demodulation Type PLL (DT-PLL) with improved DC offset rejection capacity, for the adaptive estimation of the phase angle and the frequency of a single-phase system, which avoids the use of any low-pass filter. The demodulation has good dynamic performance and disturbance rejection ability. However, due to the presence of trigonometric quantities in the estimator dynamics, small-signal modelling-based parameter tuning can be complicated for DT-PLL. Moreover, real-time implementation of trigonometric functions is computationally expensive.
The SOGI structure has also been applied to other aspects of power electronic control, especially in the current control loop [37] and [38], detection of harmonics [39] and active anti-islanding methods [22].
However, as already indicated in [15], [37], and [38], the SOGI was designed in the continuous time and quadrature phase delay and amplitude ripples are present in its discrete application. Moreover, it is difficult to apply this structure on a fixed-point DSP or FPGA due to their limited precision and sensitivity to coefficient rounding.
A second-order APF with Lattice structure was proposed in [45], [46], [47], [48], [49], and [50]. This filter generates orthogonal signals necessary for the PLL, with good noise filtering capability but amplitudes different from that of the single-phase input signal. Here a APF with Lattice structure is proposed as OSG which meets all requirements and overcomes all the drawbacks of the methods used in single-phase PLL while maintaining any unity gain with respect to the input. This paper performs a comparative steadystate analysis of the structures based on APF and SOGI as part of a PLL. These structures are widely used for filtering the power supply signal to ensure the best possible synchronization system references for use in single-phase converters operating in highly disturbed environments. Solutions for the discrete application of the two structures are also provided. Simulations and a fixed-point DSP implementation validate the effectiveness of one or another structure.
The rest of the paper is organized as follows. Section 2.
describes the lattice APF as OSG with its main diagrams and equations. In Sec. 3. , the SOGI algorithm is presented. Section 4. provides discrete time simulation results for both OSGs using as input a 50 Hz normalized sinusoidal signal in both filters. In Sec. 5. , the experimental results of a fixed-point DSP implementation of both OSGs under the same simulation conditions are discussed. Finally, Sec. 6. draws the conclusions.

2.
Lattice-Based APF In the approach proposed in [49], no unity gain has been considered while, in this paper, a new structure of OSG based on APF, as illustrated in Fig. 7, is proposed characterized by unity gain [50].
In the system, the output signals x 1 (n) and x 2 (n) have a −90 degree and 0 phase shift, respectively, with respect to the input signal with unity gain, are defined as: The space-state equation of the APF with Lattice structure can be obtained from the system in Fig. 7, is defined as: where θ 1 is associated with the notch frequency ω 0 , at which the APF offers a phase shift of π radians, and θ 2 is associated with the 3 dB attenuation Bandwidth BW of the filter. They are defined as: where f s and B correspond to the sampling frequency and bandwidth in Hz, respectively. Independent adjustment of notch frequency and bandwidth is a desirable attribute. Adjusting the bandwidth for any sampling frequency from Eq. (6), either directly or adaptively, allows the APF to reject very low frequencies, even rejecting the DC offset, without adding another type of filter and without interfering with the tuning frequency. This feature of the APF can comply with those of the OSG with DC offset rejection capability proposed in [33], with only the adjustment of a single parameter.
The structure in Fig. 7, is theoretically stable and numerically well behaved in time-varying environments [49]. Each rotation angle ω k (k = 1, 2) is directly controlled, so that θ 1 and θ 2 are converted into the adjustable parameters for adaptive performance. Elements A and B of the structure are extracted from Eq. (3):
SOGI is proposed to obtain a zero steady state error using sinusoidal references working on the αβ stationary reference frame. This method has been included in harmonic elimination algorithms (because harmonics act in a very narrow band around their resonance frequency); grid sequence detection and quadrature signal generation algorithms; algorithms for converter synchronization to the power supply; and for multifrequency detection.
The transfer function of a SOGI for a single sinusoidal signal is [37] and [38]: where ω 0 is the resonance frequency and s the Laplace operator. The integrator output contains not only the integrated input but also an insignificant additional component. In order to use them to generate quadrature signals, the original topology is modified, as shown in Fig. 9. The resulting mathematical expression is: The new transfer function has two poles at ±jω 0 and a zero at the origin, just as Eq. (9). The only difference between the two expressions is in the gain, which is not significant as far as the final performance is concerned. However, the function leads to a more general structure that can be used for both power converters control and synchronization tasks.
The SOGI structure for generation of orthogonal signals, also known as OSG-SOGI, is outlined in Fig. 10. As can be seen, the basic element is a SOGI [15], [20], [37], [38], [39], and [40]. The continuous-time transfer Discrete-time implementation of the SOGI can be accomplished by discretizing the continuous-time transfer functions or by using discrete integrators [15], [37], and [38]. Figure 11 shows the discrete-time SOGI structure. Its output behaves like that of the continuous-time SOGI in Fig. 9 upon application of a step signal of amplitude 1 at input x(n), that is a sinusoidal signal of pulsation ω 0 and amplitude 1. The choice of this SOGI is based on the use of discrete Euler Backward Integrator with computational delay added in series with the feedback gain, modeling the inherent delay caused by the programming process. Moreover, its structure is more similar to that of the classical PI controller. The transfer function of the discrete-time SOGI is: Figure 12 displays the SOGI based on discrete Euler Backward Integrator within an OSG-SOGI, which ensures that signals v' and qv' are quadrature signals at all operating frequencies. The OSG-SOGI allows independent adjustment of the notch frequency ω 0 and of the 3 dB attenuation bandwidth BW, considering the sampling period T s , according to: The OSG-SOGI can also be expressed by state equation form based on the final circuit of Fig. 13, which is equivalent to that of Fig. 12, where x 1 (n) and x 2 (n) are the signals corresponding to the orthogonal system and are denoted as in the APF, with a −90 and 0 degree phase shift, respectively, and unity gain with respect to the input signal of power u(n) at instant n. Fig. 13: Definitive OSG-SOGI structure.
This orthogonal system is given by: Figure 14 offers the Bode diagram of the OSG-SOGI, for a tuning frequency of 50 Hz. Considering that outputs x 1 (n + 1) and x 2 (n + 1) are the same answers qv'(n) and v'(n), the state equation is: Elements A and B of the structure can be extracted from Eq. (18):

Behavior and Comparison of OSGs
The structures of the lattice-based APF in Fig. 7 and the OSG-SOGI in Fig. 13 can be easily implemented as matrix system consisting of elements A and B only, thus we will have the equation of state of the form: Both structures have the ability to generate, in phase with the input signal, an orthogonal system. Figure 15 shows the implementation of the lattice-based APF and OSG-SOGI structures in state equation. Two parameters identified as x 1 (n) and x 2 (n), which constitute the orthogonal system, are observed. Both structures are simulated under the same conditions to compare them as Band-Pass Filters (BPF) which generate a disturbance-free orthogonal system with one signal image of the fundamental input signal and another one delayed 90 degrees with respect to the same input signal. The two filters are evaluated using any unity amplitude sinusoidal signal at the frequency of 50 Hz as the fundamental input signal. Is sets a sampling frequency of 20 kHz, 50 Hz tuning frequency and a low bandwidth of 4 Hz, narrow enough for many applications where a very selective magnitude response is required, with a high quality factor. The simulation is implemented in MATLAB/Simulink. The state equa-tion from Eq. (3) for the APF with the values estimated under these conditions is: And the state equation from Eq. (18) for the OSG-SOGI with the values estimated: Figure 16 gives the frequency response for outputs x 2 (n)/u(n), of Eq. (2) and Eq. (17), corresponds to the APF and the OSG-SOGI. For frequencies over 10 Hz both structures maintain a strong similarity in both magnitude and phase. But for frequencies below 10 Hz they already begin to differentiate, the APF begins to increase its phase to values greater than 90 degrees. For frequencies below 1 Hz the difference in magnitude begins to be more noticeable. As shown in Eq. (22) and Eq. (23), the values of the coefficients of both filters are nearly identical under these operating conditions, the differences between the coefficients are less than 0.0001233. Hence, their frequency responses should have a very similar behavior.
The frequency responses are obtained for x 2 (n)/u(n), in the APF and in the OSG-SOGI for a range of fundamental frequencies, from 100 Hz to 10 kHz, with a bandwidth of 4 Hz, a sampling frequency of 20 kHz, for both filters. In Fig. 17, one can observe that both OSG behave like a BPF, but for fundamental frequencies greater than 400 Hz, the magnitude responses begin to have differences, although they maintain their tuning. From frequencies greater than 3 kHz, the SOGI begins to lose its tuning, both in its magnitude and phase response.        Figure 18 displays the result of the magnitude for x 2 (n)/u(n) of the lattice APF and the OSG-SOGI with a bandwidth of 4 Hz and a sampling frequency of 20 kHz at various frequencies, for a tuning frequency of 50 Hz with sampling frequencies ranging from 100 Hz to 100 kHz and for various sampling frequencies and variations of the frequency of tuning. As can be noticed, from a tuning frequency of 600 Hz and a sampling frequency below 1 kHz, the tuning of the SOGI is not accurate, and so are its characteristics as OSG, which does not happen with the APF.
The magnitude in dB of x 2 (n)/u(n) is obtained by evaluating the APF and the OSG-SOGI with a bandwidth of 4 Hz, depicted in Fig. 18(a) for a sampling frequency of 20 kHz and the variation of the tuning frequency. In Fig. 18(b) the tuning frequency is kept at 50 Hz with variation of the sampling frequency from 100 Hz to 100 kHz and in Fig. 18(c) the result of the magnitude is shown for several sampling frequencies (500 Hz, 2 kHz, 5 kHz, 8 kHz, 11 kHz, 14 kHz, 17 kHz, 20 kHz, 23 kHz, 26 kHz, and 29 kHz) and variation of the tuning frequency. As can be seen, the APF maintains a constant magnitude of 0 dB for all the varia-tions in all the evaluated ranges. On the other hand, the SOGI loses the tuning starting from a tuning frequency of 500 Hz and a sampling frequency lower than 1 kHz, and therefore hence its characteristics as OSG. Figure 19 shows the behavior of the matrix parameters of the state equation of the APF Eq. (3) and the OSG-SOGI Eq. (18) for various tuning and sampling frequencies. The parameters begin to differ more significantly from tuning frequencies greater than 500 Hz and sampling frequencies below 1 kHz in most cases. This is demonstrated by the results in Fig. 16, Fig. 17, and Fig. 18. Figure 20, has the magnitude response surface for x 2 (n)/u(n), as a function of the tuning frequency and the sampling frequency. Observing that for the APF, the result is a completely flat surface with a magnitude of 0 dB constant for any variation of the frequencies. This does not occur for the OSG-SOGI, where it is observed that the magnitude response varies as the frequencies vary, moving away from the required passband. Being the worst case when the tuning frequency increases and the sampling frequency decreases.

Simulation and Experimental Results
In order to validate the analysis, the APF and the OSG-SOGI are simulated by using MATLAB/Simulink program and an experimental setup was implemented. A CDM2480 test platform, with a TMS320F2812 fixed-point DSP from Texas Instruments as the central element, suitable for motion control and power electronics applications, was used to implement and test both structures as OSG. The fixed point DSP, with a clock frequency of 150 MHz, was used to generate the input signal, the OSG algorithms and the output signals with a 12 bit D/A converter.
All simulated and experimental results, were obtained using the structures in Fig. 7 and Fig. 13. The outputs x 1 (t) and x 2 (t) of the APF and the OSG-SOGI are obtained. The OSG input signal and parameters are the same for the simulation and the experimental part, where the input signal is a sinusoid with unity amplitude and frequency equal to the tuning frequency of the filter. A bandwidth of 4 Hz was set for the design of the OSGs. In the DSP, a fixed-point Q15 base was used for global calculations whereas a Q30 base was used for calculations of the filters.   In the experimental results obtained for the OSGs, channels A and B in blue are x 2 (t) and x 1 (t) of the APF with [1 V/div]; channels C and D in green are x 2 (t) and x 1 (t) of the SOGI with [1 V/div]. Corresponding reference signals (in red), an of the fundamental input signal on channels A and C and delayed signals 90 degrees with respect to this input signal on channels B and D, were added.
The results for a frequency of 50 Hz for the input signal and tuning, with a sampling frequency of 20 kHz, are presented in Fig. 21, where it is evidenced that both OSGs behave in accordance with the established, both in the simulation and in the DSP implementation.
The outputs x 1 (t) and x 2 (t) follow their references and retain their waveform, and maintain the gain of 1, necessary condition for both OSGs operating as PLLs.   The sampling frequency is kept at 20 kHz and the frequency of the input and tuning signal was increased to 500 Hz in Fig. 22 and 1000 Hz in Fig. 23. In the simulation for both tuning frequencies, the signals of the orthogonal system corresponding to the APF have a good follow-up of the reference signals with a gain of 1. The OSG-SOGI, loses its characteristics like OSG, with an advance of 0.0002 seconds, relative to the reference signals, which introduces a phase shift, as well as a decrease in the gain, which is not reaching 1.   In the implementation on a DSP, the responses of the APF are almost identical as in the simulation, there is a minimum advance of the signals, with respect to the reference signals, but not as pronounced as the case of OSG-SOGI, which maintains the same simulation behavior.
In Fig. 24, the outputs x 1 (t) and x 2 (t) are shown, for a different and extreme conditions, with a 50 Hz frequency of the signal input and tuning and with the sampling frequency lowered to 500 Hz. Both in the simulation and in the implementation in the DSP, the signals of the orthogonal system of the APF have a good follow-up of the reference signals with a gain of 1. In contrast, the OSG-SOGI signals are 0.0012 s ahead of the reference signals, which introduces a phase shift, as well as a 10 % decrease in gain, with respect to the input signals.   In Fig. 25, the frequency of the input and tuning signal is increased to 300 Hz, with the sampling frequency at 10 kHz. The outputs of the APF remain the same as in the previous cases, maintaining their characteristics as OSG, which does not happen with the OSG-SOGI. The OSG-SOGI outputs continue to show poor tracking of the reference signals, with an advance of 0.0002 s, in the simulation and in the implementa-tion in the DSP, although it maintains the gain of 1 in both cases.

Conclusion
This paper compared two different methods for generating the orthogonal quantity required for the PLL algorithm present in single-phase grid-connected inverter control. The analysis based on models of the state equations, showed that the method that uses the lattice APF exhibits better performance, although the results obtained with the SOGI structure are also acceptable.
A detailed mathematical analysis showed that these two orthogonal generators are equivalent and have an almost identical response in the range around the most common tuning frequency, i.e. 50 Hz, and also for sampling frequency values greater than 1 kHz. It was also demonstrated that the lattice APF is more stable since it retained its characteristics under all test conditions, although the tuning frequency was very high and the sampling frequency was very low, which does not occur with SOGI.
The parameters or coefficients of the matrix of the state equations of the lattice-based APF are more constant than those of the SOGI. The use of trigonometric functions to obtain these parameters ensures that they will always be in a minimum dynamic range of variation between −1 and +1. This is very suitable for applications using a fixed-point DSP. The obtained results showed a balance between good precision and resolution. The APF coefficients must not be scaled to enable their fitting within the dynamic range and processor's word length to allow their storage in the program memory. In this way, APF operation is almost identical to that specified in the design.
The theoretical evaluations were verified through extensive simulation and experimental studies. The study supports the conclusion that the lattice-based APF can provide the same functions in all applications where SOGI has been used so far as orthogonal generator, and also in others where tuning frequencies are higher or sampling frequencies are lower, as well as in the field of instrumentation, communications, analog electronics.
Most PLLs for three-phase applications, such as those presented in [12], have an OSG in their structure. This role can be fulfilled very well by the lattice-based APF, providing the advantages of working at higher tuning frequencies or lower sampling frequencies. Advantages that were verified in [50] when using the APF-PLL, guaranteeing fast dynamic response, good ripple filtering, easy implementation, low computation burden and a solution for harmonic components.
Electronics Engineering Department, the University of Tachira (UNET), San Cristobal, Venezuela. His research interest areas are power electronics, digital motor control, renewable energy, distributed energy resources, voltage and frequency control, and neural networks. Band pass f s Sampling frequency u(n)

Nancy
Input signal y(n) Output filtered x 1 (n), x 2 (n) Orthogonal components V ac Grid voltage V d d-axis voltage V q q-axis voltage V α α-axis voltage output of the OSG V β β-axis voltage output of the OSG V RM S Root Mean Square Voltage