# Adaptive PI + VPI Harmonic Current Compensation Strategy under Weak Grid Conditions
## Influence of Weak Grid Conditions on the APF System
### Structure and Modeling of the Synchronous Phase-Locked Loop  
A Synchronous phase-locked loop is one of the most important modules in an APF system. It is not only used in the estimation of power fundamental parameters (phase, frequency and amplitude) but also in the measurement of power quality indicators, such as harmonics and inter-harmonics. The synchronous phase-locked loop ensures that the equipment connected to the grid is synchronized with the grid by accurately estimating the grid phase. The advantage of the three-phase SRF-PLL is that the measured three-phase grid voltage is transformed, and the control law is designed to make the \(q\)-axis voltage component equal to 0 to realize the synchronous tracking of the \(d\)-axis voltage to the voltage vector and then realize the tracking of the output estimation phase and frequency to the grid voltage phase and frequency. The structure and small signal model are shown in Figure 2.  
Figure 1: The control structure of a typical APF.  
Figure 2: SRF-PLL structure diagram and small-signal model: (**a**) SRF-PLL structure diagram; (**b**) SRF-PLL small-signal model.  
The mathematical model of the three-phase balanced grid can be described as  
\[\begin{cases}v_{a}=V_{1}\cos(\omega t)\\ v_{b}=V_{1}\cos(\omega t-2\pi/3)\\ v_{c}=V_{1}\cos(\omega t+2\pi/3)\end{cases} \tag{1}\]  
where \(\theta=\omega t\) is the grid voltage phase; then the Clarke transform is as shown in Equations (2) and (3).  
\[\begin{bmatrix}v_{a}\\ v_{\beta}\end{bmatrix}=T_{3s-2s}\begin{bmatrix}v_{a}\\ v_{b}\\ v_{c}\end{bmatrix} \tag{2}\]  
\[T_{3s-2s}=\sqrt{\frac{2}{3}}\begin{bmatrix}&1&-1/2&-1/2\\ &0&\sqrt{3}/2&-\sqrt{3}/2\end{bmatrix} \tag{3}\]  
When the phase-locked loop tracks the grid phase synchronously, the expression of the transformed grid-side voltage in the \(d\)-\(q\) coordinate system is shown in (4).  
\[\begin{bmatrix}v_{d}\\ v_{q}\end{bmatrix}=\begin{bmatrix}\cos\theta&\sin\theta\\ -\sin\theta&\cos\theta\end{bmatrix}\begin{bmatrix}v_{\alpha}\\ v_{\beta}\end{bmatrix}=T_{2s-2r}\begin{bmatrix}v_{\alpha}\\ v_{\beta}\end{bmatrix} \tag{4}\]  
\[T_{2s-2r}=\begin{bmatrix}\cos\theta&\sin\theta\\ -\sin\theta&\cos\theta\end{bmatrix} \tag{5}\]  
where \(T_{2s-2r}\) is the transformation matrix. When the \(d\)-\(q\) coordinate system rotates with \(\dot{V}\) at the synchronous speed \(\omega\), the phase difference between \(\dot{V}\) and \(d\) is fixed. Assuming that the phase estimation of the \(d\)-axis is \(\dot{\theta}\) and the phase difference is \(\delta\), it can be expressed as (6), and the projection of \(\dot{V}\) in the \(d\)-\(q\) coordinate system can be expressed as (7).  
\[\delta=\theta-\dot{\theta} \tag{6}\]  
\[\begin{cases}v_{d}=\sqrt{\frac{3}{2}}V_{1}\cos\delta\\ v_{q}=\sqrt{\frac{3}{2}}V_{1}\sin\delta\end{cases} \tag{7}\]  
When \(\delta=0\), when the \(d\)-axis coincides with \(\dot{V}\), \(v_{d}=\dot{V}\), \(v_{q}=0\). At this time, the phase between the d axis and the \(\alpha\) axis (or the a axis) is \(\omega t\), which is the phase of \(\dot{V}\), denoted by \(\theta=\omega t\). The estimated phase of the PLL output is \(\dot{\theta}\), as shown in Figure 2b. When tracking in steady state, \(\delta=\theta-\dot{\theta}\), as  
\[\vartheta_{q}=\sqrt{\frac{3}{2}}V_{1}\sin\delta\approx\sqrt{\frac{3}{2}}V_{1 }\delta=\sqrt{\frac{3}{2}}V_{1}(\theta-\dot{\theta}) \tag{8}\]  
In steady-state tracking, \(\vartheta_{q}\) is proportional to the deviation of phase tracking, and the proportional coefficient is \(\sqrt{3/2}V_{1}\). In this way, the problem of accurately estimating the phase angle of the grid voltage is transformed into the problem of adjusting the output voltage component \(\vartheta_{q}\) of the \(q\)-axis to 0 under the estimated phase angle. The PI controller is used, and the transfer function is recorded as \(G_{\text{PI}}(s)\). The structure of the above synchronous phase-locked loop is shown in Figure 2a, and the linearized small-signal model under steady-state operation is shown in Figure 2b.