Flexible Compensation of Voltage and Current Unbalance and Harmonics in Microgrids

: In recent years, the harmonics and unbalance problems endanger the voltage and current quality of power systems, due to increasing usage of nonlinear and unbalanced loads. Use of Distributed Generation (DG)-interfacing inverters is proposed for voltage or current compensation. In this paper, a ﬂexible control method is proposed to compensate voltage and current unbalance and harmonics using the distributed generation (DG)-interfacing inverters. This method is applicable to both grid-connected and islanded Microgrids (MGs). In the proposed method, not only the proper control of active and reactive powers can be achieved, but also there is ﬂexibility in compensating the voltage or current quality problems at DG terminals or Points of Common Coupling (PCCs). This control strategy consists of active and reactive power controllers and a voltage/current quality-improvement block. The controller is designed in a stationary ( αβ ) frame. An extensive simulation study has been performed and the results demonstrate the effectiveness of the proposed control scheme. Depending on the compensation modes, the harmonics and unbalance compensation of DG output current, MG-injected current to the grid, as well as PCC and DG voltages, can be achieved in grid-connected operation of MG while in the islanded operation, and the PCC and DG voltages compensation can be obtained through the proposed control scheme.


Introduction
In recent years, due to the disadvantages of conventional fossil fuels such as air pollution and extinction, the concept of benefitting from renewable energy sources (RESs) has attracted more attention [1][2][3].Microgrid (MG) and Distributed Generation DG concepts have emerged for better use of the RESs and enhancing efficiency, power quality and reliability of the conventional power systems [4,5].Since the output voltage of many of the RESs are unregulated DC or variable/high frequency AC, the integration of renewable energy to the utility grids or MGs requires power electronic converters, with an inverter as the last conversion stage in case of AC systems [6].These inverters are usually connected to the grid by an LCL or LC filter [7,8].
On the other hand, in the presence of unbalanced, single-phase and nonlinear loads, excessive voltage unbalance and harmonics may appear in the MGs.The unbalanced and harmonic distorted voltage leads to more losses and less stability of the MG.It also causes malfunction of power electronics converters and induction motors [9].Due to these problems, the allowed limit for voltage unbalance recommended by the International Electrotechnical Commission (IEC) is 2%, while the recommended limit for voltage total harmonic distortion (THD) is 5% [10].
Incorporation of multifunctional interfacing inverters for compensation of power quality-related problems has been proposed recently in some research works, such as [11][12][13][14][15][16].With proper control of these inverters, not only the extracted energy of RESs can be injected into the grid or MG, but also the improvement of voltage and current quality may be achieved.In [17], droop control for injecting the negative sequence voltage is proposed.A method based on injecting negative sequence voltage is presented in [9].The voltage injection is based on negative sequence reactive power to share the compensation effort between DG units.The voltage quality improvement using secondary and tertiary control is also proposed in [18][19][20][21].The compensation of unbalanced and nonlinear loads in a multi-bus islanded MG, using an adjustable resonance frequency, a droop control strategy, and a negative and harmonic sequence impedance controller, is discussed in [22].
All of the aforementioned works have been focused on only voltage or current quality improvement.In [23], a flexible voltage and current harmonic compensation approach is proposed through DG-interfacing inverters in a single-phase MG.The performance of the method is improved by using a frequency adaptive controller which is presented in [24].In this paper, extension of control methods of [23,24] is proposed in three-phase MGs to enable unbalance and harmonic compensations.In the proposed method, four harmonic and unbalance compensation modes can be achieved, while the fundamental positive sequence components of DG output voltage can also be properly controlled.The main contributions of this paper can be highlighted as follows: • Simultaneous control of fundamental positive and negative sequences, as well as harmonic components of voltage and current, is achieved for three-phase DG-interfacing inverters.

•
A flexible voltage or current compensation of nonlinear and unbalanced loads is proposed.

•
The proposed method is applicable in both grid-connected and islanded modes of three-phase MGs.

•
Four unbalanced and harmonic voltage or current compensation strategies can be achieved using this method.
The extensive simulation which is implemented in MATLAB/Simulink (2016a Version, MathWorks, Natick, MA, USA) verifies the effectiveness of the power-quality improvement method in both grid-connected and islanded operation modes of an MG.
The remaining parts of this paper are organized in the following order: In Section 2, the DG-interfacing control method is introduced.Section 3 is dedicated to the design of the control system.The details of the simulation study are presented in Section 4. Finally, Section 5 concludes the paper.

Power Control and Virtual Impedance
Figure 1 shows the power stage and control system of the DG-interfacing inverter.As shown in this figure, the power stage consists of a DC link, a three-phase inverter and an LCL filter.In the control system, the positive sequence active and reactive powers are calculated based on instantaneous active and reactive power theory [25].
In the control system, the droop-based voltage (V droop,αβ ) is generated by droop controllers.Virtual impedance is used for decoupling the reactive and active powers droop controllers and enhancing the dynamics of the system [26,27].Four voltage or current unbalance and harmonic compensation modes can be selected by the "Mode Selector" switch.Since the control system is based on the αβ frame, the three-phase voltages and currents should be transferred to the αβ reference frame using Clark's transformation [9].three-wire MGs, the zero sequence component of voltage and current are not taken into account [9,28,29].If a three-phase inverter is connected to a mainly inductive grid, the injected positive sequence (PS) active and reactive powers are related to the angle between output voltage of DG and grid (ϕ) and voltage amplitude (E), respectively; hence, P-ϕ and Q-E power droops are applied in order to generate reference voltage in this paper.These power droops, which add virtual inertia to the power electronics inverters, are written as [30]: where ϕ 0 and ϕ* represent the rated and voltage-phase angle reference, respectively.P + and Q + are the fundamental positive sequence active and reactive powers, respectively.E 0 and E* are rated and reference values of voltage amplitude, respectively.m P and m I are PS active power proportional and integral coefficients, respectively, while n P and n I represent the integral and proportional coefficients related to reactive power, respectively.P* and Q* are reference active and reactive powers, respectively.P*, Q* and n I must be zero if the MG operates in islanded mode [23].
As was mentioned before, the P-ϕ and Q-E droops are designed with the assumption that the MG is mainly inductive.For compensating the effect of the resistance and decoupling of the P-ϕ and Q-E droops, inductive virtual impedance is used.The fundamental frequency virtual impedance is expressed in (2) and (3) [27]: where R v and L v represent the virtual resistance and inductive impedances, respectively.The reference voltage will be written by (4):

Proposed Flexible Controller for Unbalance and Harmonic Compensation
As shown in Figure 1, four power-quality improvement strategies can be obtained by the "Mode Selector" switch.Based on this, the following compensation modes are taken into account (the mode's number associates with the position of "Mode Selector" switch):

•
Mode 1-unbalance and harmonic compensation of Point of Common Coupling (PCC) voltage (V PCC ): in this mode, the unbalance and harmonic voltage compensation is achieved by using the following equation as input of flexible power quality controller (FPQC): where G − and G h represent negative sequence and harmonic virtual conductance, respectively.The extraction of the fundamental negative sequence and harmonic (FNS&H) components of V PCC is performed using the Second Order Generalized Integrator (SOGI) method, which is presented in [29].
The multifunctional inverter acts as damping resistance at FNS&H components, and low-impedance paths are created for respective current components; hence, the voltage quality will be enhanced.This compensation is useful when a sensitive load is connected in PCC.It should be mentioned that in this mode, the inverter acts in current controlled mode (CCM) for FNS&H components.
• Mode 2-unbalance and harmonic compensation of DG output voltage (V C ): The capacitor voltage will be balanced if the (0-V C,αβ ) is applied as the input of FPQC.The unbalance and harmonic compensation of V C is obtained by injecting FNS&H sequences of V C ; hence, the performance of the inverter acts in voltage controlled mode (VCM) in FNS&H sequences.The compensation is important when a sensitive load is connected near the DG.The selection of Modes 1 or 2 is dependent on the location of the sensitive load.

•
Mode 3-local unbalanced and nonlinear loads compensation: in this mode, the aim of the compensation is the unbalance and harmonic compensations of MG-injected current (I inj ).Using (I lcaoal -I 2 ) as input of FPQC, the multifunctional inverter acts as an active filter in negative and harmonic sequences, therefore, the FNS&H parts of unbalanced and nonlinear loads are supplied by the DG-interfacing inverter and I inj will be balanced.The mode can be activated when there is a limitation for the unbalance and harmonics current of an MG, since each system has limitations in harmonic and unbalance injections according to IEEE 519 and EN 50160 standards.

•
Mode 4-the output current compensation of DG unit (I 2 ): in this mode, which is called the unbalance and harmonics rejection mode, the output current of DG will be compensated.This mode is important when the DG delivers maximum power to the grid, and injection of unbalance and harmonics current can increase the current of one/two phase(s) higher than the rated one.
Figure 2 shows more details of the proposed control diagram.As can be observed in this figure, the control scheme consists of three parts.The first part is related to the PS voltage control, where V ref is tracked as a VCM inverter.The second part is related to unbalance and harmonic compensation, and acts as a CCM inverter except in Mode 2. As discussed before, since the compensation of V C is achieved by injecting negative and harmonic sequence voltage, the inverter acts as VCM inverter in FNS&H sequences in Mode 2. The third part is applied to provide some damping [31].The following equation expresses these three parallel controllers: where GV and GPQC represent the voltage and power quality compensation controllers, respectively.KD is a proportional gain which is used for resonance damping.As illustrated in Figure 2a, in the PS voltage and unbalance compensation parts of Power Quality Controller (PQC), SOGI-based negative and positive extraction blocks are utilized.Figure 2b shows the details of the controller.As shown in this figure, the quadrature-phase waveforms (90° lag) of the original in-phase waveforms are created, and according to the following equations, the negative and positive sequences are extracted [29]: where G V and G PQC represent the voltage and power quality compensation controllers, respectively.K D is a proportional gain which is used for resonance damping.As illustrated in Figure 2a, in the PS voltage and unbalance compensation parts of Power Quality Controller (PQC), SOGI-based negative and positive extraction blocks are utilized.Figure 2b shows the details of the controller.As shown in this figure, the quadrature-phase waveforms (90 • lag) of the original in-phase waveforms are created, and according to the following equations, the negative and positive sequences are extracted [29]: Energies 2017, 10, 1568 where q is defined as q = e −jπ/2 .In other words, the extraction of negative and positive sequences is achieved by using a resonant controller.In the positive sequence, the controller acts similar to the non-ideal resonant controller expressed in (9): where K V is the gain of resonance controller at fundamental frequency, and ω b represents the cut-off bandwidth of the controller [23,29,31].
For negative sequence and harmonic compensation, the power quality controller (PQC) can be expressed by the following equation: where X ref and X, which are selected by "Mode Selector" switch, can be the reference and actual values of I 2 or V C , respectively.K P , K UCC and K I,h represent the proportional coefficient of the resonant controller, and the unbalance and harmonics resonant coefficients of the controller, respectively.Since a low value of K P is chosen [23], all the components, including fundamental positive and FNS&H components, are decoupled.
In order to damp the resonance of the LCL filter, active and passive damping is utilized.The current of the capacitor or inverter side inductor is usually used for active damping [32,33].In this paper, the inductor current feedback and a proportional controller (K D ) are employed as the third and damping part of the flexible controller.

Control System Design
As discussed before, the control of the inverter is a flexible current-and-voltage-control method.The positive sequence of the V C is related to the first part of FPQC, and the inverter can be modeled as a VCM inverter.Figure 3 shows the positive sequence voltage generation block.Since negative and harmonic sequences are generated by PQC, this part is eliminated in PS analysis.On the other hand, since the DG-interfacing inverter acts as a CCM inverter in Modes 1, 3 and 4, only PQC and the damping controller can have an influence on the negative and harmonic sequences of DG output current; hence, the control system of the FNS&H current is merely considered as depicted in Figure 4.In these figures, the LCL filter inverter-side inductance and its resistance are represented by L 1 and R L1 , respectively, while L 2 and R L2 are the grid-side inductance and its resistance, respectively.The capacitor of the LCL filter and its series resistance are shown by C and R C , respectively.
where q is defined as q = e −jπ/2 .In other words, the extraction of negative and positive sequences is achieved by using a resonant controller.In the positive sequence, the controller acts similar to the non-ideal resonant controller expressed in (9): where KV is the gain of resonance controller at fundamental frequency, and ωb represents the cut-off bandwidth of the controller [23,29,31].
For negative sequence and harmonic compensation, the power quality controller (PQC) can be expressed by the following equation: where Xref and X, which are selected by "Mode Selector" switch, can be the reference and actual values of I2 or VC, respectively.KP, KUCC and KI,h represent the proportional coefficient of the resonant controller, and the unbalance and harmonics resonant coefficients of the controller, respectively.Since a low value of KP is chosen [23], all the components, including fundamental positive and FNS&H components, are decoupled.
In order to damp the resonance of the LCL filter, active and passive damping is utilized.The current of the capacitor or inverter side inductor is usually used for active damping [32,33].In this paper, the inductor current feedback and a proportional controller (KD) are employed as the third and damping part of the flexible controller.

Control System Design
As discussed before, the control of the inverter is a flexible current-and-voltage-control method.The positive sequence of the VC is related to the first part of FPQC, and the inverter can be modeled as a VCM inverter.Figure 3 shows the positive sequence voltage generation block.Since negative and harmonic sequences are generated by PQC, this part is eliminated in PS analysis.On the other hand, since the DG-interfacing inverter acts as a CCM inverter in Modes 1, 3 and 4, only PQC and the damping controller can have an influence on the negative and harmonic sequences of DG output current; hence, the control system of the FNS&H current is merely considered as depicted in Figure 4.In these figures, the LCL filter inverter-side inductance and its resistance are represented by L1 and RL1, respectively, while L2 and RL2 are the grid-side inductance and its resistance, respectively.The capacitor of the LCL filter and its series resistance are shown by C and RC, respectively.
In other words, the inverter can be modeled using Norton-and Thevenin-equivalent circuits for FNS&H and positive sequences of fundamental frequency, respectively.As discussed before, in Mode 2 of compensation, the inverter acts as a VCM inverter in negative and harmonic sequences, and its relative model is similar to the PS part depicted in Figure 3.The closed-loop transfer function of positive sequence capacitor voltage (GPSCV(s)) is written by the following equation, according to Figure 3: where ZL1 = L1 s + RL1 is the impedance of the inverter-side inductance of the LCL filter and its series resistance.ZL2 = L1 s + RL1 represents the grid-side inductance and its series resistance, while ZC(s) = 1/Cs + RC is the capacitor impedance and its series resistance.GV is the transfer function of the resonance controller, which is defined according to (9), and KD is the damping gain, which is shown in Figure 2a.
According to Figure 4, the closed-loop current-transfer function of DG output FNS&H current (GONHC(s)) is written as: where GPQC represents the power quality compensation controller, which is expressed by Equation (10).Using Equations ( 11) and ( 12), the parameters of the controllers can be determined.The cut-off bandwidth of the non-ideal resonant controllers (ωb) is recommended to be in the range of 5-15 rad/s [31].In this paper, ωb = 5 is chosen.Firstly, the design of the damping part of the controller will be discussed.The Bode diagram of GPSCV(s) is depicted in Figure 5 using the LCL filter parameters in Table 1, KV = 700 and ωb = 5rad/sec.The Bode diagram is depicted for three amounts of KD = 0, 20 and 100.As shown in this figure, there is a peak in resonance frequency of the LCL filter when KD = 0.The resonance is damped when KD is set at 20 and 100.The large amount of KD may cause additional resonance in the system [34]; thus, KD = 20 is the selected option.In other words, the inverter can be modeled using Norton-and Thevenin-equivalent circuits for FNS&H and positive sequences of fundamental frequency, respectively.As discussed before, in Mode 2 of compensation, the inverter acts as a VCM inverter in negative and harmonic sequences, and its relative model is similar to the PS part depicted in Figure 3.
The closed-loop transfer function of positive sequence capacitor voltage (G PSCV (s)) is written by the following equation, according to Figure 3: where Z L1 = L 1 s + R L1 is the impedance of the inverter-side inductance of the LCL filter and its series resistance.Z L2 = L 1 s + R L1 represents the grid-side inductance and its series resistance, while Z C (s) = 1/Cs + R C is the capacitor impedance and its series resistance.G V is the transfer function of the resonance controller, which is defined according to (9), and K D is the damping gain, which is shown in Figure 2a.
According to Figure 4, the closed-loop current-transfer function of DG output FNS&H current (G ONHC (s)) is written as: where G PQC represents the power quality compensation controller, which is expressed by Equation (10).
Using Equations ( 11) and ( 12), the parameters of the controllers can be determined.The cut-off bandwidth of the non-ideal resonant controllers (ω b ) is recommended to be in the range of 5-15 rad/s [31].In this paper, ω b = 5 is chosen.Firstly, the design of the damping part of the controller will be discussed.The Bode diagram of G PSCV (s) is depicted in Figure 5 using the LCL filter parameters in Table 1, K V = 700 and ω b = 5 rad/s.The Bode diagram is depicted for three amounts of K D = 0, 20 and 100.As shown in this figure, there is a peak in resonance frequency of the LCL filter when K D = 0.The resonance is damped when K D is set at 20 and 100.The large amount of K D may cause additional resonance in the system [34]; thus, K D = 20 is the selected option.The closed-loop transfer function of positive sequence capacitor voltage (GPSCV(s)) is written by the following equation, according to Figure 3: where ZL1 = L1 s + RL1 is the impedance of the inverter-side inductance of the LCL filter and its series resistance.ZL2 = L1 s + RL1 represents the grid-side inductance and its series resistance, while ZC(s) = 1/Cs + RC is the capacitor impedance and its series resistance.GV is the transfer function of the resonance controller, which is defined according to (9), and KD is the damping gain, which is shown in Figure 2a.
According to Figure 4, the closed-loop current-transfer function of DG output FNS&H current (GONHC(s)) is written as: where GPQC represents the power quality compensation controller, which is expressed by Equation (10).Using Equations ( 11) and ( 12), the parameters of the controllers can be determined.The cut-off bandwidth of the non-ideal resonant controllers (ωb) is recommended to be in the range of 5-15 rad/s [31].In this paper, ωb = 5 is chosen.Firstly, the design of the damping part of the controller will be discussed.The Bode diagram of GPSCV(s) is depicted in Figure 5 using the LCL filter parameters in Table 1, KV = 700 and ωb = 5rad/sec.The Bode diagram is depicted for three amounts of KD = 0, 20 and 100.As shown in this figure, there is a peak in resonance frequency of the LCL filter when KD = 0.The resonance is damped when KD is set at 20 and 100.The large amount of KD may cause additional resonance in the system [34]; thus, KD = 20 is the selected option.In the FNS&H compensation controller, the proportional controller is used for better tracking of the FNS&H voltage or current, and a low value of it is adequate for the controller [31], hence, K P = 4 is chosen.The Bode diagram of the GONHC is shown in Figure 6, considering K UCC = 700, K I,3 = 500, K I,5 = 300 and K I,7 = 300.As depicted in this figure, the Bode diagram of the closed-loop transfer function is zero in the fundamental frequency for negative sequence and third-, fifth-and seventh-order harmonics; hence, the current can track its reference value.

Simulation Results
In this section, the effectiveness of the proposed control method for both grid-connected and islanded MG operation modes is evaluated.
To quantify the voltage and ZL,G = R + jωL.It is assumed that the grid voltage is unbalanced with VUF = 4.5%.Control system and power stage parameters are listed in Table 1.The following five steps are used for evaluating the controller in unbalance and harmonic sequences of triple and other odd harmonics will be present [35].Thus, the dominant harmonic components, selected for compensation in this paper, are third, fifth and seventh orders [20].The amount of the negative and positive sequences of third and fifth harmonics of voltage and current are listed in Table 2 in different steps.

Simulation Results
In this section, the effectiveness of the proposed control method for both grid-connected and islanded MG operation modes is evaluated.
To quantify the voltage and current compensation, the voltage/current unbalance factors (VUF and CUF, respectively) and individual harmonic factors with the following definitions are considered: where V − rms /V + rms and I − rms /I + rms are Root Mean Square (RMS) values of negative and positive sequences of voltage/current, respectively.X ± h,rms and X + 1,rms represent the harmonic positive and negative sequences and fundamental components of voltage/current variables, respectively.

Grid-Connected Operation
Figure 7 shows a grid-connected MG, which consists of both local and PCC-connected balanced and unbalanced linear and nonlinear loads.The linear unbalanced (single-phase) load is presented in this figure by R unb .The MG is connected to the grid through the line impedance Z L,G = R + jωL.It is assumed that the grid voltage is unbalanced with VUF = 4.5%.Control system and power stage Energies 2017, 10, 1568 9 of 19 parameters are listed in Table 1.The five steps are used for evaluating the controller in unbalance and harmonic compensation.
Energies 2017, 10, 1568 9 of 18 assumed that the grid voltage is unbalanced with VUF = 4.5%.Control system and power stage parameters are listed in Table 1.The following five steps are used for evaluating the controller in unbalance and harmonic compensation.
The VUFs and CUFs of the related voltages and currents are depicted in Figures 8 and 9, respectively.Since an unbalanced nonlinear load is used in this study, both sequences of triple and other odd harmonics will be present [35].Thus, the dominant harmonic components, selected for
The VUFs and CUFs of the related voltages and currents are depicted in Figures 8 and 9, respectively.Since an unbalanced load is used in this study, both sequences of triple and other odd harmonics will be present [35].Thus, the dominant harmonic components, selected for compensation in this paper, are third, fifth and seventh orders [20].The amount of the negative and positive sequences of third and fifth harmonics of voltage and current are listed in Table 2 in different steps.

Simulation Results
In this section, the effectiveness of the proposed control method for both grid-connected and islanded MG operation modes is evaluated.
To quantify the voltage and ZL,G = R + jωL.It is assumed that the grid voltage is unbalanced with VUF = 4.5%.Control system and power stage parameters are listed in Table 1.The following five steps are used for evaluating the controller in unbalance and harmonic sequences of triple and other odd harmonics will be present [35].Thus, the dominant harmonic components, selected for compensation in this paper, are third, fifth and seventh orders [20].The amount of the negative and positive sequences of third and fifth harmonics of voltage and current are listed in Table 2 in different steps.
Step 1 Step 2 Step 3 Step 4 Step 5 Energies 2017, 10, 1568 3 of 4 Step 1 Step 2 Step 3 Step 4 Step 5   Step 5: in this interval, the unbalance compensation is deactivated.As shown in Figure 8, the VUF of the VPCC and VC is approximately 5.5%, which is higher than the standard limit of 2%.In order to show the effectiveness of the FPQC, the waveforms of voltage/current in this step are also depicted in Figures 11-14.This step is used as a comparative study against methods without harmonic and unbalance compensation.For instance, as depicted in Figure 8, the VUF of VPCC  Note that due to the limitation of paper and table length, the seventh harmonic components are not presented in this Table.Furthermore, the capability of the controller in injecting the reference active and reactive powers to the grid is also investigated.Figure 10 shows that the grid-connected inverter can inject the reference active and reactive powers listed in Table 1 to the grid in different compensation modes.The details of the power quality compensation in the aforementioned steps are explained below: Step 1: Mode 1 is activated in this step.Since the PCC voltage compensation is the aim of this step and mode, the PCC voltage waveform is depicted in Figure 11.As depicted in Figures 8 and 11, the unbalance voltage of the PCC is compensated and the VUF of the VPCC is about 0.2%, which is below the standard limit of 2%.The compensation is achieved via the negative sequence virtual conductance which creates a low-impedance path for negative sequence current to pass through the DG-interfacing inverter.Therefore, IDG becomes unbalanced, as demonstrated by its CUF in Figure 9. Furthermore, as depicted in Figure 11 and Table the harmonic contents of the PCC voltage are compensated.In order to show the effectiveness of the FPQC in this mode, the PCC voltage is also magnified in Step 5, when the PQC is inactive.
Step 1 Step 2 Step 3 Step 4 Step 5 Step 2: in this interval, Mode 2 is applied to the inverter by setting the reference value of VC to 0 in the input of the unbalance compensation controller.The VC is used as feedback of the FPQC, and negative and harmonic sequence voltages with 180 phase degree difference with negative and harmonics sequences of VC are injected for compensation.Figure 12 shows the VC voltage in different steps, while this figure is magnified in Step 2 (VC compensation) and Step 5 (without compensation).Furthermore, as depicted in Figure 12 and Table 2, the harmonic compensation of VC is also achieved.Step 1: Mode 1 is activated in this step.Since the PCC voltage compensation is the aim of this step and mode, the PCC voltage waveform is depicted in Figure 11.As depicted in Figures 8 and 11, the unbalance voltage of the PCC is compensated and the VUF of the V PCC is about 0.2%, which is below the standard limit of 2%.The compensation is achieved via the negative sequence virtual conductance which creates a low-impedance path negative sequence current to pass through the DG-interfacing inverter.Therefore, I DG becomes unbalanced, as demonstrated by its CUF in Figure 9. Furthermore, as depicted in Figure 11 and Table 2, the harmonic contents of the PCC voltage are compensated.In order to show the effectiveness of the FPQC in this mode, the PCC voltage is also magnified in Step 5, when the PQC is inactive.Step 1: Mode 1 is activated in this step.Since the PCC voltage compensation is the aim of this step and mode, the PCC voltage waveform is depicted in Figure 11.As depicted in Figures 8 and 11, the unbalance voltage of the PCC is compensated and the VUF of the VPCC is about 0.2%, which is below the standard limit of 2%.The compensation is achieved via the negative sequence virtual conductance which creates a low-impedance path for negative sequence current to pass through the DG-interfacing inverter.Therefore, IDG becomes unbalanced, as demonstrated by its CUF in Figure 9. Furthermore, as depicted in Figure 11 and Table 2, the harmonic contents of the PCC voltage are compensated.In order to show the effectiveness of the FPQC in this mode, the PCC voltage is also magnified in Step 5, when the PQC is inactive.
Step 1 Step 2 Step 3 Step 4 Step 5 Step 2: in this interval, Mode 2 is applied to the inverter by setting the reference value of VC to 0 in the input of the unbalance compensation controller.The VC is used as feedback of the FPQC, and negative and harmonic sequence voltages with 180 phase degree difference with negative and harmonics sequences of VC are injected for compensation.Figure 12 shows the VC voltage in different steps, while this figure is magnified in Step 2 (VC compensation) and Step 5 (without compensation).Furthermore, as depicted in Figure 12 and Table 2, the harmonic compensation of VC is also achieved.Step 2: in this interval, Mode 2 is applied to the inverter by setting the reference value of V C to 0 in the input of the unbalance compensation controller.The V C is used as feedback of the FPQC, and negative and harmonic sequence voltages with 180 phase degree difference with negative and harmonics sequences of V C are injected for compensation.Figure 12 shows the V C voltage in different steps, while this figure is magnified in Step 2 (V C compensation) and Step 5 (without compensation).Furthermore, as depicted in Figure 12 and Table 2, the harmonic compensation of V C is also achieved.Step 1 Step 2 Step 3 Step 4 Step 5 Step 3: in this interval, Mode 3 of power-quality improvement is selected by the "Mode Selector" switch.In this mode, the (ILocal-I2) is applied to the PQC, as depicted in Figure 2, and the DG generates the negative and harmonic sequences of the local load; hence, Iinj will be compensated, as illustrated CUF (Figure 9), Table 3 and the Iinj waveform that is depicted in Figure 13. Figure 13 shows the magnified image of Iinj in Step 3 (Iinj compensation mode) and Step 5, when the PQC is deactivated for evaluating the performance of power-quality compensation in this mode and step.Step 4: in this mode, which is also called unbalance and harmonic rejection mode, the reference value of the I2 is chosen to be zero for the PQC controller.As depicted in Figure 9, the CUF of the IDG is approximately zero in this step.This fact is also demonstrated in Figure 14, which shows the Step 3: in this interval, Mode 3 of power-quality improvement is selected by the "Mode Selector" switch.In this mode, the (I Local -I 2 ) is applied to the PQC, as depicted in Figure 2, and the DG generates the negative and harmonic sequences of the local load; hence, I inj will be compensated, as illustrated by CUF (Figure 9), Table 3 and the I inj waveform that is depicted in Figure 13. Figure 13 shows the magnified image of I inj in Step 3 (I inj compensation mode) and Step 5, when the PQC is deactivated for evaluating the performance of power-quality compensation in this mode and step.Step 1 Step 2 Step 3 Step 4 Step 5 Step 3: in this interval, Mode 3 of power-quality improvement is selected by the "Mode Selector" switch.In this mode, the (ILocal-I2) is applied to the PQC, as depicted in Figure 2, and the DG generates the negative and harmonic sequences of the local load; hence, Iinj will be compensated, as illustrated by CUF (Figure 9), Table 3 and the Iinj waveform that is depicted in Figure 13. Figure 13 shows the magnified image of Iinj in Step 3 (Iinj compensation mode) and Step 5, when the PQC is deactivated for evaluating the performance of power-quality compensation in this mode and step.Step 4: in this mode, which is also called unbalance and harmonic rejection mode, the reference value of the I2 is chosen to be zero for the PQC controller.As depicted in Figure 9, the CUF of the IDG is approximately zero in this step.This fact is also demonstrated in Figure 14, which shows the Energies 2017, 10,1568 Step 4: in this mode, which is also called unbalance and harmonic rejection mode, the reference value of the I 2 is chosen to be zero for the PQC controller.As depicted in Figure 9, the CUF of the I DG is approximately zero in this step.This fact is also demonstrated in Figure 14, which shows the waveform of I DG in different steps.In this figure, the waveform is also magnified in Steps 4 (I DG compensation mode) and 5 (without compensation); however, I inj is unbalanced, with a high CUF equal to 30%.Since the unbalanced current passes through the impedances of the grid and the LCL filter, the VUFs of the V PCC and V C are high in this interval, as depicted in Figure 8.For harmonic compensation, as listed in Table 2, H 3 − , H 3 + , H 5 − and H 5 + of V PCC and V C are increased, and the DG current is also compensated.
Energies 2017, 10, 1568 13 of 18 waveform of IDG in different steps.In this figure, the waveform is also magnified in Steps 4 (IDG compensation mode) and 5 (without compensation); however, Iinj is unbalanced, with a high CUF equal to 30%.Since the unbalanced current passes through the impedances of the grid and the LCL filter, the VUFs of the VPCC and VC are high in this interval, as depicted in Figure 8.For harmonic compensation, as listed in Table 2, H3 − , H3 + , H5 − and H5 + of VPCC and VC are increased, and the DG current is also compensated.
Step 1 Step 2 Step 3 Step 4 Step 5 Step 5: in this interval, the unbalance compensation is deactivated.As shown in Figure 8, the VUF of the VPCC and VC is approximately 5.5%, which is higher than the standard limit of 2%.In order to show the effectiveness of the FPQC, the waveforms of voltage/current in this step are also depicted in Figures 11-14.This step is used as a comparative study against methods without harmonic and unbalance compensation.For instance, as depicted in Figure 8, the VUF of VPCC and VC are about 5.8% in this step, which is higher than the standard limit of 2%.The results show the advantage of this method in comparison to the methods proposed in [23,24], in which the negative sequence compensation is not the object of these papers.

Islanded Operation of the MG
The simulated islanded MG includes two DG units, which supply balanced and unbalanced linear and nonlinear loads, as depicted in Figure 15.The system's parameters are listed in Table 3. Step 5: in this interval, the unbalance compensation is deactivated.As shown in Figure 8, the VUF of the V PCC and V C is approximately 5.5%, which is higher than the standard limit of 2%.In order to show the effectiveness of the FPQC, the waveforms of voltage/current in this step are also depicted in Figures 11-14.This step is used as a comparative study against methods without harmonic and unbalance compensation.For instance, as depicted in Figure 8, the VUF of V PCC and V C are about 5.8% in this step, which is higher than the standard limit of 2%.The results show the advantage of this method in comparison to the methods proposed in [23,24], in which the negative sequence compensation is not the object of these papers.

Islanded Operation of the MG
The simulated islanded MG includes two DG units, which supply balanced and unbalanced linear and nonlinear loads, as depicted in Figure 15.The system's parameters are listed in Table 3.
Step III: In this step, Mode Y is selected, and in order to evaluate the performance of the controller in changing the load, at t = 4 s the unbalance load is changed from R Unb = 40 Ω to R Unb = 20 Ω.
Step IV: In this step, the PQC is deactivated in order to demonstrate the effectiveness of the control method in unbalance and harmonic comparison (compared to the conventional methods without harmonics and unbalance compensation).
Figure 16 shows the VUFs of the capacitor voltages of DG 1 and DG 2 (V C1 and V C2 ), and V PCC , while the harmonic contents of these variables are listed in Table 4. Figure 17 shows V PCC , and this figure is magnified in Step I (PCC compensation mode) and Step IV (without compensation) to evaluate the performance of the PQC.As depicted in Figures 16 and 17 and Table 4, in Step I, the compensation of PCC voltage is achieved; for instance, the VUF of the voltage is below the standard limit of 2% when Mode X is applied.


Step III: In this step, Mode Y is selected, and in order to evaluate the performance of the controller in changing the load, at t = 4 s the unbalance load is changed from RUnb = 40 Ω to RUnb = 20 Ω.

 Step IV:
In this step, the PQC is deactivated in order to demonstrate the effectiveness of the control method in unbalance and harmonic comparison (compared to the conventional methods without harmonics and unbalance compensation).
Figure 16 shows the VUFs of the capacitor voltages of DG1 and DG2 (VC1 and VC2), and VPCC, while the harmonic contents of these variables are listed in Table 4. Figure 17 shows VPCC, and this figure is magnified in Step I (PCC compensation mode) and Step IV (without compensation) to evaluate the performance of the PQC.As depicted in Figures 16 and 17 and Table 4, in Step I, the compensation of PCC voltage is achieved; for instance, the VUF of the voltage is below the standard limit of 2% when Mode X is applied.In this step, Mode Y is selected, and in order to evaluate the performance of the controller in changing the load, at t = 4 s the unbalance load is changed from RUnb = 40 Ω to RUnb = 20 Ω.

 Step IV:
In this step, the PQC is deactivated in order to demonstrate the effectiveness of the control method in unbalance and harmonic comparison (compared to the conventional methods without harmonics and unbalance compensation).
Figure 16 shows the VUFs of the capacitor voltages of DG1 and DG2 (VC1 and VC2), and VPCC, while the harmonic contents of these variables are listed in Table 4. Figure 17 shows VPCC, and this figure is magnified in Step I (PCC compensation mode) and Step IV (without compensation) to evaluate the performance of the PQC.As depicted in Figures 16 and 17 and Table 4, in Step I, the compensation of PCC voltage is achieved; for instance, the VUF of the voltage is below the standard limit of 2% when Mode X is applied.Furthermore, Figure 16 shows that the VUFs of V C1 and V C2 are improved in the Steps II and III, while the harmonic compensation becomes evident by selecting Mode Y, as presented in Table 4.In addition, according to Figure 16, the controller can compensate the negative sequence of the V C1 and V C2 when the load is doubled at t = 4 s.The harmonic contents of the V C1 and V C2 are compensated, according to Table 4.This is also shown in Figure 18, which depicts V C1 waveform in Steps III (V C compensation mode) and IV (without harmonics and unbalance compensation).As depicted in Figures 16-18, if the unbalance compensation block is deactivated, the unbalance voltage problem can lead to some voltage quality problem for the microgrid.This shows the effectiveness of this applied method, in comparison to methods proposed in [23,24], in which the DGs can contribute only in harmonics compensation in a single-phase microgrid.Furthermore, Figure 16 shows that the VUFs of VC1 and VC2 are improved in the Steps II and III, while the harmonic compensation becomes evident by selecting Mode Y, as presented in Table 4.In addition, according to Figure 16, the controller can compensate the negative sequence of the VC1 and VC2 when the load is doubled at t = 4 s.The harmonic contents of the VC1 and VC2 are compensated, according to Table 4.This is also shown in Figure 18, which depicts VC1 waveform in Steps III (VC compensation mode) and IV (without harmonics and unbalance compensation).As depicted in Figures 16-18, if the unbalance compensation block is deactivated, the unbalance voltage problem can lead to some voltage quality problem for the microgrid.This shows the effectiveness of this applied method, in comparison to methods proposed in [23,24], in which the DGs can contribute only in harmonics compensation in a single-phase microgrid.

Conclusions
In this paper, a flexible unbalance and harmonic compensation scheme is proposed for the improvement of current and voltage quality in MGs.The performance of the method is investigated in both grid-connected and islanded operations of MGs.The simulation results show that by applying the proposed control scheme to a grid-connected MG, not only the active and reactive powers injection is achieved, but also control modes for harmonics and unbalance compensation of PCC voltage, DG voltages, DG output current or injected current of MGs can be obtained.According to the results, by selecting the PCC compensation mode, the VUF, H3 + and H3 − of the PCC voltage are mitigated to about 0.2%, 1% and 1.1%, respectively, which are under the limitation of EN 50160 and

Conclusions
In this paper, a flexible unbalance and harmonic compensation scheme is proposed for the improvement of current and voltage quality in MGs.The performance of the method is investigated in both grid-connected and islanded operations of MGs.The simulation results show that by applying the proposed control scheme to a grid-connected MG, not only the active and reactive powers injection is achieved, but also control modes for harmonics and unbalance compensation of PCC voltage, DG voltages, DG output current or injected current of MGs can be obtained.According to the results,

1 iFigure 1 .
Figure 1.Diagram of the proposed flexible power-quality improvement scheme.If a three-phase inverter is connected to a mainly inductive grid, the injected positive sequence (PS) active and reactive powers are related to the angle between , and ωb represents the cut-off bandwidth of KUCC = 700, KI,3 = 500, KI,5 = 300 and KI,7 = 300.As depicted in this figure, the Bode diagram of the closed-loop transfer function is zero in the fundamental frequency for negative sequence and third-, fifth-and seventh-order harmonics; hence, the current can track its reference value.

Figure 1 .
Figure 1.Diagram of the proposed flexible power-quality improvement scheme.

Figure 7 .
Figure 7. Simulated grid-connected MG with unbalanced linear and nonlinear local and PCC loads.

Figure 7 .
Figure 7. Simulated grid-connected MG with unbalanced linear and nonlinear local and PCC loads.

Figure 9 .
Figure 9. CUF curves of currents in grid-connected MG.

Figure 14 .
Figure 14.IDG in Step 4 and Step 5 (without compensation) of unbalance compensation.

Figure 9 .
Figure 9. CUF curves of currents in grid-connected MG.

Figure 10 .
Figure 10.Active and reactive powers of DG.

Figure 10 .
Figure 10.Active and reactive powers of DG.

Figure 10 .
Figure 10.Active and reactive powers of DG.

Figure 11 .
Figure 11.V PCC in Step 1 and Step 5 (without compensation) of unbalance compensation.

Figure 12 .
Figure 12.VC waveform in Step 2 and Step 5 (without compensation) of unbalance compensation.

Figure 12 .
Figure 12.V C waveform in Step 2 and Step 5 (without compensation) of unbalance compensation.

Figure 12 .
Figure 12.VC waveform in Step 2 and Step 5 (without compensation) of unbalance compensation.

Figure 13 .
Figure 13.I inj in Step 3 and Step 5 (without compensation) of unbalance compensation.

Figure 14 .
Figure 14.IDG in Step 4 and Step 5 (without compensation) of unbalance compensation.

Figure 14 .
Figure 14.I DG in Step 4 and Step 5 (without compensation) of unbalance compensation.

Figure 17 .
Figure 17.V PCC in Step I (V PCC compensation) and Step IV (without compensation) for islanded MG.

Figure 18 .
Figure 18.VC1 in Step III (VC compensation) and Step IV (without compensation) for islanded MG.

Figure 18 .
Figure 18.V C1 in Step III (V C compensation) and Step IV (without compensation) for islanded MG.

Table 1 .
Parameters of grid-connected MG.

Table 1 .
Parameters of grid-connected MG.

Table 2 .
Harmonic contents of .

Table 2 .
Harmonic contents of V PCC , V C , I DG and I inj in different steps for grid-connected MG.

Table 4 .
Harmonic contents of V PCC , V C1 and V C2 in different steps for islanded MG.

Table 4 .
Harmonic contents of VPCC, VC1 and VC2 in different steps for islanded MG.