# Dung Beetle Optimized Fuzzy PID Algorithm Applied in Four-Bar Target Temperature Control System
## 2 Principles and Methods
### Fuzzy PID Control  
Combining fuzzy control theory with classical PID control forms a fuzzy PID controller, where the fuzzy algorithm can play an auxiliary optimization role. Based on a conventional PID controller, the deviation \(e\) and the rate of change of the deviation \(ec\) are used as input variables to the fuzzy controller, and the classical PID's three incremental correction values \(Kp\), \(Ki\), \(Kd\) serve as the output of the fuzzy controller, resulting in a two-input and three-output structure [23,24]. The principle block diagram of a fuzzy PID control system is shown in Figure 3.  
According to the characteristics of the temperature control system in this system, all variables are described using trimf (triangular membership functions), as shown in Figures 4 and 5:  
Figure 4: \(e\) and \(ec\) membership function diagram.  
Figure 3: The principle block diagram of a fuzzy PID control system.  
In this paper, the inputs are the temperature deviation \(e\) and the rate of change of temperature deviation \(ec\), which are subject to fuzzification. The fuzzy subsets are defined as NB, NM, NS, ZO, PS, PM, and PB. Furthermore, a fuzzy rule table is deduced as shown in Tables 1-3:  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \multirow{2}{*}{\(e\)} & \multicolumn{8}{c}{_ec_} \\ \cline{2-9}  & **NB** & **NM** & **NS** & **ZO** & **PS** & **PM** & **PB** \\ \hline NB & PB & PB & PM & PM & PM & PB & PB \\ NM & PB & PB & PM & PM & PM & PB & PB \\ NS & PM & PS & PS & ZO & PS & PM & PM \\ ZO & PM & PS & PS & ZO & PS & PM & PM \\ PS & PM & PM & PS & PS & PS & PM & PM \\ PM & PB & PB & PM & PM & PM & PM & PB \\ PB & PB & PB & PM & PM & PM & PB & PB \\ \hline \end{tabular}
\end{table}
Table 1: _Kp_ fuzzy rules.  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \multirow{2}{*}{\(e\)} & \multicolumn{8}{c}{_ec_} \\ \cline{2-9}  & **NB** & **NM** & **NS** & **ZO** & **PS** & **PM** & **PB** \\ \hline NB & PB & PB & PM & PM & PM & PB & PB \\ NM & PB & PM & PS & PS & PS & PM & PB \\ NS & PM & PS & ZO & ZO & ZO & PS & PM \\ ZO & PM & PS & ZO & ZO & ZO & PS & PM \\ PM & PB & PM & PS & PS & PM & PM & PB \\ PB & PB & PB & PM & PM & PM & PB & PB \\ \hline \end{tabular}
\end{table}
Table 2: _Ki_ fuzzy rules.  
Figure 5: _Kp, Ki, and Kd membership function diagram.  
The de-blurring is performed using a weighted averaging method, with the results automatically generated by the fuzzy PID controller, as shown in Figure 6. The values of \(e\) and \(ec\) can be manually input to verify the magnitude changes of \(\Delta Kp\), \(\Delta Ki\), and \(\Delta Kd\).  
According to fuzzy rules, the PID controller dynamically adjusts the proportional (P), integral (I), and derivative (D) gains. When the error e is large, \(Kp\) is set to a higher value, \(Ki\) is set relatively smaller, and \(Kd\) is moderately smaller. When the errors \(e\) and \(ec\) are moderate, \(Kp\) is set to a lower value. The values of \(Ki\) and \(Kd\) need to be moderate. In cases of larger errors, for better robustness, \(Kp\) is set to a smaller value, \(Ki\) is increased to prevent oscillations, and \(Kd\) is set to a moderate level.