1 Introduction

Reductions in greenhouse gas emissions, competition policies, diversification of energy sources, and global power requirements have given rise to the interest in micro-grid (MG) schemes [1]. Use of distributed generation units imposes various power quality related problems in distribution networks such as voltage sag or swell, reverse power flow, voltage imbalances, harmonic distortion, and interruptions [2]. The high penetration of renewable power generating resources interfaced with power electronic devices in microgrids along with increased none-linear loads has attracted the attention to develop dynamic and adjustable solutions to cope with the power quality problems. In this regard, use of custom power devices such as UPQC can provide effective means for addressing poor power quality in grids connected or islanded MGs.

The UPQC employs two active power filters (APF) (voltage source inverters) which are connected to a DC link capacitor. One of these two APFs is connected in series with the AC line, while the other is connected in shunt with the same line [3]. To eliminate negative sequence currents and harmonics shunt, an active filter will be in operation with series active filter reducing voltage distortion and imbalances. Several research works have been conducted on control schemes for UPQC's filters for obtaining flexible control algorithms and fast tracking response to obtain the inverters' switch control signals [4,5,6]. Artificial Intelligence (AI) methods are currently under extensive application in this regard to offer global optimum or closer global optimum values for switching signals. In [7], genetic algorithm (GA) was applied to determine the parameters of the shunt and series active filters. The artificial neural network (ANN) was considered as a tool to design control circuitry for UPQC in distribution network in [8]. The AI tools are able to give solutions to power system problems if the problem features and the AI tool features match each other. Further, depending on the initial values, hardware dependence, premature convergence, and tracking local optimum are the demerits that reduce trust in an AI-based controller performance [9, 10].

There are also a number of classical control schemes for UPQC. In [11], a mixed linear quadratic regulator with an integral action control technique was applied to a UPQC to keep regulation and stability under sever load variations. Elsewhere, [12] presented a classic discrete-time control model for a three-dimensional space vector pulse width modulation (3D-SVPWM) to be used with a dual UPQC, for obtaining a fixed commutation frequency and a low computation cost. Classical approaches for obtaining optimum control use time-consuming trial and error and provide suboptimal control when several parameters are to be optimized at the same time.

This paper presents real-time control of a unified power quality conditioner using second-order ESO-based sliding mode controller (ESOSM) to improve the power quality of MGs. Distinguishing features of the sliding mode control such as insensitivity to bounded matched uncertainties, order reduction of sliding motion equations, decoupling design procedure, and zero-error convergence of the closed-loop system are the main motivations for choosing ESOSM as the UPFC control method [12].

Besides, numerous research projects carried out to improve fabrication technology, evaluation and test scheduling of semiconductors in control circuitry. The results of these projects can easily be implemented in UPQC's control circuits. In [13, 14] different techniques for minimizing test time in system on chip (SoC) overviewed and new methods introduced to reduce production costs of controlling microchips by minimizing the test time of each SoC.

The controllers proposed for UPQCs have always relied on a fixed grid frequency [15, 16]. Since grid frequency variations in MGs are larger than those experimented in classical distribution networks, they must be considered in the controller designation. In the proposed control scheme, not only variations of angular frequency of the grid but also the other model uncertainties such as smoothing inductor L and parasitic phase resistance r are fully considered. The main contributions of the paper can be summarized as follows:

  • Introduction of an effective technique for regulating DC-link voltage and testing its significance.

  • Implementation and evaluation of the proposed method and the PQ problem compensating performances to be analyzed in different scenarios.

Comparative analysis of the effectiveness of the proposed methods and conventional methods.

2 Problem Formulation

2.1 System Dynamic

The general configuration of UPQC is shown in Fig. 1, where the series and shunt voltage source inverters (active filters) are connected via a DC-link energy storage capacitor on the DC side. To eliminate negative sequences’ current and harmonics shunt, an active filter will be in operation where the series active filter reduces voltage distortion and imbalances. The power transfer between the network and DG resources in interconnected and separated mode can be expressed by Eqs. (1) and (2) respectively:

$$\begin{gathered} P_{{gri}} + P_{{DG}} = \left( {P + Q + H} \right)_{{load}} + P_{{loss}} + P_{{series}} + \hfill \\ P_{{Storage}} \quad and\quad \left( {Q + H} \right)_{{shunt}} = - \left( {Q + H} \right)_{{load}} \hfill \\ \end{gathered}$$
(1)
$$\begin{gathered} P_{{DG}} + P_{{Storage}} = \left( {P + Q + H} \right)_{{load}} + P_{{loss}} \hfill \\ and\left( {Q + H} \right)_{{shunt}} = - \left( {{\text{Q}} + H} \right)_{{load}} \hfill \\ \end{gathered}$$
(2)
Fig. 1
figure 1

General structure of UPQC

where P, Q, and H represent active, reactive, and harmonic powers. The dynamic equations of system in the d − q synchronous reference frame can be written as:

$$L\frac{{di_{{inj_{d} }} }}{dt} = - ri_{{inj_{{\text{d}}} }} + \omega Li_{{inj_{q} }} + u_{{load_{d} }} - MU_{DC}$$
(3)
$$L\frac{{di_{{inj_{q} }} }}{dt} = - ri_{{inj_{q} }} + \omega Li_{{inj_{d} }} + u_{{load_{q} }} - MU_{DC}$$
(4)
$$C\frac{{dU_{DC} }}{dt} = M\left( {i_{{inj_{d} }} + i_{{inj_{q} }} } \right) - i_{load}$$
(5)

where \({\text{u}}_{{{\text{load}}_{{\text{d}}} }}\) and \({\text{u}}_{{{\text{load}}_{{\text{q}}} }}\) represent load voltages, \({\text{U}}_{{{\text{dc}}}}\) is the DC-link voltage, \({\text{i}}_{{{\text{inj}}_{{\text{d}}} }}\) and \({\text{i}}_{{{\text{inj}}_{{\text{q}}} }}\) denote the injected current of the shunt active filter, \({\text{M}}\) is the switching functions, and \({\upomega }\) is the main grid angular frequency. Reduced number of equations, less complexities, and easier control tasks have been the main motivations to use d − q synchronous reference frame in this paper.

2.2 UPQC Integration Strategy and Modeling

There are several strategies to connect a UPQC to the grid. The integration scheme of UPQC to the MG in this paper has been inspired by [17] where the placement, integration, capacity enhancement, and real-time control of the UPQC are investigated. In the proposed method, the photovoltaic system and its storage devices are connected to the grid through UPQC inverters (Fig. 2). Use of this strategy will be economically helpful as high cost of application has always been considered the UPQC drawback [18]. In addition, in this scheme the UPQC will be capable of injecting active power to the network in the case of any changes in the load demand, utility power delivery failure, or variations in the other DG generations. The next section will further discuss that the controller design is such that any changes in the load side active power will be considered as a disturbance and will be attempted to be compensated.

Fig. 2
figure 2

UPQC integration Scheme

To achieve the same behavior with the real system, common assumptions in parameter uncertainties in UPQC modeling have been avoided in this paper. To guarantee controller robustness, parameters’ uncertainties in the system and UPQC converters model are fully considered using the following formulations:

$$L = L_{0} + \Delta L,{ }r = r_{0} + \Delta r,{ }\omega = \omega_{0} + \Delta \omega$$
(6)

where \({\text{L}}_{0}\), \({\text{r}}_{0}\), and \(\upomega _{0}\) are nominal values of smoothing inductor, parasitic phase resistance, and the angular frequency of the grid, respectively. Also, \(\Delta {\text{L}}\), \(\Delta {\text{r}}\), and \(\Delta {\upomega }\) are their variation which represent parametric uncertainties.

2.3 Control Objectives

The first problem of control is to produce a suitable shunt filter injected current (\({\text{i}}_{{{\text{inj}}}}\)) to eliminate harmonics in the load side current. \({\text{i}}_{{{\text{inj}}}}\) is controlled indirectly by processing the actual source current and the estimated reference current. The reference value for \({\text{i}}_{{{\text{inj}}_{{\text{d}}} }}\) should be determined such that the DC-link current remains constant. The more it is constant, the more linear the system will be.8 Further, \({\text{i}}_{{{\text{inj}}_{{\text{q}}} }}\) should be regulated so that it injects a desired compensating reactive power. Thus, tracking reference values by \({\text{i}}_{{{\text{inj}}_{{\text{d}}} }}\) and \({\text{i}}_{{{\text{inj}}_{{\text{q}}} }}\) is the first control objective. At the same time, as the second control objective, the DC component of the DC-link capacitor voltage should be driven to its reference value.

3 Controller Design

In the MG structure, there are various kinds of disturbances such as parametric uncertainties, load variations, and changes in generation of the other DG units. Thus, the controller should have strong disturbance rejection ability to meet the control objectives efficiently. In the proposed controller, two controlling loops are implemented consisting of an inner loop for current tracking and voltage regulation loop, the outer loop. Super twisting algorithm (STA) is applied in the inner loop to ensure the quick convergence of \({\text{i}}_{{{\text{inj}}_{{\text{d}}} }}\) and \({\text{i}}_{{{\text{inj}}_{{\text{q}}} }}\) to their reference values. Extensive state observer is designed to estimate variations of the load power which is accounted as an external disturbance. Using estimated disturbance, a parallel STA regulates the DC link capacitor voltage.

3.1 Basic STA

The sliding mode controller changes the dynamics of the nonlinear system by applying a control signal pushing the system’s orientation to slide along a desired sliding surface. In the sliding mode control, uncertainties and disturbances are addressed efficiently without any need to understand the precise model of the system to extract control rules [19].

Sliding mode control scheme includes two steps: selecting the sliding surface in the state/error space, called the switching function, so that the sliding motion would satisfy the control specification, and selecting a control law which makes the selected sliding surface desirable to force the system trajectories slide on the surface. The general designation of a sliding mode control would be as follows:

$${\dot{\text{x}}}_{{\text{i}}} = {\text{x}}_{{{\text{i}} + 1}} ,{\text{ i}} = 1,2, \ldots ,{\text{n}} - 1{ }$$
(7)
$$\begin{aligned} {\dot{\text{x}}}_{{\text{n}}} & = {\text{F}}\left( {{\text{t}},{\text{x}},{\text{u}}} \right) + {\text{D}} \\ {\text{y}} & = {\text{x}}_{1} , \\ \end{aligned}$$

where \({\text{x}} = \left[ {{\text{x}}_{1} + {\text{x}}_{2} + \ldots {\text{x}}_{{\text{n}}} } \right]^{{\text{T}}}\) represents the system state vector,\({\text{ u}}\) is the control input, \({\text{F}}\left( {{\text{t}},{\text{x}},{\text{u}}} \right){ }\) denotes nonlinear continues function with a known structure, \({\text{y}}\) is the system output vector, and D is external disturbance.

To accomplish the control objective, s and its derivatives should be forced to zero.

$${\dot{\text{s}}} = \frac{\updelta }{{\updelta {\text{t}}}}{\text{s}}\left( {{\text{t}},{\text{x}}} \right) + \frac{\updelta }{{\updelta {\text{x}}}}{\text{s}}\left( {{\text{t}},{\text{x}}} \right)\left[ {{\text{a}}\left( {\text{x}} \right) + {\text{b}}\left( {{\text{x}},{\text{u}}} \right)} \right]$$
(8)
$$\mathop {\text{s}}\limits = \frac{\updelta }{{\updelta {\text{t}}}}{\dot{\text{s}}}\left( {{\text{t}},{\text{x}},{\text{u}}} \right) + \frac{\updelta }{{\updelta {\text{x}}}}{\dot{\text{s}}}\left( {{\text{t}},{\text{x}},{\text{u}}} \right)\left[ {{\text{a}}\left( {\text{x}} \right) + {\text{b}}\left( {{\text{x}},{\text{u}}} \right)} \right] + \frac{\updelta }{{\updelta {\text{u}}}}{\dot{\text{s}}}\left( {{\text{t}},{\text{x}},{\text{u}}} \right){\dot{\text{u}}} = \varphi \left( {{\text{t}},{\text{x}},{\text{u}}} \right) +\upgamma \left( {{\text{t}},{\text{x}},{\text{u}}} \right){\dot{\text{u}}}$$
(9)

To ensure stability of the control action, the following boundary conditions must be satisfied:

$${ }0{ } < { }\Gamma _{{\text{m}}} <\upgamma \left( {{\text{t}},{\text{x}},{\text{u}}} \right) < { }\Gamma_{{\text{M}}}$$
(10)
$$-\Phi \le \varphi \left( {{\text{t}},{\text{x}},{\text{u}}} \right) \le \Phi$$
(11)

Under foregoing conditions, the control law of a super-twisting sliding mode controller is obtained as follows:

$${\text{u}} = {\text{u}}_{1} + {\text{u}}_{{\text{2}}}$$
(12)
$${\dot{\text{u}}}_{1} = - \upalpha {\text{sign}}\left( {\text{s}} \right)$$
(13)
$${\text{u}}_{2} = -\uplambda \left| {\text{s}} \right|^{\frac{1}{2}} {\text{sign}}\left( {\text{s}} \right)$$
(14)

Using boundary conditions, \(\upalpha\) and \(\uplambda\) can be calculated as:

$$\upalpha > \frac{\Phi }{{\Gamma_{{\text{m}}} }},{ }\uplambda ^{2} \ge \frac{4\Phi }{{\Gamma_{{\text{m}}}^{2} }}\frac{{\Gamma_{{\text{M}}} }}{{\Gamma_{{\text{m}}} }}\frac{{\upalpha + \Phi }}{{\upalpha - \Phi }}$$
(15)

3.2 Enhanced Extended State Observer

Extended state observer (ESO) has been implemented in the control scheme to deal with uncertainties and rejection of external disturbance simultaneously. Feed forward compensation of the control law by ESO improves tracking performance and disturbance rejection ability of the control system. The key to ESO design is to consider the external disturbance as an additional state of the dynamic system. Accordingly, system dynamics (7) is extended as follows:

$$\dot{x}_{i} = x_{i + 1} ,\quad i = 1,2, \ldots ,n - 1{ }$$
(16)
$$\begin{aligned} \dot{x}_{n} & = F\left( {t,x,u} \right) + x_{n + 1} \\ \dot{x}_{n + 1} & = \varepsilon \left( t \right) \\ y & = x_{1} , \\ \end{aligned}$$

where \(\varepsilon \left( t \right)\) is the derivative of D.

Motivated by the design theory in [20], the proposed linear ESO will be proved and designed in this section. To design the ESO, Eq. (5) can be restated as:

$$C\frac{{dV_{dc} }}{dt} = \frac{1}{{V_{dc} }}\left( {p^{*} - pload} \right)$$
(17)

where, \(p^{*} = i_{d} v_{d} + v_{q} i_{q}\) and \(pload = V_{DC} I_{LOAD}\).

The proposed linear ESO has the following state space representation:

$$C\dot{z} = p^{*} - d\left( t \right)$$
(18)
$$C\dot{\hat{z}} = p^{*} - \dot{\hat{d}}\left( t \right) + \beta_{1} \left( {z - \hat{z}} \right)$$
(19)
$$\dot{\hat{d}}\left( t \right) = - \beta_{2} \left( {z - \hat{z}} \right)$$
(20)

where \(\beta_{1}\) and \(\beta_{2}\) are positive gains and should be chosen such that system remains constant. The error dynamic can be stated as:

$${ }\dot{\varepsilon } = A\varepsilon + {\Psi }$$
(21)

where, \(\varepsilon = \left[ {\varepsilon_{z} ,\varepsilon_{d} } \right]^{T}\), \(A = \left[ {\begin{array}{*{20}c} { - \frac{{\beta_{1} }}{{\text{C}}}} & { - \frac{1}{C}} \\ {\beta_{2} } & 0 \\ \end{array} } \right]\) and \({\Psi } = \left[ {0{\text{ h}}\left( {\text{t}} \right)} \right]^{T}\).

3.3 Current Tracking Loop

For a fixed operating point, the transfer function of an inverter can be expressed as: 8

$$K_{C} = \frac{{\nabla I_{DC} }}{{\nabla i_{inj} }} = 3\left( {\frac{{u_{sh} - c_{sh} u_{sh} s - 2i_{inj} R_{sh} }}{{L_{DC} I_{{{\text{D}}C}} s}}} \right)$$
(22)

The block diagram of the current control loop is illustrated in Fig. 3. The characteristic equation of the current control loop has been proved in 8 and can be rewritten as:

$$1 + (K_{p} + { }\frac{{K_{i} }}{s}) \times 3 \times \left( {\frac{{u_{sh} - c_{sh} u_{sh} s - 2i_{inj} R_{sh} }}{{L_{DC} I_{DC} s}}} \right) = 0$$
(23)
Fig. 3
figure 3

Block diagram of current control loop

\(K_{p}\) determines the current response and \(K_{i}\) defines the damping factor of the current control loop.

4 Simulation and Results

To validate the effectiveness of the proposed control system, MATLAB/Simulink based simulation was conducted in this section for investigating the voltage sag and current harmonics compensation capability of the UPQC. The system parameters utilized for simulation are listed in Table 1.

Table 1 Study system parameters

A comprehensive analysis was done in two different scenarios:

Scenario Ι: in this scenario, harmonics elimination capability of UPQC under highly nonlinear loading condition was examined while there was no voltage sag. Since there was no voltage deviation in the load voltage (no fault condition), the series inverter operated in the standby mode and as shown in Fig. 4, no voltage was injected by this inverter. Meanwhile, the shunt converter was in operation to eliminate the current harmonics. Figure 5 illustrates the load current, injected current, and source current respectively. It is evident that because of the presence of UPQC current harmonics have been compensated effectively. After compensation, as can be seen in Fig. 6, the total harmonic distortion (THD) in source current has been low i.e. 0.61% as compared to that of the load current i.e. 25.08% (Fig. 7). Table 2 compares the UPQC performance in harmonic filtration in this scenario under a simple PI controller, enhanced phase-locked loop controller [EPLL] [21], and SOSM controller. While the load current in all cases is found to be content of all odd harmonics, providing THD of 25.08%, THD of source current has been reduced to 8.53%, 2.71%, and 1.79% using PI, EPLL, and SOSM controllers respectively. Table 3 reports the harmonic contents of the load side current and source current for phase A in the presence of the UPQC with the proposed controller. The values of this table are obtained by FFT analysis of the load and source currents (Figs. 8, 9). The DC link voltage wave-form is demonstrated in Fig. 6. In addition to normal advantages of implementing UPQC in grids, the power injection capability of the proposed configuration is obvious in Fig. 7. The load, source, series and shunt inverters injected active and reactive power is illustrated in Fig. 7.

Fig. 4
figure 4

Source, load and injected voltage for scenario Ι

Fig. 5
figure 5

Feeder, load and injected current of phase A for scenario Ι

Fig. 6
figure 6

DC-link Capacitor Voltage for scenario Ι

Fig. 7
figure 7

Load, Source, series and shunt inverter active and reactive power for scenario Ι

Table 2 Comparison of the PI, EPLL and SOSM Controllers performance
Table 3 Harmonic contents of Load and source currents of Phase-A
Fig. 8
figure 8

FFT analysis of load current

Fig. 9
figure 9

FFT analysis of source current

Scenario ΙΙ: harmonic elimination and voltage sag compensation of controller with voltage sag under nonlinear loads was investigated in this case. To evaluate single phase and three-phase sag compensation capability of the proposed configuration, a supply disturbance has been simulated and analyzed to decrease the peak voltage value by 30% from 0.2 to 0.4 s. The simulation results for single phase sag have been demonstrated in Figs. 10, 11 and 12. The injected voltage under single-phase sag conditions by the proposed UPQC configuration is displayed in Fig. 10. It can be seen that when the voltage is below its normal value, an effective compensation has been done and the load voltage has risen to its required level. The supply current under the sag condition and the load current with mitigated sag and compensating current are shown in Fig. 11. The DC-link voltage wave-form is revealed in Fig. 12. As can be seen, the DC-link voltage drop due to sag condition has been eliminated and has reached its nominal value.

Fig. 10
figure 10

Load, Source and series converter injected current for scenario ΙΙ (single phase sag)

Fig. 11
figure 11

Load, transmission line and compensation current for scenario ΙΙ (single phase sag)

Fig. 12
figure 12

DC-link capacitor voltage for scenario ΙΙ (single phase sag)

Simulation results for 3-phase sag have been demonstrated in Figs. 13, 14 and 15. The source, load and injected (in-phase) voltage in the 3-phse sag condition is shown in Fig. 13. Similar to the previous section, the 3-phase voltage sag has been successfully compensated and the load voltage has reached its permissible set point. The DC link voltage wave-form is also demonstrated in Fig. 14. The load, Source, series, and shunt inviter active as well as reactive power are shown in Fig. 15.

Fig. 13
figure 13

Source, load and injected (in-phase) voltage for scenario ΙΙ (3- phase sag)

Fig. 14
figure 14

DC-link capacitor voltage for scenario ΙΙ (3- phase sag)

Fig. 15
figure 15

Load, Source, series and shunt inviter active and reactive power for scenario ΙΙ (3- phase sag)

5 Experimental Setup

In order to validate the efficiency of proposed control scheme, an experimental setup was conducted in the well-equipped distribution level laboratory of Shiraz Electricity Distribution Company (SHEDC). The setup consisted of a PV simulator module and a set of FARATEL 240v, 42AH battery storage connected to a 3 phase 400v test grid through UPQC inverters (Fig. 16). Key features and specifications of PV simulator are stated in Table 4.

Fig. 16
figure 16

Experimental set up

Table 4 Key features and specifications of PV simulator

A programmable RISC type micro-controller and 32-bit floating-point digital signal processor of inverters enabled us to reload the provided MATLAB based control program. The component of the inverters’ cabinet is shown in Fig. 17. To extract and analyze the parameter values, the FTU-P100 remote control unit (RTU) was applied. FTU-P100 is a load break switch control unit enabling us to measure and manipulate the magnitude and phase angle, true RMS, harmonics and THD of current and voltage, as well as the active and reactive power of each phase or three phases. FTU-p100 is equipped with a dedicated PC or notebook operating software (FTU-set) used to display results, configurations, and fault waveform view. The parameters of the experimental system are stated in Table 5 with the performance of the proposed control method evaluated. In the implemented setup, a nonlinear power electronic based load was connected to the system. As observed in Figs. 18 and 19, the THD of the source current of phase A (because of limited number of CT's in test module only one phase has been analyzed) diminished to 1.02%, while the THD of the load current was measured as 23.87%. Furthermore, a 30% 3-phase voltage sag was established in the voltage source to reveal the function of UPQC. As observed in Figs. 20 and 21 (where x and y axis are respectively time and voltage magnitude), the voltage sag has been compensated effectively.

Fig. 17
figure 17

cabinet boxes

Table 5 Experimental system parameters
Fig. 18
figure 18

Load side and source side current harmonic analysis

Fig. 19
figure 19

Load side and source side current harmonic analysis

Fig. 20.
figure 20

3-phase voltage sag in source current

Fig. 21
figure 21

Compensated source side voltage

6 Conclusion

A State Observer Based Sliding Mode (SOSM) control scheme was introduced in this paper to enhance the performance of UPQC in a micro-grid integrated power system. Using the proposed control scheme, the power quality improvement capability of UPQC in the micro-grid improved. THD of the load voltages using the proposed compensation strategy was always kept below the IEEE voltage harmonic limits (IEEE Standard-519, 1992). While the load current in all cases is found to be content of all odd harmonics, providing THD of 25.08%, using proposed controller THD of source current has been reduced to 1.7945%. Compared with the current traditional and classical UPQC controllers, both single and three phase voltage sags under nonlinear loading were compensated effectively. Results showed that in spite of 30% source voltage sag, load voltage has risen to its required level due to presence of UPQC and designed controller. The simulation results showed the superiority of the method regarding accuracy and tracking speed.