Active Harmonic Filtering With Selective Overcurrent Limitation for Grid-Forming VSCs: Stability Analysis and Experimental Validation

The high penetration of renewable energy sources (RES) interfaced with power electronics together with new non-linear loads pose new challenges in the grid operation. In fact, power systems with reduced inertia and high harmonic distortion will be common in a near future. Recently, the grid-forming operation of voltage source converters (VSCs) has emerged to address these challenges, mimicking the contribution of synchronous generators to the system inertia. In addition, these grid-connected VSCs can be used at the same time for reducing the harmonic distortion by applying active filtering techniques. However, these harmonic compensation algorithms can generate VSC overloading. This paper proposes a method for dynamically adjusting the individual virtual impedance of the filtered harmonics to prevent the power converter overcurrent. For this purpose, the value of each harmonic virtual impedance is modified according to a priority which can be set by the final user according to the established power quality standard. The paper includes a theoretical stability analysis of the controller and experimental results to validate the proposed algorithm.


I. INTRODUCTION
T HE future of power generation will be dominated by renew- able energy sources (RES).In this way, the conventional Francisco Jesús Matas-Díaz, Manuel Barragán-Villarejo, and José María Maza-Ortega are with the Department of Electrical Engineering, Universidad de Sevilla, 41004 Sevilla, Spain (e-mail: fmatas@us.es;manuelbarragan@us.es;jmmaza@us.es).
Color versions of one or more figures in this article are available at https://doi.org/10.1109/TIA.2024.3369595.
Digital Object Identifier 10.1109/TIA.2024.3369595synchronous generators will be replaced with RES power plants which will be connected to the grid using converter interfaced generators (CIGs).This scenario may lead to new technical challenges, where larger frequency and voltage deviations are expected due to the reduced system inertia [1], affecting the secure and reliable operation of the power system [2].This change comes along with a transition in the demand side, where traditional electro-mechanical loads are being replaced by power electronics such as variable speed drives, power supplies or lighting devices.These non-linear loads improve the performance, efficiency and flexibility but, at the same time, introduce harmonic currents.This has a negative effect on the distribution system causing, among others, distorted nodal voltages [3] and transformer overheating [4].The impact on the power quality is particularly high in low voltage networks and microgrids, where the penetration of non-linear loads is steadily increasing within industrial, commercial and domestic consumers [5].With this regard, CIGs based on voltage source converters (VSCs) composed of switched devices such as insulated-gate bipolar transistors (IGBTs) may contribute to address these new challenges due to the inherent flexibility provided by their control algorithms.
On the one hand, regarding the reduced inertia of modern power systems, grid-forming operation of CIGs has recently emerged to support and control the system frequency and voltage [6].For doing so, it is required to either operate below the RES maximum power point or include an energy storage system [7].Several ways to implement the grid-forming mode can be found in the specialized literature [8]: droop controllers for active and reactive power sharing [9], advanced algorithms mimicking the dynamic performance of a synchronous generator [10] or virtual oscillators [11].All of them provide frequency and voltage control and they can operate in both islanded and grid-connected systems.This is because they do not require a phase-locked loop (PLL) or other frequency estimation method to synchronize with the system they are connected to.In general, the control structure of a grid-forming VSC consists of a hierarchical controller composed of an outer and an inner control loop, OCL and ICL respectively [12].The OCL is in charge of the synchronization and the computation of the frequency and voltage references for the ICL.Meanwhile, the ICL can be implemented in different ways: open loop [13], single current controller [14], [15], single voltage controller [16] and cascade voltage and current controllers [17].The main drawback of the three first algorithms is the lack of controllability of the capacitor voltage and/or inductor current which is critical in abnormal operation conditions with a fast dynamics such as short-circuit faults.With this regard, the use of cascade controllers guarantees that the VSC voltage and current remain within the technical limits.This approach, however, is extremely sensitive to the characteristics of the Point of Interconnection (POI), i.e. short-circuit power and R/X ratio [8].In addition, the voltage control loop may become unstable because of the feedforward terms of the current controller [18].This drawback can be overcome using an ICL based just on a current controller.In this case, the voltage control is included within the OCL through primary and secondary control loops [19].Evidently, this voltage control has a slower dynamic response than those strategies with a voltage control within the ICL, but enough to maintain the voltages within technical limits under normal operation conditions.Moreover, these controllers are also able to limit the VSC current in case of short-circuit faults [20], [21].
On the other hand, with respect to the harmonic mitigation, passive filters [22], active power filters [23] or hybrid filters can be installed nearby large non-linear loads at the cost of additional investments.Alternatively, CIGs with proper control actions may help to reduce the harmonic distortion [24].A set of resonant controllers tuned to the targeted harmonics can be added to the ICL either in the current or voltage control loop.In the first case, the harmonic current reference is computed using a virtual harmonic admittance and the POI harmonic voltage [25].This virtual harmonic admittance is dynamically modified until the reference harmonic voltage is reached, as long as the VSC rated current is not exceed.This is an indirect method of harmonic voltage compensation since the virtual admittance is modified following a trial and error process.For this reason, this methodology is not suitable in case of rapidly time-varying non-linear loads.As an alternative, the harmonic compensation can be integrated in the ICL voltage control loop by adding to the fundamental frequency controller a set of cascade resonant controllers tuned at the targeted harmonics [26], [27].In this way, any harmonic voltage reference can be directly tracked.The harmonic voltage references can be computed using a virtual impedance approach to improve the power sharing and the selective voltage harmonic compensation [28].Independently of the implemented harmonic controller, the system harmonic stability needs to be ensured.For doing so, different approaches have been previously proposed ranging from simplified Nortonbased impedance model [29] to sophisticated ones based on state-space models [30].The selection of the stability analysis tool depends on several factors: available information, main goal of the analysis (design-oriented process, identification of dynamic modes, participation factors, modularity, scalability, computational effort, etc.).A comprehensive overview of this topic with the pros and cons of each method can be found in [31].
Nevertheless, it is still possible to improve the design process and the performance of the existing harmonic controllers.Particularly, it is required to compute the resonant controller parameters to guarantee the controller stability and an adequate tracking of the harmonic references independently of the network characteristics.Furthermore, VSC operational limits, i.e. rated current and voltage, may be reached during the provision of the active harmonic filtering (AHF) service.In the existing literature, there are several current-limiting control strategies based on whether the total output current magnitude of the gridforming VSC is directly or indirectly controlled [32].Basically, these are classified in three categories: (i) direct current-limiting control [33], (ii) indirect current-limiting control [34] as virtual impedance current limiter [35] and, (iii) hybrid current-limiting control [36].Regardless of the method used to limit the current, all of them aim to limit the total current, without discriminating between the different current components of this current.With this regard, the limitation of the AHF capability in case of VSC overload has been previously explored in current controllers for active power filters: saturation approaches [37], [38], virtual impedance techniques [39] and optimization algorithms [40].However, the limitation of the AHF capability in case of VSC overcurrent with direct harmonic voltage tracking remains unexplored.
The main objective of this paper is to provide a stable AHF functionality to grid-forming VSCs by adding a direct harmonic voltage controller with selective current limitation in case of overloading.The harmonic voltage reference is set by means of an adaptive virtual harmonic impedance which is modified to maintain the current below its rated value.Each virtual harmonic impedance can be calculated independently to reflect the relative importance of each harmonic according to the established power quality standard.The proposed strategy can be implemented at any CIG, since it does not require adding new measurement devices or hardware components.Moreover, its application is of particular interest in CIGs within low voltage networks and microgrids, where the non-linear loads may deteriorate the power quality.
Finally, it is important to highlight that this paper has the following contributions with respect to [41]: r Evaluation of the proposed solution in grid-connected, instead of islanded, grid-forming VSCs.
r OCL based on a virtual synchronous generator (VSG) which allows the synchronization with the grid and inertial response.
r Stability analysis of the grid-forming VSC controller with AHF and selective overcurrent protection resorting to a small-signal analysis based on state-space equations.
r Computation of the virtual harmonic impedance to prevent VSC overloading according to the priority established in the EN 50160 standard [42] for each targeted harmonic.The rest of the paper is organized as follows.Section II presents the state-space modelling of the grid-forming VSC including the system dynamics: VSG, AHF and selective overloading protection.Section III outlines a small-signal stability analysis to evaluate the influence and stability range of the controller parameters.From this analysis, the final values of the controller gains are determined.Section IV provides the experimental validation of the proposal.Finally, the paper closes with the main conclusions.

II. STATE-SPACE MODELLING OF THE GRID-FORMING VSC
This section outlines the state-space model of a gridconnected VSC providing grid-forming capability with AHF and selective overcurrent protection.The proposed control algorithm is shown in Fig. 1, where all the parameters, variables and controller gains used along paper are specified.The state-space model is composed of four main blocks analyzed in the following subsections: (i) the grid-connected VSC model, (ii) the main controller of the grid-forming VSC implemented through a VSG, (iii) the AHF functionality through direct harmonic voltage control, and (iv) the selective harmonic overcurrent protection.

A. Grid-Connected VSC Model
The grid-connected VSC is a three-phase three-wire device connected to the grid through an LCL coupling filter, which also has a physical damping resistor incorporated in series with the capacitor.The grid is modeled as an AC voltage source with an series connected inductive impedance (R g and L g ).The differential equations of the grid-connected VSC in the dq rotating reference frame, which is synchronized with the VSG angle, θ vsg , are as follows: where L t and L s are the inverter-side and the grid-side filter inductances respectively, R t and R s are their corresponding resistances, C f is the filter capacitance, R d is the damping resistance, v t,dq = [v td , v tq ] is the voltage at the VSC terminals, v m,dq = [v md , v mq ] is the voltage across the capacitor and damping resistor, is the grid-side inductor current, and ω vsg is the VSG angular frequency.
Considering the equations above, the model of the gridconnected VSC adds six state variables x f to the state-space equations:

B. Virtual Synchronous Generator
The selected VSG model for providing grid-forming capability is the one presented in [15], which is composed of an OCL and an ICL.
The OCL consists of two parallel proportional-integral (PI) controllers for the active and reactive power, as shown in Fig. 1.The active power controller enables the synchronization with the grid by modifying the virtual rotor angle, θ vsg .The reactive power controller computes the amplitude of the virtual electromotive force, E. Therefore, the OCL equations are the following: Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
where ξ p is the integral of the active power error, p is the POI active power, p is the reference active power, ω 0 is the rated frequency, k pp and k ip are the proportional and integral gains of the PI active power controller, ξ q is the integral of the reactive power error, q is the POI reactive power, q is the reference reactive power, E 0 is the rated electromotive force, and k pq and k iq are the proportional and integral gains of the PI reactive power controller.
The POI active and reactive powers, p and q, are calculated in dq axes as: The electromotive force lies along the q axis as shown in Fig. 2.This leads to an electromotive force in the dq coordinates always equal to e dq = [0, −E].On the other hand, it is considered that the grid voltage rotates at the nominal frequency, ω 0 .This means that the grid voltage is considered a perturbation not adding any dynamic to the system [43].Therefore, it can be defined a phase shift, ψ, between the grid voltage and the electromotive force, as shown in Fig. 2, which evolves according to the VSG angle dynamics: This approach allows to replace θ vsg by ψ in (7), maintaining the VSG dynamics but adding the grid angular frequency ω 0 in the model.
The ICL consists of a single PI current controller implemented in dq coordinates.The current references are obtained from the electromotive force, e dq , the POI voltage, v s,dq , and a virtual admittance, Y v = G v − jB v .Additionally, a low-pass filter (LPF) is applied to these reference currents before introducing them into the current controller with the aim of providing references with the lowest possible harmonic content.The current references, i vsg sd and i vsg sq , can be formulated as follows: where τ lpf is the LPF time constant and i s,dq = [i sd , i sq ] is filtered reference current.
Finally, the PI current controller equations, including the cross-coupling cancellation and feed-forward terms are: where ξ id and ξ iq are the integral of the current errors in dq axis and k pi and k ii are the proportional and integral gains of the PI current controller respectively.Considering ( 7)-( 13), the model of the VSG control loops adds seven new state variables to the state-space equations:

C. Active Harmonic Filtering
The harmonic voltage control is provided by including a set of resonant controllers to each of the targeted harmonics.The objective is to track a harmonic voltage reference in the αβ domain, v h,αβ = [v hα , v hβ ], which corresponds to the required POI harmonic voltage.Note that the resonant controllers are implemented in the αβ coordinates, rather than in the dq frame, since it is necessary to compensate each harmonic in its corresponding sequence.These resonant controllers generate a new current reference, i h,αβ = [i hα , i hβ ], which is converted to the dq-axes before being added to the VSG fundamental reference current (13), as shown in Fig. 1.
The resonant controllers in the αβ reference frame can be formulated in the Laplace domain as: where h,αβ = [ hα , hβ ] is the harmonic voltage error, v s,αβ = [v sα , v sβ ] is the POI harmonic voltage while k rh , δ h and ω h are the gain, damping and tuned harmonic frequency of the h-th resonant controller.However, it is required to transform (15) to the dq coordinates, where the grid-connected VSC and VSG Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.models have been derived: where h,dq = [ hd , hq ] is the harmonic voltage error, i h,dq = [i hd , i hq ] is the reference harmonic current and v h,dq = [v hd , v hq ] is the reference harmonic voltage.Finally, the timedomain formulation of ( 16) is as follows: where γ h,dq = [γ hd , γ hq ] is a new state variable representing the integral of i h,αβ in the dq reference frame: The reference harmonic currents i h,dq are added to the previously computed VSG reference current, i dq = i s,dq + i h,dq , which is the input of the PI current controller.Therefore, ( 13) is reformulated as: Note that the perfect tracking of the reference harmonic currents i h,dq requires the use of resonant controllers tuned for each harmonic, like the ones used for the harmonic voltages.However, it is also possible to apply just a regular PI controller which, along with the resonant voltage controllers, provides a high bandwith to track the reference harmonic currents.In this manner, the computational cost of the AHF functionality is considerably reduced.The harmonic voltage control introduces four new differential ( 17)-( 18) per each targeted harmonic h and their corresponding state variables: The performance analysis of the AHF can be alternatively evaluated through a simplified control model in the frequency domain.This type of models allow a fast interpretation of the impact of the resonant controllers.However, they neglect some dynamics that can be critical for the grid-forming VSC stability.The simplified control model of the AHF can be found in the Appendix A.

D. Selective Harmonic Overcurrent Protection
The harmonic voltage references v h,αβ are set to zero by default in order to achieve a perfectly sinusoidal POI voltage.Ideal resonant controllers guarantee null harmonic voltages thanks to the extra harmonic current injection i h,αβ .This, however, may cause VSC overloading if these current terms are not limited.To avoid this situation, it is proposed to add an algebraic The parameters, R h and X h , can be independently defined for each targeted h-th harmonic, according to the limits imposed in the existing grid code.Larger virtual harmonic impedances can be related to harmonics with higher permissible limits.For doing so, it is proposed to use different harmonic weighting factors, σ h , to define the virtual harmonic impedances with respect to a base value as: where R b and L b represent the base virtual harmonic resistance and inductance respectively.In this way, it is possible to selectively reduce the compensation of each h-th harmonic to avoid VSC overcurrents.Table I defines a set of harmonic weighting factors considering the voltage harmonic limits imposed by the standard EN 50160.Note that the lowest harmonic weighting factor is assigned to the harmonic with the lowest limit, i.e. the sixth harmonic, while the other factors are scaled with respect their relative amplitudes A h : The base virtual harmonic impedance is dynamically adapted depending on the VSC current to prevent the overload.Note that, according to ( 21) and ( 22), the base virtual harmonic impedance could be computed as a function of the harmonic voltages, harmonic currents and the fundamental current.This work, however, proposes an adaptive approach where the base virtual harmonic impedance is linearly increased whenever the VSC current is greater than its rated current I rat .Considering that the base virtual harmonic impedance is defined as a piece-wise linear function, it is incorporated a hysteresis band ±H I s to limit the impedance variations.This band is centered around a current, I hys , below I rat , as shown in Fig. 3.If the POI current, I s , is lower than I rat , the base virtual harmonic impedance is set to zero, i.e. v h,αβ = 0, being possible to achieve a sinusoidal POI voltage.However, if I s is greater than I rat , the overcurrent limitation is activated by increasing linearly the base virtual Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.harmonic impedance as: where m r and m l are the variation rate of the base virtual harmonic resistance and inductance respectively and Δt is the controller sample time.Therefore, the VSC current diminishes, because of the harmonic current reduction, reaching I hys .From this point on, the base virtual harmonic impedance remains constant.As soon as the VSC current drops below the threshold I hys − H I s , the base virtual harmonic impedance is reduced.This leads to an increase of the injected current harmonic currents.If the VSC current reaches I hys and the base virtual harmonic impedance is not null, the VSC current is limited to this value, as shown in Fig. 3.In the case of reaching I hys but with a null base virtual harmonic impedance, it is allowed to increase the VSC current above I hys as long as I rat is not exceeded.The impact that the components of the base virtual harmonic impedance, R b and L b , has on the control algorithm is addressed in Section III.
The differential equations of the four previous subsections (1)-( 23) can be gathered into a unique state-space model which integrates the system and control dynamics:

III. SMALL-SIGNAL ANALYSIS
The aim of this section is to evaluate the stability and dynamic performance of the proposed controller.First, a preliminary computation of the controller gains according to state-of-the-art methods is carried out.Then, the non-linear state-space model of the system presented in the previous section is linearized around an equilibrium point to evaluate their eigenvalues.In addition, the stability range of each control parameter is determined to set the final control gains.

A. Preliminary Computation of the Controller Gains
This subsection proposes a preliminary computation of the controller gains shown in Fig. 1: VSG Outer Control Loop: The active power control loop is based on a PI controller.The integral gain, k ip , is calculated to obtain a given inertial response, while the proportional gain, k pp , is computed depending on the required damping factor.These gains are computed according to [15]: where H is the inertia constant, V g is the peak value of the grid voltage, and X v = 1/Y v is the virtual reactance.Similarly, the gains of the reactive power control loop are set as [7]: where S n is the rated power of the VSC.

VSG Inner Control Loop:
The virtual admittance Y v is defined as a pure inductive impedance and set to a 10% of the VSC base impedance, whereas the time constant of the LPF, τ lpf , is set to 1.6 ms [7].The proportional and integral gains of the current control loop are computed according to [44] as: where τ i is the time constant of the current controller.The value of τ i is set 10 times higher than the PWM switching period to neglect the PWM dynamics in the design of the current controller.
Active Harmonic Filtering: The resonant gains and the damping term of the resonant controllers are initially calculated according to [45]: where M p is the phase margin and ω c is the cutoff filter frequency.These parameters are usually set to π/3 and a 20% of the maximum compensated harmonic frequency respectively.The base virtual harmonic impedance is initially set to zero for obtaining a full voltage harmonic compensation at the POI.
Table II collects all these controller gains particularized for the system detailed in Table III.

B. Linearization of the State-Space Model
The stability analysis is performed through a small-signal model by linearizing the state-space equations around an equilibrium point x 0 .This is obtained by solving (25) for ẋ = 0 and a given input vector u.The analysis has been carried out  III.The inputs u have been set for a VSC injected power equal to 9 kW and 4.5 kvar.Regarding the AHF functionality, the targeted harmonics are 5th and 7th harmonics and with a null base virtual harmonic impedance.
The system is linearized as follows: leading to the small-signal model: The matrices A 0 and B 0 are the linearized version of A and B respectively.
The system stability can be evaluated around the equilibrium point by analyzing the eigenvalues of A 0 , which are shown in Table IV for the preliminary values of the controller gains.All the eigenvalues have a non-zero real part, meaning that the system is linearized around an hyperbolic equilibrium point.According to the Hartman-Grobman theorem, the system is structurally stable, so the linearized system faithfully represents the non-linear one in this equilibrium point [46].It is worth noting that the AHF functionality introduces non-conjugated eigenvalues.Particularly, the 5th harmonic compensation is related to eigenvalues at +400π rad/s (λ 18 , λ 19 ) and −600π rad/s (λ 16 , λ 17 ).Correspondingly, the 7th harmonic introduces other two eigenvalues at +600π rad/s (λ 20 , λ 21 ) and −800π rad/s (λ 15 , λ 16 ).

C. Sensitivity Analysis
This subsection evaluates the stability range of the system using the small-signal model and considering the possible variations of the controller gains and the grid impedance.For this purpose, the evolution of the eigenvalues in the complex plane are analyzed when these parameters are modified within the range detailed in Table II.The results are represented using two plots focusing on the eigenvalues of the VSG dynamics, left side, and the AHF functionality, right side, respectively.The arrows within these plots indicate the evolution of the eigenvalues with respect to the analyzed parameter.
VSG active power control loop: The integral gain k ip is inversely proportional to the inertia constant H according to (26).It has been considered that H is within the interval [0.01, 20] s, with the results shown in the top left plot of Fig. 4. The system is unstable for very small values of the inertia constant (H < 1 s).Larger H stabilizes the system, since the real part of the eigenvalues gets reduced.Therefore, H is adjusted to the required VSC inertial response but greater than 1 s to guarantee the system stability.With respect to the eigenvalues of the AHF, analyzed in the right top plot, these are barely affected by this parameter variation.Regarding the proportional gain k pp , the system stability is compromised if it is increased as shown in the bottom left plot of Fig. 4.This effect is further accentuated from k pp > 10 −3 rad/(sW) to k pp = 10 −3 , where a drastic damping reduction from 0.8 to an almost null value is noticed in λ 4 and λ 10 , both related to VSG dynamics.The effect on the AHF eigenvalues is asymmetrical, as depicted in the bottom right plot of Fig. 4. The eigenvalues at negative frequencies are consistently Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.damped, whereas those at positive frequencies get progressively separated from each other approaching to the imaginary axis.
VSG reactive power control loop: The effect of this control loop in the small-signal analysis is usually neglected in the literature as indicated in [47], [48].Fig. 5, which shows the evolution of the eigenvalues as k pq and k iq increase, reinforces this hypothesis.The proportional gain k pq has a relevant impact on eigenvalues as its value increases, but it does not threaten the system stability.Therefore, this gain is selected according to the desired VSC reactive power injection in case of a given POI voltage variation.On the other hand, the integral gain k iq has practically no effect on the dynamics as reflected at the bottom plot of the Fig. 5.

VSG virtual admittance:
The effect of the virtual conductance and susceptance are shown in Fig. 6.The virtual conductance G v has almost no effect on the system dynamics, generating just a slight shift in the eigenvalues as its value increases.In the case of B v , a slight damping reduction of most of the eigenvalues happens as its value decreases, specially when it is too small.Considering that G v has almost no impact on the the system Fig. 6.Evolution of the eigenvalues with respect to the variations the VSG virtual admittance: dynamics, the virtual admittance is set as purely inductive VSG LPF time constant: A LPF time constant equal to zero, i.e. controller without LPF, leads to an unstable system with λ 2,10 = 472.92± j10889π.The left plot of the Fig. 7 shows that as τ lpf increases the natural frequency of the eigenvalues λ 3 , λ 4 , λ 10 and λ 11 are reduced through a constant-damping path until reaching values only composed of negative real part.With respect to eigenvalues λ 2 and λ 12 , these are shifted to the left increasing the stability of the system.Conversely, the eigenvalues λ 1 and λ 13 are displaced to the right which can lead to an unstable system.On the other hand, the eigenvalues related to the AHF barely move to the left when the LPF bandwidth decreases.From this analysis, and taking into account that the objective of the LPF is to provide reference currents with the lowest possible harmonic content without affecting too much the dynamics of the current control loop, the LPF time constant is set to τ lpf = 1.6 ms.
VSG current controller: As shown in Section III-A, the gains of the PI current controller are limited by the minimum time constant of 1 ms, so the maximum considered values are: k pi = 5 and k ii = 157.Fig. 8 depicts the evolution of the eigenvalues within the ranges of k pi and k ii .The damping of the VSG and AHF increases for large values of k pi .As expected, the wider the PI controller bandwidth the better system performance is obtained.In the case of k ii , its effect is not significant on the system stability.However, this parameter depends on the resistance of the coupling filter as shown in (28).This analysis Fig. 8. Evolution of the eigenvalues with respect to the variations of the PI current controller: assumes inductors with a quality factor equal to 10, but it has to be considered that, in practice, the resistance is prone to large variations (manufacturing tolerances, temperature, material degradation, wiring, etc.).For this reason, the final value of k ii is tuned through some experimental tests to obtain a closed-loop time constant of the current controller τ i = 1 ms.
Active harmonic filtering: As mentioned above, the AHF functionality is exclusively activated for 5th and 7th harmonics.For the sake of simplicity, it has been considered k r5 = k r7 = k rh and δ 5 = δ 7 = δ h .The increase of δ h increases the damping of the AHF functionality, as shown in Fig. 9, compromising the AHF performance but without any effect on the VSG dynamics.With this regard, the best performance is achieved for δ h = 0 but with the drawback of a limited stability margin which mainly depends on exogenous damping sources.Again, δ h is a trade-off between providing a large enough AHF capability with enough damping.On the other hand, the resonant gain k rh significantly affects the VSG and AHF dynamics for values higher than 100.Particularly, the natural frequency of the AHF eigenvalues are largely affected, especially those corresponding to the negative sequence.Therefore, it is recommended a low value of k rh with the aim that the AHF capability affects the VSG performance as less as possible.Finally, it is worth noting that the bandwidth of the harmonic voltage controller, involving the cascade operation of the resonant and PI current controllers, is 2931.1 rd/s considering the final values of the controller gains summarized in Table II.This controller bandwidth is enough to mitigate 5th and 7th harmonic voltages without including additional resonant controllers in the VSG current control.
Overcurrent protection: The effect on the stability of the resistive and inductive terms of the base virtual harmonic impedance are shown in Fig. 10.The VSG eigenvalues are hardly affected, whereas the AHF eigenvalues change differently with respect to the variations of R b and L b .The resistance produces a left-side shift of the eigenvalues, increasing the damping.Conversely, the inductive term leads to an unstable system for higher values than L b = 80 μH.Therefore, it is concluded that the base virtual harmonic impedance must be just resistive.
Grid impedance: The grid impedance has been studied for a wide interval of values of R g and L g .The higher the resistance the higher damping of all the eigenvalues.Even with a null value of R g the system maintains stability.Nevertheless, eigenvalues at average frequencies, λ 3 , λ 4 , λ 10 and λ 11 , tend to move to the right, so it is expected reaching instability for extremely weak grids (e.g.islanded grids).Regarding L g , the eigenvalues are shifted to the imaginary axis as it is increased.For values higher than 1 mH and a R/X ratio of 0.07 the system becomes unstable.
Considering this sensitivity analysis, the final gains of the controllers used in the experimental validation of the proposed methodology are shown in Table II.

IV. EXPERIMENTAL VALIDATION
The experimental validation of the grid-forming VSC including AHF with overload protection has been carried out using a testbed with the one-line diagram shown at the bottom of Fig. 12.This consists of a three-phase three-wire VSC with a DC voltage source and connected through an LCL filter to a low-voltage power grid.This grid is composed of a controllable power source, being possible to add voltage harmonics, and a series impedance.The controller gains and relevant parameters of this experimental testbed are summarized in the Tables II and III Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.respectively.The AHF is exclusively activated for compensating the 2th, 4th, 5th and 7th harmonics.The experimental validation has been done through steady-state and dynamic tests which are summarized in the next subsections.

A. Steady-State Results
The AC controllable source has been adjusted to supply a fundamental phase-to-neutral voltage of 220 V distorted with the following harmonics: U 2 = 6.9 V, U 4 = 2.3 V, U 5 = 22.7 V and U 7 = 13.5 V.The active and reactive power references of the grid-forming VSC have been set to 9 kW and 4.5 kvar.Using this testbed configuration, three different VSC modes have been tested: r Test 1: (T1).No voltage harmonic compensation is applied.r Test 2: (T2).The AHF capability for the 2nd, 4th, 5th and 7th harmonics is activated but without overloading protection.
r Test 3: (T3).The AHF functionality is enabled including the proposed selective overload protection.The instantaneous VSC voltages and currents, v s,abc and i s,abc , for these steady-state tests are shown in Fig. 13, whereas their corresponding harmonic spectrum for the targeted harmonics is detailed in Fig. 14 and Table V.
Test 1 is characterized by highly distorted POI voltages which lead to distorted currents, since the current controller uses the POI voltage to track the power references.Note that the VSC current, I s , is below its rated value, I rat , since Test 1 is only focused on supplying the active and reactive power reference without any harmonic compensation.
Test 2 evidences a remarkable improvement of the POI voltage as shown in the middle plot of Figs. 13, 14 and   the THD V is reduced below a 2%.Furthermore, it is relevant to note these low THD V evidences that the rest of harmonic frequencies have not been excited by the use of the harmonic resonant controllers.This harmonic voltage improvement, however, is achieved at the cost of a high VSC harmonic current which leads to the VSC overload (106.05%).This situation can be fully prevented implementing the proposed AHF functionality with selective overload protection, evaluated in Test 3.With this regard, the POI voltage is more distorted than this of Test 2, since the AHF controller increases the harmonic voltage references with the aim of limiting the harmonic current injection.For doing so, the virtual harmonic base impedance is dynamically adjusted to limit the harmonic current, reaching a final value of R b = 0.0942Ω.Furthermore, the selective harmonic limitation using σ h is noticed by comparing the harmonic voltages of Test 2 and Test 3 in Table V and Fig. 14.Since the standard allows a greater 5th harmonic content, the AHF functionality imposes a higher reduction of the 5th harmonic current injection compared to the other targeted harmonics.

B. Dynamic Test Results
The purpose of this test is to show the dynamic performance of the proposed AHF with selective overload protection.This dynamic test has been done by modifying the harmonic voltages of the programmable AC source: from 4.6 V to 6.9 V for the 2nd harmonic, from 1.2 V to 2.3 V for the 4th harmonic, from 16.1 V to 22.7 V for the 5th harmonic and from 9.2 V to 13.5 V for the 7th harmonic at t = 7.5 s and returning to the original values at t = 17.5 s.The active and reactive VSC power references are set to 9 kW and 4.5 kvar, which lead to scenario below the VSC rated current at the beginning of the test.In this situation, the POI voltage harmonics are almost null, as shown in the top plot of Fig. 15, thanks to the injection of VSC harmonic currents.Due to the change of the source harmonic voltages at t = 7.5 s, the AHF functionality provides additional current harmonic injection to reduce the POI voltage harmonics, as shown in the two top plots of Fig. 15.As a result, the VSC current overpasses its rated value and the selective overload protection is activated by increasing the base virtual harmonic resistance as depicted in the second to last plot of Fig. 15.This linear increase is stopped when the current reaches the current I hys , set to 19 A, as previously explained with the help of Fig. 3 and the base virtual harmonic resistance remains constant up to t = 17.5 s.At this instant, the sudden reduction of the POI voltage harmonics leads to a reduction of the VSC current which overpasses the lower limit of the hysteresis band, I hys − H I s .Therefore, the base virtual harmonic resistance starts decreasing up to zero since the VSC current remains below I hys .Finally, the bottom plot of Fig. 15 shows the evolution of the average active and reactive powers throughout the test.It is observed that these remains constant in the setpoints regardless of the activation or deactivation of the AHF selective overcurrent protection.This reflects that limiting the provision of AHF to avoid VSC overcurrent does not affect other functionalities such as the provision of active and reactive power.

V. CONCLUSION
This paper has presented a selective current limitation to regulate the AHF capability of grid-forming VSCs to prevent overload conditions.A harmonic voltage reference, obtained as a function of injected VSC current and a virtual harmonic impedance, is fed to a set of resonant controllers tuned to the frequencies.The output of these resonant Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.controllers is added to the reference current of the VSG current control loop.The value of the virtual harmonic impedance for each harmonic is selected according to its relative importance within the existing power quality standard, e.g.EN 50160.This allows to prioritize the reduction of the VSC harmonic currents in overload conditions.A sensitivity analysis based on the small-signal model of the state-space equations has been done to evaluate the dynamic performance and stability of the controller as well as the influence of each controller gain.This analysis reflects that the tuning of the proportional gain in the VSG active power control loop, the proportional gain of the PI current controller, the LPF of the current controller and the virtual harmonic reactance in the overload protection is key to achieve an stable system.As a matter of fact, this analysis reveals that the suppression of the LPF and the use of the virtual harmonic reactance may lead to system instability.Furthermore, this analysis has evidenced that the proposed VSG with AHF functionality is stable for a wide range of grid impedances.
The proposal has been validated in a laboratory testbed through test cases dealing with steady-state and dynamic conditions.The steady-state results show that the controller is able to eliminate the targeted harmonic components within the resonant controllers.In addition, the controller shows a good dynamic response in transient conditions when sudden changes in the grid harmonic voltages take place.With respect to VSC overload situations, the virtual harmonic impedance strategy has demonstrated to be an efficient methodology to maintain the VSC currents within the permissible technical limits without affecting the other functionalities of the grid-forming VSC.
Future research lines will involve the analysis of unbalanced scenarios with three-phase four-wire VSCs.In addition, this local control strategy can be complemented with another centralized or distributed controller in charge of optimizing globally some network variable like harmonic distortion, imbalance or power losses.

APPENDIX A SIMPLIFIED MODEL OF THE AHF FUNCTIONALITY
The simplified model of the AHF functionality based on transfer functions using the nomenclature of Fig. 1 is represented in Fig. 16.The terms R(s) and P I(s) represent the transfer functions of the resonant controller within the harmonic voltage controller and the PI controller of the current control loop where Z p = Z s + Z g and Z e = Z t + Z s + Z g .
The Bode diagram related to G OL (s) is shown in Fig. 17 particularized with the final controller gains and parameters of Tables II and III respectively.Note that the AHF functionality has been applied just to the 6th harmonic, which represents the negative sequence of the 5th harmonic and the positive sequence of the 7th harmonic in the dq domain.As reflected in the Bode diagram, the peak magnitude is located at 300 Hz (6th harmonic) while the rest of frequencies have a magnitude lower than −50 dB.This means that the AHF functionality only acts on the 6th harmonic without affecting to the rest of frequencies of the system.This result is consistent with the experimental results depicted in Fig. 14, where only the harmonics tuned at the resonant controllers are mitigated without affecting the rest of frequencies.

Manuscript received 13
September 2023; revised 15 December 2023 and 7 February 2024; accepted 20 February 2024.Date of publication 26 February 2024; date of current version 21 May 2024.Paper 2023-PSEC-1148.R2, presented at the 2022 International Conference on Smart Energy Systems and Technologies, Eindhoven, The Netherlands, Sep.05-07, and approved for publication in IEEE TRANSACTIONS ON INDUSTRY APPLICATIONS by the Power Systems Engineering Committee of the IEEE Industry Applications Society [DOI: 10.1109/SEST53650.2022.9898155].This work was supported by Grant PID2021-124571OB-I00 funded by MCIN/AEI/ 10.13039/501100011033, by "ERDF A way of making Europe" and the European Union under the H2020 project EASY-RES (GA 764090).(Corresponding author: Manuel Barragán-Villarejo.)

Fig. 1 .
Fig. 1.Proposed controller for the grid-forming VSCs with AHF and overcurrent protection.

Fig. 3 .
Fig. 3. Overview of the hysteresis band used in the selective overload reduction.

Fig. 12 .
Fig. 12. Main components and one-line diagram of the testbed used for the experimental validation.

Fig. 15 .
Fig. 15.Experimental tests.From top to bottom: Harmonic voltages, harmonic currents, RMS current I s , evolution of the virtual harmonic resistances and active and reactive power for the fundamental component during the dynamic test.

Fig. 17 .
Fig. 17.Bode plot of the magnitude for the G OL (s) of the system.

TABLE I MAXIMUM
AMPLITUDE OF THE HARMONIC VOLTAGES ALLOWED IN THE EN 50160 STANDARD AND VALUE OF THE WEIGHTING FACTORS virtual harmonic impedance, Z h = R h + jX h , which modifies the default harmonic voltage reference in the dq reference frame as:

TABLE IV EIGENVALUES
OF THE SYSTEM USING THE PRELIMINARY CONTROLLER GAINS

Table V .
Note that the 2nd, 4th, 5th and 7th harmonic voltages are almost null and

TABLE V STEADY
-STATE TESTS RESULTS: THD, 2nd, 4th, 5th, 7th HARMONICS, VSC TOTAL CURRENT AND FUNDAMENTAL ACTIVE AND REACTIVE POWERS