Real-Time Implementation of High Performance Control Scheme for Grid-Tied PV System for Power Quality Enhancement Based on MPPC-SVM Optimized by PSO Algorithm

: This paper proposes a high performance control scheme for a double function grid-tied double-stage PV system. It is based on model predictive power control with space vector modulation. This strategy uses a discrete model of the system based on the time domain to generate the average voltage vector at each sampling period, with the aim of canceling the errors between the estimated active and reactive power values and their references. Also, it imposes a sinusoidal waveform of the current at the grid side, which allows active power ﬁltering without a harmonic currents identiﬁcation phase. The latter attempts to reduce the size and cost of the system as well as providing better performance. In addition, it can be implemented in a low-cost control platform due to its simplicity. A double-stage PV system is selected due to its ﬂexibility in control, unlike single-stage strategies. Sliding mode control-based particle swarm optimization (PSO) is used to track the maximum power of the PV system. It offers high accuracy and good robustness. Concerning DC bus voltage of the inverter, the anti-windup PI controller is tuned ofﬂine using the particle swarm optimization algorithm to deliver optimal performance in DC bus voltage regulation. The overall system has been designed and validated in an experimental prototype; the obtained results in different phases demonstrate the higher performance and the better efﬁciency of the proposed system in terms of power quality enhancement and PV power injection. demonstrates its capability to design an optimal


Introduction
Nowadays, the use of renewable energies is more than necessary; it is a global strategic issue. Indeed, It is a major tool against global warming [1]. It is crucial to preserve resources and the environment while meeting the global demand for energy [2,3]. Solar energy is one of the so-called renewable energies in the sense that the sun is almost an inexhaustible resource [4].
It appears that photovoltaic presents itself as a solution for the future [5] because it offers a multitude of advantages; photovoltaic energy is exploitable in a mountainous area, in a remote village, Currently, moving towards approaches that provide fixed switching frequency is a vital issue. In this context, many algorithms that have been designed with fixed switching frequencies have been proposed for grid-connected converters [38][39][40].
The main contribution of this paper is to propose a high-performance control scheme for double function grid-tied PV system based on model predictive power control (MPPC) with space vector modulation (SVM). This approach is used to solve the variable frequency of MPPC based on cost function minimization that was presented in [23,37]. Moreover, it requires a reduced number of sensors compared to that presented in [1,4]. In addition, it offers a high capability in harmonic current mitigation and power factor correction, as well as in active power injection. In addition, it operates at low switching frequencies [41]. The Particle swarm optimization algorithm (PSO) became one of the most useful and most popular algorithms to solve various optimization problems in various fields. Among the key features of the PSO are its simplicity and flexibility. However, it is a powerful algorithm [42]. The parameters of Linear Proportional-Integral (PI) controller with anti-windup, which is used to perform the control of DC bus voltage, have been tuned through a particle swarm optimization algorithm considering Integral Time Absolute Error (ITAE) as an objective function [43,44]. The performance of the proposed PSO-PI controller has been compared to that of an ordinary PI controller, which is achieved through a computing approach. The gain of sliding mode MPPT has been tuned offline using the PSO algorithm to find the optimum gain that provides good accuracy in tracking the MPP. The efficiency and the performance of the proposed system have been investigated using real-time hardware implementation based on dSPACE board (dS1104). The obtained results in various cases (at filter switch on, load variation, after connecting PV system) present good static performance as compared to the DPC approach, whereas the dynamic performance has been improved after using anti-windup PI controller optimized by the PSO algorithm.
The paper is structured as follows: In Section 1, a comprehensive overview is presented. The general configuration of the global system is described in Section 2. Section 3 explains the basic principle of the proposed control strategy based on the MPPC-SVM approach, and presents its mathematical model. In Section 4, modeling and control of PV system are presented. After that, Section 5 takes a look at the particle swarm optimization algorithm and the optimization of different parameters. Then, in Section 6, the experimental results are given with a discussion. Lastly, the conclusion is given in Section 7.

General Configuration of the System
The proposed system relies on four main parts, as depicted in Figure 1: the power supply, nonlinear load, voltage source inverter (VSI) and double stage PV system. The inverter has a double function. Firstly, it operates as shunt active filter by minimizing the current harmonic distortion of the grid and suppressing the phase shift that are caused by the nonlinear load. Then, it injects PV power into the load/grid. PV panels are connected to VSI via a boost converter to operate with MPPT. The three-phase network is connected to a nonlinear load via three inductors. The nonlinear load is shaped from a three-phase diode rectifier with a resistive load, which is the most common source of harmonic currents. A two-level VSI based on six IGBT switches with a capacitor for energy storage is connected at the point of common coupling (PCC) through the inductors (L f ).
The instantaneous voltage of the three-phase balanced and sinusoidal system is based on the following expression: v sa (t) = √ 2v s cos(ωt) v sb (t) = √ 2v s cos(ωt − 2 π 3 ) v sc (t) = √ 2v s cos(ωt + 2 π 3 ) (1) The measured voltages at PCC are passed through the phase-locked loop (PLL) to estimate the fundamental component of the supply voltage. The theoretical principle of PLL is discussed in [45]. The equation that connects the current and the voltage of the active filter will be obtained after the application of Kirchhoff's laws to the above circuit, and can be expressed as follows: , , x a b c = (2) where s v is the source voltage at PCC, and f u is the voltage at the output of the inverter.
By neglecting the effect of filter resistance, Equation (2) can be written as: where: .
where: vs is the measured voltage at PCC, v is the source voltage, and is is the source current. The basic topology of the two-level VSI, as displayed in Figure 1, comprises six switches. Such a structure makes it possible to make eight combinations of switching that provide eight voltage vectors at the output of the inverter. Two voltages vectors are null and the others are given by expression (5).
where vdc is the DC bus voltage, n is a number of voltage vector, and un is the value of voltage vector at the output of VSI. The equation that connects the current and the voltage of the active filter will be obtained after the application of Kirchhoff's laws to the above circuit, and can be expressed as follows: where v s is the source voltage at PCC, and u f is the voltage at the output of the inverter. By neglecting the effect of filter resistance, Equation (2) can be written as: where: where: v s is the measured voltage at PCC, v is the source voltage, and i s is the source current. The basic topology of the two-level VSI, as displayed in Figure 1, comprises six switches. Such a structure makes it possible to make eight combinations of switching that provide eight voltage vectors at the output of the inverter. Two voltages vectors are null and the others are given by expression (5).
where v dc is the DC bus voltage, n is a number of voltage vector, and u n is the value of voltage vector at the output of VSI.

General Description of MPPC-SVM Approach
The MPPC-SVM strategy, as illustrated in Figure 2, relies on forecasting the instantaneous active and reactive power values using a predictive model. The control of VSI uses the concept of applying an average voltage vector, in each sampling period, that is converted into a sequence of adjacent control vectors in order to obtain the desired active and reactive powers [38]. The predictive value of active power is calculated by the outer control loop of the DC bus voltage based on a predictive model. The reactive power value is almost zero to ensure power factor correction. The optimal parameters of the anti-windup PI controller are calculated offline using PSO that takes into consideration total harmonic distortion of supply current THD(t) and the error of the DC bus voltage control loop as an objective function. A detailed description of this model is provided below.

General Description of MPPC-SVM Approach
The MPPC-SVM strategy, as illustrated in Figure 2, relies on forecasting the instantaneous active and reactive power values using a predictive model. The control of VSI uses the concept of applying an average voltage vector, in each sampling period, that is converted into a sequence of adjacent control vectors in order to obtain the desired active and reactive powers [38]. The predictive value of active power is calculated by the outer control loop of the DC bus voltage based on a predictive model. The reactive power value is almost zero to ensure power factor correction. The optimal parameters of the anti-windup PI controller are calculated offline using PSO that takes into consideration total harmonic distortion of supply current ( ) THD t and the error of the DC bus voltage control loop as an objective function. A detailed description of this model is provided below.

Computational Analysis of the Model
Any predictive strategy is based mainly on predicting the control quantities to be applied during a sampling period in order to accomplish the favorite performance. Firstly, the variable quantities that will be controlled in the proposed predictive model are the active and reactive powers. The balanced three-phase system, and the active and reactive power expressions in a stationary reference frame (α, β) are defined as: The variation of instantaneous active and reactive powers can be obtained using the time derivative as follows: If the sampling period is infinitely small compared with the fundamental period, the discretization of the Equation (7) yield:

Computational Analysis of the Model
Any predictive strategy is based mainly on predicting the control quantities to be applied during a sampling period in order to accomplish the favorite performance. Firstly, the variable quantities that will be controlled in the proposed predictive model are the active and reactive powers. The balanced three-phase system, and the active and reactive power expressions in a stationary reference frame (α, β) are defined as: The variation of instantaneous active and reactive powers can be obtained using the time derivative as follows: If the sampling period is infinitely small compared with the fundamental period, the discretization of the Equation (7) yield: In SAPF, the load consumes non-sinusoidal current that is composed mainly of the source current in addition to the current generated by the filter. The fundamental current is ensured by the source and the filter provides the harmonic currents as detailed below.
where: i l : Current consumed by the load. It can be noticed that the variation in filter current is equal to that of source current but with opposite sign: Then For a small variation of source and filter currents, the Equation (13) can be written as: The last expression allows us to obtain the variation in filter current as well as the voltage at the point of common coupling PCC without the need to measure filter current. Thus, the Equation (3) will be: The variation of the source current in α-β reference frame is given by the following expression: By inserting the previous expression into Equation (8), the predictive values of active and reactive power can be obtained by the following predictive model: It is observed that the sampling period, as well as filter and source inductance, are the main parameters that play an important role in the prediction stage. The objective of the predictive algorithm consists of tracking the active and reactive power values by making the error between the reference value and the actual value as near to zero as possible: For an optimal convergence towards the desired values of powers, the following equations must be verified. Then By inserting the Equation (20) into (17): By considering this, the reference value of active power is varied linearly between two successive sampling periods, as described in Figure 3. This consideration makes the assumption that the variation of the error of the voltage regulation loop during two successive sampling periods is null.
For an optimal convergence towards the desired values of powers, the following equations must be verified. ( By inserting the Equation (20) into (17): By considering this, the reference value of active power is varied linearly between two successive sampling periods, as described in Figure 3. This consideration makes the assumption that the variation of the error of the voltage regulation loop during two successive sampling periods is null.
In contrast, the reference value of reactive power is often imposed as a constant with zero value in order to ensure an operation with the unity power factor. As a result, the reference values of active and reactive power for the next sampling period can be estimated by the following: By using the Equations (21) and (22), the average control vector to be applied during the sampling period [kTs (k + 1)Ts] is obtained by the following equation: In contrast, the reference value of reactive power is often imposed as a constant with zero value in order to ensure an operation with the unity power factor. As a result, the reference values of active and reactive power for the next sampling period can be estimated by the following: By using the Equations (21) and (22), the average control vector to be applied during the sampling period [kT s (k + 1)T s ] is obtained by the following equation:

Control of DC Bus Voltage
The control of the DC bus voltage of VSI is an essential stage to ensure a good operation of the whole system. A DC side control loop is necessary to make the voltage constant and to estimate the reference value of grid current. A proportional integral controller (PI) has been proposed to correct the oscillation of the DC bus voltage and to ensure the stability of the system. Hence, the gains of the PI controller are computed as [35]: where ω represents the natural frequency, whereas ξ is the frequency of damping which is equal to 0.707 for optimal operation. In spite of this, high performance cannot be achieved by PI controller, in transient time, because of the large error that is caused by the saturation of controller [46]. A high gain of anti-windup has been introduced to the PI controller (G a ), as depicted in Figure 4 [35,46], with the aim of solving saturation problem and obtaining smooth operations in the transient state.

Control of DC Bus Voltage
The control of the DC bus voltage of VSI is an essential stage to ensure a good operation of the whole system. A DC side control loop is necessary to make the voltage constant and to estimate the reference value of grid current. A proportional integral controller (PI) has been proposed to correct the oscillation of the DC bus voltage and to ensure the stability of the system. Hence, the gains of the PI controller are computed as [35]: where ω represents the natural frequency, whereas ξ is the frequency of damping which is equal to 0.707 for optimal operation. In spite of this, high performance cannot be achieved by PI controller, in transient time, because of the large error that is caused by the saturation of controller [46]. A high gain of anti-windup has been introduced to the PI controller (Ga), as depicted in Figure 4 [35,46], with the aim of solving saturation problem and obtaining smooth operations in the transient state.

Modeling of Solar PV Module
PV module is treated as a number of PV cells associated in series and in parallel [47]. Multiple mathematical models for PV cells are found in the literature [48,49]. The adopted PV module is designed based on a single-diode model represented by Equation (26) where: Isc: Photo-current generated by PV cell. I0: Saturation current of the diode. Vt: Thermal voltage of PV cell.

Modeling of Solar PV Module
PV module is treated as a number of PV cells associated in series and in parallel [47]. Multiple mathematical models for PV cells are found in the literature [48,49]. The adopted PV module is designed based on a single-diode model represented by Equation (26) [49].
where: I sc : Photo-current generated by PV cell. I 0 : Saturation current of the diode. α: Diode ideality factor. V cell : Voltage at the output of PV cell. I cell : Current generated by PV cell.
In the experiment, four PV modules (ALPV85-125M-36) are connected in series to achieve the desired voltage level and to raise the power of the whole PV system. However, the installation of the PV modules depends on its geographical location. It is necessary to choose the optimal orientation and inclination for the location. This makes it possible to produce a maximum of energy. The PV modules are oriented south (azimuth 0 • ) and inclined 34.8 • relative to the horizontal, which is the optimum tilt angle in that location, as demonstrated in [50]. The parameters of the PV panel are listed in Table 1, whereas the P-V and I-V characteristics of the overall PV system in different climate conditions are given in Figure 5. In the experiment, four PV modules (ALPV85-125M-36) are connected in series to achieve the desired voltage level and to raise the power of the whole PV system. However, the installation of the PV modules depends on its geographical location. It is necessary to choose the optimal orientation and inclination for the location. This makes it possible to produce a maximum of energy. The PV modules are oriented south (azimuth 0°) and inclined 34.8° relative to the horizontal, which is the optimum tilt angle in that location, as demonstrated in [50]. The parameters of the PV panel are listed in Table 1, whereas the P-V and I-V characteristics of the overall PV system in different climate conditions are given in Figure 5.

Sliding Mode Based MPPT
Sliding mode control for non-linear systems has become a motivating solution. It is one of the most used control approaches thanks to its advantages.(robustness, good stability, and very low response time) [51]. It is characterized by the discontinuity of the control at the passages by a sliding surface. So everything depends on the appropriate choice of this surface [20]. Therefore, for simplicity, Equation (27) has been transformed for the sliding surface for SM-MPPT. Then The structure of the sliding mode controller focuses on two main parts: a continuous part and another discontinuous part [51], as presented below: The first part, is extracted from the condition (30) which satisfies Lyapunov stability theory [52].
The continuous part is as follows (31).
The second part is important in nonlinear control because its role is to eliminate the effects of inaccuracies and disturbances on the model of the system when the system has not reached the sliding surface [20]. It is defined by: K: is the maximum value desired at the output of the controller to assure steady-state stabilization. The output of the SMC can be represented by (33): The sliding mode gain has been tuned using PSO algorithm as shown in Figure 6.
The structure of the sliding mode controller focuses on two main parts: a continuous part and another discontinuous part [51], as presented below: The first part, is extracted from the condition (30) which satisfies Lyapunov stability theory [52].
The continuous part is as follows (31).
The second part is important in nonlinear control because its role is to eliminate the effects of inaccuracies and disturbances on the model of the system when the system has not reached the sliding surface [20]. It is defined by: .
( ) disc u K sign S = (32) K: is the maximum value desired at the output of the controller to assure steady-state stabilization.
The output of the SMC can be represented by (33): The sliding mode gain has been tuned using PSO algorithm as shown in Figure 6.

Designing of PSO Algorithm
PSO contains a population of candidate solutions called a swarm; this swarm is a set of particles [44]. Any particle has a position in the search space y. Therefore, any particle has a velocity h, which describes the movement of a particle in the sense of direction, distance, and the step size. In addition to position and velocity, every particle has a memory of its own best position and best experience. This is denoted by the personal best P best . However, the best experience of all particles is known as the global best G best [53]. Particles of the swarm are interacting and learning from each other, obeying some simple rules to find the best solution for an optimization problem [54]. The mathematical model of the motion of particles can be described as follows: where: i: Number of particle. k: Current number of iteration. r 1 , r 2 : are random number confined between 0 and 1. o 1 , o 2 : are acceleration coefficients.
δ: is the inertia coefficient that is defined by (36) as indicated in [55].
The new position of a particle is probably a better location, because it is created according to the previous decision about the movement of this particle, and it uses the previous experience of the particle itself as well as the previous experience of the whole swarm.

The Optimization Problem
A PI controller with anti-windup provides good performance in DC bus voltage regulation for the proposed system. However, anti-windup PI controller needs an accurate mathematical model, which is unreachable in the case of parameter variations and system nonlinearity. Consequently, a PI controller that is designed based on the conventional method fails to achieve optimal performance under different operating modes. Hence, the PSO algorithm has been proposed to improve the performance of the anti-windup PI controller. It executes an offline search in three search spaces to obtain the optimized parameters for the PI controller, i.e., integral gain Ki, proportional gain Kp, and anti-windup gain Ga that give better dynamic and steady performance.
The optimization problem, which is being solved by the PSO, is an objective function that would like to minimize its fitness. The objective function is based on the instantaneous error of DC bus voltage control loop e(t) and instantaneous THD(t) of current supply, as described in Figure 2: whereas: The performance of above-mentioned objective functions is evaluated according to the PSO mechanism, as shown in Figure 7; the initial parameters of the PSO algorithm are listed in Table 2. The suitable objective function for DC bus voltage regulation was selected according to its corresponding fitness value. After many experiments, the lowest fitness value has been obtained using ITAE objective function. ITAE = t e pv (t) ·dt (39) where: where P PVre f (t): Reference value of output PV power. P PV (t): Measured value of output PV power.
where:    Then again, sliding mode gain is properly adjusted for each sliding mode application with the aim of satisfying the stability condition of the system, because there is no generalized rule to determine SMC gain [56]. The PSO algorithm has been used to determine the optimal gain for sliding  Then again, sliding mode gain is properly adjusted for each sliding mode application with the aim of satisfying the stability condition of the system, because there is no generalized rule to determine SMC gain [56]. The PSO algorithm has been used to determine the optimal gain for sliding mode MPPT considering the objective function ITAE in standalone mode. Thus, the obtained optimized and calculated gains are given in Table 3.

Results and Discussion
The proposed system has been investigated in an experimental bench test developed in the laboratory, as shown in Figure 8. The experimental pattern is designed for low voltage rates due to laboratory limitations. It consists mainly of the following:

1.
Three phase power supply based on three-phase autotransformer.

2.
Two-level inverter and boost converter manufactured by SEMIKRON based on IGBTs (SKM 50 GB 123D) in addition to three-phase diode bridge rectifier.

3.
Measurement and visualization tools.
All the experimental results were recorded through a four-channel Oscilloscope Instek GDS-3154, 150 MHz, 5 GSa/s (Giga Samples per Second). The size of memory necessary to stock a captured signal based on two parameters depends on the sample rate and the waveform length (time period). The waveform length is the product of the horizontal scale multiplied by the number of divisions. The used oscilloscope has 10 horizontal divisions and the sample rate as equal to 5 GS/s. The lowest horizontal scale used in the measurement is 10 ms/div. The total time period is 10 div × 10 ms/div. Then, the necessary waveform memory could be calculated as follows: 10 × 10 ms × 5 GS/s = 0.5 GSample (half million sample). On the other hand, the frequency range of the used oscilloscope is 150 MHZ, which designates the bandwidth of an input signal that can be captured with negligible loss. However, the frequencies of the measured signals do not exceed 2 kHz. Therefore, the used oscilloscope (Instek GDS-3154, 150 MHz, 5 GSa/s) can effectively capture the details of the signals with high accuracy.
The pyranometer SHARP SOLAR METER SPRM-2 was used for measuring solar irradiance. Its irradiance range is 0 to 1200 W/m 2 .  All the experimental results were recorded through a four-channel Oscilloscope Instek GDS-3154, 150 MHz, 5 GSa/s (Giga Samples per Second). The size of memory necessary to stock a captured signal based on two parameters depends on the sample rate and the waveform length (time period). The waveform length is the product of the horizontal scale multiplied by the number of divisions. The used oscilloscope has 10 horizontal divisions and the sample rate as equal to 5 GS/s. The lowest horizontal scale used in the measurement is 10 ms/div. The total time period is 10 div × 10 ms/div. Then, the necessary waveform memory could be calculated as follows: 10 × 10 ms × 5 GS/s = 0.5 GSample (half million sample). On the other hand, the frequency range of the used oscilloscope is 150 MHZ, which designates the bandwidth of an input signal that can be captured with negligible loss. However, the frequencies of the measured signals do not exceed 2 kHz. Therefore, the used oscilloscope (Instek GDS-3154, 150 MHz, 5 GSa/s) can effectively capture the details of the signals with high accuracy.
The pyranometer SHARP SOLAR METER SPRM-2 was used for measuring solar irradiance. Its irradiance range is 0 to 1200 W/m 2 . For real-time implementation, dSpace 1104 is used. The computing time of the process is set to the lowest possible sample time of the DSP (4 × 10 −4 S). The detailed system parameters are given in Table 4. Firstly, the performance of PSO-PI with anti-windup is compared to that of the conventional PI controller. The response of each one under double step change of DC bus voltage from 160 V to 140 V and vice versa is shown in Figure 9. It is noted that PSO-PI with anti-windup can improve the transient state by dipping the over-and upper-shoot of DC-link voltage, as well as by providing a much-reduced settling time. Therefore, the supply current is not highly affected by DC-link voltage variation after using the optimized anti-windup PI controller. For real-time implementation, dSpace 1104 is used. The computing time of the process is set to the lowest possible sample time of the DSP (4 × 10 −4 S). The detailed system parameters are given in Table 4. Firstly, the performance of PSO-PI with anti-windup is compared to that of the conventional PI controller. The response of each one under double step change of DC bus voltage from 160 V to 140 V and vice versa is shown in Figure 9. It is noted that PSO-PI with anti-windup can improve the transient state by dipping the over-and upper-shoot of DC-link voltage, as well as by providing a much-reduced settling time. Therefore, the supply current is not highly affected by DC-link voltage variation after using the optimized anti-windup PI controller.
The feasibility and efficiency of the proposed control scheme have been evaluated based on power quality enhancement. Various tests have been established before connecting the PV system, comparing it with those obtained using conventional DPC such as steady-state operation, Connection/disconnection of SAPF and Load variation

•
Steady state operation The steady state performance of both control strategies can be evaluated in Figures 10-12. The source current has been analyzed using a Fast Fourier Transformation tool (FFT). Figure 10 shows the source current and its spectrum analysis before connecting the filter (inverter), which is the same current of the load. The current has a non-sinusoidal waveform with high harmonic distortion, as shown in the spectrum graph.  The feasibility and efficiency of the proposed control scheme have been evaluated based on power quality enhancement. Various tests have been established before connecting the PV system, comparing it with those obtained using conventional DPC such as steady-state operation, Connection/disconnection of SAPF and Load variation.

• Steady state operation
The steady state performance of both control strategies can be evaluated in Figures 10-12. The source current has been analyzed using a Fast Fourier Transformation tool (FFT). Figure 10 shows the source current and its spectrum analysis before connecting the filter (inverter), which is the same current of the load. The current has a non-sinusoidal waveform with high harmonic distortion, as shown in the spectrum graph.
The filtered current waveform when using the conventional DPC strategy is shown in Figure 11a. It was observed that the fifth and the seventh harmonic components appear in the spectrum graph in addition to the fundamental component. However, the obtained current after filtering has a sinusoidal waveform, and the higher order harmonic components are effectively suppressed when MPPC-SVM is used, which demonstrates the superiority of the proposed algorithm in harmonic current filtering. Figure 12 illustrates the supply voltage, supply current, filter current, and the DC bus voltage. It is clearly observed that supply current has a smooth sinusoidal waveform which is in phase with the corresponding source voltage. The DC bus voltage is perfectly regulated at 160 V, whereas the inverter injects the current harmonic components needed for the main current filtering. As can be seen, good electrical signal waveforms are given after using the proposed control strategy with low distortion of the supply current.
• Disconnection/connection of SAPF Figure 13 represents, from top to bottom: source voltage and source current, filter current, and DC bus voltage. As can be seen, before connecting the filter, the load current is totally supplied by the utility grid; as a result, the source voltage is affected by harmonic components in the supply current. The DC side capacitor is charged via the open loop scheme (through antiparallel diodes) to reach a line voltage level v dc = 100 V.  The filtered current waveform when using the conventional DPC strategy is shown in Figure  11a. It was observed that the fifth and the seventh harmonic components appear in the spectrum graph in addition to the fundamental component. However, the obtained current after filtering has a Figure 10. FFT analysis of supply current before connecting the filter. sinusoidal waveform, and the higher order harmonic components are effectively suppressed when MPPC-SVM is used, which demonstrates the superiority of the proposed algorithm in harmonic current filtering.
(a) (b) Figure 11. FFT analysis of supply current after using conventional DPC (a) and MPPC-SVM (b) strategy. Figure 12 illustrates the supply voltage, supply current, filter current, and the DC bus voltage. It is clearly observed that supply current has a smooth sinusoidal waveform which is in phase with the corresponding source voltage. The DC bus voltage is perfectly regulated at 160 V, whereas the inverter injects the current harmonic components needed for the main current filtering. As can be • Disconnection/connection of SAPF Figure 13 represents, from top to bottom: source voltage and source current, filter current, and DC bus voltage. As can be seen, before connecting the filter, the load current is totally supplied by the utility grid; as a result, the source voltage is affected by harmonic components in the supply After inserting SAPF, the inverter starts to inject the current if that is necessary to make the supply current free from harmonics. The PSO-PI controller only needs 0.08 s to keep the DC bus voltage at its reference value 160 V. The active and reactive powers of the source are illustrated with their references in Figure 14. The reactive power is successfully compensated after connecting the filter in the case of the proposed control strategy. Hence, the active power perfectly tracked its reference with reduced ripple compared to that of a conventional DPC.   After inserting SAPF, the inverter starts to inject the current i f that is necessary to make the supply current free from harmonics. The PSO-PI controller only needs 0.08 s to keep the DC bus voltage at its reference value 160 V. The active and reactive powers of the source are illustrated with their references in Figure 14. The reactive power is successfully compensated after connecting the filter in the case of the proposed control strategy. Hence, the active power perfectly tracked its reference with reduced ripple compared to that of a conventional DPC. •

Load variation
To demonstrate the higher effectiveness of the DC bus voltage controller, double step change in nonlinear load was established; the value of the nonlinear load presents a variation of 32% (R1= 16 Ω to R2 =11 Ω and vice versa). Very satisfactory results are achieved, as can be observed in Figure 15. It shows a good transient behavior of the system other than smooth variation in supply current. The

• Load variation
To demonstrate the higher effectiveness of the DC bus voltage controller, double step change in nonlinear load was established; the value of the nonlinear load presents a variation of 32% (R1= 16 Ω to R2 =11 Ω and vice versa). Very satisfactory results are achieved, as can be observed in Figure 15. It shows a good transient behavior of the system other than smooth variation in supply current. The increase in source current leads to a slight voltage dip in the DC link capacitor voltage. During this phase, the load consumes additional energy from the capacitor to reach its need. Alternatively, an excess in DC bus voltage is seen once the supply current is decreased. However, the PSO-PI controller quickly corrects these voltage variations. Generally, the obtained results in different phases prove the superiority of the proposed control strategy in terms of power quality. It presents a better current waveform with less harmonic components, reduced active power ripples, and better reactive power compensation.
Energies 2018, 11, x FOR PEER REVIEW 20 of 28 increase in source current leads to a slight voltage dip in the DC link capacitor voltage. During this phase, the load consumes additional energy from the capacitor to reach its need. Alternatively, an excess in DC bus voltage is seen once the supply current is decreased. However, the PSO-PI controller quickly corrects these voltage variations. Generally, the obtained results in different phases prove the superiority of the proposed control strategy in terms of power quality. It presents a better current waveform with less harmonic components, reduced active power ripples, and better reactive power compensation. •

SM-MPPT under variable illumination.
To demonstrate the efficiency and the robustness of SM-MPPT algorithm, a simulation test has been established under variable illumination in standalone mode. The photovoltaic generator is composed of four PV panels of 85 W associated in series. The output power of the PV generator using sliding mode MPPT-based PSO is compared to that obtained using a conventional P_O algorithm. As seen in the curves of Figure 16, sliding mode MPPT optimized by PSO perfectly follows the theoretical reference. It follows the maximum power with a very good stability and lower oscillation. However, the panels are still at their optimal power despite the sudden variation of illumination. In addition, the proposed MPPT reaches the MPP with a very short convergence time when compared to the P_O algorithm. • SM-MPPT under variable illumination.
To demonstrate the efficiency and the robustness of SM-MPPT algorithm, a simulation test has been established under variable illumination in standalone mode. The photovoltaic generator is composed of four PV panels of 85 W associated in series. The output power of the PV generator using sliding mode MPPT-based PSO is compared to that obtained using a conventional P_O algorithm. As seen in the curves of Figure 16, sliding mode MPPT optimized by PSO perfectly follows the theoretical reference. It follows the maximum power with a very good stability and lower oscillation. However, the panels are still at their optimal power despite the sudden variation of illumination. In addition, the proposed MPPT reaches the MPP with a very short convergence time when compared to the P_O algorithm.
• Inserting the PV system.
The proposed system was designed to operate as shunt active power filter (SAPF) when the PV system is disconnected (lack of illumination); it performs power quality improvements by reducing the current harmonics of the source and enhancing its power factor, but once the PV system is connected (exist of illumination), additional active power is injected into the load/grid as can be seen in Figure 17. After connecting the PV system, in Figure 18, it is observed that the current provided by the main source is reduced, the injected current is increased, and the PV power is different to zero, whereas the active power provided by the source is reduced. The experimental tests were done in real time under • Inserting the PV system.
The proposed system was designed to operate as shunt active power filter (SAPF) when the PV system is disconnected (lack of illumination); it performs power quality improvements by reducing the current harmonics of the source and enhancing its power factor, but once the PV system is connected (exist of illumination), additional active power is injected into the load/grid as can be seen in Figure 17. After connecting the PV system, in Figure 18, it is observed that the current provided by the main source is reduced, the injected current is increased, and the PV power is different to zero, whereas the active power provided by the source is reduced. The experimental tests were done in real time under the following conditions (T = 37 °C and G = 860 W/m 2 ). In this test, the fixed tilt ground-mounted PV string provides its maximum available power (240 W) to the load, and the grid ensures the remaining needed power.   The investigated scenarios of the proposed system operation are summarized in Figure 17. It shows the results in three different phases; before connecting the inverter (filter) into the grid, after connecting the inverter into the grid (filtering phase), during the operation of the PV system. Before connecting the filter, the load was supplied directly by the source that offers the needed active and reactive power simultaneously and the harmonic currents. Once the filter is connected, the inverter provides the needed reactive power and the harmonic currents to the load in order to make the source operate with unity power factor and suppress the higher order harmonic components. Then, after The investigated scenarios of the proposed system operation are summarized in Figure 17. It shows the results in three different phases; before connecting the inverter (filter) into the grid, after connecting the inverter into the grid (filtering phase), during the operation of the PV system. Before connecting the filter, the load was supplied directly by the source that offers the needed active and reactive power simultaneously and the harmonic currents. Once the filter is connected, the inverter provides the needed reactive power and the harmonic currents to the load in order to make the source operate with unity power factor and suppress the higher order harmonic components. Then, after connecting the PV system, the inverter performs three main functions: reactive power compensation, active power injection by PV system, and source current filtering. The three operation phases are clearly demonstrated by the source and injected current waveform, DC bus voltage, in addition to active and reactive power waveform.
It is shown in Figure 19 that the injected current after connecting PV system has a different waveform compared to that obtained in the absence of PV system, because it includes harmonic current, reactive current, and active current provided by PV panels. However, the active current does not exist before connecting PV system. Figure 20 shows the spectrum analysis of the main source current when the PV system is connected. It is clearly shown that higher order harmonics are effectively suppressed and only the 5th and 13th harmonics appear in the spectrum graph with small magnitudes, which proves the proficiency of the proposed system in suppressing harmonic currents in addition to PV power injection. active power injection by PV system, and source current filtering. The three operation phases are clearly demonstrated by the source and injected current waveform, DC bus voltage, in addition to active and reactive power waveform.
It is shown in Figure 19 that the injected current after connecting PV system has a different waveform compared to that obtained in the absence of PV system, because it includes harmonic current, reactive current, and active current provided by PV panels. However, the active current does not exist before connecting PV system.  Figure 20 shows the spectrum analysis of the main source current when the PV system is connected. It is clearly shown that higher order harmonics are effectively suppressed and only the 5th and 13th harmonics appear in the spectrum graph with small magnitudes, which proves the proficiency of the proposed system in suppressing harmonic currents in addition to PV power injection.

Conclusions
In this paper, an MPC with SVM for double function grid-tied PV system has been designed and validated in an experimental prototype. The proposed control scheme replaces the cost function block of the MPC approach by SVM to operate at fixed and low switching frequencies, enhance the performance of the system, and to ensure the reliability of its hardware components. One important feature that characterizes this control strategy is the simplicity of implementation; it does not need the coordinate transformation of system variables into rotating reference frame (d-q) as well as current control loops. In addition, it does not require a current harmonic extraction stage, which reduces the number of required sensors and minimizes the cost and the size of SAPF. Likewise, it decreases the computing time and improves accuracy. Furthermore, the voltage control vectors are calculated without using linear controllers. The efficiency of the developed SM-MPPT-based PSO algorithm has been clearly demonstrated during a sudden change in illumination. Then again, the PSO algorithm demonstrates its capability to design an optimal anti-windup PI controller that can improve the control of DC side of the inverter. The obtained results in different operating conditions

Conclusions
In this paper, an MPC with SVM for double function grid-tied PV system has been designed and validated in an experimental prototype. The proposed control scheme replaces the cost function block of the MPC approach by SVM to operate at fixed and low switching frequencies, enhance the performance of the system, and to ensure the reliability of its hardware components. One important feature that characterizes this control strategy is the simplicity of implementation; it does not need the coordinate transformation of system variables into rotating reference frame (d-q) as well as current control loops. In addition, it does not require a current harmonic extraction stage, which reduces the number of required sensors and minimizes the cost and the size of SAPF. Likewise, it decreases the computing time and improves accuracy. Furthermore, the voltage control vectors are calculated without using linear controllers. The efficiency of the developed SM-MPPT-based PSO algorithm has been clearly demonstrated during a sudden change in illumination. Then again, the PSO algorithm demonstrates its capability to design an optimal anti-windup PI controller that can improve the control of DC side of the inverter. The obtained results in different operating conditions demonstrate the efficiency of the proposed control scheme in terms of harmonic current filtering, power factor correction, and DC bus voltage regulation, as well as PV power injection. It offers a superior performance and higher power quality compared to conventional DPC strategies.