Real-Time Implementation of Robust Control Strategies Based on Sliding Mode Control for Standalone Microgrids Supplying Non-Linear Loads

: In this paper enhanced control strategies for standalone microgrids based on solar photovoltaic systems (SVPAs) and diesel engine driven ﬁxed speed synchronous generators, are presented. Single-phase d-q theory-based sliding mode controller for voltage source converter voltage source converter (VSC) is employed to mitigate harmonics, balance diesel generator (DG) current, and to inject the generated power by SVPA into local grid. To achieve fast dynamic response with zero steady-state error during transition, sliding mode controller for inner control loop is employed. To achieve maximum power point tracking (MPPT) from SVPA without using any MPPT method, a DC-DC buck boost converter supported by battery storage system is controlled using a new control strategy based on sliding mode control with boundary layer. In addition, modeling and detailed stability analysis are performed. The performance of the developed control strategies, are validate by simulation using MATLAB/Simulink and in real-time using hardware prototype.


Introduction
Most of remote areas in the world are not connected to the main grid. Generally, conventional diesel generators (DGs) are employed as the energy source to provide electricity to the connected loads in these areas [1][2][3]. Considering the transport and fuel costs, electricity in these isolated areas is costly. In addition, the performance of a DG is reduced when it is operated at light load, as well as, when connected to balanced and unbalanced nonlinear loads [4]. Many solutions are proposed in the literature to solve these issues and to reduce CO 2 emissions [5][6][7][8]. In [9], a hybrid wind-diesel system-based solution is proposed, and in [10,11] solar-wind-diesel hybrid systems are suggested. These solutions are effective from the point of view of fuel consumption but hard to implement in practice. Recently, in [12], many technical solutions with reduced number of power converters, are suggested to reduce the complexity of hybrid standalone system and achieve high performance from the available energy sources (ESs) in isolated localities.
Solar is the most abundant renewable energy source (RES) in the world. This RES is stochastic, not available at night, and it cannot dispatch power directly to the load. To ensure uninterruptible power supply to connected isolated loads, DG and storage elements, such as batteries, are required as reliable ESs. In a standalone system configuration proposed in [13], a solar photovoltaic system (SPVA) is connected to the DC bus through a DC-DC boost converter and a battery is connected directly to the DC bus without using any power converter. However, in [14], SPVA and batteries are connected to the DC bus through power converters. This configuration is costly and hard to implement 2 of 18 in a real situation. In addition, operating many power converters, which are connected to the same DC bus using different switching frequency is challenging and can damage the batteries, and affect the system stability. In [13,14], the DC-DC boost converter and the DC-DC buck boost converter, are controlled using simple control algorithms based on a linear proportional integral (PI) controller, which is not robust and cannot perform well under large variations of the system parameters or loading conditions. To overcome these problems and achieve high performance without saturation issues, sliding mode control is proposed in [15]. The obtained simulation results showed satisfactory performance. Unfortunately, in [15] the chattering issue is not considered. To overcome this issue, terminal sliding mode control (SMC), and high-order SMC, are proposed in [16,17]. The obtained experimentally results show satisfactory performance without any chattering issues. Compared to the classical SMC proposed in [15], terminal and high-order SMCs are robust but complex and require more compilation time, which is hard to implement using simple microprocessors.
Generally, in the conventional grid, power quality issues at the point of common coupling (PCC), such as voltage sag and swell, harmonics, etc. can be solved using filters [18]. This solution is also adopted in standalone microgrid to improve the power quality at the point of common coupling (PCC).
In standalone microgrids based on SPVA and DG, the interfacing power electronic converter is mostly controlled to achieve various tasks, such as regulation of the voltage and frequency, as well as improve the power quality at PCC [19,20]. Regarding the harmonics mitigation and to balance the source current at PCC, many control strategies are proposed in the literature such as the synchronous reference frame (SRF) control strategy applied in [21], or the instantaneous p-q theory developed first by Akagi and applied to improve the power quality in standalone microgrid in [18]. In [18], direct and indirect controls are suggested. In the control strategies proposed in [18,21], the authors have used a conventional proportional integral (PI) controller to track the errors in outer and inner loops. This controller is simple but requires tuning to achieve optimal regulation, which is hard to achieve, especially if the proposed control strategy requires more than one PI controller. Furthermore, PI controllers can saturate during transition and when input signals are polluted. To solve this issue, a proportional integral based artificial neural network fuzzy interference system (PI-ANFIS) controller is proposed in [22], and in [23] an adaptive controller is suggested. These controllers are robust compared to simple PI controllers but require more computation time, which is hard to implement in real time using simple microprocessor chips. To overcome the issue of the linear PI controller, a fuzzy sliding mode controller is proposed in [24], in [25] a neural global SMC using a fuzzy approximator is employed, and in [26], an adaptive fractional fuzzy SMC, is suggested. The solutions proposed in [24][25][26], are effective but complex to implement, especially if the inner and outer loop control requires more than one controller. Sliding mode (SM)-based control is proposed in [27] for the inner loop control in order instead of the conventional PI controller to ensure a fast-time and optimal tracking control. The obtained experimental and simulation results show satisfactory performance. Unfortunately, the proposed concept is dedicated to controlling an interfacing voltage source converter, which is connected to the grid, where the frequency and voltage regulation are not achieved by the control system, and synchronization between the interfacing converter and the grid is not a big challenge. In addition, DC link voltage regulation is ensured by a PI controller, where saturation issues are not considered.
To solve these issues, which are related to the cost of energy in isolated areas, power quality and stable operation of standalone microgrids based on SPVA and DG, the following solutions are proposed: (1) Standalone microgrid -microgrid configurations with less power converters where SPVA and battery energy storage system are controlled using only one DC-DC buck-boost converter to connect and control the lead acid battery pack. (2) Using only one PI controller with anti-windup for the outer control loop for DC-link voltage regulation. (3) Replacing the PI controller by a SMC with boundary layer in the inner control loop for single-phase d-q control strategy, which is proposed for power quality improvement.  Figure 1 shows a standalone microgrid-based configuration for remote areas. It consists of two energy sources: (1) a fixed speed diesel engine driven synchronous generator, and (2) a SPVA. The DG is connected directly to the PCC and the SPVA is connected directly to the common DC bus and to the PCC through a three-phase voltage source converter (VSC). A lead acid battery pack is connected to the common DC bus through a controller DC-DC buck boost converter. For the proposed configuration, the AC voltage and system frequency are regulated by the governor and automatic voltage regulator (AVR) of the DG. For power quality improvement at the PCC and injection of the generated power from SPVA, the VSC is controlled using a single-phase d-q theory based-sliding mode control strategy. Regarding the power balance in the system and for achieving MPPT from SPVA, an enhanced control strategy based on sliding mode control is used to control the DC-DC buck boost converter. To reduce the ripple voltage due to high switching frequency of VSC, a resistance-inductor-capacitor (RLC) passive filter is employed. (3) Replacing the PI controller by a SMC with boundary layer in the inner control loop for singlephase d-q control strategy, which is proposed for power quality improvement. (4) Developing a new control strategy based on sliding mode control for DC-DC buck boost converter where the system parameters are taken on consideration in equivalent control. (5) Achieving maximum power point tracking (MPPT) from SPVA by controlling only the DC link voltage. (6) Employing the boundary layer in SMC to reduce the chattering phenomena. Figure 1 shows a standalone microgrid-based configuration for remote areas. It consists of two energy sources: (1) a fixed speed diesel engine driven synchronous generator, and (2) a SPVA. The DG is connected directly to the PCC and the SPVA is connected directly to the common DC bus and to the PCC through a three-phase voltage source converter (VSC). A lead acid battery pack is connected to the common DC bus through a controller DC-DC buck boost converter. For the proposed configuration, the AC voltage and system frequency are regulated by the governor and automatic voltage regulator (AVR) of the DG. For power quality improvement at the PCC and injection of the generated power from SPVA, the VSC is controlled using a single-phase d-q theory based-sliding mode control strategy. Regarding the power balance in the system and for achieving MPPT from SPVA, an enhanced control strategy based on sliding mode control is used to control the DC-DC buck boost converter. To reduce the ripple voltage due to high switching frequency of VSC, a resistance-inductor-capacitor (RLC) passive filter is employed.

Control System
In this section, the developed control strategies for the DC-DC buck boost converter and for three-phase voltage source converter (VSC), are detailed.

3.1.Control of the DC-DC Buck-Boost Converter
As shown in Figure 1 the lead acid battery is connected to the common DC-link through a controlled DC-DC buck-boost converter, which consists of two continuous systems. To balance the power in the system and achieve MPPT from SPVA, sliding mode control (SMC) with boundary layer is used.

Control System
In this section, the developed control strategies for the DC-DC buck boost converter and for three-phase voltage source converter (VSC), are detailed.

Control of the DC-DC Buck-Boost Converter
As shown in Figure 1 the lead acid battery is connected to the common DC-link through a controlled DC-DC buck-boost converter, which consists of two continuous systems. To balance the power in the system and achieve MPPT from SPVA, sliding mode control (SMC) with boundary layer is used. The DC-DC buck-boost converter shown in Figure 1 consists of battery voltage (V bat ) controlled switches (S 8 and S 9 ), inductor (L b ), output voltage (V dc ) and a capacitor (C dc ). Depending on the state of the switches, the state-space equations of the DC-DC buck boost converter when the switch is ON are written as: where R is load resistance, and when the switch is OFF the state-space equations are expressed as: Replacing, x 1 by i bat , and x 2 by V dc , then; .
x 2 = dV dc dt . The state-space equations, which are expressed in (1) and (2) are written as: The average state-space equation of the DC-DC buck-boost converter is obtained using (3) and (4) as, . where 0 v bat , and C = 0 1 . Figure 2 shows the block diagram of the developed control strategy for the DC-DC buck boost converter. Based on (6), the model of the DC-DC buck-boost converter is nonlinear. However, for achieving high dynamic performance during transition with optimal accuracy regulation and robust trajectory tracking in presence of uncertain parameters, the SMC approach is employed. The control design of the general control (d) for the DC-DC buck boost converter is obtained using the following steps:

Selection of the Sliding Surface
The sliding surface (σ) as expressed in (6) is selected to ensure reaching the surface with desiring dynamics of the corresponding sliding motion [28][29][30]: where β1 and β2 represent the sliding gains and they should be positive. The * and * denote the battery current and DC-link voltage references, respectively. The value of the DC-link voltage reference is equal to output PV voltage (VPV), which is selected equal to 350 V. As presented in Figure 3, VPV corresponds to the maximum extracted power from the SPVA for different solar irradiations. Therefore, by controlling the DC-link voltage, one can easily extract the maximum of power without using any MPPT method.

Equivalent Control
The structure of the desired control (d) is obtained as: where represents the nonlinear control and is the equivalent control, which is obtained using (5), (6) and by setting the derivative of (6) to zero as: By replacing and by their equality, one obtains the following expression as:

Selection of the Sliding Surface
The sliding surface (σ) as expressed in (6) is selected to ensure reaching the surface with desiring dynamics of the corresponding sliding motion [28][29][30]: where β 1 and β 2 represent the sliding gains and they should be positive. The x * 1 and x * 2 denote the battery current and DC-link voltage references, respectively. The value of the DC-link voltage reference is equal to output PV voltage (V PV ), which is selected equal to 350 V. As presented in Figure 3, V PV corresponds to the maximum extracted power from the SPVA for different solar irradiations. Therefore, by controlling the DC-link voltage, one can easily extract the maximum of power without using any MPPT method.

Selection of the Sliding Surface
The sliding surface (σ) as expressed in (6) is selected to ensure reaching the surface with desiring dynamics of the corresponding sliding motion [28][29][30]: where β1 and β2 represent the sliding gains and they should be positive. The * and * denote the battery current and DC-link voltage references, respectively. The value of the DC-link voltage reference is equal to output PV voltage (VPV), which is selected equal to 350 V. As presented in Figure 3, VPV corresponds to the maximum extracted power from the SPVA for different solar irradiations. Therefore, by controlling the DC-link voltage, one can easily extract the maximum of power without using any MPPT method.

Equivalent Control
The structure of the desired control (d) is obtained as: where represents the nonlinear control and is the equivalent control, which is obtained using (5), (6) and by setting the derivative of (6) to zero as: By replacing and by their equality, one obtains the following expression as:

Equivalent Control
The structure of the desired control (d) is obtained as: where d n represents the nonlinear control and d eq is the equivalent control, which is obtained using (5), (6) and by setting the derivative of (6) to zero as: By replacing .
x 1 and .
x 2 by their equality, one obtains the following expression as: Energies 2018, 11, 2590 6 of 18

Stability Analysis
The objective of the approach using SMC is to ensure the convergence of the operating points to define the sliding boundary. Therefore, for assuring the stability of the control, Lyapunov stability function. According to Lyapunov theorem, a non-linear time variant system is globally and uniformly stable if satisfies the following conditions as [31,32]: For the DC-DC buck-boost converter Lyapunov function is defined as [33,34] as: The system is considered asymptotically stable as detailed in (10), the derivative of (11) should be negative: Replacing (6) and (8) in (12), one gets: where the x * 1 and x * 2 denote the references of the battery current, which represents the output of the PI controller with anti-windup DC link voltage regulator, and DC-link voltage, which is equal to the 350 V, respectively Substituting terms .
x 2 , x 1 , x 2 , and d by their equivalences in (12) gives the following expression: Replacing the parameters L b , C dc , V bat , V dc , as well as the optimal gains of the SMC β 1 and β 2 by their value given in Table 1, the first term with negative sign in (14) is larger than the second term. This leads that condition given in (13) is satisfied, which confirms that the system is asymptotically stable. To ensure the robustness, the second of the desired control d n , which represents the discontinuous control is written as [35][36][37]: d n = β 3 sat(σ, ∅) (15) where β 3 is positive control gain.
To reduce the chattering of the control signal, saturation function with boundary conditions is defined as: where ∅ denotes the sliding layer, which is selected between 0.5 and −0.5 [11]. The optimal gains (β 1 , β 2 and β 3 ) of the SMC, are selected equal to β 1 = 0.001, β 2 = 0.8, and β 3 = 5, respectively. One observes in Figure 4c, that based on the optimal values of β 1 , β 2 and β 3 the signal reaches the origin rapidly. To ensure the robustness, the second of the desired control , which represents the discontinuous control is written as [35][36][37]: where is positive control gain. To reduce the chattering of the control signal, saturation function with boundary conditions is defined as: where ∅ denotes the sliding layer, which is selected between 0.5 and −0.5 [11]. The optimal gains ( , and ) of the SMC, are selected equal to 1 = 0.001, 2 = 0.8, and

3.2.Control of Three-Phase Voltage Source Converter
In Figure 5 the single-phase d-q theory-based sliding mode controller for VSC to improve the power quality and inject the generated power from the solar photovoltaic system into PCC, is presented. Regarding the DC link voltage regulation, is ensured by controlling the DC-DC buck boost converter. Inverter voltage ( ) and current ( ), load current ( ) and voltage( ), are used to determine the inverter voltage references ( * ). The d-q rotating frame and (α-β) stationary frame are employed to transform all time-varying signals to DC quantities with timeinvariant.
The rotating angle of d-q frame is calculated using the in-phase and quadrature united vectors as in [18]. The amplitude of the PCC voltage (Vp) is calculated as: The in-phase unit templates of the PCC voltage, are calaculted as follows: and the quadrature unit templates of the PCC voltages are expreesed as: The cosθ and sinθ, are defined as:

Control of Three-Phase Voltage Source Converter
In Figure 5 the single-phase d-q theory-based sliding mode controller for VSC to improve the power quality and inject the generated power from the solar photovoltaic system into PCC, is presented. Regarding the DC link voltage regulation, is ensured by controlling the DC-DC buck boost converter. Inverter voltage (v invabc ) and current (i invabc ), load current (i Labc ) and voltage(v Labc ), are used to determine the inverter voltage references (v * invabc ). The d-q rotating frame and (α-β) stationary frame are employed to transform all time-varying signals to DC quantities with time-invariant.
The obtained dq-axis load current consist of the fundamentals ( , ) and harmonics components ( , ): Regarding the harmonics ( , ), which are extracted using high pass filter (HPF) represent the output inverter currents, they are transformed into the (α-β) stationary frame., and are used after to determine the reference inverter voltages.

Sliding Mode Current Controller
A sliding mode current controller (SMCC) is proposed for the inner current control loop to achieve high performance during transition with a fast-dynamic response. To design the controller, the following steps are used.  The rotating angle of d-q frame is calculated using the in-phase and quadrature united vectors as in [18]. The amplitude of the PCC voltage (V p ) is calculated as: The in-phase unit templates of the PCC voltage, are calaculted as follows: and the quadrature unit templates of the PCC voltages are expreesed as: The cosθ and sinθ, are defined as: The obtained dq-axis load current consist of the fundamentals (I d , I q ) and harmonics components ( I q , I d ): Regarding the harmonics ( I q , I d ), which are extracted using high pass filter (HPF) represent the output inverter currents, they are transformed into the (α-β) stationary frame., and are used after to determine the reference inverter voltages.

Sliding Mode Current Controller
A sliding mode current controller (SMCC) is proposed for the inner current control loop to achieve high performance during transition with a fast-dynamic response. To design the controller, the following steps are used.

Selecting the Switching Surface
Switching surface for SMCC σ 1 = σ α σ β T is selected to ensure fast dynamic response during transition with zero steady-state [38]: where k 1 , and k i1 are positive gains. The e α , e β represent the obtained errors between measured and reference output VSC currents, which are defined as: Energies 2018, 11, 2590 9 of 18 Applying the Kirchhoff current and voltage law at the output of the VSC, one obtains the following expression in stationary (α-β) frame: where L inv and R inv denote the inductor and resistor of the output filter of VSC.
Using (24), (22) and (23) and its derivative, one obtains the following expression: The structure of the desired control (v * invα , and v * invβ ), are expressed as: where v invα_eq , v invβ_eq , ∆v invα , and ∆v invβ represent the equivalent controls and nonlinear control in the stationary (α-β) frame.
Regarding, the equivalent controls are obtained by set the sliding switching From (25), one obtains the equivalent controls stationary (α-β) frame: The nonlinear control is selected equal to: where K 2 represents the controller gain and is positive.

Stability Analysis
The system is considered globally stable only if the derivative of (10) is negative. Using (26) and (22), one gets the following expression: Equation (28) can be written as: To determine the sign of (31), one determines first the sign of each term independently.
Considering the first term (k 1 . i * invα ), which represents the derivative of the reference inverter current, is equal to zero and regarding, that DG ensures the regulation of the voltage at PCC, one assumes that the PCC voltage and the voltage at the output of the VSC are equal, which leads that the second As known the integral is always positive, so the sign of the sixth term (k i1 t 0 e α (i invα )dt) is positive. The error between the inverter current and its reference is smaller, so, the fifth term (k 1 e α (t)) is smaller than the sixth term. Based on this analysis, one concludes that the sign of . σ α σ α is always negative, which implies that the system is asymptotically stable.

Results and Discussion
The performance of the developed control strategies for the VSC and DC-DC buck-boost converter, was tested through a simulation using MATLAB/Simulink and in real-time using a hardware prototype. In Figure 6 the hardware prototype of a standalone microgrid is presented. It consists of: (1) ABB drive, (2) synchronizer of DG, (3) induction motor, (4) synchronous generator, (5) SPVA simulator, (6) loads, (7) Protections cards, dSPACE and SEMIKRON power converter, (8) sensors, (9) step down transformer, (10) RC passive filter, and (11) lead acid battery pack.
To determine the sign of (31), one determines first the sign of each term independently. Considering the first term ( * ), which represents the derivative of the reference inverter current, is equal to zero and regarding, that DG ensures the regulation of the voltage at PCC, one assumes that the PCC voltage and the voltage at the output of the VSC are equal, which leads that the second term ( − + ) being equal to zero, and * ≪ − − . As known the integral is always positive, so the sign of the sixth term ( ( ) ) is positive. The error between the inverter current and its reference is smaller, so, the fifth term ( ( )) is smaller than the sixth term. Based on this analysis, one concludes that the sign of is always negative, which implies that the system is asymptotically stable.

Results and Discussion
The performance of the developed control strategies for the VSC and DC-DC buck-boost converter, was tested through a simulation using MATLAB/Simulink and in real-time using a hardware prototype. In Figure 6 the hardware prototype of a standalone microgrid is presented. It consists of: (1) ABB drive, (2) synchronizer of DG, (3) induction motor, (4) synchronous generator, (5) SPVA simulator, (6) loads, (7) Protections cards, dSPACE and SEMIKRON power converter, (8) sensors, (9) step down transformer, (10) RC passive filter, and (11) lead acid battery pack. In Figure 7 the dynamic performances of the terminal voltage ( ) and current of synchronous generator, load current , inverter current ( ), DC-link voltage ( ) and its reference ( * ), battery current ( ) and its reference ( ), and output SPVA current ( ) are shown. The zoomed waveforms presented in Figure 6 are shown in Figure 8. It is observed that the AC voltage at the PCC and the frequency are regulated at their rated values, which confirms that the governor and the automatic voltage regulator of the DG are working well. One can see clearly in the zoomed The zoomed waveforms presented in Figure 6 are shown in Figure 8. It is observed that the AC voltage at the PCC and the frequency are regulated at their rated values, which confirms that the governor and the automatic voltage regulator of the DG are working well. One can see clearly in the zoomed waveforms presented in Figure 8a-c, that the DG currents are balanced and sinusoidal, which confirms that the single-phase d-q control-based sliding mode controller performs well in the presence of balanced nonlinear loads. One observes that the DC-link voltage and battery current follow their references during solar irradiation changes, which confirms the robustness of the developed control strategy-based sliding mode control with boundary layer. One observes from the obtained results shown in Figure 8a-c that during transitions when solar irradiation changes the battery current follows its reference, which represents the output of the DC-link voltage regulator without saturation and with zero steady state error. The output SPVA current, which represents the maximum of SPVA current and DC-link voltage varies with variation of solar irradiation as shown in Figure 3, which confirms that it is possible to achieve MPPT without using any MPPT method.
In Figures 9 and 10, the waveforms and the zoomed of terminal voltage (v DG ) and current i DG of synchronous generator, load current i L , inverter current (i inv ), DC-link voltage (V dc ) and its reference (v * dc ), battery current (v DG ) and its reference (v DG ), and output SPVA current (I PV ), are presented. To test the performance of the developed control strategies, the system is subjected to severe conditions, such as the presence of balanced and unbalanced nonlinear RL and RC load types as well as during solar irradiation changes. It is observed that in the presence of different loads, the DG current is balanced and sinusoidal.
Energies 2018, 11, x FOR PEER REVIEW 11 of 18 waveforms presented in Figure 8a-c, that the DG currents are balanced and sinusoidal, which confirms that the single-phase d-q control-based sliding mode controller performs well in the presence of balanced nonlinear loads. One observes that the DC-link voltage and battery current follow their references during solar irradiation changes, which confirms the robustness of the developed control strategy-based sliding mode control with boundary layer. One observes from the obtained results shown in Figure 8a-c that during transitions when solar irradiation changes the battery current follows its reference, which represents the output of the DC-link voltage regulator without saturation and with zero steady state error. The output SPVA current, which represents the maximum of SPVA current and DC-link voltage varies with variation of solar irradiation as shown in Figure 3, which confirms that it is possible to achieve MPPT without using any MPPT method.
In Figures 9 and 10, the waveforms and the zoomed of terminal voltage ( ) and current of synchronous generator, load current , inverter current ( ), DC-link voltage ( ) and its reference ( * ), battery current ( ) and its reference ( ), and output SPVA current ( ), are presented. To test the performance of the developed control strategies, the system is subjected to severe conditions, such as the presence of balanced and unbalanced nonlinear RL and RC load types as well as during solar irradiation changes. It is observed that in the presence of different loads, the DG current is balanced and sinusoidal.      In addition, DC-DC buck boost can extract the maximum of power from the SPVA and balance the power in the system by charging and discharging the battery, which confirms the robustness of the proposed control strategies based on sliding mode control for the standalone microgrid system. In Figure 11 the harmonics spectrum of the PCC voltage, DG current, and load currents when RL and RC nonlinear load, are presented. It is observed that in the both cases the total harmonic distortion (THD) of the load current is high (THD = 24% with RL nonlinear and 27% with RC nonlinear load), and the THD of the source current, which represents in the standalone microgrid shown in Figure 1, the output current of the DG is less than 5% (THD = 4.07% with RL nonlinear and 4.28% with RC nonlinear load). This respects the norms of IEEE standard 519-1992. One sees clearly that the THD of the PCC voltage is less than to 5% in the presence of the both nonlinear loads, which confirms the robustness of the proposed Single-phased d-q theory-based on SMC for power quality improvement. In addition, DC-DC buck boost can extract the maximum of power from the SPVA and balance the power in the system by charging and discharging the battery, which confirms the robustness of the proposed control strategies based on sliding mode control for the standalone microgrid system. In Figure 11 the harmonics spectrum of the PCC voltage, DG current, and load currents when RL and RC nonlinear load, are presented. It is observed that in the both cases the total harmonic distortion (THD) of the load current is high (THD = 24% with RL nonlinear and 27% with RC nonlinear load), and the THD of the source current, which represents in the standalone microgrid shown in Figure 1, the output current of the DG is less than 5% (THD = 4.07% with RL nonlinear and 4.28% with RC nonlinear load). This respects the norms of IEEE standard 519-1992. One sees clearly that the THD of the PCC voltage is less than to 5% in the presence of the both nonlinear loads, which confirms the robustness of the proposed Single-phased d-q theory-based on SMC for power quality improvement. Energies 2018, 11, x FOR PEER REVIEW 14 of 18 Figure 11. Harmonics spectrum of the PCC voltage, DG current and load current with RL and RC nonlinear loads.
In Figure 12a,b, the steady-state performance of the DG is presented. One observes that the terminal voltage before step down transformer ( ) and at the secondary of transformer are regulated constant and sinusoidal. Seeing that DG operates at fixed speed, excitation current ( ) is constant, one can observe that the system frequency is constant, and the stator current are sinusoidal. To test the performance of the developed control strategies-based sliding mode control, the system is subjected to load variations as presented in Figure 13a-c. It is observed in Figure 13a that at t = 0.2 ms the system is subjected to a sudden variation of nonlinear load type RL. One observes that VSC operates as a shunt active filter, and it compensates the harmonics and balances the DG current. One observes that the DC-link voltage is well regulated. In Figure 13b, the system is subjected to sudden switching off the nonlinear load type RC at t = 0.2 ms. It is observed that the VSC acts as a shunt filter and compensates the harmonics as well as balances the DG current. One sees that DClink voltage is increased when the load is switched off, because the battery starts charging. In Figure  13c, the system is subjected to sudden switching on and off at t = 0.1 ms and at t = 1 s, and one observes In Figure 12a,b, the steady-state performance of the DG is presented. One observes that the terminal voltage before step down transformer (v DGa1 ) and at the secondary of transformer v DGa2 are regulated constant and sinusoidal. Seeing that DG operates at fixed speed, excitation current (i exc ) is constant, one can observe that the system frequency is constant, and the stator current are sinusoidal. To test the performance of the developed control strategies-based sliding mode control, the system is subjected to load variations as presented in Figure 13a-c. It is observed in Figure 13a that at t = 0.2 ms the system is subjected to a sudden variation of nonlinear load type RL. One observes that VSC operates as a shunt active filter, and it compensates the harmonics and balances the DG current. One observes that the DC-link voltage is well regulated. In Figure 13b, the system is subjected to sudden switching off the nonlinear load type RC at t = 0.2 ms. It is observed that the VSC acts as a shunt filter and compensates the harmonics as well as balances the DG current. One sees that DC-link voltage is increased when the load is switched off, because the battery starts charging. In Figure 13c, the system is subjected to sudden switching on and off at t = 0.1 ms and at t = 1 s, and one observes that the DC-link voltage is well regulated and the VSC acts as a shunt active filter and injects the power into the PCC. One sees clearly in Figure 13a-c, that the both developed control strategies perform well in the presence of severe conditions. The performance of DC-link voltage (V dc ), battery current (i bat ), load current (i La ) and inverter current (i inva ), are presented in Figure 14a,b. It is observed that the DC-link voltage is regulated at their rated value when the system is subjected to load variations at t = 0.4 s and t = 0.8 s in Figure 14a, and at t = 0.3 s, and t = 0.8 s in Figure 14b. One observes that the battery current varies with load variation, balancing the power in the system. This leads that the system performing well during all conditions, which confirms the robustness of the developed control strategy-based sliding mode control.

Conclusions
In this paper, a real-time implementation of robust control strategies based on sliding mode control for a standalone microgrid has been presented. Single-phase d-q theory based on sliding mode controller for fast inner control loop for three-phase voltage source converter was studied and analyzed. Furthermore, modeling and stability analyses are given in detail. Sliding mode control with boundary layer is developed for DC-DC buck boost. It has been proven that the developed control strategies perform well during severe conditions, such as load variation and solar irradiation changes. The obtained simulation, as well as, experimental results show satisfactory performance.
Author Contributions: This paper was a collaborative effort between the authors. The authors under supervision of A.C. contributed collectively in all steps of this research work including validation in real-time.
Funding: This research received no external funding.