## 6 Implementation of the SMC and the MPPT Algorithm
### Limiting the Switching Frequency  
Theoretical sliding-mode controllers operate with infinite switching frequency [29]; hence, a widely adopted solution is to introduce a hysteresis band around the sliding surface, where the bandwidth defines the maximum switching frequency [30].  
Figure 4 illustrates the hysteresis band effect on the switching frequency: the switching function derivative, given in (21), exhibits the derivatives imposed by the operating conditions; thus, increasing the width of the hysteresis band decreases the switching frequency because the switching function derivative will be a longer time in a given state (positive or negative).  
Introducing a hysteresis band \(\{-H,+H\}\) around the switching function \(\psi_{x}\) (20) produces the practical sliding surface given below:  
\[-H<k_{1}\cdot\left(v_{pv}-v_{mpt}\right)+i_{pv}-k_{2}\cdot i_{m}<+H \tag{39}\]  
Taking into account that the design process provided in the previous sections ensures the global stability of the SMC, the average value of the PV voltage is equal to the MPPT reference, i.e., \(\left\langle v_{pv}\right\rangle=v_{mpt}\). Similarly, the average value of the magnetizing current multiplied by the duty cycle is equal to the PV current, as given in (8), i.e., \(\left\langle i_{m}\right\rangle\cdot d=i_{pv}\). On the other hand, both the PV voltage \(v_{pv}\) and magnetizing current \(i_{m}\) exhibit voltage \(\delta v_{pv}\) and current \(\delta i_{m}\) ripples, respectively, due to the switching action of the converter:  
\[v_{pv}=\left\langle v_{pv}\right\rangle+\delta v_{pv}\quad\wedge\quad i_{m}= \left\langle i_{m}\right\rangle+\delta i_{m} \tag{40}\]  
Therefore, the practical sliding surface defined in (39) can be rewritten as in (41), which considers the value \(k_{2}=d\), as previously defined in (29).  
\[-H<k_{1}\cdot\delta v_{pv}-d\cdot\delta i_{m}<+H \tag{41}\]  
The ripples of the magnetizing current (\(\delta i_{m}\)) and PV voltage (\(\delta v_{pv}\)) are calculated from the switched Equations (1) and (2) using the flux-balance (\(\delta i_{m}\)) and charge balance (\(\delta v_{pv}\)), respectively. The \(\delta i_{m}\) value was calculated in the interval with \(u=1\), with duration \(T_{sw}\cdot d\), to use the shortest equation for the current derivative; similarly, the \(\delta v_{pv}\) value was calculated in the interval with \(u=0\), with duration \(T_{sw}\cdot(1-d)\), which provides the shortest equation for the voltage derivative. The ripple expressions are reported as follows:  
\[\delta i_{m}=\frac{v_{pv}\cdot d\cdot T_{sw}}{2\cdot L_{m}}\quad\wedge\quad \delta v_{pv}=\frac{i_{pv}\cdot(1-d)\cdot T_{sw}}{2\cdot C_{pv}} \tag{42}\]  
Figure 4: Practical sliding surface for limited switching frequency.  
It is worth noting that the ripples defined in (42) can be used for a preliminary design of \(L_{m}\) and \(C_{pv}\) to obtain the desired values of \(\delta_{im}\) and \(\delta v_{pv}\), respectively. In that case, it would be necessary to define a given operating condition (i.e., irradiance and temperature) to determine \(v_{pv}\) and \(i_{pv}\) and define a given switching frequency and duty cycle in order to define \(T_{sw}\) and \(d\).  
Substituting the previous expressions into (41) and considering the switching frequency \(F_{sw}=1/T_{sw}\), the hysteresis limit \(H\) is calculated by (43) to ensure a maximum switching frequency \(F_{sw}\), where the duty cycle is calculated from (9) and depends on \(v_{pv}\), \(v_{o}\), \(L_{m}\), \(L_{k}\), and \(n\).  
\[H=\frac{1}{2\cdot F_{sw}}\cdot\left|\frac{k_{1}\cdot i_{pv}\cdot(1-d)}{C_{pv} }-\frac{v_{pv}\cdot d^{2}}{L_{m}}\right| \tag{43}\]  
Finally, the maximum switching frequency is defined depending on the characteristics of the MOSFET and diode used for the construction of the flyback converter.