# Design and Control of a Battery Charger/Discharger Based on the Flyback Topology
## 6 Simulation Results
### Performance Evaluation
This confirms that the SMC parameters fulfill both the transversality and reachability conditions imposed in (24), (29), and (30), which provide both global stability and the desired bus voltage performance. The second simulation (right) considers a bus current perturbation with almost infinite derivative (step change), thus \(\frac{d\dot{i}_{\omega}}{dt}\geq 50\) [A/ms], which forces the switching function to leave the hysteresis band. However, since that high current derivative disappears when the perturbation ends, the reachability of the SMC forces the system to enter the hysteresis band, ensuring again global stability. Therefore, the proposed charger/discharger and SMC could support even step-like perturbations in the DC bus current, since the reachability conditions will force the system into stability as demonstrated in the previous and these tests, i.e., simulations reported in Figures 12 and 13. Figure 13: Stability on low-frequency and high-frequency current perturbations. **Left**: low-frequency perturbation; **Right**: high-frequency perturbation. The fourth test evaluates the performance of the charger/discharger in compensating the bus voltage after a step-current occurs in the DC bus. The results of this test are reported in Figure 14, where the maximum instantaneous current perturbation of 2 [A], defined in Table 1, is considered. Since the bus capacitor was designed under the minimum \(C_{dc}\) capacitor reported in Figure 8, the maximum voltage deviation achieved with the designed charger/discharger is lower than the limit defined in Table 1 (3.5%), achieving \(\Delta v_{dc}/v_{dc}=3.35\%\). Thus, the designed charger/discharger ensures a safe bus voltage to the devices connected to the bus, even under an extreme step-like perturbation on the bus current. This satisfactory behavior is achieved due to the dynamic change of the \(K_{i}\) parameter, which enables the SMC to adapt the sliding surface to the instantaneous operation conditions of the system. Finally, the simulation also confirms that the settling time \(t_{s}=1\) [mA] for the bus voltage, imposed in Table 1, is achieved; this precise behavior is caused by the exact calculation of \(K_{p}=0.2\) [A/V] performed in Figure 9, which takes into account the \(C_{dc}=50\) [\(\mu\)F] value adopted for the implementation. In conclusion, this test confirms the correctness of the closed-loop dynamics reported in expression (35), and the accurate calculation of \(K_{p}\) using expression (36) and Figure 9.  
The last test is designed to evaluate the charger/discharger behavior in the three possible operating states: battery discharge (\(i_{dc}>0\)), battery charge (\(i_{dc}<0\)), and battery in stand-by (\(i_{dc}=0\)). Moreover, the test also evaluates the performance of the system for the transition between those operation states, which is a realistic condition since the power flow requested to the battery could suddenly change depending on the operation of both sources and loads. The results of this test are presented in Figure 15, where the DC bus current changes from 1 [A] (battery discharge), to 0 [A] (battery in stand-by) to \(-1\) [A] (battery charge). Since the perturbations have a 1 [A] amplitude, which is half of the perturbation evaluated in the previous test, the deviation of the DC bus voltage is much smaller, thus a safe operation is provided to the devices connected to the bus. Moreover, the simulation also reports the duty cycle, which is never saturated; therefore, the equivalent control condition (31)-(32) is always fulfilled and the system has global stability for all the operating conditions. Similarly, the switching frequency is always lower than the maximum limit (44), defined in Table 1, which confirms the correctness of the HFT selection reported in Figure 6b. In conclusion, this last test demonstrates the ability of the proposed charger/discharger to operate in all the possible conditions of the battery, providing global stability within those states and in the transitions between the states.