## 2 Materials and Methods
### Electrical Circuit Model  
The electrical model of the power system, based on a buck-boost converter, is depicted in Figure 2. All parasitic losses are considered to ensure an accurate description of the system behavior. This circuit models the battery (\(E=v_{in}(t)\)) and its internal resistance (\(r_{in}\)), and also considers the conduction resistance (\(r_{sw}\)) of the MOSFET channel N. In addition, the inductance (\(L\)) includes the parasitic resistance (\(r_{L}\)) and the capacitance (\(C\)) includes the corresponding parasitic resistance (\(r_{C}\)). Furthermore, the diode (\(D\)) considers both the resistance (\(r_{d}\)) and the forward voltage (\(v_{fd}\)). Finally, the load is connected to the circuit and represented as (\(Z_{L}\)). The mathematical model of this circuit is obtained as follows. The differential equations of both the inductor current and capacitor voltage are obtained for both states of the switch, and then those equations are combined in the switched model. The first condition of the circuit occurs when the switch is closed (ON), which forces the diode to be open, enabling the input source (\(E=v_{in}(t)\)) to feed the circuit. In this case, the input current is equal to the inductor current (\(i_{in}=i_{L}\)), while the capacitor supplies the load power. The differential equations in this state are expressed as in Equations (1) and (2). \[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]  
\[x_{2}=\frac{di_{L}(t)}{dt}=\frac{-[r_{in}+r_{sw}+r_{L}]}{L}i_{L}(t)+\frac{v_{ in}(t)}{L} \tag{2}\]  
In a compact form, it can be written as in Equations (3) and (4). \[x_{1}=bx_{1}(t) \tag{3}\]  
and  
\[\dot{x_{2}}=ax_{2}(t)+\frac{v_{in}(t)}{L} \tag{4}\]  
where \(a\) and \(b\) are parameters given in Equations (5) and (6). \[a=-\bigg{[}\frac{r_{in}+r_{sw}+r_{L}}{L}\bigg{]}, \tag{5}\]  
Figure 2: Model that represents the parameters of the buck-boost converter. \[b=\frac{-1}{C(r_{c}+Z_{L})}. \tag{6}\]  
Finally, the load voltage (\(v_{o}(t)\)) is calculated as in Equation (7)  
\[v_{o}(t)=\bigg{(}1-\frac{r_{c}}{r_{c}+Z_{L}}\bigg{)}v_{c}(t) \tag{7}\]  
The second condition occurs when the switch is open (OFF), which forces the diode to close, isolating the input source from the circuit. In this case, the input current is equal to zero (\(i_{in}=0\)), while the inductor feeds both the capacitor and the load. The differential equations in this second state are presented in Equations (8) and (9). \[\dot{x_{1}}=\frac{dv_{c}(t)}{dt}=\frac{Z_{L}}{C(Z_{L}+r_{c})}i_{L}(t)-\frac{1} {C(Z_{L}+r_{c})}v_{c}(t) \tag{8}\]  
\[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]0  
In a compact form, it can be written as in Equations (10) and (11). \[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]1  
\[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]2  
where \(g\), \(f\), \(p\), and \(m\) are parameters given in Equations (12) and (13). \[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]3  
\[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]4  
Finally, the load voltage (\(v_{o}(t)\)) is calculated with Equation (14). \[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]5  
Combining the previous differential equations, using the control signal of the switch (\(u\)), where \(u=1\) closes the switch and \(u=0\) opens the switch (\(\bar{u}=1-u\)), leads to the following switched model (Equations (15) and (16)):  
\[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]6 \[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]7  
\[x_{1}=\frac{dv_{c}(t)}{dt}=\frac{-1}{C(r_{c}+Z_{L})}v_{c}(t) \tag{1}\]8  
where the load voltage (\(v_{o}(t)\)) is calculated with Equation (17) and the battery current (\(i_{in}(t)\)) is calculated with Equation (18).