# Adaptive PI + VPI Harmonic Current Compensation Strategy under Weak Grid Conditions
## Influence of Weak Grid Conditions on the APF System
### Influence of Grid Voltage Distortion and Unbalance  
Considering the unbalanced grid-side voltage, the three-phase grid-side voltage can be written as  
\[\left\{\begin{array}{c}v_{a}=V_{1}\cos(\omega t)\\ v_{b}=(1+\gamma)V_{1}\cos(\omega t-2\pi/3)\\ v_{c}=(1+\mu)V_{1}\cos(\omega t+2\pi/3)\end{array}\right. \tag{9}\]  
where \(\gamma\) and \(\mu\) are constants, indicating a three-phase unbalance. If \(\omega t=\theta\) is defined as the phase of the grid voltage and \(\hat{\theta}\approx\theta\) in the steady state, then  
\[\theta+\hat{\theta}\approx 2\theta \tag{10}\]  
Bring into (2), (3), (4), (5) and (6) to sort out.  
\[v_{qu}=\sqrt{\frac{3}{2}}V_{1}\delta(\frac{3+\gamma+\mu}{3})+\sqrt{\frac{3}{2} }V_{1}k_{pu}\cos(2\theta-\varphi_{pu}) \tag{11}\]  
\[k_{pu}=\sqrt{\left(\frac{\mu-\gamma}{2\sqrt{3}}\right)^{2}+\left(\frac{\mu+ \gamma}{6}\right)^{2}} \tag{12}\]  
\[\phi_{pu}=\arctan(\frac{\mu+\gamma}{\sqrt{3}(\mu-\gamma)}) \tag{13}\]  
\[P_{qu}=\sqrt{\frac{3}{2}}V_{1}k_{pu}\cos(2\theta-\phi_{pu}) \tag{14}\]  
Equation (14) represents the equivalent disturbance caused by the grid-side voltage unbalance. Because the \(q\)-axis voltage is adjusted to zero by the PI controller, the phase tracking error caused by the phase unbalance is:  
\[\delta_{u}\widetilde{=}\frac{3}{3+\mu+\beta}k_{pu}\cos(2\theta-\phi_{pu}) \tag{15}\]  
The phase tracking error caused by the three-phase unbalance is twice the fundamental frequency signal.  
Considering the voltage distortion, the grid voltage expression is shown in Equation (16).  
\[\left(\begin{array}{c}v_{a}\\ v_{b}\\ v_{c}\end{array}\right)=\left(\begin{array}{c}V_{1}\cos(\theta)-V_{5}\cos(5 \theta)+V_{7}\cos(7\theta)-V_{11}\cos(11\theta)+\cdots\\ V_{1}\cos(\theta-\frac{2\pi}{3})-V_{5}\cos(5(\theta-\frac{2\pi}{3}))+V_{7}\cos (7(\theta-\frac{2\pi}{3}))+\cdots\\ V_{1}\cos(\theta+\frac{2\pi}{3})-V_{5}\cos(5(\theta+\frac{2\pi}{3}))+V_{7}\cos (7(\theta+\frac{2\pi}{3}))+\cdots\end{array}\right) \tag{16}\]  
Bring into (2), (3), (4), (5) and (6) to sort out:  
\[v_{qd}=\sqrt{\frac{3}{2}}V_{1}\delta+\sqrt{\frac{3}{2}}(V_{5}+V_{7})\sin(6 \theta)+\sqrt{\frac{3}{2}}(V_{11}+V_{13})\sin(12\theta)+\cdots \tag{17}\]  
\[p_{qd}=\sqrt{\frac{3}{2}}(V_{5}+V_{7})\sin(6\theta)+\sqrt{\frac{3}{2}}(V_{11}+ V_{13})\sin(12\theta)+\cdots \tag{18}\]  
Equation (18) represents the equivalent disturbance caused by the grid voltage distortion. The phase tracking error caused by the grid voltage distortion is:  
\[\delta_{d}=(\frac{V_{5}+V_{7}}{V_{1}})\sin(6\theta)+(\frac{V_{11}+V_{13}}{V_{1 }})\sin(12\theta)+\cdots \tag{19}\]  
The tracking error caused by distortion is 6 times and 12 times the fundamental frequency signal. That is, 6 \(n\) (\(n=1\), 2, 3) times the fundamental frequency signal.  
In summary, under the dual effects of grid voltage unbalance and distortion, when the \(v_{q}\) steady state of the contaminated phase estimation signal satisfies \(v_{q}=v_{q}^{*}=0\), the steady-state error of the phase angle estimation obtained by expressions (15) and (19) is shown in (20).  
\[\hat{\theta}=\theta+\frac{3}{3+\mu+\beta}k_{pu}\cos(2\theta-\varphi_{pu})+( \frac{V_{5}+V_{7}}{V_{1}})\sin(6\theta)+(\frac{V_{11}+V_{12}}{V_{1}})\sin(12 \theta)+\cdots \tag{20}\]  
According to (20), if the grid-side voltage is unbalanced and distorted and the SRF-PLL design cannot filter out undesired harmonic disturbances, the output phase estimation will have a significant disturbance error of the 2 nd and 6\(\mu\)th (\(n=1,2,3\)) harmonic frequencies. The output frequency estimation is the derivative of the output phase estimation so that it also contains the disturbance error of the same frequency.  
In the APF system for harmonic compensation, the phase estimation error will lead to the given error of the harmonic current reference signal, which affects the accurate calculation of the \(d\) and \(q\) control channels, as shown in Figure 3. Obviously, improving phase and frequency estimation is important for accurate control performance.