## 2 Methodology
### New Control Methodology  
The control strategy proposed in this study is applied within a Li-Ion BESS connected to the Point of Common Coupling (PCC) through a bidirectional power inverter. This inverter facilitates precise control over the injection and absorption of active and reactive power into the grid. Controlled conditions have been established to evaluate the efficacy of this approach. The V2 GSUN method fundamentally relies on the MA approach, enhanced through FLC. This method utilizes input parameters such as photovoltaic solar power and the grid generator frequency to make informed decisions. The implementation of the V2 GSUN method involves several key steps. First, data collection is essential, where real-time information on PV solar power generation and grid generator frequency is obtained. Next, fuzzy logic integration is employed to process these input parameters, guided by fuzzy rules. This integration helps to refine the data window for the output time, ensuring effective smoothing of power injections into the grid. The system is connected to a fixed load and an EV, where the EV's batteries play a critical role in mitigating power peaks caused by solar irradiation while maintaining an optimal state of charge. The optimization of the V2 GSUN method focuses on refining the parameters used within the fuzzy logic framework to improve decision-making efficiency. This involves adjusting input parameters to enhance the system's responsiveness and regularly updating the fuzzy rules based on system performance and real-time data analysis. To illustrate the effectiveness of the V2 GSUN method, it was applied in a scenario where it managed power injections from a grid-connected PV solar system. An off-grid diesel generator is incorporated into a bus bar system, operating as a three-phase voltage source that provides frequency and voltage references for an isolated grid. This isolated bus bar includes an inverter linked with PV energy systems and emulates an EV-BESS. The main goal is to reduce fluctuations in PV power and enhance grid frequency stability, achieved through the energy buffering capacity of the Li-Ion BESS. Innovatively, the strategy enhances the MA method's effectiveness by incorporating an FLC. The FLC acts as a dynamic control system that adjusts the time window of the MA power based on input parameters such as energy input, PV power, and the SoC of the BESS. The FLC's output offers a variable power change rate over time, providing adaptability during periods of high loads and limited resources. The diagram of the new controller is shown in Figure 2.  
The algorithm samples injected active power, PV power, BESS SoC, and grid frequency from the diesel generator at a time interval \(\Delta T\). Pre-established fuzzy rules are applied to make determinations that directly impact the duration of the time window \(N\times\Delta T\), modifying it to suit the immediate requirements for smoothing power in real time. As a result, the resulting output is shaped by the current status of input parameters such as PT, SoC, and system frequency. The time window size, \(WS=N\Delta T\), is dynamically adjusted using fuzzy logic to optimize the SoC of the Li-Ion BESS in real time. Control rules for the proposed strategy are detailed in Table 1, outlining different levels of smoothing (HS = high smoothing, S = smoothing, MS = moderate smoothing, LS = low smoothing, NS = no smoothing) categorized VH (very high), H (high), M (medium), L (low) and VL (very low). Membership functions designed for this approach are depicted in Figure 3. These functions adapt the data window size based on real-time power, frequency, and BESS SoC changes. Triangular and trapezoidal membership functions are utilized, with defuzzification employing the centroid method. It is worth noting that, in the case of the Ecuadorian electrical utility used for the experimental tests, the nominal frequency is 60 Hz, with slight variations of \(\pm\)0.15 Hz (0.25%) during normal operation.