# 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  
To establish a fuzzy PID controller, the first step is to select the input parameters and establish the corresponding affiliation functions, that is, to construct independent rule sets for \(K_{p}\), \(K_{i}\), and \(K_{d}\), respectively. With the corresponding rule sets, the controller can adapt to the changes of parameters in a regular manner [41; 42; 43]. (1) Fuzzy linguistic variables and fuzzy design  
If the CO\({}_{2}\) concentration in the aquatic product gas distribution system is set as \(y\), the detection value is \(g\), the deviation is \(e\), then \(e=y-g\), the rate of change in error is \(ec=\frac{y-g}{g}\), and the flow output of the mass flow controller is \(u\). Figure 4: Schematic diagram of the fuzzy PID controller structure. The program for fuzzy logic reasoning consists of fuzzy control languages, each of which contains the input and output variables of the fuzzy controller and their states, such as 'negative neutral','medium', and 'positive neutral'. The fuzzy design means that the deviation \(e\) of the input variable CO\({}_{2}\) concentration value; the rate of change \(ec\) of the deviation; and the output variables, including the proportional coefficient correction \(\Delta K_{p}\), the integral coefficient correction \(\Delta K_{i}\), and the differential coefficient correction \(\Delta K_{d}\), are represented by the fuzzy vocabulary [negative large, negative medium, negative small, medium, positive small, positive medium, positive large], briefly expressed as {NB, NM, NS, ZO, PS, PM, PB}. According to the target aquatic product's gas preservation requirements, the basic theoretical domain for the concentration error \(e\) of the gas distribution system chosen for this study is [\(-60\%\), \(60\%\)]. The fuzzy design is such that A = \(\{-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6\}\) as the domain of \(E\). Then, the quantization factor of the concentration error \(e\) of the gas distribution system is 0.1. The variable language of \(E\) corresponds to its theoretical domain: negative large NB, negative medium NM, negative small NS, medium ZO, positive small PS, positive medium PM, and positive large PB. Similarly, the basic theoretical domain [\(-6\%\), \(6\%\)] for the rate of change of the error \(e\) in the gas distribution system. If B = \(\{-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6\}\) is the theoretical domain of \(ec\), then the quantization factor of \(e\) is 1. The change in \(E\) is similarly expressed in the variable language of NB, NM, NS, ZO, PS, PM, and PB. Empirically, the basic domain of the scale factor correction quantity \(\Delta K_{p}\) can be set to [\(-0.6\), \(0.6\)], and if C = \(\{-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6\}\) is the domain of \(\Delta K_{p}\), then the scale factor of \(\Delta K_{p}\) is 0.1. The basic domain of the integral factor correction \(\Delta K_{i}\) is set to [\(-0.006\), \(0.006\)], and if D = \(\{-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6\}\) is the domain of \(\Delta K_{i}\), then the scale factor of \(\Delta K_{i}\) is 0.01. The fundamental domain of the integral coefficient correction \(\Delta K_{d}\) is set to [\(-0.6\), \(0.6\)], and if we let F = \(\{-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6\}\) be the domain of \(\Delta K_{d}\), then the scale factor of \(\Delta K_{d}\) is 0.1. For \(\Delta K_{p}\), \(\Delta K_{i}\), and \(\Delta K_{d}\), the fuzzy rules are also represented in the language of variables in the form of NB, NM, NS, ZO, PS, PM, and PB. After the fuzzification process, the solution can be solved directly using the MATLAB software. The software comes with its own fuzzy logic editor, as shown in Figure 5.  
The fuzzy PID controller is designed as a structure with two inputs and three outputs according to the gas mixture distribution system.