# I. INTRODUCTION

Due to the rapid growth of non-linear loads and power electronic devices, electrical power systems have become a source of harmonics pollution. The harmonic currents caused by these non-linear loads and power electronic devices are not suitable for microgrids or electrical distribution systems. Due to excessive unbalance currents and damaged voltage waveforms, power quality has deteriorated, which results in either interference or resonance. Active power filters (APFs) have been studied with considerable interest in the field of power systems [1]. They achieve a fast response in the case of transient load trip variations and they can help alleviate harmonics. It has been demonstra ted in [2] that the shunt active power filter (S-APF) can be the most effective technique in order to regulate and compensate load voltage harmonics due to its easiness, effectiveness and harmonic compensation features.

Normally, unbalance voltage harmonic compensation for the distributed generators (DGs) in a microgrid is accomplished by series active power filters or shunt active power filters [2], [3]. In [4], a hybrid active power filter has been used in a islanded microgrid for selective harmonic compensation. Generally, a shunt active power filter (S-APF) injects harmonic currents that are opposite in phase angle to compensate unbalance voltage harmonics. In [5], a coordinated control strategy of DGs and an APF has been carried out. However, the APF used for the DGs in a microgrid is highly dependent on its control strategy for effective harmonic compensation performance. The compensation capability of a S-APF mainly depends on existing control schemes. The control schemes comprise of two main functions, which are a harmonic detection function and a control function [6], [7]. Many control techniques have been investigated in the past including deadbeat control [8], resonant control [9], proportional integral control [10], hysteresis control [11], proportional resonant control and repetitive control [9], [12]. The main aim of this paper is to improve the control technique of a current controller in order to make a better control strategy of the current controller, and to enhance the compensation performance of an APF under transient and steady state conditions. Generally, nonlinear loads and unbalanced loads are highly dispersed in distributed power generation systems (DPGSs), which magnifies the difficulty and cost of detecting harmonic load current for S-APFs operating in the current controlled mode (CCM) [13]. Therefore, in [14]-[17] a local harmonic voltage detection based resistive active power filter (R-APF) has been explored. Its harmonic compensation performance varies remarkably by the matching condition that exists between the harmonic conductance and the grid impedance. The handling capability problem of the shunt R-APF in compensating harmonics decreases since the grid impedance does not remain stable due to different nonlinear loads and variable power factor correction capacitors [18], [19].

Conventionally, in a R-APF, the point of common coupling (PCC) voltage is considered and measured at the PCC. Then the harmonic elements are extracted and scaled by 1/R to get the harmonic currents according to the instantaneous values of the PCC voltage. Moreover, while controlling the R-APF, two main fundamental controls are targeted in its control part to dampen the harmonics and make the system stable, which are the emulation of virtual impedance and dc-link voltage control [4], [20]. In [4], [21] the dynamic virtual resistance is tuned at the PCC for the purpose of getting a low total harmonic distortion (THD). In [22], [23] cooperative control is implemented for distributed generation interfaced converters and with a distributed APF. In [24], an attempt has been made to emulate the virtual resistance with an improved accuracy using a grid-voltage-sensorless control technique. However, this technique has a disadvantage since the accuracy and precision of the virtual impedance emulation is highly dependent on the accuracy of the plant model.

Using a R-APF does not require any remote current signals. However, it needs to calculate the harmonic current reference according to the PCC voltage, which can sometimes be considered the most irritating task. Therefore, this control strategy is not suitable for microgrid applications [25], [15]. Aiming at this objective in determining the virtual harmonic impedance without the worry of tuning the parameters, a harmonic voltage controlled mode compensation approach in terms of local voltage measurement is presented in [26].

Various studies have demonstrated the advantages of an APF working in the CCM, while others indicated inadequate performance in terms of robustness and stability [15], [26]. Presently, a growing body of literature acknowledges the significance of the voltage-controlled mode for S-APFs both in the grid connected and islanding modes. The same approach has been investigated in [27]. Hence, to avoid the challenge of adjusting and tuning the resistance (R), a voltage controlled mode S-APF has been designed by using V_{pcc} at the PCC [28]. This strategy deals with the instantaneous value PCC voltage and directly adjusts its harmonic compensation. Therefore, both of these control schemes deal with the PCC voltage and can handle the realization of harmonic compensation without current measurement.

The rest of paper is structured as follows. The working of the conventional harmonic compensation control strategy has been provided in section II. The proposed control approach is discussed in section III. In section IV, the design control procedure of the proposed method is presented, which is considered to be suitable for microgrid applications. Section V illustrates comprehensive laboratory experimental results and a discussion of these results. Lastly, section VI provides some concluding remarks.

# II. CONVENTIONAL HARMONIC COMPENSATION STRATEGY

Voltage harmonic compensation at the PCC can be made to produce a harmonic current with nearly the same amplitude and phase angle with respect to the harmonic load current. In other words, the fundamental current is injected into the grid to produce a better PCC voltage power quality. The conventional S-APF harmonic compensation control approach is depicted in Fig. 1. An active power filter (converter) is connected in shunt with the grid through an LCL filter and a nonlinear load is also attached at the PCC.

**Fig. 1. Traditional harmonic compensation strategy using a current controlled R-APF.**

It can be seen from Fig. 1 that the CCM APF controller contains a fundamental current controller, active damping and a DC voltage controller.

Two different control schemes are generally adopted in the current generation reference block. The first one measures the harmonic load current (I_{L}), and the corresponding harmonic components are extracted from it using the harmonic detection method so it can be utilized as a compensation reference. Meanwhile, in the other control scheme, the PCC voltage is used and current is drawn from it, which is proportional to the PCC voltage, i^{*}=V_{PCC_h}/R_{h}, where R_{h} indicates the harmonic resistance at the h^{th} order harmonic frequencies since the R-APF is taken into account as resistive in nature. Therefore, this method offers a very low-impedance path for these harmonic currents. The later method does not require any remote load monitoring measurement arrangement. However, due to the different phase angle of the injected harmonic current with the voltage drop generated across unfamiliar and unpredictable grid impedance, it is a very difficult task to tune the exact parameters for the R-APF in real time microgrid applications. Therefore, another method is proposed for APFs based on the voltage controlled mode (VCM). In this scheme, the PCC voltage can be directed to the harmonic detection module for the detection of harmonics, where numerous bandpass filters (BPFs) have been used to carry out the extraction process for its various harmonic component orders V_{pcch}. Then the output harmonic reference voltage is carried out as V^{*}=K.V_{pcch}, where Kh represents the harmonic voltage feedback element at the h^{th} corresponding harmonic frequencies.

# III. PROPOSED HARMONIC COMPENSATION STRATEGY

When compared to the R-APF compensation method, a novel control approach is presented. The design comprises a fundamental current controller, active damping control loop and voltage harmonic compensation controller (HCC). Additionally, a DC voltage controller is presented in this paper. The equivalent control layout is depicted in Fig. 2. The studied scheme includes a VCM APF connected at the PCC with the grid through an LCL filter, and a nonlinear load based on a three-phase diode rectifier. When compared with the conventional harmonic compensation shunt R-APF shown in Fig. 1, the proposed scheme offers better compensation performance since its harmonic voltage can be regulated in a closed-loop manner. Moreover, by not performing remote load current measurements, a sufficient cost reduction of the overall system can be observed. In addition, no extra sensors are required when compared with the conventional current detection method. The capacitor current can easily be achieved by taking the difference between the grid side and the converter side inductor current [15]. Similarly, in the CCM, the capacitor current is also needed to improve system stability. Hence, it can be assumed that the proposed strategy is compatible with an LCL filter without adopting extra sensors in the system.

**Fig. 2. Proposed experimental microgrid test setup.**

To accomplish harmonic compensation utilizing only locally measured signals, the capacitor voltage is used and considered as a feedback closed control loop variable [29]. Note that K is regarded as the voltage feedback gain. It is worth noting that the harmonic compensation performance can be realized by settling both the sign and value of K.

Precise characterization of the grid voltage and correct extraction of the corresponding harmonics under distorted load conditions are considered as crucial issues for effective harmonic compensation. Therefore, the use of bandpass filters for the extraction of harmonics seems to be a very promising solution in active power filter applications since it gives information about the magnitude and phase angle of the corresponding harmonic frequencies in order to determine proper harmonic compensation controller gains for effective harmonic compensation. The controller gains can easily be determined based on their phases and the magnitudes of the selected harmonic frequencies. The concept of BPF for the detection of harmonics has been widely applied in [30] and [31] due to its good harmonic detection accuracy for APF applications. Hence, BPF increases the effectiveness of the detection system and extracts the harmonic of V_{pcc} when the grid voltage offers high order harmonics. Therefore, BPF is used, as illustrated in Fig. 3, to calculate the harmonics of Vpcc to ensure an effective and accurate voltage harmonic extraction. The corresponding transfer function of the bandpass filter can be shown in the z-domain as below

\(G_{B P F}(z)=\frac{K_{m}\left\{z^{2}-\cos \left(2 \pi T_{s} f_{pll} n\right) z\right\}}{\left.a_{n} z^{2}-b_{n} \cos \left(2 \pi T_{s} f_{pll} n\right) z\right)+1}\) (1)

where K_{m}=K_{im}T_{s}, a_{n}=1+K_{m} and b_{n}=2+K_{m}. In this case, K_{m} represents integral coefficient, T_{s} shows the sampling period and m represents the harmonic order. Up to the 13^{th} harmonic have been compensated at the same time by using the adopted BPF. Bode plots of the adopted BPF are shown in Fig. 4 for easy understanding of its performance. After the extraction of the harmonics from V_{pcc}, the harmonic reference voltage can be achieved after scaling it by K.

**Fig. 3. Bandpass filter for the extraction of harmonics.**

**Fig. 4. Bode plot of the bandpass filter BPF.**

# IV. DESIGN AND STABILITY ANALYSIS OF THE PROPOSED HC

In order to validate the performance of the proposed method, Fig. 5 shows a laboratory-scale microgrid test bed, which comprises of two 2.2-kW Danfoss inverters. One of the inverters emulate as a grid-forming unit, while the other one acts as grid parallel unit, for the proposed voltage controlled S-APF. The DC link voltage is maintained at 250 V, the nominal phase supply voltage and grid frequency are set to be 110 V and 50 Hz, respectively. The control algorithm is carried out in a dSPACE 1005 test setup and the switching frequency is set as 10kHz. A three-phase diode rectifier based nonlinear load is connected at the PCC.

**Fig. 5. Proposed experimental microgrid test setup.**

As indicated in Fig. 5, the grid forming inverter receives both the inverter output current and capacitor voltage. The integration of these signals is used as a feedback control signal to control the PCC voltage. The double loop control scheme contains a voltage/current inner control loop, which is based on proportional resonant (PR) controllers that are used for tracking the sinusoidal reference variables in the αβ reference frame. The designing of PR controllers has already been discussed in the literature [30]. Thus, it is not going to be discussed again here. However, the grid parallel unit which is the proposed voltage controlled S-APF, takes the measurable signals directly to accomplish power injection and harmonic voltage compensation. The grid side inverter current is utilized to regulate the output power whereas the inner capacitor current is used to stabilize the system. In addition, grid synchronization and harmonic compensation can be carried out by implementing PCC voltage measurement. Hence, no additional remote measurements or sensor are required.

The harmonic compensator designed for the proposed active power filter (APF) includes four parts which are an active damping compensator, fundamental current loop, harmonic voltage compensator control loop and DC voltage control loop. This is discussed step by step in the following section.

## A. Active Damping Loop

According to Fig. 5, the transfer function in the s-domain from the inverter-side output voltage V_{o} to the grid side current I_{2} of the converter can be derived. The LCL filter parasitic parameters are ignored here for the sake of simplicity:

\(G_{m 1}(s)=\frac{I_{2}(s)}{V_{o}(s)}=\frac{1}{L_{l} L_{2} C_{f} s} \cdot \frac{1}{s^{2}+\omega_{s}^{2}}\) (2)

Where L_{1} represents the inverter side inductor and L_{2} represents the grid side inductor. Meanwhile, C indicates the capacitor LCL filter, and ω_{s} defines the resonance which can be written as follows:

\(\omega_{s}=\sqrt{\frac{L_{1}+L_{2}}{L_{1} L_{2} C_{f}}}\) (3)

In accordance with Fig. 2, the transfer function G_{c} from the inverter output side voltage V_{o} to the capacitor current I_{c} can be shown as below:

\(G_{c}(\mathrm{s})=\frac{I_{c}(\mathrm{s})}{V_{o}(\mathrm{s})}=\frac{1}{L_{1}} \cdot \frac{s}{s^{2}+\omega_{r}^{2}}\) (4)

Since the implementation of the control algorithms are executed in the discrete time domain, the transformations for the expressions of (2) and (4) are carried out from the discrete time domain into the z-domain as given in (5) and (6) by means of the zero order hold (ZOH) transformation method for the sake of convenience while designing the controller.

\(\begin{aligned} G_{m 1}(z) &=Z\left\{\left(1-e^{-T_{s} s}\right) \frac{G_{m 1}(s)}{s}\right\} \\ &=\frac{\omega_{s} T_{s}\left[z^{2}-2 \cos \left(\omega_{s} T_{s}\right) z+1\right]-\sin \left(\omega_{s} T_{s}\right)(z-1)^{2}}{\omega_{s}\left[L_{1}+L_{2}\right](z-1)\left[z^{2}-2 \cos \left(\omega_{s} T_{s}\right) z+1\right]} \end{aligned}\) (5)

\(\begin{aligned} G_{c}(z) &=Z\left\{\left(1-e^{-T_{s} s}\right) \frac{G_{c}(s)}{s}\right\} \\ &=\frac{\sin \left(\omega_{s} T_{s}\right)}{\omega_{s} L_{1}} \cdot \frac{z-1}{z^{2}-2 \cos \left(\omega_{r} T_{s}\right) z+1} \end{aligned}\) (6)

where T_{s} indicates the sampling period.

Since resonance peaks are present in the expressions (5) and (6), the capacitor-current-feedback active-damping loop is displayed in Fig. 5. It is used to suppress resonances, where L(z) refers to the lead-lag compensator used for the compensation of the delays in the active damping loop.

The mathematical active damping plant model can be deduced as follows:

\(L(z)=K_{d} \frac{z-1}{z-0.5}\) (7)

Where K_{d} shows the active damping loop gain.

Referring to expression (7), the root locus of the active damping (AD) can be drawn as presented in Fig. 7. In order to increase the active damping loop performance, the gain is chosen as 7.84 in this paper.

**Fig. 6. Active damping plant model.**

**Fig. 7. Root locus of active damping.**

## B. Fundamental Current Control Loop

The main functions of the current loop are to maintain a smooth power flow, and to track the fundamental current and its harmonic components. PR and PI controllers are usually adopted to handle the tracking of the current reference for a given control system.

Fig. 8 elaborates on the control block diagram of a PI control loop expressed in the z-domain for an active power filter, where z^{-1} denotes the inherent unit delay in the digital control system.

**Fig. 8. Block diagram of a current controller in the z-domain.**

The current controller Gp(z) is indicated in this paper. It consists of a fundamental proportional integral (PI) controller. Based on the block diagram of a PI controller, which is shown below, in the z-domain, the open loop and closed loop gains transfer functions are denoted by G_{OL2} and G_{CL2},respectively. This can be expressed as below:

\(G_{O L 2}(z)=\frac{P I(z) z^{-1} G_{m 1}(z)}{1+z^{-1} L(z) G_{c}(z)}\) (8)

In the light of the above expression (8), a root locus plot to design the fundamental PI controller is plotted as shown in Fig. 9.

\(G_{C L 2}(z)=\frac{G_{O L 2}(z)}{1+G_{O L 2}(z)}\) (9)

**Fig. 9. Root locus of the inner PI control loop.**

## C. Harmonic Voltage Control Loop

Despite the fact that active damping is employed to make the current loop stable, an extra phase lag is injected into the capacitor voltage feedback circuit. This introduced phase shift can be avoided and ignored at the fundamental frequency. Therefore, this problem may become severe when the phase lag intensifies and enters into the high frequency range, which may affect the performance of harmonic tracking. In order to clarify this issue, the following is the transfer function for the harmonic compensation loop in the s-domain:

\(G_{h v}(s)=\frac{V_{c}}{V_{i}}=\frac{1}{L_{1} C_{f} s^{2}+K_{d} C_{f} s+1}\) (10)

Due to advances in the digital control methods and techniques, the above continuous-time transfer function of the controller is then discretized using the method of zero order hold (ZOH) as given below in (11). Then it is checked for further stability issues.

\(\begin{aligned} G_{i v}(z) &=Z\left\{\frac{1-e^{-s T}}{s} \cdot G_{i v}(s)\right\} \\ &=\left(1-z^{-1}\right) \cdot Z\left\{\frac{G_{i v}(s)}{s}\right\} \\ &=\left(1-z^{-1}\right) \cdot Z\left\{\frac{1}{s\left(L_{1} C_{f} s^{2}+K_{d} C_{f} s+1\right)}\right\} \\ &=\left(1-z^{-1}\right) \cdot Z\left\{\frac{z}{z-1}-\frac{z \sqrt{1-\xi_{0}^{2}}+e^{-\xi \omega_{0} T} \sin \left(\omega_{0} \sqrt{1-\xi^{2}} T-\phi\right)}{z^{2}-2 z e^{-\xi \omega_{0} T} \cos \left(\omega_{0} \sqrt{1-\xi^{2}} T\right)+e^{-2 \xi \omega_{0} T})}\right\} \end{aligned}\) (11)

The effect of the ZOH method is significant at higher frequencies because an extra phase lag appears in the control loop. This can be addressed and compensated while tuning the G_{c}(z).

To compensate for those phase lags, it is desirable to propose a harmonic compensator based on resonant controllers that can be modeled to compensate for phase lags through active damping, and perform the computational delay (z^{-1}) and PWM converter operations [32].

The transfer function in the s-domain for the resonant controller is written as follows:

\(G_{r e s h}(s)=k_{r e s} \frac{s \cos \phi_{c}-h \omega \sin \phi_{c}}{s^{2}+(h \omega)}\) (12)

This defines the resonant controller gain, where h denotes the order of the harmonics, T_{s} is the sampling time period, and φ is the leading phase angle at the resonance frequency. By adopting an impulse invariant transformation technique for discretizing the resonant controller, an effective compensation can be made towards accuracy and the computational burden can be reduced. Hence, the transfer function after discretization can be obtained as follows:

\(G_{resh}(z)=k_{res} T_{s} \frac{\cos \varphi_{c}-z^{-1} \cos \left(\varphi_{c}-h \omega T_{s}\right)}{1-2 z^{-1} \cos \left(h \omega T_{s}\right)+z^{-2}}\) (13)

It is worth mentioning that the harmonic compensator uses a set of arrays G_{resh}(z) for compensating numerous orders of harmonics. Taking into account the time delays caused by the calculation and estimation as well as processing the PWM, the damped control plant together with the harmonic voltage control loop is illustrated in the z-domain as shown in Fig. 10. As a result, the open loop transfer function of the harmonic voltage compensation loop can be inferred as follows:

\(\begin{array}{c} G_{o l}(z)=G_{r e s h}(z) G_{d e l a y}(z) G_{p l}(z) \\ G_{d e l a y}(z)=z^{-1} \end{array}\) (14)

where G_{delay}(s) denotes the computational delay inherited from the digital control system.

**Fig. 10. Block diagram of the harmonic compensation loop.**

Normally, the Nyquist stability criterion is used to evaluate the stability of the closed loop system by only considering its open loop performance. This also determines the stability of the system and provides an accurate stability margin with reference to the sensitivity function [22], [23].

**Fig. 11. Nyquist harmonic voltage control loop.**

## D. DC Voltage Controller

The control of a shunt active power filter is made in such a way that an external DC voltage loop is connected with an inner fundamental current loop. In order to adjust and stabilize DC voltage, the DC voltage controller considers the voltage V_{dc} of the DC capacitor and compares it with the DC voltage reference V_{dcref} to generate the current reference ∇_{id} for the fundamental current controller. In this paper, the reference for the DC link voltage is kept at 250 V to prevent DC link voltage ripple, switching losses and other problems that may affect the overall cost and size of the LCL filters.

**Fig. 12. DC voltage control loop.**

The transfer function for the dc voltage loop G_{v}(s) is obtained as:

\(G_{v}(z)=T_{s} \frac{z}{(z-1) C_{d c}}\) (15)

Bode plots for the DC voltage are shown in Fig. 13.

**Fig. 13. Bode plot of the DC voltage loop.**

# V. EXPERIMENTAL RESULTS

In order to investigate the performance of the proposed control strategy, an experiment has been performed in the laboratory as shown in Fig. 14.

**Fig. 14. Experimental test setup.**

Experimental results are presented below. The control parameters of the power stage are listed in Table I. Fig. 15(a) and (b) illustrate the PCC harmonic voltages before and after enabling the harmonic compensation. From these figures it can be seen that the PCC voltage is more sinusoidal after implementing the proposed harmonic compensation strategy. It can also be seen that the corresponding total harmonic distortions THDs of the PCC voltage shows a marked decrease from 9.61% to 2.99%. Fig. 16(a) and (b) show the corresponding frequency spectrum of the PCC voltage before and after compensation.

**TABLE I APF SYSTEM PARAMETERS**

**Fig. 15. PCC voltage (Proposed APF): (a) Before compensation; (b) After compensation.**

**Fig. 16. Frequency spectrum of the PCC voltage in the proposed APF: (a) Before compensation; (b) After compensation.**

It can be analyzed from Fig. 17(a) that the grid-side current is more distorted due to nonlinear load. It can also be seen that the THD of the grid side current is 21% without compensation. In addition, a while after applying the harmonic compensation, the total harmonic distortion THD of the grid current is decreased noticeably from 21% to 5.5%, as shown in Fig. 17(b). As a result, the harmonic components of the load current get distorted at the cost of grid current compensation. The frequency spectrum of the grid current before and after compensation is depicted in Fig. 18 (a) and (b).

**Fig. 17. Grid current in the proposed APF: (a) Before compensation; (b) After compensation.**

**Fig. 18. Frequency spectrum of the grid current in the proposed APF: (a) Before compensation; (b) After compensation.**

It can be observed that the higher order harmonics like the 5^{th}, 7^{th}, 11^{th} and 13^{th} orders distortions of current and voltage have been considerably decreased in the proposed method since it was an anticipated goal while designing the controller part. Hence, the grid current is improved. The same can be seen from Fig. 16(b) and Fig. 18(b). To have a better understanding of the harmonic mitigation, the dynamic and transient responses of the APF output current, grid current and corresponding load current are depicted in Fig. 19 (a), (b) and (c).

**Fig. 19. Dynamic waveforms of the proposed method: (a) APF output current; (b) Grid current; (c) Load current.**

It is obvious after 0.2 sec that the APF is going to reach its steady state and that the load side current gets amplified. Once the proposed APF is activated, the grid current varies in a sinusoidal manner. The cost of achieving this goal suffers from high distortion in the load current as shown in Fig. 19 (c). This shows the effectiveness of the proposed controller.

A experimental study is conducted to investigate the harmonic compensation capability and performance of the proposed controller in comparison to the conventional R-APF method. The PCC voltage and grid current after activating the harmonic compensation of the R-APF are presented in Fig. 20 (a) and (b). Meanwhile, Fig. 21 (a) and (b) illustrate the frequency spectrum of the THDs of the PCC voltage and grid current, respectively. Based on the associated harmonic analysis of the PCC voltage and grid currents of the R-APF depicted in Fig. 21, it is possible to conclude that even though the voltage quality of the PCC voltage and grid currents can be enhanced by utilizing the R-APF, the PCC voltage and the grid current, the harmonic component is much higher than that of the proposed controller.

**Fig. 20. R-APF (conventional method) after compensation: (a) PCC voltage; (b) Grid current.**

**Fig. 21. R-APF (conventional method) frequency spectrum after compensation: (a) PCC voltage; (b) Grid current.**

# VI. CONCLUSIONS

In this paper, a new control harmonic compensation approach based on local PCC voltage detection for a S-APF has been investigated. The control strategy of the proposed scheme comprises four parts: active damping, fundamental current controller, harmonic voltage compensation controller and DC voltage controller. The PCC voltage and grid current compensation can be achieved at the same time without taking any remote load current measurements. This harmonic compensation is acquired by implementing a voltage controlled active power filter that is shunt connected to the grid at the PCC using an LCL filter. The comprehensive design of the proposed method is given. In addition, the proposed method is compared with the conventional control scheme R-APF and it can be concluded that the proposed control approach is more suitable for microgrid applications. Therefore, better harmonic compensation can be achieved without tuning the parameter of R_{h} by utilizing PCC voltage measurement. Experimental results verify the flexible control of harmonics by adopting the proposed scheme.