## 3 The Dynamic Harmonic Compensation Sliding Mode Control Method  
### Proportional Resonant Controller  
In current loop control, PI controllers are typically used to regulate current. However, due to the presence of harmonic currents, the current in the d-q coordinate system contains not only the fundamental component but also harmonic components. Since PI controllers cannot accurately track harmonic currents, the PI current control algorithm in the d-q coordinate system struggles to eliminate these harmonics. An ideal resonant controller provides infinite gain at its resonant frequency point, enabling it to track harmonic currents without steady-state error and effectively suppress the influence of harmonics in three-phase currents. The general expression of an ideal resonant controller is as follows:  
\[G_{\text{R}}=\frac{2K_{\text{r}}s}{s^{2}+\omega_{0}^{2}} \tag{8}\]  
Due to the absence of a damping term in the ideal resonant controller, its bandwidth at the resonant frequency is very narrow, making the system extremely sensitive to frequency variations. By adjusting the cutoff frequency, the bandwidth of the controller can be expanded, which not only reduces the sensitivity of the system to frequency changes but also enhances the overall stability of the control system. The general expression of a quasi-resonant controller is as follows:  
\[G_{R}(s)=\frac{2k_{r}\omega_{c}s}{s^{2}+2\omega_{c}s+\omega_{0}^{2}} \tag{9}\]  
where \(k_{r}\) is the resonant coefficient; \(w_{0}\) is the resonant frequency; and \(w_{c}\) is the cutoff frequency.  
As shown in Figure 1, the Bode plots of the ideal resonant controller and the quasi-resonant controller are compared. The parameters are set as follows: \(w_{c}=10\) rad/s, \(k_{r}=100\), and \(w_{0}=200\pi\) rad/s. It is evident that the ideal resonant controller exhibits a higher gain at the resonant frequency. In contrast, although the quasi-resonant controller shows a reduced gain at this frequency point, its bandwidth is significantly increased.  
In three-phase stator currents, the higher the harmonic frequency, the greater its fluctuation range. The narrow bandwidth of an ideal resonant controller causes a significant drop in gain for frequencies near the resonant point. This results in substantial gain variations when the resonant frequency fluctuates, affecting the adaptability of the controller to frequency change. In contrast, a quasi-resonant controller can adjust its bandwidth to accommodate frequency fluctuations, maintaining a high gain within the fluctuation range.  
Figure 1: Bode plot of the ideal resonant controller and the quasi-resonant controller.  
However, while quasi-resonant controllers can accurately track harmonic signals, they have the drawback of slow dynamic response. Therefore, proportional control is used in parallel with the quasi-resonant controller.  
To enhance dynamic response and extend the bandwidth around the resonant point, this paper adopts a quasi-proportional-resonant (QPR) controller. Its expression is as follows [23]:  
\[G_{PR}(s)=k_{p}+\frac{2k_{r}\omega_{c}s}{s^{2}+2\omega_{c}s+\omega_{0}^{2}} \tag{10}\]  
where the terms \(k_{p}\) and \(k_{r}\) represent the proportional gain and resonant gain of the controller, respectively, and \(w_{0}\) denotes the resonant frequency, which matches the frequency of the motor current harmonics.  
Substituting \(s=jw_{0}\) into Equation (10), the gain of the quasi-proportional-resonant controller at the resonant frequency \(w_{0}\) is obtained as follows:  
\[|G_{\text{QPR}}(\text{j}\pm\omega_{0})|=k_{p}+k_{r} \tag{11}\]  
From Equation (11), it can be derived that for the AC harmonic component with a frequency of \(w_{0}\), the quasi-proportional-resonant controller provides a gain of \(k_{p}+k_{r}\).