# Adaptive PI + VPI Harmonic Current Compensation Strategy under Weak Grid Conditions
## 5 Simulation Analysis and Experiment
### Verification of APF Compensation Performance under Weak Grid Conditions  
To verify the effectiveness of the control system, a 60 kVA L-type shunt APF prototype machine is constructed (Figure 16), including the following components: (1) StarSim RCP real-time control simulation module; (2) main circuit and interface circuit part; (3) transfer board; and (4) host. The StarSim RCP real-time control simulation module is configured with Kintex-7 325T FPGA @ Xilinx and 16 analog I/O channels, with a transmission rate of 1 MB/s. The device is used to run the proposed controller and to realize real-time operation of the control code. (2) The main circuit and interface circuit part mainly include a three-phase programmable AC power supply, a voltage-source three-phase inverter circuit with output filter inductance, nonlinear load circuit, Hall-effect current and voltage transducers and an IGBT switch drive circuit. The Hall-effect current and voltage transducers sense the AC voltage and current signal of the power source, current signal of the inverter circuit and DC-side voltage signal and transmit them to the RCP circuit through an adapter plate. The IGBT switch drive module circuit receives the switching logic signal from the adapter plate and generates the switching signal to control the three-phase inverter circuit to output the harmonic compensation current. The programmable AC power supply is responsible for generating a three-phase unbalanced and distorted grid voltage with frequency mutation. Nonlinear loads are used to generate harmonic currents and to perform sudden loading operations when needed. (3) The transfer board is used to realize the signal connection between the two parts of components (1) and (2) to the component observation signals. (4) The host is used to download the control algorithm implemented in Simulink to the rapid control prototype using a code generation function and to receive and process signals of interest in the RCP module using special application software. Table 4 provides the parameter settings of the experimental system. The measurement equipment used in the experiment mainly includes a CA8334 power quality analyzer and a DSO-X2024A digital oscilloscope, both of which can easily display the signal waveforms and their frequency spectrum. Figure 16: Laboratory prototype of the shunt APF. To verify the compensation effect when the grid voltage is unbalanced, distorted and has a large frequency deviation, we compare and study the harmonic compensation performance of the APF system under three control strategies: fixed frequency VPI control plus SRF-PLL (Fixed VPI/SRF-PLL), frequency adaptive VPI control plus NF-PLL (Adaptive VPI/NF-PLL) and frequency adaptive VPI control plus ANF-PLL (Adaptive VPI/ANF-PLL). Figure 17 presents the compensation effect comparison of the three control strategies in the case of +4 Hz frequency deviation under non-ideal grid voltage conditions. Figure 17a is the waveform of the three-phase power supply voltage, with obvious unbalance and distortion. The red, blue and green lines represent the _abc_ three-phase of the three-phase voltage, respectively. At the time of the red dotted line, the frequency changes from 50 Hz to 54 Hz. Figure 17b is the three-phase load current; the waveform is seriously distorted; and the THD of the three-phase current reaches approximately 23.8%. If the harmonic components are not compensated, they will be injected into the grid. To more easily observe the performance of compensation, the next compensation results are shown and analyzed with the a-phase as an example. Figure 17c presents the a-phase grid current after harmonic compensation using the Fixed VPI/SRF-PLL strategy. The THD at the rated frequency is 7.6%. When the frequency changes abruptly, the compensated THD is 18.8%.