Power Quality Improvement through a UPQC and a Resonant Observer-Based MIMO Control Strategy

: Performance degradation is, in general, regarded as a power quality problem. One solution to recover grid performance is through the application of a uniﬁed power quality conditioner (UPQC). Although these devices are multi-input/multi-output (MIMO) systems, the most common control strategies consist of two decoupled controllers, which neglect the coupling effects and add uncertainty to the system. For this reason, this paper proposes a multivariable resonant observer-based control strategy of a UPQC system. This method includes all signiﬁcant coupling effects between this system and the grid. This strategy results in a stability-based compensator, which differs from recently proposed strategies that are based on signal calculation and cannot assure closed-loop stability. In addition, this paper introduces a simpliﬁed controller tuning strategy based on optimal conventional methods without losing closed-loop performance. It implies that the controller can be easily tuned, despite the complexity of the MIMO dynamic model. The UPQC with the resonant observer is veriﬁed on an experimental setup for a single-phase system, obtaining three relevant results for power quality improvement: (1) harmonics compensation tested with a total harmonic distortion limit of 5%; (2) sags and swells mitigation; and (3) power factor correction, achieving a unitary value on the grid side.


Introduction
Power quality (PQ), as defined in the recommended practice IEEE-1159-2019 [1], establishes some characteristics for both the voltage and current signals to achieve good performance for a grid and its connected load. This concept provides some limits for electromagnetic phenomena based on the Electromagnetic Compatibility Standards defined by the International Electrotechnical Commission (IEC). Some of these phenomena cause performance problems for both grids and the connected loads. Voltage disturbances such as sags swells and harmonics cause issues that could lead to damage or malfunctions of loads. Furthermore, if a nonlinear load is connected, current harmonics cause a loss of grid performance. With non-pure resistive loads (whose power factor is different from one), the grid provides reactive power, which increases the drawn current, the losses, the maintenance, and the costs of the power system.
The power electronics field has provided several solutions for PQ compensation to improve grid performance and robustness. Some solutions such as the dynamic voltage restorer (DVR) for handling voltage disturbances include [2,3], which provide voltage harmonics and amplitude variations compensation. Another solution is the active filter [4,5], whose main objective is to reject current harmonics caused by nonlinear loads. Both solutions (DVR and shunt active filter) use DC/AC converters, with the main difference being the DVR is series-connected with the power grid, while the active filter is shunt-connected with the load. A back-to-back connection between the DVR and the active filter allows the simultaneous compensation of voltage and current. This connection comprises a unified power quality conditioner (UPQC).
UPQC open-loop operation does not assure internal stability and suitable performance. Therefore, the UPQC model uses linear averaged approximations to obtain a closed loop based on two decoupled control systems, as shown in [6]. However, there are coupling effects between the power converters and the grid [7] that must be considered in the system model to prevent undesired behavior in transient events such as sags, swells, and load changes. However, some control strategies have been explored with satisfactory steadystate results, as shown in [8,9], who proposed resonant and repetitive controllers on a decoupled UPQC model. Those strategies are considered the best options to assure robust performance for reference tracking and disturbance rejection for periodic sinusoidal signals with stability-based control.
Thus, to avoid unmodeled coupling effects, this paper proposes a MIMO model for a UPQC, and the control system uses a resonant extended state observer. This design allows direct disturbance rejection and reference tracking. The resonators reject grid voltage and load current harmonics that usually appear in a conventional grid-load connection, such that the load voltage and the grid current follow the IEEE-1159-2019 standard [1]. Additionally, the proposed control architecture is oriented to mitigate grid voltage amplitude variations through transient design and DC-link constant-voltage control.
Resonant observers have been extensively used for energy applications as grid-tied inverters [10,11], interconnection of solar PV systems to the grid [12], and mechanical applications in robotics and joint control [13]. All of these approaches use a resonant system to reject specific frequencies.
In addition, the literature shows few applications of MIMO-based multiple-resonant observer, and there are no researchers that used this strategy in UPQC systems. Some recent advances in UPQC control show the tendency to use a signal calculation control philosophy for the PQ compensator instead of using stability-based controllers that avoid instability in the UPQC operation, as in [14,15]. Therefore, the main contributions of this paper are: (1) We adapt the resonant control technique in the form of a multiple-resonators MIMO observer-based control strategy applied to a UPQC system. This strategy considers the coupling effects between the UPQC stages (converters and DC link) and the grid. This model reduces the uncertainty of the coupling effects, and the resulting control system is more accurately tuned than other stability-based proposals such as [8,9]. (2) This work proposes a simplified optimal conventional-based tuning method for the control system so that the high-order MIMO model (with multiple resonators) can be tractable with an easy-tuning method without closed-loop performance loss. In [15], some intelligent control strategies are described with similar performance indexes for PQ disturbances compensation to the work presented here. However, the intelligent control techniques are not oriented to achieve the internal stability of a grid-tied UPQC, while this paper describes a stability-based design. Other recent advances, such as [14,16], provide signal-based control without any UPQC dynamic model. Instead, they apply either advanced PLL, PV-based DC links, or Kalman filters to obtain the correct signals for the power converters. Those mthods have some drawbacks: usage with decoupled controllers in each power converter with many sensors, and complex DC-link stages based on photovoltaic cells. The method presented in this document uses fewer signal measurements and does not need complex designs for the DC link. Moreover, the design considers all coupling effects in the UPQC with the grid, and the design is stabilitybased. Therefore, this method is more cost effective in an implementation environment, assures internal stability in the design stage, and achieves acceptable performance in PQ improvement.
The main results for the control system implementation were obtained in an experimental environment, describing five relevant functionalities related to a PQ improvement: (1) The UPQC compensates for the harmonics for both the load voltage and the grid current, obtaining a total harmonic distortion (THD) index if less than 5%, ac-cording to the limits described in the IEEE-519-2014 [17], IEEE-1547-2018 [18], and IEC 61000-3-2:2018+AMD1:2020 [19] standards. (2) The UPQC achieves a steady state within a half sinusoidal cycle. Then, the connected load has sag and swell immunity because the time response is less than the minimum time for an instantaneous sag or swell specified in the IEEE 1159-2019 standards [1]. (3) The UPQC performs a power factor correction (PFC) function, achieving reactive power compensation despite the connection of any load. (4) The DC link voltage remains in a desired constant value, despite the transient events of grid voltage amplitude variations or load changes (connection or disconnection events). (5) The proposed control system on the UPQC prevents saturation of the control signals to avoid undesired or uncontrolled behavior.
This document describes the control system design process for the PQ compensator, where the next section depicts the UPQC and constructs an input-delay MIMO discretetime model for an experimental setup with a digital platform. Based on well-defined control objectives, the next section depicts the resonant extended state observer-based control design. The following section describes the experimental setup for a single-phase system to verify the UPQC control architecture.

System Model Description
This section explains the dynamic model of the UPQC with coupling effects and DClink dynamics considerations. The first subsection describes the UPQC continuous-time model based on conventional circuit analysis. The second subsection describes the MIMO discrete-time model with an input delay with consideration of a constant-voltage DC link. The third subsection depicts a separate DC-link discrete-time model such that these dynamics can be considered in the control system design. The last subsection discusses the necessary key points to suitably select the sampling time for the discrete models. Figure 1 depicts the main stages of the UPQC. This system consists of three main parts: the series converter, which has DVR features (compensates all grid voltage variations); the shunt converter (compensates current harmonics like an active filter); and the DC link. Both power converters have LC filters to ensure smooth injected current and voltage to the grid. Furthermore, the UPQC has an injection transformer that isolates the DC-;ink nodes from the grid to avoid short circuits, as described in [20]. The main DC link feature is to keep an energy balance for the entire system. The shunt converter maintains a constant value for the DC link.

UPQC Stages and Continuous-Time Model
The UPQC compensates the grid voltage disturbances to provide suitable load voltage. Additionally, the load current is compensated to achieve a desired grid current. Thus, following the Kirchhoff laws based on Figure 1, the main compensation equations are: where the compensated load voltage v L (t) is based on the disturbed-grid voltage v s (t) and the UPQC injected voltage v inj (t). The grid current i s (t) depends on the disturbed load current i L (t) and the shunt converter injected current i inj (t). In addition, the UPQC has a series converter current i se (t).
To construct a dynamic model, the grid-tied UPQC is transformed to an equivalent model, as depicted in Figure 2 [21]. As the UPQC should compensate for PQ disturbances in most connected loads, the disturbances are modeled as uncertain independent current sources. The parameters of the series LC filter are the filter inductance L se , the inductor loss resistance R se , and the filter capacitance C se . The shunt converter has similar parameters for its LC filter: L sh , R sh , and C sh . The line inductance and the line resistance, L l and R l , respectively, describe the grid losses and represent a simplified equivalent model for the injection transformer. The transformer has a ratio of 1:1 so that the series LC filter parameters do not change due to impedance transformations.  Subsequently, applying the Kirchhoff laws to the equivalent circuit and transforming the resulting equations in state space, the continuous-time UPQC model results in with The state matrix is A c , the input matrix is B c , the output matrix is C c , and the state disturbance matrix is E c . So, the continuous-time model has an order of n c = 5, a number of inputs p = 2, a number of outputs q = 2, and two state disturbances. The state vector for this model is x c = i s i se i inj v inj v L T . The output of the continuous-time model (which has the controlled variables) is described by the vector The input vector is defined as u(t) = u 1 (t) u 2 (t) T and describes the voltage control signals that supply each power converter (modeled as dependent voltage sources in Figure 2) to achieve suitable injected current and voltage. The power converters are controlled through PWM (whose control variable is the duty cycle d(t)). Then, the relationship between the control signals and the power converter duty cycles using an unipolar switching is where µ i (t) is defined as an averaged PWM input signal and has amplitude limits on the interval −1 1 . The input voltages applied to the equivalent circuit in Figure 2 are defined as u i (t) = µ i V dc , with the parameter V dc as the constant voltage of the DC link based on the approximation v dc (t) ≈ V dc . The DC link voltage is approximated as a constant in this continuous-time model (despite the DC capacitor dynamics in this stage that produce a variable v dc (t)), to maintain an LTI model for the UPQC. So, the control signals of u(t) depend directly on the DC link constant value and have amplitude limits in the interval −V dc V dc . The numerical value of V dc is shown in Table 1.
Both the grid voltage v s (t) and the load current i L (t) are assumed to be sinusoidal signals with odd harmonics and are embedded in a disturbance vector δ(t) as follows: with ω 0 as the fundamental grid frequency. The UPQC model considers odd harmonicbased disturbances because they are the most common components that appear in a grid-load system, as explained in [22] for current harmonics (given by linear and nonlinear loads) and [23] for voltage harmonics.

UPQC Discrete-Time System Model
After defining the continuous-time model, a zero-order hold (ZOH) approximation is applied according to the infinite series method based on [24]: where the time is approximated as t = kT m , k is the sample number, and T m is the sampling period. The discrete-time state-space matrices are defined with the subscript d. The infinite series approximation is achieved through numeric solvers. The output matrix remains equal using the aforementioned discretization method. Then, the resulting discrete-time model of the UPQC is where an input delay is included due to the dynamics of the PWM interfaces used in the experimental setup. The time delay is depicted as a sample-integer number τ and is considered equal for both PWM interfaces in each power converter. Moreover, the input-time delay can be represented as a different system G ret connected to the input port of the UPQC model, as shown in Figure 3. Here, the UPQC system is considered as G pd and the vector u d (k) is the output of the delay system. Version July 28, 2021 submitted to Energies 6 of 20 Using the block reduction for the diagram of Figure 3, the 171 UPQC discrete-time model with implicit input delay is shown in (8). The dimensions for 172 the zero matrices in the system model are defined as 0 a ∈ R 2τ,n c , 0 b ∈ R n c ,2 , 0 δ ∈ R 2τ,2 173 y 0 s ∈ R 2,2τ . The entire system order is n = n c + pτ. The system with input delays is 174 considered as an augmented model with the states of both the UPQC and the time-delay 175 system. This scheme has the main advantage that the control design could be applied on 176 a non-explicit delay model. is composed by a capacitor that has an associated dynamics. Therefore, this stage must 181 have its own control system to avoid instability in the UPQC. Then, considering the node 182 Figure 3. Input delay separation for the UPQC system model.
Then, the state-space representation of the time-delay system is defined as with Using the block reduction in Figure 3, the UPQC discrete-time model with implicit input delay results in The dimensions for the zero matrices are defined as 0 a ∈ R 2τ,n c , 0 b ∈ R n c ,2 , 0 δ ∈ R 2τ,2 and 0 s ∈ R 2,2τ . The entire system order is n = n c + pτ. The system with input delays is considered as an augmented model with the states of both the UPQC and the time-delay system. This scheme has the main advantage that the control design can be applied to a non-explicit delay model.

DC-Link Discrete-Time Model
As shown in the previous section, the DC link voltage in the UPQC model is considered as a constant value to avoid a nonlinear model. However, in the experimental setup, this stage is a capacitor that has associated dynamics. Considering the node analysis based on Figure 4 and the ZOH method, the discrete-time dynamics of the DC link are where the DC link current is defined as i dc (k) = i se (k) + i inj (k) and C dc is the capacitance of the DC link. The sampling period for this model is considered equal to the UPQC.

Sampling Period Selection
The discrete-time model eigenvalues (whose imaginary part must be less than π/T m ) are the main criteria to choose the sampling period [24]. Additionally, this selection is related to both the cutoff frequency of the LC filters and the switching method applied to the power converters. For this case, a unipolar switching method is used based on the reduced harmonic content of the power converters compared with the bipolar technique [25]. This switching method assures that the LC filters can attenuate switching harmonics with high reliability. Therefore, as the cutoff frequency of an LC filter is given by f c = 1/ √ LC, a recommended criterion to achieve an attenuation higher than 40 dB for the switching harmonics is f s ≥ 5 f c . According to [26,27], the recommended sampling period for the discrete-time models should be equal to the switching frequency on the PWM interfaces ( f m = 1/T m = f s ). However, the recommendation by [26,27] considers the measurement and sampling of unfiltered signals. If the measured and sampled signals of the control system are filtered (on the LC filters outputs), the sampling frequency could be less than the switching frequency.
However, if f m f s , an aliasing effect takes place on the sampled and measured signals, while an oversampling with f m > f s causes unnecessary digital platform CPU usage. Consequently, the feedback controller could not be supported. Therefore, if Λ c is the largest imaginary part of all the eigenvalues of the continuous-system model, the criterion to choose the sampling frequency should be and the resulting discrete-time model will have the imaginary part of the eigenvalues in

Control System Design
This section explains the feedback control system design based on specific control objectives and an observer-based architecture. The first subsection outlines the control system objectives. The second subsection describes the control system architecture with details for each stage. The third subsection describes the tuning and design of the resonant MIMO observer. The fourth subsection explains state feedback control based on an LQR tuning and design method. The fifth subsection provides details of the UPQC control law and some technical requirements to achieve the desired closed-loop performance. The last subsection describes a proportional-integral (PI) compensator design to achieve a constant voltage in the DC link stage.

Control Objectives
Based on the IEEE-1159-2019 standard, PQ issues could be compensated if the following objectives are assured in the closed loop: • The feedback control must track desired pure sinusoidal reference signals so that the grid current and the load voltage can be free-distorted. Similarly, as the disturbance vector δ(k) causes harmonic content on the controlled variables, the feedback control system must reject the grid voltage and the load current. According to the IEEE-519-2014 standard, the THD index for the voltage and the current (with low current consumption on the common connectionpPoint) must achieve the condition: where F depicts either a voltage or a current signal. F i is the magnitude for the ith harmonic and F 1 is the magnitude of the fundamental component. • The power factor on the grid side must be 1. Therefore, the reference vector r(k) is defined with the variable φ as the grid voltage phase. The load voltage should have the same phase as v s to avoid phase jumps in loads. The current reference i * s must have the same phase of v s to achieve the desired power factor correction. The parameter f 0 is the grid fundamental frequency. As a result, the reference signals are defined as • The control system must achieve the steady state in a time less than a half sinusoidal cycle. This condition assures that the sags and swells will be imperceptible on the connected load according to the definition of a sag or swell in the IEEE-1159-2019 standard. Defining the settling time of the control system as t ss , the transient time objective should be Similarly, during a sag or swell event, the load voltage amplitude must be in the interval of 0.9 ≤ V L V * L ≤ 1.1 following the same IEEE standard. • To avoid saturation in the PWM interfaces, the control signals u i (k) must not exceed the interval limit −V dc V dc (Table 1 lists the numerical value of V dc ). For the case of µ i (k), the available magnitude is within −1 1 .

•
The DC-link voltage must remain at a constant voltage V dc and the settling time for this stage should be 10 to 100 times lower than t ss [28]. It implies that the DC-link variations due to transient events could be seen as static in the UPQC closed-loop dynamics.

Control Architecture
There are many control architectures, as proposed in [29], which use a robust outputfeedback approach to achieve the mentioned control objectives. However, this work proposes an observer-based approach with a discrete-time model description, so that a direct estimation and rejection of the coupled disturbances could be applied in the control law. The proposed control system architecture is shown in Figure 5. As the UPQC model is entirely controllable and observable, the state disturbance δ(k) could be transformed to an equivalent input disturbance ξ(k) that is added to the control input u(k). The extended state observer (ESO) can estimate both the UPQC states and the input equivalent disturbance ξ(k). If the estimated disturbanceξ(k) is close to ξ(k), it could be subtracted directly on the UPQC input port to achieve disturbance rejection.
The ESO features reference tracking if the observer input is the error vector defined as e(k) = y(k) − r(k) instead of y(k). This characteristic is associated with a regulation control law that leads the plant states to the equilibrium point, such that the tracking depends only on the observer dynamics. Thus, an estimated state feedback design results in the matrix K to achieve that regulation. The DC link is related to the UPQC through the output vector c dc , where a sum between the states i se (k) and i inj (k) is performed to obtain the DC-link current i dc (k). Next, using the capacitor dynamics in (9), v dc (k) is controlled through the PI compensator to track the desired constant value V dc . In addition, the PI control signal corresponds to the grid current reference magnitude, and it is multiplied by the grid-voltage-based unitary sine wave to achieve the sinusoidal grid current reference i * s (k). This nonlinear operation of the DC link control loop performs an energy balance on the grid-tied UPQC.
In conclusion, the control system design for the proposed scheme consists of tuning the ESO, the state feedback matrix K, and the PI control of the DC link.

Resonant Extended State Observer Design
The extended observer must have the disturbance model in its design. Both the reference and the disturbance vector can be described through the same disturbance model since they are sinusoidal signals. One method to represent sinusoidal signals involves using repetitive control, as in [30,31], but it implies a very high system order of the closed loop. Another option, is the use of resonators which could be applied to estimate sinusoidal components. According to [32], the discrete-time representation of a single resonator is and it enforces an infinite gain at a fixed frequency ω, such that the observer can exactly estimate a pure sinusoidal signal of the same frequency. If the ESO must estimate several frequencies, the observer should consider several single resonators (called here a compound resonator). Based on δ(k), the control system must reject many harmonics, but the limitation is related to the closed-loop order. The system order increases two units per resonator into the ESO. If the order is higher, the control system will require more CPU usage of the digital-experimental platform. Thus, the most significant harmonics decide the resonators tuning for both v s and i L . Additionally, as the UPQC controls two variables and rejects two disturbances, different resonators must be considered for each signal type (current or voltage). Hence, the pair v s and v L will have a compound resonator, while i s and i L will have another one. Using these two compound resonators, a compact resonator is achieved with h v single resonators for the voltage and h i single resonators for the current signals. According to the control objective, the most significant frequency harmonic components decide the number of resonators to achieve a THD of less than 5% .
The frequency for each single resonator is defined as ω j = 2π(2j − 1) f 0 with j ∈ N and 1 ≤ j ≤ h v for the voltage compound resonator and 1 ≤ j ≤ h i for the current resonator. Hence, the compact state-space model representation of disturbances and references is where the model dynamic matrix is A ξ = diag A v1 , A v2 , · · · , A vh v , A c1 , A c2 , · · · , A ch i , with the subscript v or c representing either the voltage or current resonator, respectively; and A vj and A cj are the dynamics matrix for the jth single resonator with the same elements of A R in (14). The output matrix is T with c ξ1 = c v1 c v2 · · · c vh v 0 1,2h i and c ξ2 = 0 1,2h v c c1 c c2 · · · c ch i . The matrices c vj and c cj has the same structure as c R in (14). The state vector of the disturbances and references model is After defining the disturbance model, the extended state observer follows a Luenberger model plus the compact resonator (15), resulting in where the observer gain matrix is defined as The zero matrices are 0 1 ∈ R n,m y 0 bξ ∈ R m,p . The vectorx(k) has the UPQC-estimated states andx ξ (k) has the estimated states of the disturbances model. The observer outputs are the plant-estimated states inx(k) and the estimated coupled disturbances from the vectorξ(k). The ESO design results in the matrix L definition based on the control objectives. This matrix can be achieved through pole placement or complex optimization techniques, as shown in [33]. However, a straightforward tuning method to find a suitable design is the linear quadratic estimator (LQE), which follows the minimization of the cost function where the weighting matrix Q o assigns bounds for the state signal amplitudes, while the matrix R o assigns a weight for the input ones. High values of Q o limit the amplitude of the state signals and, hence, the time response of the closed loop tends to increase. In the case of R o , high values limit the magnitude of the error vector e(k).
The selection of the weighting matrices for J o can follow different strategies, such as the Kalman-Busy filter method used in [34], who used diagonal matrices for Q o and R o . This matrix structure allows high versatility to assign different weights per state (UPQC states or resonator states) and per input signal. Therefore, Q o = diag Q e Q ξ is a block diagonal, with Q e = α · diag a 0.1a 0.1a 0.1a a bI 2τ , α, a and b are tuning parameters, and I 2τ ∈ R 2τ,2τ is an identity matrix. The matrix Q e assigns weights to each UPQC state with high penalization of the controlled variables (first and fifth state), so that the overshoots on i s and v L can be avoided. To achieve a fast response, the other UPQC states have a lower weight. The parameter b assigns a weight for the delay model states, and is assigned through iteration until the ESO results are stable.
The matrix Q ξ assigns weighting values per state for the compact resonator model into the ESO. The structure of the internal model weighting matrix is Q ξ = (I 2 0.1I β I f requency.The f u2 . 0.01I β , where different weights per single resonator states are assigned according to its tuned ndamental component resonator has a higher weight than the harmonics to achieve disturbance rejection. The identity matrices I 2 and I β have dimensions of 2, 2 and β, β, respectively, with β = m 2 − 2 and γ as a tuning parameter. The input weighting matrix is defined as R o = I 2 , where one value defines the weight for both error signals in the vector e(k). If a low value of is assigned, the ESO will have high sensitivity to noise effects in y(k), while a high value of this variable causes a slower transient response of the entire closed loop.
The solution for the optimization problem based on the cost function (17) consists of calculating a definite positive matrix P o in the following Riccati equation (based on the general problem described in [24,35]): The gain matrix L ∈ R (m+n),q is calculated as based on the Riccatti solution matrix P 0 . The gain matrix achieves a regulation law so that the dynamics imposed by A ex − LC ex minimize the cost function J o .

State Feedback Design
The state feedback design results in the calculation of the matrix K. Here, we use a linear quadratic regulator (LQR) algorithm based on the cost function J c , whose definition is By the separation principle [24], the state-feedback regulator can be designed without considering the observer. Therefore, the cost function depends on the UPQC model states and the input vector u(k). The state feedback control leads the states to an equilibrium point, so that lim k→∞ x(k) = 0 based on u = −Kx.
The weighting matrices Q c and R c are diagonal, similar to the ESO design; hence, Q c = ρ · diag a 0.1a 0.1a 0.1a a bI 2τ . Empirically, we find that ρ ≥ 1000α is a good scaling parameter for tuning the state feedback because it achieves a settling time difference between the observer and the regulator. The main idea is to obtain a faster ESO response than the stabilization law, so that the estimated statesx(k) can be fed back with gain matrix K. This criterion assures that the state feedback stabilizes the closed loop using the estimated states. The control weighting matrix is defined as R c = νI 2 with ν ≥ 1000ε, such that the stabilization law applies the suitable control signals after the ESO achieves the steady state. The solution of the optimization method for the stabilization law is related to the following Riccati equation: with Based on the solution matrix P c of above equation, the state feedback matrix is calculated as:

Control Law and Closed-Loop Dynamics
Using the designs for the ESO and the stabilizing matrix K, the control law for the UPQC control system is A good-performance closed loop is achieved if ξ(k) ≈ξ(k), where all disturbances can be rejected appropriately and the controlled variables have a THD less than 5%. The time response t ss reaches the limits if the weighting matrices generate suitable eigenvalues for the matrices A ex − LC ex and A − BK. Saturation is avoided with the appropriate selection of the weighting matrix R c in the LQR algorithm because this matrix is directly related to the magnitude of the control signals u i (k).
The closed-loop dynamics yields system G cl as with x cl = x e oxξ T , and v = r δ T . The vector e o (k) = x(k) −x(k) is the estimation error.

PI Control for DC Link
A DC link needs a control system based on the associated control objective. Therefore, a block reduction in the control scheme in Figure 5 is proposed in Figure 6 to achieve a suitably tuned PI controller. On the basis of the G cl state equation, and having a new output vector c dc = c 2 0 dc with c 2 = 0 1 1 0 0 (to obtain the i dc (k) value) and 0 dc ∈ R 1,2τ , the new system G clc is defined. Subsequently, the resulting system G dc from the cascade of the DC link discrete-time model G pdc and G clc yields:

(a)
As the control output of the PI block is the magnitude of the grid current reference, the system G dc has a single control input depicted as i * s (k), while the other three components of v(k), which are v * L (k), v s (k), and i L (k), are considered as state disturbances. Thus, a frequency domain reduction is proposed to achieve a plant model, such that a unity feedback control loop can be reached, as shown in Figure 6b. The frequency domain model for the state-space representation of (25) is depicted as where G 1 is the transfer function from i * s to the output v dc ; G 2 , G 3 , and G 4 are the transfer functions from v * L → v dc , v s → v dc , and i L → v dc , respectively. The variables ϑ 1 , ϑ 2 , and ϑ 3 represent the effects of those disturbances on the DC-link voltage.
The PI compensator is tuned based on the analysis of the sinusoidal disturbances rejections on ϑ 1 , ϑ 2 , and ϑ 3 ; the transfer function G 1 ; and the linear approximation of i * s ≈ I * s . Thus, with classic control tuning techniques such as root locus, the approximated closed-loop eigenvalues are achieved. The main idea is that the PI controller must have low bandwidth to achieve both the slow response of the DC link and the desired attenuation of the described sinusoidal disturbances. The PI controller follows a backward Euler method: with P and I being the PI constants achieved with the desired tuning.

Experimental Setup and Results
This section describes the experimental setup and the key results, divided into harmonics compensation for the load voltage and the grid current, power factor correction (PFC) on the grid side, and grid amplitude fluctuations mitigation in the load voltage. The implementation considered a single-phase system, but the controller could be applied to three-phase systems using the Clarke stationary-frame transformation, as in [36], where the controller is the same for both the α and β components.

Experimental Setup Description
The UPQC control system was implemented on the experimental setup shown in Figure 7. The experiment had a grid emulator that generated the PQ disturbances as grid voltage harmonics, sags, and swells. The grid emulator consisted of a diode bridge connected to a common AC line, a power module STK581U3C2DGEVB DC/AC converter [37], and an LC output filter. This emulator had a feedback voltage control system that was implemented with the DSP Texas Instruments Delfino C2000 TMS320F28335 (Texas Instruments; Dallas, TX, USA) [38].
The UPQC consisted of two STK581U3C2DGEVB modules: one for the series converter and the other for the shunt converter. Each power converter had output LC filters, and those were tied to the injection transformer (for the series compensation) or shunt-connected to the grid according to the circuit diagram in Figure 1. The modules STK581U3C2DGEVB had DC-link capacitors that allowed connecting both power modules back-to-back. The output LC filters are based on power toroidal inductors and polyester film capacitors to achieve good performance against harmonics, and Table 1 lists their values. The inductance values followed the identification process detailed in [20].
The overall MIMO control system for the UPQC was programmed in another DSP TMS320F28335 using the tuning parameters in Table 1 for the ESO, the state-feedback loop, and the PI controller. The digital platform acquired voltage and current signals from LEM LV25P, LA-55P, and HX10-P through a signal conditioning stage. The output PWM signals from the DSP transmitted to the power converters through a voltage-level conditioning stage.
Lastly, the experimental setup had a load connection stage for connecting different linear and nonlinear loads. In the implementation, we used this stage to analyze current disturbances caused by any load and to show the UPQC's reactive compensation feature.

Harmonics Compensation
The main objective of the UPQC in terms of harmonic compensation is to reduce the THD index of the load voltage v L and the source current i s despite the grid voltage v s and the load current i L being highly distorted. The results shown in Table 2, with some experimental evidence in Figure 8, depict the desired harmonic compensation performance in both controlled signals. The table shows several load-changing experiments using resistive loads, RL loads, and nonlinear diode bridge-based loads with a parallel fixed capacitance and a per-experiment varying resistance. In each experiment, we applied a different kind of connected load that caused harmonic components and RMS variations in the grid emulator voltage v s .
The results in Table 2 and the measured THD values in Figure 8 for the specific experiment RNL_50 show that the UPQC with the proposed controller achieves THD values below 5% for v L and i s , despite the high harmonic content in the disturbed signals. In addition, the UPQC compensates for the v s amplitude to the desired RMS value on v L .
According to the Table 2, the THD for the grid current increases when the load consumption lowers because this index is a relative quantity. If the fundamental value is lower, the ratio between it and the sum of the amplitude of the harmonics will be lower. Therefore, as the load impedance was high in experiments RNL_80 and R_50, both the load and the grid currents had low amplitude, and the THD increased. For the load voltage, as the fundamental amplitude was higher than the harmonics, the THD percentages were low. For the RNL_80 experiment, as the load was nonlinear and had a high impedance, the load current harmonics with frequencies higher than (2h i − 1) f 0 had a significant amplitude compared with the fundamental frequency and, hence, the grid current THD approached the limit.

Power Factor Compensation
The UPQC can compensate for the power factor on the grid side due to i * s , which has the same phase and frequency as the grid voltage. A unitary power factor on the grid side avoids the reactive power flux from the load to the grid. In Table 3, the results show the unitary power factor on the grid side for various loads and and experiments. The table shows that the reactive power of the grid is reduced to zero, while the UPQC supplies the required Q L for connected lagging-linear or nonlinear loads. On the other hand, this effect does not occur on pure-resistive loads because they do not require reactive power from the grid. However, the power losses in the PQ compensator cause an increase in the grid active power P s compared with P L . The active-power losses depended on the load impedance in each experiment, where low impedance resulted in high UPQC currents and, thus, higher power losses.
The power factor compensation is also demonstrated by the phase shift of i s and v s , where it must be zero to achieve a unitary power factor. Figure 9 depicts the results of the power quality analyzer and oscilloscope, where the phase shift between the grid voltage and the grid current is zero.

Sags and Swells Compensation
The sags and swells were tested on a resistive load of 50 Ω, and the sag response for the UPQC is shown in Figure 10a, where the grid emulator generated a 70% sag (0.7V s ). The UPQC responded within a time of t ss ≈ 1 4 f 0 = 4 ms, which is less than a half cycle; therefore, the control objective was achieved because v L does not change the amplitude despite the sag event on v s . For the swell event, shown in Figure 10b, a 20% variation (1.2V s ) was applied, obtaining the desired results in terms of response time and no overshoots in the transient regimen. Here, the sags and swells had a time duration of 250 ms and showed the transients of both the event start and the recovery.
When an amplitude variation occurs in the single-phase grid, the DC link stage changes its voltage by the power flux variation in the entire system. Figure 10c shows the transient regimens of the DC link controlled by the PI stage for the sag event. The duration of the transient state for the DC link for both the event occurrence and the recovery is near to 100 ms, which is 25 times higher than the obtained t ss . Regardless, the PI control system can recover the desired V dc value so that are changes neither in the DC-link voltage, nor the event compensation, nor in a normal mode.

Conclusions
This paper proposed a control system based on a resonant extended state observer to achieve disturbance rejection and reference tracking for sinusoidal signals using a unified power quality conditioner. As a difference from other related methods, the control system is MIMO and is based on a multivariable plant model. It helps to set the internal stability statement considering all coupling effects given among the power converters and the grid-load system. As a result, the UPQC achieves harmonics rejection for both current and voltage signals, power factor correction, and sags and swells compensation.
The input delay UPQC model is essential to design stable control systems on the experimental setup that has PWM generators with this characteristic. If the UPQC model does not consider input delays, robust stability in the closed-loop design cannot be assured. The discrete-time control design ensures accurate resonators instead of working with a continuous-time design and subsequently applying a discretization method on the closed loop.
If the number of single resonators increases in the control system, higher performance is achieved. However, the digital platform, which supports the control system implementation, limits this number of resonators. As such, the designer should choose the higher-magnitude harmonic components so that the total harmonic distortion is below 5%.
The UPQC with the proposed control system achieves harmonic compensation, providing better performance with low impedance loads. However, the proposed closed loop fulfills the control objective of avoiding harmonic distortion with a THD lower than 5% in all experiments. Similarly, the UPQC can compensate for the power factor so that the grid supplies only active power to the connected load, despite its kind. The reactive power on the grid side is zero due to PFC, while the grid active power slightly increases compared with the load active power due to the PQ compensator losses.
The control system on the UPQC achieves compensation of the voltage amplitude variations such as sags and swells with a short settling time. The transient regimen experiences no overshoots either in the event start or in the recovery. The DC link experiences mild changes in its voltage that assure UPQC stability in those variations.
The proposed closed loop shows high PQ compensation performance for the load voltage and the grid current. The control system is versatile in achieving desired transient regimens and providing the desired steady-state operation during events of harmonic distortion, sags, swells, and power factor deviations. The proposed design was verified on an experimental setup, obtaining desired results according to the IEEE standards and technical recommendations.