System modeling is perhaps an important phase in addition to the other forms of system control design work. The system model depends on the aims of the simulation. If the objective is to predict the behavior of a system before it is built, a good system model should support the designer with important information about the system dynamics, and so on. Because of the difficulty involved in solving nonlinear equations, all the governing equations will be put together in block diagram form and then simulated using MATLAB’s Simulink environment. Simulink will solve these nonlinear equations numerically and provide a simulated response of the system dynamics [12]. The proposed system under study comprises a PV array, boost converter, an MPPT-based PID and PWM controller in addition to a resistive DC load. The model for each of the system elements is derived as follows:

### PV system model

Figure 1 displays the stand-alone PV system to be considered in this work. The operation of the proposed system should operate at the strategies of: maximum power point operation, boosting the voltage of the PV array to the desired level of the load voltage, battery backup units with charge regulators and load matching.

Figure 2 displays the complete electrical equivalent circuit for PV cells which can be represented by two equations as:

$$I_{pv} = I_{ph} - I_{0} \left\{ {\exp \left[ {\frac{e}{{kT_{C} }}\left( {V_{pv} + R_{s} I_{pv} } \right)} \right] - 1} \right\} - \frac{{V_{pv} + R_{s} I_{pv} }}{{R_{sh} }}$$

(1)

$$V_{pv} = \frac{{A k T_{c} }}{e}\ln \left( {\frac{{I_{ph} + I_{o} - I_{pv} }}{{I_{o} }}} \right) - R_{s} I_{pv}$$

(2)

Based on Eqs. (1) and (2), the MATLAB Simulink block for the PV array has been considered in the system modeling by setting the array parameters in accordance with the selected data given in Appendix A. Figure 3 displays the I–V and P–V characteristics of the module and the array of the considered PV system.

### Boost converter model

The boost converter of Fig. 4 with a switching period of **T** and a duty cycle of **D** is considered as a part of the proposed stand-alone PV system. Assuming continuous conduction mode of operation, the state space equations when the main switch is ON are given by Eq. (3), [13].

$$\left\{ {\begin{array}{*{20}l} {\frac{{{\text{d}}i_{L} }}{{{\text{d}}t}} = \frac{1}{L}\left( {V_{{{\text{in}}}} } \right)} \hfill \\ {\frac{{{\text{d}}v_{0} }}{{{\text{d}}t}} = \frac{1}{C}\left( { - \frac{{v_{0} }}{R}} \right)} \hfill \\ \end{array} ,\quad 0 < t < {\text{d}}T, } \right.\;\underline{O} :\;{\text{ON}}$$

(3)

and when the switch is OFF are shown by Eq. (4):

$$\left\{ {\begin{array}{*{20}l} {\frac{{{\text{d}}i_{L} }}{{{\text{d}}t}} = \frac{1}{L}\left( {V_{{{\text{in}}}} - V_{{\text{o}}} } \right)} \hfill \\ {\frac{{{\text{d}}v_{0} }}{{{\text{d}}t}} = \frac{1}{C}\left( {i_{L} - \frac{{v_{0} }}{R}} \right)} \hfill \\ \end{array} ,\quad {\text{d}}T < t < T, } \right.\;\underline{O} :\;{\text{OFF}}$$

(4)

Figure 5 illustrates Eqs. (3) and (4) in MATLAB Simulink using a simulated boost converter circuit with a control signal applied to the gate of the switching element in order to get the desired switching operation of the converter and obtain the states \(i_{L} \left( t \right)\) and \(v_{o} \left( t \right)\) [14,15,16].

### Maximum power point tracking (MPPT) algorithms

Maximum power point tracking MPPT is used in PV systems to maximize the output power of photovoltaic cells. MPPT can be achieved through the implementation of an electronic circuit, programmed algorithm, or it may be simulated in MATLAB Simulink environment. It varies the electrical operating point of the modules so that they are able to deliver maximum power [17]. Several algorithms for MPPT are proposed and introduced in the literature including: perturb and observe, open circuit voltage, short circuit current, incremental conductance algorithms, in addition to the neural networks and fuzzy logic [17]. The selection of the algorithm depends on the complexity of system and the time taken to track the maximum power point. In this work, the proposed method to track the maximum power for the stand-alone PV system is the incremental conductance **IC** algorithm using MATLAB/Simulink.

### Incremental conductance algorithm

In this algorithm, it is needed to apply two voltages sensor and two current sensors for sensing both the output voltage and current of the PV array. The maximum power point is achieved when the slope of the P–V curve has a value of zero, this can be explained as:

$$\left( {\frac{{{\text{d}}P}}{{{\text{d}}V}}} \right)_{{{\text{MPP}}}} = {\text{d}}\left( {VI} \right) / {\text{d}}V$$

(5)

$$0 = I + V\left( {\frac{{{\text{d}}I}}{{{\text{d}}v}}} \right)_{{{\text{MPP}}}} \quad {\text{or}}\quad \left( {\frac{{{\text{d}}I}}{{{\text{d}}v}}} \right)_{{{\text{MPP}}}} = - \frac{I}{V}$$

(6)

The Flow chart of the incremental conductance MPPT algorithm is displayed in Fig 6, [18].

### MPPT-based PID controller

In most of the applications, it is needed to maintain the output voltage of converter as constant regardless the changes in the load or input voltage. The DC–DC power converters are sited in middle stage of most of electrical power systems; their input is connected to solar cells, and output is connected to the load. Both input and output sides are prone to sudden changes in values, slow transient response increase losses in the system and leads to reduction in efficiency.

Several methods have been proposed by researchers to control output voltage of DC–DC converters. This paper proposes an MPPT-based PID controller to be implemented to the converter as described in Figs. 7 and 8.

Nowadays, the PID controller is the most widely used, it is used to optimize the system performance like the stability, the voltage regulation, rapidity and the precision. The proposed PID controller is illustrated in Fig. 9 [19]. The PID tuning and optimization can be carried out by many algorithms Genetic, Ant Colony, Particle Swarm, Harmony, and other algorithms presented in the literature [20]. In this work, the Particle Swarm Optimization (PSO) has been employed to get the gains of the optimal PID (OPID) and the MPPT-based PID proposed controllers. Figure 10 represents the flowchart of PSO algorithm [21].

The PID controller can be described as illustrated in Eq. (7) [22]:

$$\begin{aligned} & u\left( t \right) = K_{t} e\left( t \right) + K_{i} \mathop \int \limits_{0}^{t} e\left( t \right){\text{d}}t + K_{d} \frac{{\text{d}}}{{{\text{d}}t}} e\left( t \right) \;{\text{or}} \\ & u\left( s \right) = K_{t} E\left( S \right) + K_{i} \frac{E\left( S \right)}{D} + K_{d} \cdot s E\left( s \right) \\ \end{aligned}$$

(7)

The parameters of OPID and MPPT-based PID controllers have been designed and optimized using the PSO technique with the objective function that is chosen to be the Integral Time Square Error (ITSE) which can be defined as in Eq. (8) to minimize the squared error:

$${\text{ITSE }} = \int {t \cdot e^{2} {\text{d}}t}$$

(8)

In addition, among the evolutionary computation, the updated velocity and position for each particle in the swarm can be calculated using the current velocity and the distance from the particle best solution **p**_{besti} and the global best solution **g**_{besti} by employing Eqs. (9) and (10) [23, 24]:

$$v_{i}^{k + 1} = w*v_{i}^{k} + c_{1} *rand_{1} *\left( {x_{pbesti}^{k} - x_{i}^{k} } \right) + c_{1} *rand_{1} *\left( {x_{gbesti}^{k} - x_{i}^{k} } \right)$$

(9)

$$x_{i}^{k + 1} = x_{i}^{k} + v_{i}^{k + 1}$$

(10)

Initialization parameters used for PSO are: population size = 30, maximum number of iterations = 2000, minimum and maximum velocities are 0 and 2, cognitive and social acceleration coefficient C1 = 2, C2 = 1.4, minimum and maximum inertia weights are 0.6 and 0.9.