## 5 Implementation of the Adaptive SMC and Detailed Circuital Simulations
### Digital Implementation of the Adaptive SMC  
The proposed SMC can be implemented in a digital microprocessor by coding Algorithm 2 in any supported language. However, such an approach will impose high requirements on the Analog-to-Digital Converters (ADCs) needed to measure the two inductor currents, both the battery and C2 voltages, and the load current. Since Algorithm 2 produces the control signals \(u\) and \(\overline{u}\), the time resolution for the rising and falling of \(u\) (and \(\overline{u}\)) impacts the accuracy of the SMC implementation. Therefore, adopting an acquisition time between 80 and 100 times smaller than the switching period is common, thus providing a resolution for the control signal between 1% and 1.25% of the period. Using such a traditional approach, the implementation of Algorithm 2, for the application characteristics reported in Table 2, will require ADCs with sampling frequencies between 9.6 MSPS (\(9.6\times 10^{6}\) samples per second) and 12 MSPS, which are very high. Therefore, this section proposes a modified formulation of the practical sliding surface (42) to reduce the ADC sampling frequency. This new formulation represents the high-frequency signal \(i_{L1}\) of \(\Psi\) (24) as a function of the other terms, which results in the following representation of the practical sliding surface \(-\Delta\Psi<\Psi<+\Delta\Psi\):  
Figure 7: Consecutive perturbations and settling time. \[\Psi_{L1,Set}<i_{L1}<\Psi_{L1,Reset} \tag{54}\] \[\Psi_{L1,Reset}=i_{R}+k_{v}\cdot(v_{R}-v_{C2})+(k_{c}-1)\cdot i_{L2}+\Delta\Psi\] (55) \[\Psi_{L1,Set}=i_{R}+k_{v}\cdot(v_{R}-v_{C2})+(k_{c}-1)\cdot i_{L2}-\Delta\Psi \tag{56}\]  
Then, using the new \(\Psi\) formulation given in (54)-(56), we also obtain a new formulation for the control law (53), as follows:  
\[u=\left\{ \begin{array}{l}\text{if }i_{L1}\geq\Psi_{L1,Reset}\ \rightarrow\ u=0\ \wedge\ \overline{u}=1\\ \text{if }i_{L1}\leq\Psi_{L1,Set}\ \rightarrow\ u=1\ \wedge\ \overline{u}=0\end{array} \right. \tag{57}\]  
Then, two processes are needed. The first one calculates the limits \(\Psi_{L1,Set}\) and \(\Psi_{L1,Reset}\), and the second one uses those limits to calculate the MOSFET signals with Equation (57). Considering that the calculation of \(\Psi_{L1,Set}\) and \(\Psi_{L1,Reset}\) requires the measurement of multiple analog signals, this process imposes the requirements in the ADC frequency. Instead, the calculations of \(u\) and \(\overline{u}\) only require simple comparisons; hence, this section proposes using a microcontroller able to perform both processes. For example, the F28379D Microcontroller reported in [38] has multiple ADC channels, has Digital-to-Analog Converters (DACs), and has a Comparator Subsystem (CMPSS). The CMPSS is based on two analog comparators, which have the negative inputs of the comparators connected to two DAC channels, and the positive inputs of the comparators are connected to a single pin of the F28379D. Therefore, two threads can be designed to run with different sampling periods inside the microcontroller, using the CMPSS to perform the analog comparisons of the new control law given in (57). The first thread (Thread 1) calculates the comparator inputs \(\Psi_{L1,Set}\) and \(\Psi_{L1,Reset}\). Since such a comparison is used in each switching period, the values of \(\Psi_{L1,Set}\) and \(\Psi_{L1,Reset}\) must be updated at least twice in each period; thus, the sampling frequency must be at minimum double the maximum switching frequency. From Table 2, it is observed that the application example imposes a maximum switching frequency of 120 kHz, and introducing a safety factor of 10%, the sampling frequency needed is 264 kSPS (0.264 MSPS), hence reducing the sampling frequency to 2.2% of the requirement imposed by the traditional digital implementation. Figure 8 illustrates the digital implementation of the control algorithm, where Thread 1 delivers the limits \(\Psi_{L1,Set}\) and \(\Psi_{L1,Reset}\) to the CMPSS.