*3.3. Implementation of the Grid-Interfaced Controller*

It is necessary to perform d-q analysis to make the essential data from the grid end relatable with the controller so that it can send the switching signal to the inverter to ensure that the PV source can receive the maximum amount of power. The exhaustive control methodology is illustrated in Figure 3.

**Figure 3.** Flowchart of the proposed HHO-AFOPID control algorithm.

For the PV-connected grid's infrastructure, resistance R, and inductance (L), the potential of the system is depicted as *vd* and *vq*, and *id*, and *iq* show the grid's currents. Conventional MPPT algorithms are the best fit for uniform environmental conditions. To overcome the shortcomings, a hybrid MPPT is proposed. The suggested control methodology is initiated by combining perturb and observe (P&O) with non-linear discrete PID (NDPID) to induce reference power (*Pref*) during varying solar irradiations and ambient temperature constants. The error is calculated by subtracting the reference power from the output power.

$$\text{Error} = \left| P\_{out} - P\_{ref} \right| \tag{44}$$

The error is termed as the integral absolute error (IAE) and integral time absolute error (ITAE), which can be described as:

$$\text{IAE} = \int\_0^t |e(t)|dt\tag{45}$$

$$\text{ITAE} = \int\_0^t t|e(t)|dt\tag{46}$$

where *t* is the simulation time.

By introducing the optimization, the superior value of fitness is achieved and, thereafter, the law of adaptive control can be set. The preliminary amplitude of the controller is obtained using horse herd optimization, which initiates the control logic expansion. The hybrid PO-NDPID MPPT controller is incorporated to induce the voltage of dc link *v*∗ *dc* under changing irradiation from the PV source. Accordingly, to achieve the power factor of unity, the reference of quadrature axis *i* ∗ *<sup>q</sup>* is calculated using thePV inverter. Later, by defining the state vector as . *x* = (*x*<sup>1</sup> , *x*<sup>2</sup> , *x*<sup>3</sup> ) *<sup>T</sup>*, which indicates that the parameters

are *iq* , *id*, *vdc<sup>T</sup>* , output matrix y can be defined as y = (*y*1, *y*2) *<sup>T</sup>* = *iq*, *vdc<sup>T</sup>* , and input u = (*u*1, *u*2) *T*= *vdc*, *vq T* . The photovoltaic inverter's state equation can be written as:

$$
\dot{\boldsymbol{\omega}} = \begin{bmatrix}
\frac{i\_p}{\mathcal{C}} & \frac{\varepsilon\_d\boldsymbol{\omega}\_1 + \varepsilon\_q\boldsymbol{\omega}\_2}{\mathcal{C}\boldsymbol{\omega}\_3} & 0
\end{bmatrix} + \begin{bmatrix}
\frac{1}{L} & 0 \\
0 & \frac{1}{L} \\
0 & 0
\end{bmatrix} \mathbf{u} \tag{47}
$$

the trailing error is defined as e = [*e*1,*e*2] *<sup>T</sup>*= *iq* − *i* ∗ *<sup>q</sup>* , *vdc* − *v*<sup>∗</sup> *dc T* (48)

The control input u is obtained by differentiating error e.

$$
\begin{bmatrix}
\dot{e} \\
\ddot{e}
\end{bmatrix} = \begin{bmatrix}
f\_{1(\boldsymbol{x})} \\
f\_{2(\boldsymbol{x})}
\end{bmatrix} + \mathbf{B}(\mathbf{x}) \begin{bmatrix}
u\_1 \\ \mu\_2
\end{bmatrix} - \begin{bmatrix}
i\_q^\* \\ \upsilon\_{dc}^\* \end{bmatrix} \tag{49}
$$

$$
\begin{bmatrix} f\_{1(\mathbf{x})} \\ f\_{2(\mathbf{x})} \end{bmatrix} = \mathbf{Matrix} \, \mathbf{A} \tag{50}
$$

Matrix A is further elaborated:

$$f\_1(\mathbf{x}) = -\frac{R}{L}\dot{\mathbf{i}}\_q + \omega \dot{\mathbf{i}}\_d - \frac{e\_q}{L} \tag{51}$$

$$f\_2(\mathbf{x}) = \frac{i\_p}{\mathcal{C}} - e\_d \left( -\frac{R}{L}i\_d - \omega i\_q - \frac{e\_d}{L} \right) + e\_q \left( -\frac{R}{L}i\_q + \omega i\_d - \frac{e\_q}{L} \right) / \mathcal{C}v\_{dc} - \frac{\left( e\_{di\_d + e\_q i\_q} \right)}{\mathcal{C}^{2r\_{dc}^2}} i\_p + \frac{\left( e\_d i\_d + e\_q i\_q \right)^2}{\mathcal{C}^2 v\_{dc}^3} \tag{52}$$

where

<sup>B</sup>(x) = \$ <sup>−</sup> 0 0 *ed LCvdc* <sup>−</sup> *eq LCvdc* % (53)

The controlling input [*u*1, *u*<sup>2</sup> ] can be achieved for photovoltaic inverters based on numerous HHO-AFOPID objectives.

The following formulation is obtained from (49).

$$\begin{aligned} u\_1 &= -\frac{\text{LC}\mathbf{v}\_{dc}}{\epsilon\_d} \left( \mathbf{v}\_{dc}^\* - \mathbf{v}\_{dc} + \mathbf{v}\_{dc}^\* \right) + \frac{\epsilon\_q}{\text{LCV}\_{dc}} \left( k\_{p1} + \frac{k\_{l1}}{s^{l1}} + k\_{d1}s^{q1} \right) - \frac{i\_p}{\mathbb{C}} + \\\ \frac{\epsilon\_d \left( -\frac{R}{L}i\_d - \omega i\_l - \frac{\epsilon\_d}{L} \right) + \epsilon\_q \left( -\frac{R}{L}i\_l + \omega i\_d - \frac{\epsilon\_q}{L} \right)}{\text{Cv}\_{dc}} &+ \left\{ \left( \mathbf{e}\_d i\_d + \mathbf{e}\_q i\_q \right) / \mathbf{C} \mathbf{v}\_{dc}^2 \right\} i\_P - \left( k\_{p2} + \frac{k\_{l2}}{s^{l2}} + k\_{d2}s^{q2} \right) \end{aligned} \tag{54}$$

$$\mu\_2 = \mathrm{Li}\_q^\* - \omega \mathrm{Li}\_d + \mathrm{Ri}\_q^\* + e\_q + (v\_{d\varepsilon} - v\_{d\varepsilon}^\*) \left[ (k\_{p1} + k\_{p2}) + \left( \frac{k\_{l1}}{s^{l1}} + \frac{k\_{l2}}{s^{l2}} \right) + \left( k\_{d1}s^{l1} + k\_{d2}s^{l2} \right) \right] \tag{55}$$

To attain the target, two control inputs (*u*1, and *u*2) are executed. The mentioned control topology is termed as numerous objectives due to its two fold adaptive features combined with the current of the q-axis (*iq* and the potential of the dc-link (*vdc*). The focus of the proposed HHO-AFOPID is to reduce the objective function or fitness function as follows:

$$\text{Reducing F}(\mathbf{x}) = \int\_0^{T\_{\text{sim}}} \left( (v\_{dc} - v\_{dc}^\*) + \left( i\_q - i\_q^\* \right) \right) dt \tag{56}$$

$$\text{Subjected to } \begin{cases} k\_{pi}^{\min} \le k\_{pi} \le k\_{pi}^{\max} \\ k\_{di}^{\min} \le k\_{di} \le k\_{di}^{\max} \\ k\_{ii}^{\min} \le k\_{ii} \le k\_{ii}^{\max} \quad \text{for } i = 1, 2 \\ \mu\_{i \min} \le \mu\_{i} \le \mu\_{i \max} \\ \lambda\_{i \min} \le \lambda\_{i} \le \lambda\_{i \max} \end{cases} \tag{57}$$

With a view to affirm the stability of the proposed HHO-AFOPID control topology, the single-input single-output (SISO) system is analyzed in terms of error reduction. The transfer function of the SISO system is written as follows:

. *R ki*<sup>1</sup> *ki*2 

$$\dot{e}\_1 + \left(k\_{p1} + k\_{p2} + \frac{\kappa}{L}\right)e\_1 + \left(\frac{k\_{l1}}{s^{\lambda 1}} + \frac{k\_{l2}}{s^{\lambda 2}}\right)e\_1 + \left(k\_{d1}s^{\mu 1} + k\_{d2}s^{\mu 2}\right)e\_1\tag{58}$$

$$\ddot{e} + \frac{1}{\mathcal{C}R\_{dc}}e\_2 + k\_{p2}e\_2 + k\_{p1}e\_2 + \left(\frac{k\_{l2}}{s^{\lambda 2}} - \frac{k\_{l1}}{s^{\lambda 1}}\right)e\_2 + \left(k\_{d2}s^{\mu 2} - k\_{d1}s^{\mu 1}\right)e\_1 \tag{59}$$

$$G\_{1}(\mathbf{s}) = \frac{1}{1 + \frac{s + \frac{R}{L}}{\left(k\_{p1} + k\_{p2}\right) + \left(k\_{d1}s^{p1} + k\_{d2}s^{p2}\right) + \left(\frac{k\_{i1}}{s^{j1}} + \frac{k\_{i2}}{s\lambda^2}\right)}}\tag{60a}$$

$$G\_{2}(s) = \frac{1}{1 + \frac{CR\_{dc}s^{2} + 1}{CR\_{dc}\left(k\_{p1} + k\_{p2} + k\_{d2}s^{\mu 2} - k\_{d1}s^{\mu 1} + \frac{k\_{i1}}{s^{\mu}2} + \frac{k\_{i1}}{s^{\mu}1}\right)}}\tag{60b}$$

The investigation of the stability of the advanced HHO-AFOPID control topology is analyzed in terms of IAE and ITAE. Figure 4 shows a grid-connected PV system where HHO-AFOPID generates the gate signal to operate the inverter in order to achieve the desired goal.

**Figure 4.** Block diagram of the proposed methodology.

The other parameters that are supplied to the same controller from the grid end are translated into d-q values in order to meet the control operation. The error produced from the differentiation between reference power and output power is delivered at the input of the AFOPID controller. To adjust the controller's settings, *kp*, *ki*, *kd*, μ, and λ, an intelligent optimizing algorithm, horse herd optimization, is introduced on the basis of the cost function or integral absolute error (IAE) and integral time absolute error (ITAE) objective functions.

#### **4. Results and Discussions**
