Noise Immunity Analysis and Improvement of dq Frame Based Open-Loop Phase Detection Scheme

: To improve the noise immunity of a dq frame based open-loop phase detection (OPD) under high-frequency noise grid conditions, this paper develops a detailed model to quantitatively evaluate the phase detection error and noise immunity. It is found that the OPD behaves di ﬀ erently in terms of noise immunity when the dq frame is in di ﬀ erent angle positions with the grid voltage. When the grid voltage coincides with the d axis, the high-frequency noise has the smallest impact on the phase detection accuracy, and the OPD thus has the strongest noise immunity. Inspired by this conclusion, an improved OPD algorithm is proposed in this paper, which can e ﬀ ectively reduce the phase detection error by ﬁne-tuning the rotation angle of the dq frame to ensure that the angle between the voltage vector and d axis is always close to 0. The improved OPD algorithm has a fast and precise character to detect the phase information with less error and is ﬂexible for application. noise grid it can also e ﬀ ectively shorten the dynamic response time in the phase-detecting process using a low-pass ﬁlter (LPF) with a higher cut-o ﬀ frequency. The correctness of the noise immunity analysis and the e ﬀ ectiveness of the improved OPD algorithm are veriﬁed by the simulations and experimental results in MATLAB and RT-LAB. ratio to the voltage initial phase, which results the maximum


Introduction
The voltage synchronous phase is one of the key signals of converter control systems in distributed power generation systems. It is of paramount importance to detect the voltage phase quickly and accurately for high-performance system control strategies [1,2]. In recent years, increasing numbers of power electronic devices have been put into operation for electricity transformation in the power system. However, the collected power voltage signal often contains high-frequency random noise, which greatly interferes with the accurate detection of the voltage phase and becomes an unfavorable factor for achieving the high-performance control of grid-connected inverters [3][4][5]. Thus, phase detection schemes should have excellent noise immunity to suppress the interference.
In practical terms, phase detection schemes can be divided into open-loop phase detection (OPD) and closed-loop phase detection (CPD). The open-loop phase detection scheme eliminates the PI adjustment process, which can realize the rapid detection of the voltage phase. It is always applied to conditions such as a relatively ideal grid environment, and the requirement of phase accuracy is not very high [6][7][8]. A zero-crossing phase detection scheme is suggested in [8], which is the most commonly used OPD scheme at present. Its basic principle is to take the zero-crossing point as the reference point, and then the grid voltage phase can be calculated at each moment. However, high-frequency noise will affect the accurate detection of the zero-crossing point and result in phase

Basic Principles of OPD
First, three-phase balanced voltages can be described by where U m , ω and θ represent the voltage magnitude, the gird frequency and initial phase, respectively.
Using Clarke's and Park's transformation, the voltages U = [U a U b U c ] T in Equation (1) are transformed as U d and U q as follows: sin ωt cos ωt sin(ωt − 2π/3) cos(ωt − 2π/3) sin(ωt+2π/3) cos(ωt+2π/3) The DC components of the three-phase voltages can thus be expressed as Energies 2020, 13, 1145 3 of 15 From Figure 1, it can be seen that the initial phase θ of the three-phase gird voltages is the angle between U and the d axis.
Energies 2020, 13, 1145 3 of 15 From Figure 1, it can be seen that the initial phase θ of the three-phase gird voltages is the angle between U and the d axis. The voltage initial phase θ can thus be captured by We define the initial phase angle as agreeing with [0, 2π); however, the phase computed by Equation (4) belongs to (-π/2, π/2). To convert the initial angles to the set interval, this paper employs a compensation phase θex, which is defined by  (6) Similarly, the magnitude of grid voltages also can be computed as For the ideal grid voltage conditions without high-frequency random noise interference, substitute Equation (1) into Equations (2), (5) and (7); the instantaneous magnitude and synchronous phase can be captured immediately and accurately, respectively.
However, when noise interference occurs, the computed magnitude of the grid voltages undoubtedly contains random fluctuations. As shown in Figure 2, the actual detection phase computed by Equation (4) thus offsets the actual value, which results in an obvious phase error.  The voltage initial phase θ can thus be captured by We define the initial phase angle as agreeing with [0, 2π); however, the phase computed by Equation (4) belongs to (-π/2, π/2). To convert the initial angles to the set interval, this paper employs a compensation phase θ ex , which is defined by In summary, the current position of the three-phase voltages can thus be computed as Similarly, the magnitude of grid voltages also can be computed as For the ideal grid voltage conditions without high-frequency random noise interference, substitute Equation (1) into Equations (2), (5) and (7); the instantaneous magnitude and synchronous phase can be captured immediately and accurately, respectively.
However, when noise interference occurs, the computed magnitude of the grid voltages undoubtedly contains random fluctuations. As shown in Figure 2, the actual detection phase computed by Equation (4) thus offsets the actual value, which results in an obvious phase error.
In brief, the OPD based on the dq frame exhibits the advantages of rapidity and simplicity, which can detect voltage synchronous phase faster than traditional CPDs and thus ensure the high-performance operation of grid-connected inverters. It is worth noticing that the important premise of improving phase measurement accuracy is to ensure the rapidity of the OPD scheme under noise conditions. Based on this premise, it is necessary to evaluate the noise immunity and thus propose an enhanced scheme to ensure that the phase error is acceptable. For the ideal grid voltage conditions without high-frequency random noise interference, substitute Equation (1) into Equations (2), (5) and (7); the instantaneous magnitude and synchronous phase can be captured immediately and accurately, respectively.
However, when noise interference occurs, the computed magnitude of the grid voltages undoubtedly contains random fluctuations. As shown in Figure 2, the actual detection phase computed by Equation (4) Figure 2. Initial phase waveform under high-frequency random noise conditions. Figure 2. Initial phase waveform under high-frequency random noise conditions.

Noise Immunity Analysis Model of OPD
The gird voltages are regarded as the combination of the three-phase balanced grid voltages and the high-frequency noise DC components. Thus, the three-phase voltage signal with high-frequency noise could be described as The physical quantities with superscript ∼ in this paper indicate the existence of random noise. Considering the existence of high-frequency random noise, Equation (4) can be rewritten as In Equation (9), x q and x d denote noise values in the dq frame, respectively. θ* is the actual detection phase. Assume x q ≤ N, x d ≤ N, where N is the possible maximum noise value; to analyze the noise immunity systematically in this paper, we define λ as the noise ratio of gird voltages, which can be expressed as By incorporating Equations (9) and (10), we can get Figure 3 shows that if the initial phase interval is θ ∈ (0, π/2), obviously, sin θ > 0 and cos θ > 0. In the case of cos θλ = 0 or sin θλ = 0, we can observe that θ = arccos λ or θ = arcsin λ, respectively. In brief, the OPD based on the dq frame exhibits the advantages of rapidity and simplicity, which can detect voltage synchronous phase faster than traditional CPDs and thus ensure the highperformance operation of grid-connected inverters. It is worth noticing that the important premise of improving phase measurement accuracy is to ensure the rapidity of the OPD scheme under noise conditions. Based on this premise, it is necessary to evaluate the noise immunity and thus propose an enhanced scheme to ensure that the phase error is acceptable.

Noise Immunity Analysis Model of OPD
The gird voltages are regarded as the combination of the three-phase balanced grid voltages and the high-frequency noise DC components. Thus, the three-phase voltage signal with high-frequency noise could be described as The physical quantities with superscript ∼ in this paper indicate the existence of random noise.
Considering the existence of high-frequency random noise, Equation (4) can be rewritten as In Equation (9), xq and xd denote noise values in the dq frame, respectively. θ* is the actual detection phase. Assume xq ≤ N, xd ≤ N, where N is the possible maximum noise value; to analyze the noise immunity systematically in this paper, we define λ as the noise ratio of gird voltages, which can be expressed as By incorporating Equations (9) and (10) Figure 3 shows that if the initial phase interval is θ  (0, π/2), obviously, sin θ > 0 and cos θ > 0.
As displayed in Figure 4, the maximum phase error can thus be denoted as   In the case of θ  (π/4, arccos λ), we can see that Δθmax equals ΔθLower = θ -θmin; i.e., the actual detection value falls away from the theoretical value.
In the case of θ  (0, arcsin λ), from Equation (11), it is easy to observe that θmin < 0, θmax > 0, and |θmin| < θmax. Thus, the maximum phase error in the interval can be expressed as In the case of θ ∈ (π/4, arccos λ), we can see that ∆θ max equals ∆θ Lower = θθ min ; i.e., the actual detection value falls away from the theoretical value. In the case of θ ∈ (0, arcsin λ), from Equation (11), it is easy to observe that θ min < 0, θ max > 0, and |θ min | < θ max . Thus, the maximum phase error in the interval can be expressed as When θ ∈ (arccos λ, π/2), we can see that θ max < 0, θ min > 0, and θ min < |θ max |. From Equation (6), if θ < 0, the compensation phase θ ex equals π. Thus, the maximum phase error can be obtained as As aforementioned, in the case of θ ∈ (0, π/2), the expression of ∆θ max corresponding to different initial phases under noise conditions can be expressed as According to Figure 1 and Equation (20), we can see that the initial phase is the angle between the voltage vector U and d axis. Obviously, a different initial phase means that if the dq frame is in different positions with voltage U, this will thus lead to a different voltage initial phase error under high-frequency random noise interference.
In Equation (20), the maximum phase error of θ ∈ (0, π/4) and (π/4, arccos λ) could, respectively, be obtained by From Equation (21), it can be observed that, when the angle between U and d axis is around 45 • , the phase error is the largest and the noise immunity of OPD is the worst. The maximum phase error is shown as In addition, substituting θ = 0, θ 3 = arcsin λ, θ 4 = arccos λ into Equation (20), it is easy to observe that From Equation (23), it can be seen that, if the angle between U and d axis is 0 • , high-frequency noise has the weakest interference on the phase measurement accuracy, and the phase error is thus the smallest.
In the case of the initial phase belonging to the other quadrants, the analysis process and scheme are the same as above and will not be repeated in this paper.
In the actual operating condition, assume that the phase measurement accuracy of the grid-tied inverter is K under noise interference. From Equation (22), the maximum phase error can be expressed as From Equation (24), the relationship between the phase-precision K and noise ratio λ can be expressed as Energies 2020, 13, 1145

of 15
If the voltage phase-accuracy is set as K < 2%, the accepted range of the voltage noise ratio agrees with 0 < λ < 8.88%. This means that, if the original voltage magnitude is 100 V and the noise signal value does not exceed 8.88 V, the phase error detected by OPD can meet the accuracy requirement. However, when the high-frequency random noise increases, the phase error is thus larger, which does not meet the requirement of practical accuracy.
From Figure 6, if the noise ratio agrees with 0 < λ < 0.1, the initial phase fluctuates at about 45 • , which corresponds to the maximum phase error. However, when λ increases, as shown in Figure 6 and Equation (21), θ 1 and θ 2 are not at the maximum value point.
The bigger λ is, the more θ 1 and (or) θ 2 deviate from π/4, which will lead to the amplification of ∆θ max and other phase errors.
Energies 2020, 13, 1145 7 of 15 If the voltage phase-accuracy is set as K < 2%, the accepted range of the voltage noise ratio agrees with 0 < λ < 8.88%. This means that, if the original voltage magnitude is 100 V and the noise signal value does not exceed 8.88 V, the phase error detected by OPD can meet the accuracy requirement. However, when the high-frequency random noise increases, the phase error is thus larger, which does not meet the requirement of practical accuracy.
From Figure 6, if the noise ratio agrees with 0 < λ < 0.1, the initial phase fluctuates at about 45°, which corresponds to the maximum phase error. However, when λ increases, as shown in Figure 6 and Equation (21), θ1 and θ2 are not at the maximum value point.
The bigger λ is, the more θ1 and (or) θ2 deviate from π/4, which will lead to the amplification of Δθmax and other phase errors. In summary, the conclusions of noise immunity on OPD are as follows: a) The voltage initial phase detection error is associated with the voltage noise ratio λ. The greater the voltage noise ratio, the greater the phase error. The accuracy of phase detection is greatly affected by the noise value. b) If the angle between U and d axis is different, OPD has a different noise immunity. When θ ≈ 45°, the phase error is the largest. If θ = 0°, the phase error is the smallest, and the noise interference to phase accuracy is the lowest.

Improved OPD
Based on the above, to reduce the phase error, this paper proposes an improved OPD to enhance the noise immunity of OPD. First, the rotation angle of the dq frame is fine-tuned to ensure that the angle between the voltage vector and d axis is always close to 0°, so that the voltage vector could be located in the angle position with the smallest phase error in the dq frame. The noise immunity of OPD could thus be enhanced, and the initial phase detection accuracy can thus be improved. The enhanced OPD algorithm is elaborated in detail below.
From Equation (2) and Figure 1, it can be seen that, in Clarke's and Park's transformation, ωt is the rotation angle of the dq frame, which determines the rotation speed and relative position relationship between the dq frame and voltage vector U. For a different initial phase θ and fixed frequency, the actual detected phase value θ* has a different phase error (i.e., the closer θ is to π/4, the larger the detected phase error.). Hence, ωt + θ can be used as a simple and effective controlled factor to fine-tune the position of the dq frame.
As shown in Figure 7, θ* is the actual detected value of the voltage initial phase under noise interference. θd0 is the difference between the theoretical initial phase and actual detected value; i.e., the angle between the d0 axis and voltage U. In summary, the conclusions of noise immunity on OPD are as follows: (a) The voltage initial phase detection error is associated with the voltage noise ratio λ. The greater the voltage noise ratio, the greater the phase error. The accuracy of phase detection is greatly affected by the noise value. (b) If the angle between U and d axis is different, OPD has a different noise immunity. When θ ≈ 45 • , the phase error is the largest. If θ = 0 • , the phase error is the smallest, and the noise interference to phase accuracy is the lowest.

Improved OPD
Based on the above, to reduce the phase error, this paper proposes an improved OPD to enhance the noise immunity of OPD. First, the rotation angle of the dq frame is fine-tuned to ensure that the angle between the voltage vector and d axis is always close to 0 • , so that the voltage vector could be located in the angle position with the smallest phase error in the dq frame. The noise immunity of OPD could thus be enhanced, and the initial phase detection accuracy can thus be improved. The enhanced OPD algorithm is elaborated in detail below.
From Equation (2) and Figure 1, it can be seen that, in Clarke's and Park's transformation, ωt is the rotation angle of the dq frame, which determines the rotation speed and relative position relationship between the dq frame and voltage vector U. For a different initial phase θ and fixed frequency, the actual detected phase value θ* has a different phase error (i.e., the closer θ is to π/4, the larger the detected phase error.). Hence, ωt + θ can be used as a simple and effective controlled factor to fine-tune the position of the dq frame.
As shown in Figure 7, θ* is the actual detected value of the voltage initial phase under noise interference. θ d0 is the difference between the theoretical initial phase and actual detected value; i.e., the angle between the d 0 axis and voltage U. When adding the detected phase value θ* to the dq coordinate transformation matrix to finetune the dq frame, Tabc/dq (ωt + θ*) can thus be rewritten as After fine-tuning the rotation angle of the dq frame, the voltage DC components in the d0q0 frame can thus be expressed as follows: From Equation (27), the current position of the three-phase voltages could be calculated by From Equation (28), it can be observed that, under the ideal grid environment (i.e., θ* = θ), the current position of the three-phase voltages calculated by Equation (28) equals that of Equation (6), which shows that the improved OPD algorithm has the same phase detection function as the original OPD.
When the three-phase voltages contain high-frequency random noise, we take θ = π/4 as an example to better illustrate the effect of fine-tuning the rotation angle dq frame to reduce phase detection errors.
First, the relationship between θ* and θd0 can be expressed as From Equation (22), we can see that if θ equals π/4, the phase error Δθ (i.e., θd0 ) equals arcsin (λ 1/2 ) and the actual detected value θ* equals π/4 -arcsin (λ 1/2 ); using the original OPD, the current position of the three-phase voltages in the dq frame is shown as  When adding the detected phase value θ* to the dq coordinate transformation matrix to fine-tune the dq frame, T abc/dq (ωt + θ*) can thus be rewritten as After fine-tuning the rotation angle of the dq frame, the voltage DC components in the d 0 q 0 frame can thus be expressed as follows: From Equation (27), the current position of the three-phase voltages could be calculated by From Equation (28), it can be observed that, under the ideal grid environment (i.e., θ* = θ), the current position of the three-phase voltages calculated by Equation (28) equals that of Equation (6), which shows that the improved OPD algorithm has the same phase detection function as the original OPD.
When the three-phase voltages contain high-frequency random noise, we take θ = π/4 as an example to better illustrate the effect of fine-tuning the rotation angle dq frame to reduce phase detection errors.
First, the relationship between θ* and θ d0 can be expressed as From Equation (22), we can see that if θ equals π/4, the phase error ∆θ (i.e., θ d0 ) equals arcsin (λ 1/2 ) and the actual detected value θ* equals π/4 -arcsin (λ 1/2 ); using the original OPD, the current position of the three-phase voltages in the dq frame is shown as Using Equation (26) to fine-tune the dq frame, the DC components can thus be expressed as Energies 2020, 13, 1145 9 of 15 From Equation (31), the current position of the three-phase voltages in the d 0 q 0 frame is shown as From Equations (30) and (32), it can be seen that ϕ d0q0 in Equation (32) is closer to π/4 than ϕ dq in Equation (30), which shows that the improved OPD algorithm can effectively reduce the phase detection error by fine-tuning the rotation angle of the dq frame.
Moreover, the phase error percentage comparison from Equations (30) and (32) is shown in Figure 8. It can be seen that the proposed improved OPD algorithm can significantly reduce the phase detection error and ensure that the phase detection error is acceptable. From Equations (30) and (32), it can be seen that φd0q0 in Equation (32) is closer to π/4 than φdq in Equation (30), which shows that the improved OPD algorithm can effectively reduce the phase detection error by fine-tuning the rotation angle of the dq frame.
Moreover, the phase error percentage comparison from Equations (30) and (32) is shown in Figure 8. It can be seen that the proposed improved OPD algorithm can significantly reduce the phase detection error and ensure that the phase detection error is acceptable. From Equation (32) and Figure 7, we can see that the larger θd0, the larger the error calculated by Equation (31) in the d0q0 frame. While directly adding the initial phase detection value θ* into the coordinate transformation matrix without considering the real-time variation of random noise value, which may result in a relatively large angle difference between the d0 axis and voltage vector U, the phase detection accuracy of the proposed OPD algorithm will thus be reduced.
Hence, it is of paramount importance to detect the value of θd0 in real time to further reduce the phase detection errors. To ensure that the grid voltage vector almost coincides with the d0 axis in the d0 q0 frame, the flow chart of tracking the θd0 between the voltage vector and d0 axis and fine-tuning the relative angular position of d0q0 frame is shown in Figure 9.
The judgment condition of angle difference θd0 (i.e., arctan (Uq0/Ud0) + θex) is set as follows: 1) After fine-tuning the rotation angle of the dq frame first, if |arctan(Uq0/Ud0) + θex| ≤ 2πK, it can be seen from Equation (24) that the voltage synchronous phase angle calculated by Equation (30) meets the phase accuracy requirements.
2) Conversely, while the judgment condition is not satisfied (i.e., |arctan (Uq0/Ud0) + θex| > 2πK), the d0q0 frame must be fine-tuned again; arctan (Uq0/Ud0) + θex is simultaneously added to the dq coordinate transformation matrix in Equation (26) for the fine-tuning of the dq frame. From Equation (32) and Figure 7, we can see that the larger θ d0 , the larger the error calculated by Equation (31) in the d 0 q 0 frame. While directly adding the initial phase detection value θ* into the coordinate transformation matrix without considering the real-time variation of random noise value, which may result in a relatively large angle difference between the d 0 axis and voltage vector U, the phase detection accuracy of the proposed OPD algorithm will thus be reduced.
Hence, it is of paramount importance to detect the value of θ d0 in real time to further reduce the phase detection errors. To ensure that the grid voltage vector almost coincides with the d 0 axis in the d 0 q 0 frame, the flow chart of tracking the θ d0 between the voltage vector and d 0 axis and fine-tuning the relative angular position of d 0 q 0 frame is shown in Figure 9.
The judgment condition of angle difference θ d0 (i.e., arctan (U q0 /U d0 ) + θ ex ) is set as follows: (1) After fine-tuning the rotation angle of the dq frame first, if |arctan(U q0 /U d0 ) + θ ex | ≤ 2πK, it can be seen from Equation (24) that the voltage synchronous phase angle calculated by Equation (30) meets the phase accuracy requirements. (2) Conversely, while the judgment condition is not satisfied (i.e., |arctan (U q0 /U d0 ) + θ ex | > 2πK), the d 0 q 0 frame must be fine-tuned again; arctan (U q0 /U d0 ) + θ ex is simultaneously added to the dq coordinate transformation matrix in Equation (26) for the fine-tuning of the dq frame. Energies 2020, 13, 1145 10 of 15 Particularly, when the voltage phase detection requirement for engineering application is higher, even if the included angle of the d axis and voltage vector is close to 0, the phase error may not meet accuracy requirements. Although the enhanced OPD algorithm proposed in this paper can significantly suppress the interference of high-frequency random noise without using LPF, it is difficult to eliminate its influence completely (i.e., 100 % noise suppression).
To further attenuate noise, the high-frequency random noise can be filtered by LPF, however, which will simultaneously sacrifice the dynamic response performance of the control system. The improved OPD algorithm proposed in this paper has achieved the suppression of high-frequency noise for phase measurement accuracy, and the dynamic performance of OPD can thus be enhanced using an LPF with a higher cutoff frequency. The transfer function of the first-order LPF is given as where ωf represents the cut-off frequency of LPF. The scheme of the enhanced OPD algorithm adopting the improved algorithm proposed in this paper is shown in Figure 10. The actual detection value θ *

Judgement condition
Eq.(29) θ-θ * Fine-tuning the rotation angle of dq-frame Figure 10. Scheme of the enhanced OPD by fine-tuning the rotation angle of the dq frame.

Simulation Verification
To evaluate the correctness of the noise immunity analysis on the OPD scheme and the enhanced algorithm, this paper implements OPD verification based on MATLAB/Simulink and RT-LAB. Particularly, when the voltage phase detection requirement for engineering application is higher, even if the included angle of the d axis and voltage vector is close to 0, the phase error may not meet accuracy requirements. Although the enhanced OPD algorithm proposed in this paper can significantly suppress the interference of high-frequency random noise without using LPF, it is difficult to eliminate its influence completely (i.e., 100 % noise suppression).
To further attenuate noise, the high-frequency random noise can be filtered by LPF, however, which will simultaneously sacrifice the dynamic response performance of the control system. The improved OPD algorithm proposed in this paper has achieved the suppression of high-frequency noise for phase measurement accuracy, and the dynamic performance of OPD can thus be enhanced using an LPF with a higher cutoff frequency. The transfer function of the first-order LPF is given as where ω f represents the cut-off frequency of LPF. The scheme of the enhanced OPD algorithm adopting the improved algorithm proposed in this paper is shown in Figure 10.  Particularly, when the voltage phase detection requirement for engineering application is higher, even if the included angle of the d axis and voltage vector is close to 0, the phase error may not meet accuracy requirements. Although the enhanced OPD algorithm proposed in this paper can significantly suppress the interference of high-frequency random noise without using LPF, it is difficult to eliminate its influence completely (i.e., 100 % noise suppression).
To further attenuate noise, the high-frequency random noise can be filtered by LPF, however, which will simultaneously sacrifice the dynamic response performance of the control system. The improved OPD algorithm proposed in this paper has achieved the suppression of high-frequency noise for phase measurement accuracy, and the dynamic performance of OPD can thus be enhanced using an LPF with a higher cutoff frequency. The transfer function of the first-order LPF is given as where ωf represents the cut-off frequency of LPF. The scheme of the enhanced OPD algorithm adopting the improved algorithm proposed in this paper is shown in Figure 10. The actual detection value θ *

Judgement condition
Eq.(29) θ-θ * Fine-tuning the rotation angle of dq-frame Figure 10. Scheme of the enhanced OPD by fine-tuning the rotation angle of the dq frame.

Simulation Verification
To evaluate the correctness of the noise immunity analysis on the OPD scheme and the enhanced algorithm, this paper implements OPD verification based on MATLAB/Simulink and RT-LAB.

Simulation Verification
To evaluate the correctness of the noise immunity analysis on the OPD scheme and the enhanced algorithm, this paper implements OPD verification based on MATLAB/Simulink and RT-LAB.
The purpose of verification is to prove that the enhanced algorithm is effective at improving the phase measurement accuracy under different working conditions, such as by adding noise suddenly, frequency step change, increasing the noise ratio λ and θ, and through comparison with the addition of LPF, where U m = 100 V in the simulation scenario.
The three-phase voltage parameters of simulation verification are shown in Table 1:  Figure 11 shows that when high-frequency noise is suddenly added to a grid voltage at 0.5 s, the current magnitude of the grid voltage fluctuates, and the current position waveform captured by conventional OPD thus greatly deviates. The error of phase detection increases, which will count against the high-performance control of the grid-connected inverter. The purpose of verification is to prove that the enhanced algorithm is effective at improving the phase measurement accuracy under different working conditions, such as by adding noise suddenly, frequency step change, increasing the noise ratio λ and θ, and through comparison with the addition of LPF, where Um = 100 V in the simulation scenario.

Noise Immunity Verification of OPD
The three-phase voltage parameters of simulation verification are shown in Table 1:  Figure 11 shows that when high-frequency noise is suddenly added to a grid voltage at 0.5 s, the current magnitude of the grid voltage fluctuates, and the current position waveform captured by conventional OPD thus greatly deviates. The error of phase detection increases, which will count against the high-performance control of the grid-connected inverter.  For the different initial phase θ under high-frequency noise interference (i.e., the angle between U and d axis is different), the phase simulation results detected by the conventional OPD are shown in Figure 12. It can be observed that, when the initial phase of grid voltage is 45°, the noise has the largest interference on the initial phase measurement; the noise immunity is the worst, and the voltage phase error is the largest. When the angle between the voltage vector and d axis is close to 0, the phase error is the smallest. The experimental results are consistent with the above analysis. For the different initial phase θ under high-frequency noise interference (i.e., the angle between U and d axis is different), the phase simulation results detected by the conventional OPD are shown in Figure 12. It can be observed that, when the initial phase of grid voltage is 45 • , the noise has the largest interference on the initial phase measurement; the noise immunity is the worst, and the voltage phase error is the largest. When the angle between the voltage vector and d axis is close to 0, the phase error is the smallest. The experimental results are consistent with the above analysis.  Figure 13 shows the phase measurement waveform comparison results when the power grid frequency changes from 50 Hz to 55 Hz. The initial phase waveform detected by the improved algorithm presented in this paper hardly changes under the condition of frequency step change, which could imply that the voltage initial angle detected by this improved algorithm is almost unaffected.  Figure 14 shows the initial phase response waveform contrast when the noise ratio changes from 0.1 to 0.2. The result shows that as the voltage noise ratio increases, the interference degree to voltage noise immunity becomes larger, and the phase error increases significantly. Figure 15 shows the initial phase waveform response process using the improved algorithm. The waveform shows that by fine-tuning the rotation angle of the dq frame, the phase error of voltage initial phase is significantly smaller than that of the conventional OPD, and the phase error is almost equal to θ = 0°. The phase error mainly depends on the magnitude of the voltage signal-noise ratio. The proposed algorithm can improve the phase measurement accuracy under noise interference.   Figure 13 shows the phase measurement waveform comparison results when the power grid frequency changes from 50 Hz to 55 Hz. The initial phase waveform detected by the improved algorithm presented in this paper hardly changes under the condition of frequency step change, which could imply that the voltage initial angle detected by this improved algorithm is almost unaffected.  Figure 13 shows the phase measurement waveform comparison results when the power grid frequency changes from 50 Hz to 55 Hz. The initial phase waveform detected by the improved algorithm presented in this paper hardly changes under the condition of frequency step change, which could imply that the voltage initial angle detected by this improved algorithm is almost unaffected.  Figure 14 shows the initial phase response waveform contrast when the noise ratio changes from 0.1 to 0.2. The result shows that as the voltage noise ratio increases, the interference degree to voltage noise immunity becomes larger, and the phase error increases significantly. Figure 15 shows the initial phase waveform response process using the improved algorithm. The waveform shows that by fine-tuning the rotation angle of the dq frame, the phase error of voltage initial phase is significantly smaller than that of the conventional OPD, and the phase error is almost equal to θ = 0°. The phase error mainly depends on the magnitude of the voltage signal-noise ratio. The proposed algorithm can improve the phase measurement accuracy under noise interference.   Figure 14 shows the initial phase response waveform contrast when the noise ratio changes from 0.1 to 0.2. The result shows that as the voltage noise ratio increases, the interference degree to voltage noise immunity becomes larger, and the phase error increases significantly.  Figure 13 shows the phase measurement waveform comparison results when the power grid frequency changes from 50 Hz to 55 Hz. The initial phase waveform detected by the improved algorithm presented in this paper hardly changes under the condition of frequency step change, which could imply that the voltage initial angle detected by this improved algorithm is almost unaffected.  Figure 14 shows the initial phase response waveform contrast when the noise ratio changes from 0.1 to 0.2. The result shows that as the voltage noise ratio increases, the interference degree to voltage noise immunity becomes larger, and the phase error increases significantly. Figure 15 shows the initial phase waveform response process using the improved algorithm. The waveform shows that by fine-tuning the rotation angle of the dq frame, the phase error of voltage initial phase is significantly smaller than that of the conventional OPD, and the phase error is almost equal to θ = 0°. The phase error mainly depends on the magnitude of the voltage signal-noise ratio. The proposed algorithm can improve the phase measurement accuracy under noise interference.   Figure 15 shows the initial phase waveform response process using the improved algorithm. The waveform shows that by fine-tuning the rotation angle of the dq frame, the phase error of voltage initial phase is significantly smaller than that of the conventional OPD, and the phase error is almost equal to θ = 0 • . The phase error mainly depends on the magnitude of the voltage signal-noise ratio. The proposed algorithm can improve the phase measurement accuracy under noise interference.  Figure 13 shows the phase measurement waveform comparison results when the power grid frequency changes from 50 Hz to 55 Hz. The initial phase waveform detected by the improved algorithm presented in this paper hardly changes under the condition of frequency step change, which could imply that the voltage initial angle detected by this improved algorithm is almost unaffected.  Figure 14 shows the initial phase response waveform contrast when the noise ratio changes from 0.1 to 0.2. The result shows that as the voltage noise ratio increases, the interference degree to voltage noise immunity becomes larger, and the phase error increases significantly. Figure 15 shows the initial phase waveform response process using the improved algorithm. The waveform shows that by fine-tuning the rotation angle of the dq frame, the phase error of voltage initial phase is significantly smaller than that of the conventional OPD, and the phase error is almost equal to θ = 0°. The phase error mainly depends on the magnitude of the voltage signal-noise ratio. The proposed algorithm can improve the phase measurement accuracy under noise interference.  In Figure 16, the green phase waveform is captured by the conventional OPD when the phase angle increases from 0 to π/4. The blue one is captured by the improved OPD.

Noise Immunity Verification of OPD
Energies 2020, 13, 1145 13 of 15 In Figure 16, the green phase waveform is captured by the conventional OPD when the phase angle increases from 0 to π/4. The blue one is captured by the improved OPD. To get the same random noise suppression effect, the conventional OPD sets ωf as 1 kHz, while the improved OPD sets ωf as 5 kHz. From Figure 15, it can be seen that the improved OPD algorithm effectively avoids noise amplification, and the ωf can therefore be higher (i.e., 5 kHz), which is conducive to shortening the response time (about 4.2 ms). However, to obtain a better noise attenuation effect, the conventional OPD is set ωf as 1 kHz, which thus results in the poor dynamic performance of tge phase detection process; its response time is about 8.6 ms.

Real-Time Simulation Experiment Verification
In this paper, after using MATLAB/Simulink to build the analysis model of OPD and its enhanced algorithm, a real-time simulation platform based on RT-LAB is imported for comparative verification.
In the experimental scenario, the voltage phase changes suddenly, as shown in Figure 17a. The DC component results detected by the conventional OPD are shown in Figure 17b,c, respectively.
As shown in Figure 17d,e, the response time of the improved OPD is shorter than the conventional OPD when the phase changes from 0 to π/4; the conventional OPD sets ωf as 2 kHz and the improved OPD sets ωf as 6 kHz. According to the experimental result, under the same noise suppression effect, the improved OPD makes the response process faster, which is important to achieving the high-performance control of grid-connected inverters. It can be noticed that the effectiveness of the improved OPD algorithm has also been verified by RT-LAB. To get the same random noise suppression effect, the conventional OPD sets ω f as 1 kHz, while the improved OPD sets ω f as 5 kHz. From Figure 15, it can be seen that the improved OPD algorithm effectively avoids noise amplification, and the ω f can therefore be higher (i.e., 5 kHz), which is conducive to shortening the response time (about 4.2 ms). However, to obtain a better noise attenuation effect, the conventional OPD is set ω f as 1 kHz, which thus results in the poor dynamic performance of tge phase detection process; its response time is about 8.6 ms.

Real-Time Simulation Experiment Verification
In this paper, after using MATLAB/Simulink to build the analysis model of OPD and its enhanced algorithm, a real-time simulation platform based on RT-LAB is imported for comparative verification.
In the experimental scenario, the voltage phase changes suddenly, as shown in Figure 17a. The DC component results detected by the conventional OPD are shown in Figure 17b,c, respectively.
As shown in Figure 17d,e, the response time of the improved OPD is shorter than the conventional OPD when the phase changes from 0 to π/4; the conventional OPD sets ω f as 2 kHz and the improved OPD sets ω f as 6 kHz. According to the experimental result, under the same noise suppression effect, the improved OPD makes the response process faster, which is important to achieving the high-performance control of grid-connected inverters. It can be noticed that the effectiveness of the improved OPD algorithm has also been verified by RT-LAB.
To demonstrate the technical advantages of the improved OPD algorithm in terms of the dynamic response speed and digital implementation, this paper compares its dynamic response time with the widely used SSRF-SPLL and DDSRF-SPLL algorithms. The experimental conditions and comparative analysis results are shown in Table 2. It can be seen in Table 2 that, under the experimental conditions of amplitude change and waveform distortion, all three phase detection algorithms have a fast dynamic response speed. When the impact of high-frequency random noise is small (i.e., λ = 0.08), the proposed OPD can respond quicker to the dynamic processes without using LPF. When λ = 0.2, the dynamic response time of the three methods increased to varying degrees. However, the proposed OPD still responds quicker using an LPF with a lower cut-off frequency. To obtain better noise suppression, the other two algorithms significantly sacrifice dynamic performance. DC component results detected by the conventional OPD are shown in Figure 17b,c, respectively.
As shown in Figure 17d,e, the response time of the improved OPD is shorter than the conventional OPD when the phase changes from 0 to π/4; the conventional OPD sets ωf as 2 kHz and the improved OPD sets ωf as 6 kHz. According to the experimental result, under the same noise suppression effect, the improved OPD makes the response process faster, which is important to achieving the high-performance control of grid-connected inverters. It can be noticed that the effectiveness of the improved OPD algorithm has also been verified by RT-LAB.  To demonstrate the technical advantages of the improved OPD algorithm in terms of the dynamic response speed and digital implementation, this paper compares its dynamic response time with the widely used SSRF-SPLL and DDSRF-SPLL algorithms. The experimental conditions and comparative analysis results are shown in Table 2.

Conclusions
The fast and accurate acquisition of a grid voltage synchronous phase is the basic requirement of the high-performance control of grid-connected inverters. This paper focuses on the noise immunity of OPD and proposes a novel, enhanced OPD algorithm to improve the phase accuracy without sacrificing response time. Based on the theoretical analysis and simulation results, our conclusions are as follows: (1) If the included angle between the voltage vector and d axis is about 45 • , the phase measurement accuracy is most affected by noise. When the included angle equals 0, the noise immunity is the strongest and the phase error is the smallest. The voltage phase error depends on the noise ratio. (2) By fine-tuning the rotation angle of the dq frame, which can ensure that the voltage U is always at the position with minimum noise interference in the dq frame and enhance the noise immunity of OPD, the phase error can thus be ensured to be acceptable.