## 3 Methodology
### Optimization Method
By comparing the performance of the two other controllers with the dashed black line, which represents a 100-volt reference, it becomes apparent that our proposed controller performs better. Furthermore, we will report the integral of absolute error for these three methods in Table 3 to quantitatively compare their effectiveness in minimizing voltage ripples. ### Battery Current Minimization

Our proposed controller aims to optimize the utilization of the EV battery by reducing its activity. This approach leverages the supercapacitor's shorter charging and discharging times, allowing it to compensate for most short-term changes in system load and voltage ripples. As a result, the system bandwidth is significantly enhanced due to the fast responses to the effects of load and source changes on the bus voltage of the DC microgrid. Moreover, this strategy reduces the wear and tear on the battery from frequent use compared to the supercapacitor. The supercapacitor is also more cost-effective and easier to replace within the system than the EV battery. The flow of current for the battery, supercapacitor, and stabilizer are important, and have been shown in \[L =0.001\]2 In this figure, by comparing the middle figure with the bottom one, we can determine when the battery, supercapacitor, or both are charging and when they are discharging. To illustrate how the system achieves this process, it is important to consider the total value of the battery current during operation, as shown in \[L =0.001\]3 Although it may not be evident in the Figure 14, when employing the PSO-based fuzzy controller, the current drawn by the battery is substantially lower than the total value of the two other controllers, as shown in

\[L =0.001\]4 The output voltage of the DC microgrid: a comparison for all scenarios. \begin{table}
\begin{tabular}{c c} \hline \hline
**Methods** & **IAE** \\ \hline PI controller & 33.5499 \\ \hline Fuzzy controller & 37.3996 \\ \hline PSO-based fuzzy controller & 18.768 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Integral of absolute error (IAE) for voltage ripple of the DC microgrid bus. ### Energy Transfer between Battery and Supercapacitor

Another innovative aspect explored in this study is the ability to transfer energy between the battery and supercapacitor, as illustrated in Figure 16. This capability is highlighted due to the rapid charge and discharge times of the supercapacitor compared to the battery. There are two notable advantages to this energy transfer between the two components. Firstly, it helps prevent battery damage by avoiding discharge below the undercharge level. Secondly, it reduces the frequency of battery usage for ripple minimization. These advantages will be further elucidated in the subsequent discussion. Even if in Figure 16 there is a small difference between two scenarios, this small variation helped the system to reduce the battery current drawn because of charge and discharge. The rapid energy transfer between critical components is demonstrated in Figure 16, facilitating swift recharge and reducing the risk of undercharging and damage, especially to the battery. Notably, this process does not significantly alter the charge level of the components. Conversely, when the battery is fully charged and the supercapacitor is depleted, energy redirection occurs, effectively reducing system ripples through supercapacitor operation and lowering battery activation frequency; while immediate outcomes may not be evident, a comparison of total current drawn from the battery across controllers highlights the approach's efficacy in achieving objectives. Figure 16: Energy transfer between battery and supercapacitor. Figure 15: The current of the ultracapacitor in three scenarios. ## 5 Conclusions

This paper has introduced a novel method for controlling DC microgrids utilizing a fuzzy controller with four input variables: bus voltage error, integrated error of bus voltage, state of charge (SOC) of the battery, and SOC of the ultracapacitor.