## 3 The Dynamic Harmonic Compensation Sliding Mode Control Method
### Parameter Design of the Proportional Resonant Filter  
To reduce the sixth harmonic content in the currents \(i_{d}\) and \(i_{q}\), a sixth harmonic resonant controller is proposed to be added to the current loop controller. The resonant frequency \(w_{0}\) of this controller is determined based on the specific harmonic that needs to be compensated. Therefore, \(w_{0}\) can be set to \(6w_{e}\) to track the corresponding harmonic signals. This way, the harmonic compensation term only responds to signals around the frequency \(6w_{e}\), thus achieving compensation for the sixth harmonic. This study further designs the parameters of the sixth harmonic quasi-proportional-resonant controller. With a set speed of \(500\)\(\tau/\mathrm{min}\) and a frequency of \(40\) Hz, the corresponding sixth harmonic frequency is \(240\) Hz. Therefore, \(w_{0}\) is set to \(480\tau\) rad/s. The transfer function is expressed as follows:  
\[G_{PR6}(s)=k_{p6}+\frac{2k_{r6}\omega_{c}s}{s^{2}+2\omega_{c}s+\left(480\pi \right)^{2}} \tag{21}\]  
As analyzed previously, the control parameters \(k_{p}\) and \(k_{r}\) influence the gain of the quasi-proportional-resonant controller. To achieve a gain of \(38\) dB at the resonant frequency \(w_{0}\) in the current loop system, the parameters were set as follows: \(k_{p6}\) at \(0.1\), \(0.5\), and \(1\), \(k_{p6}\) at \(80\), and \(w_{c}\) at \(4\) rad/s. The Bode plots for different parameter values are shown in Figure 3. From these plots, the following conclusions can be drawn:  
1. When the proportional gain coefficient \(k_{p6}\) decreases, the overall gain of the controller decreases, the phase margin increases, and the effect on bandwidth is minimal. 2. Increasing \(k_{p6}\) enhances the gain at the resonant frequency, resulting in a faster dynamic response. Different values of \(k_{p6}\) primarily affect the attenuation of frequency signals other than at the resonant point; the smaller \(k_{p6}\) is, the lower the gain at other frequencies, but it does not impact the gain at the resonant point, thus having a minimal effect on bandwidth. 3. Increasing \(w_{c}\) broadens the bandwidth of the resonant gain band without affecting the gain at the resonant point. Conversely, decreasing \(w_{c}\) narrows the bandwidth of the resonant gain band, improving adaptability to frequency variations. Therefore, the cutoff frequency \(w_{c}\) mainly influences the bandwidth of the controller; the smaller \(w_{c}\) is, the better the frequency selection characteristics of the controller. However, due to current frequency fluctuations caused by harmonics in the AC drive system, a smaller \(w_{c}\) results in greater gain fluctuations of the controller, making the system stability more susceptible to influence. Hence, the value of \(w_{c}\) should not be too small. In this study, the bandwidth of the controller is adjusted by setting the cutoff frequency \(w_{c}\) to accommodate frequency fluctuations. Based on the previous analysis, \(k_{p}\) is set to 0.1 and \(k_{r}\) is set to 80. The permissible speed fluctuation of the experimental motor is \(\pm 5\,\mathrm{r}/\min\), which corresponds to a frequency fluctuation of \(\pm 0.08\) Hz. This fluctuation results in a sixth harmonic frequency fluctuation of \(\pm 0.48\) Hz. To ensure that the controller maintains a gain of no less than 35 dB between 239.52 Hz and 240.48 Hz, the cutoff frequency \(w_{c}\) should be no less than 1.47 rad/s. In this study, \(w_{c}\) is set to 2 rad/s, and its Bode plot is shown in Figure 4.  
Based on the previous analysis, to balance the filtering performance and dynamic performance of the system, this study selects \(k_{pr}=0.1\), \(k_{r}=80\), and \(w_{cr}=0.2\) rad/s as control parameters.