# Fuzzy-PID-Based Atmosphere Packaging Gas Distribution System for Fresh Food
## 2 Materials and Methods
### Fuzzy PID Algorithm
#### 2.4.2 Fuzzy PID Controller Design for Gas Distribution Systems
The membership function of \(E\), \(Ec\), \(\Delta K_{p}\), \(\Delta K_{i}\), and \(\Delta K_{d}\) are obtained by using a trigonometric function as the membership function of all variables because a trigonometric function is simple and convenient to apply to an actual controller. The membership functions are shown in Figures 6 and 7. Figure 5: Fuzzy logic toolbox. (2) Fuzzy rule design and defuzzification  
With the CO\({}_{2}\) concentration error \(E\), the rate of change in the error \(Ec\), and the affiliation functions of the proportional coefficient correction \(\Delta K_{p}\), the integral link coefficient correction \(\Delta K_{i}\), and the differential link coefficient correction \(\Delta K_{d}\) available, a table of fuzzy rules for \(\Delta K_{p}\), \(\Delta K_{i}\), and \(\Delta K_{d}\) can be established based on the corresponding fuzzy subsets, as shown in Tables 1-3. The determination of the fuzzy rules is generally based on the system characteristics and the opinions of domain experts obtained from previous interviews. Appropriate fuzzy rules have a great role in improving the speed of regulation, reducing errors, and improving the robustness of the system. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{EC} & \multicolumn{2}{c}{E} & \multirow{2}{*}{NM} & \multirow{2}{*}{NS} & \multirow{2}{*}{ZO} & \multirow{2}{*}{PS} & \multirow{2}{*}{PM} & \multirow{2}{*}{PB} \\ \cline{1-1} \cline{5-7}  & & & & & & & PS & & ZO \\  & \multirow{2}{*}{NM} & \multirow{2}{*}{PN} & \multirow{2}{*}{NM} & \multirow{2}{*}{PN} & \multirow{2}{*}{ZO} & \multirow{2}{*}{NS} & \multirow{2}{*}{NM} \\  & & & & & PS & ZO & & NS & \\  & \multirow{2}{*}{PS} & \multirow{2}{*}{PS} & \multirow{2}{*}{ZO} & \multirow{2}{*}{NS} & \multirow{2}{*}{NM} & \multirow{2}{*}{NM} & \multirow{2}{*}{NB} \\  & & & & & & & \\ \cline{1-1} \cline{5-7}  & & & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: \(\Delta K_{p}\) fuzzy rule table. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{EC} & \multicolumn{2}{c}{E} & \multirow{2}{*}{NB} & \multirow{2}{*}{NM} & \multirow{2}{*}{NS} & \multirow{2}{*}{ZO} & \multirow{2}{*}{PS} & \multirow{2}{*}{PM} & \multirow{2}{*}{PB} \\ \cline{1-1} \cline{5-7}  & & & & & & & \\ \cline{1-1} \cline{5-7}  & & & & & & & \\ \hline \hline \multirow{5}{*}{EC} & NB & \multirow{5}{*}{NM} & NB & \multirow{5}{*}{NM} & \multirow{5}{*}{NS} & \multirow{5}{*}{ZO} & \multirow{5}{*}{PS} \\  & NM & & & & & & \\ \cline{1-1} \cline{5-7}  & NS & NM & & & & & \\ \cline{1-1} \cline{5-7}  & ZO & & NS & & & & \\ \cline{1-1} \cline{5-7}  & PS & & & & & & \\ \cline{1-1} \cline{5-7}  & PM & & & & & & \\ \cline{1-1} \cline{5-7}  & PB & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: \(\Delta K_{i}\) fuzzy rule table. Figure 6: E and Ec membership function. Figure 7: \(\Delta K_{p}\), \(\Delta K_{i}\), and \(\Delta K_{d}\) membership function. The corresponding fuzzy sets can be obtained according to the fuzzy rules [32; 33; 34]. The fuzzy rule sets consist of fuzzy control language instructions based on the requirements of the control target, which are expressed as follows:  
1. If (E is ZO) and (Ec is PS), then (\(\Delta\)K\({}_{\rm p}\) is NS), (\(\Delta\)K\({}_{\rm i}\) is PM), and (\(\Delta\)K\({}_{\rm d}\) is NS). 2. If (E is ZO) and (Ec is NS), then (\(\Delta\)K\({}_{\rm p}\) is PS), (\(\Delta\)K\({}_{\rm i}\) is NS), and (\(\Delta\)K\({}_{\rm d}\) is NS). 3. If (E is NS) and (Ec is PS), then (\(\Delta\)K\({}_{\rm p}\) is ZO), (\(\Delta\)K\({}_{\rm i}\) is ZO), and (\(\Delta\)K\({}_{\rm d}\) is NS). 4. If (E is NB) and (Ec is ZO), then (\(\Delta\)K\({}_{\rm p}\) is PS), (\(\Delta\)K\({}_{\rm i}\) is NS), and (\(\Delta\)K\({}_{\rm d}\) is NB). 5. If (E is NS) and (Ec is ZO), then (\(\Delta\)K\({}_{\rm p}\) is PS), (\(\Delta\)K\({}_{\rm i}\) is NS), and (\(\Delta\)K\({}_{\rm d}\) is NM).