## 3 Controller Design
### Fuzzy PID Controller  
Traditionally, PID adjusts frequency but struggles with large and rapid changes. The fuzzy algorithm, combining PID fuzzy control, improves performance and was implemented in this research for fast, stable frequency control. Using the fuzzy logic module in the MATLAB/Simulink platform, the proposed fuzzy PID controller was designed. Mamdani fuzzy inference system and the Centroid method were employed for fuzzification and defuzzification, respectively, as shown in Figure 12.  
A Fuzzy PID controller is employed to automatically adjust the parameters of the PID controller--_Kp_, _Ki_, and _Kd_--in real-time operation based on the system's error signals. This adjustment allows the performance of the controller to meet specific system requirements. As shown in Figure 13, the fuzzy logic controller takes two inputs--the error (e(t)) and the change in error (\(\Delta\)e(t))--and gives three outputs: _Kp_, _Ki_, and _Kd_. Figure 11: PLC computed PID parameter values. Figure 12: Fuzzy logic Structure. The error signal is generated by comparing the actual speed with the desired speed of the stand-alone SG, while the change in error is calculated by differentiating the error signal. Both signals are then fed into the fuzzy logic controller block. The fuzzy logic controller generates correction coefficients (\(\Delta\)K\({}_{p}\), \(\Delta\)K\({}_{i}\), and \(\Delta\)K\({}_{d}\)) to adjust the parameters of the PID controller accordingly, which subsequently adjusts the set point in the plant block. The fuzzy design, depicted in Figure 14, uses seven linguistic membership functions (MF) for both the error and change in error inputs, along with the outputs (\(\Delta\)K\({}_{p}\), \(\Delta\)K\({}_{i}\), and \(\Delta\)K\({}_{d}\)). These membership functions are 'Negative Small' (NS), 'Negative Medium' (NM), 'Negative Big' (NB), 'Zero' (ZE), 'Positive Small' (PS), 'Positive Medium' (PM), and 'Positive Big' (PB). Trapezoidal membership functions (trapmf) were employed for the 'NB' and 'PB' values of all the variables, while triangular membership functions (trimf) were used for the remaining variables. The input MF range for both inputs was normalized between \([-0.5,1]\), while the output ranges for (\(\Delta\)K\({}_{p}\), \(\Delta\)K\({}_{i}\), and \(\Delta\)K\({}_{d}\)) were normalized within \([-6,6]\), \([-10,10]\), and \([-1,1]\), respectively. In fuzzy control systems, the performance of membership functions has been widely investigated. In both industry-based applications, such as process control, motor control,  
Figure 14: MFs of inputs and outputs. Figure 13: Block diagram of the FLPID controller. and PLC-oriented control, and literature studies aimed at performance improvement, triangular and trapezoidal membership functions are commonly preferred. In [44], the impact of membership functions on the performance of fuzzy controller systems has been reviewed in detail. The step responses of controllers with different types of membership functions, including triangular, trapezoidal, and Gaussian, have been compared in terms of maximum overshoot, settling time, Integral of Absolute Error (IAE), and Integral of Squared Error (ISE). The fuzzy controller with a triangular membership function has been observed to perform better in these comparisons. In [45], five popular methods for online tuning of PID controllers were compared. Experimental simulation results demonstrated that the fuzzy logic approach was the most successful method, enabling the dynamic adjustment of PID gain parameters over time and enhancing system robustness. This method significantly reduced both the settling time and the Integral of Time-weighted Absolute Error (ITAE). In an Automatic Voltage Regulator (AVR) system, a fuzzy PID filter (FPDF) controller was proposed in [46] to maintain the output voltage of the generation unit within permissible limits despite unexpected variations. Triangular membership functions were preferred in this controller.