At present, the internal temperature and humidity control of the pigsty is mainly based on direct control, which is semi-intelligent control. The on–off control of the equipment is based on the detected value to ensure that the internal environmental factors of the pigsty are within the corresponding threshold value. However, due to the hysteresis of temperature changes in the house, the direct control method cannot stably control the temperature in the house, and the energy consumption is large. Therefore, this paper conducted fuzzy control research on the environment of the pigsty based on the prediction results of known environmental factors in the building. Taking the pigsty as an example, in the pigsty, the air temperature is required to be 20–25 °C, the relative humidity is 60–70%, the upper limit of NH
3 concentration is 20 mg/m
3, the upper limit of CO
2 concentration is 1300 mg/m
3, and the upper limit of H
2S concentration is 8 mg/m
3. The fuzzy control process is as follows [
30]:
3.2. Input Volume Blur
In the process of blurring the input factor, it is necessary to determine the physical domain, quantitative factor, and fuzzy domain of the input variable based on the set value. In the environmental prediction control system of the pigsty, the corresponding physical domain and quantitative factors are set according to the prediction deviation (e) of the pigsty, as shown in
Table 1. Considering that the internal environment of the pigsty may be affected by many factors, the physical field is set to be large to meet the needs of drastic changes in the predicted values. Here, in order to make the fuzzy theory domain of each environmental factor the same, by setting different quantification factors, the physical theory domain is quantized into the same fuzzy theory domain, so that each environmental factor can use the same set of fuzzy rules, thereby simplifying the design difficulty of the fuzzy controller. The fuzzy domain of the deviation of each environmental factor was set to [−3,−2,−1,0,1,2,3]. The fuzzy control language was {NB, NM, NS, ZO, PS, PM, PB}, where the calculation formula of the quantification factor is shown below:
where
are the upper and lower limits of the physical domain.
are the upper and lower limits of the fuzzy domain.
Similarly, the fuzzy domain of environmental deviation (ec) was set to [−3,−2,−1,0,1,2,3]. The fuzzy control language was {NB, NM, NS, ZO, PS, PM, PB}, and the physical domain and quantitative factors of environmental deviation are shown in
Table 2. In this paper, the triangle membership function was selected to blur the input variables.
MATLAB2020B was used to design three fuzzy controllers for temperature, humidity, and NH3 concentration, respectively. Where E represents the prediction deviation, that is, the difference between the predicted value and the set value, EC represents the environmental deviation, U1 represents the amount of control over the heater, U2 represents the amount of control over the humidifier, and U3 represents the amount of control over the fan. However, the range of U1, U2 and U3 needs to be set according to the actual control time. Because the prediction interval is 5 min, and the change in environmental factors is delayed, the maximum time to control the corresponding equipment is not greater than 3 min. The specific control time needs to be calculated based on the change value of environmental parameters. Taking temperature as an example, the physical domain is set to [−10,10], that is, with the set point as the center, the span of change on both sides is 10, which can be understood as the need to heat up or cool down 10 °C operation, the calculated operation time required is the range of the output change. When the pigsty needs to be heated up, control the operation of the heater to increase the temperature in the house. However, when it is necessary to cool down, if the temperature in the pigsty is higher than the temperature outside the house, control the operation of the fan so that the cold air enters the house; if the temperature inside the pigsty is lower than the temperature outside the house, the operation of the fan will cause the hot air to enter the pigsty and the cooling cannot be completed. At this time, the operation of the air cooler needs to be controlled to achieve the purpose of cooling. When controlling humidity, we need to choose to turn on the fan or humidifier, according to the situation. When the NH3 concentration is controlled, the fan can be turned on by the control.
When setting the fuzzy domain, the range of the output needs to be considered comprehensively. Taking temperature as an example, the output result of temperature corresponds to the heater, fan, and refrigerator, that is, it corresponds to the three adjustment methods of heating, ventilation and cooling, and cooling and cooling. The running time of each adjustment method is different. Among them, the heating produces a control result through a fuzzy controller. The refrigeration and cooling can be directly controlled by the refrigerator. When cooling down through ventilation, it is necessary to comprehensively consider the temperature inside and outside the pigsty and the amount of ventilation for calculation. When the temperature inside and outside the pigsty is different, the threshold range of the ventilation time is different, and the temperature and humidity compensation time range caused by ventilation cannot be accurately calculated. Therefore, fuzzy control is combined with direct control, and the operating time of the fan is calculated when the temperature inside and outside the fan and the set temperature are known.
When heating, according to the domain of temperature physics, it can be seen that the maximum heating range is set to [
13,
23], that is, the maximum time required for a temperature rise needs to be calculated as the threshold range of the output U1. The calculation formula is as follows:
where
represents the maximum and minimum values within the temperature range, respectively, and the molecules in the equation represent the heat required to heat up.
represents the maximum heating power of the heater, and
is the boundary value of the fuzzy domain of U1.
When cooling down through ventilation, the required amount of ventilation can be calculated from Equation (5), and then the ventilation time can be obtained. The approximate calculation formula is as follows:
where
represents the set temperature value in the house, and
represents the maximum ventilation rate per second. According to the final calculated
, the on–off work of the equipment can be completed.
When cooling down through the refrigerator, because the cooling effect is related to the temperature outside the house, the condensation temperature and other factors, it is more difficult to formulate a specific formula; therefore, a refrigerator with a constant temperature function is used for temperature control, and the final model only outputs the opening and closing status instructions of the refrigerator. The final temperature fuzzy control setting is shown in
Figure 1:
When performing the fuzzy design of humidity, the principle of heating is the same as that of heating. When calculating the set temperature of 23 °C, the amount of water vapor required for humidity to rise from 45% to 65%, combined with the amount of atomization of the humidifier, the maximum humidification time can be calculated. Derived according to Equations (1)–(4), the specific formula is as follows:
where
represents the moisture content at 65% and 45% humidity, respectively.
represents the amount of atomization of the humidifier, in Kg/H.
When using ventilation to reduce humidity, the principle is the same as that of ventilation and cooling. The required amount of ventilation needs to be calculated based on the moisture content inside and outside the pigsty and the set value of the humidity in the house, and then the ventilation time is obtained, which is directly controlled. Derived from Equation (3), the approximate calculation formula for the ventilation time is as follows:
where
represents the moisture content corresponding to the set humidity. According to the final calculated
, the on–off work of the equipment can be completed.
The final humidity fuzzy control setting is shown in the
Figure 2:
When performing the fuzzy design of NH
3 concentration, it is necessary to calculate the maximum time required to reduce the ammonia gas in the pigsty from 20 mg/m
3 to 10 mg/m
3. During the calculation process, if the NH
3 concentration outside the pigsty is regarded as 0, it can be considered that the proportion of air that needs to be exchanged is 50%. Therefore, the approximate calculation formula for the ventilation time is as follows:
where
represent the highest and set NH
3 concentration, respectively.
The final NH
3 concentration fuzzy control setting is shown in
Figure 3:
3.3. Fuzzy Control Rule Design
When the temperature, humidity and NH
3 concentration of the pigsty are controlled separately, the temperature and humidity in the pigsty need to be regulated if they exceed or falls below the threshold value, while the NH
3 concentration only needs to be adjusted if it exceeds the threshold value. Therefore, the regulation rules are shown in
Table 3,
Table 4 and
Table 5. The basic rules for setting fuzzy regulation are as follows:
(1) Temperature control rules
When the predicted temperature exceeds the set threshold value, there are three situations of NB, NM, and NS in the E of the temperature fuzzy controller. When the temperature in the pigsty is higher than that outside the house, the fan needs to be turned on to adjust the temperature in the house. At this time, according to the Ec situation, the fan is operated for heat dissipation. When the fan is running, it will cause the humidity and NH3 concentrations in the pigsty to decrease. At this time, according to the humidity caused by the air exchange caused by the operation of the fan, the humidifier is switched on to perform humidity compensation to ensure that the humidity is within the appropriate threshold value. Therefore, U1 is ZO at this time, and the running time of U3 needs to be derived and calculated according to Equation (11).
When the predicted temperature is lower than the set threshold value, there are three situations of PS, PM and PB in the E of the temperature fuzzy controller. At this time, the heater needs to be turned on to increase the temperature in the room. Therefore, at this time, according to the situation of E and EC, U1 is selected between ZO, PS, PM and PB.
When the predicted temperature is the same as the set temperature, the operating modes of U1 and U3 are selected according to the Ec. When the environmental deviation is NB, NM or NS, the value is less than 0, that is, the current temperature in the room is higher than the set temperature; therefore, at this time it is necessary to calculate the U3 running time and calculate the humidity compensation. When the deviation changes to PB, PM, or PS, the change is greater than 0, that is, the current temperature in the room is lower than the set temperature. At this time, U1 can be turned on for temperature compensation;
(2) Humidity control rules
When the predicted humidity exceeds the set threshold value, there are three situations of NB, NM and NS in the E of the humidity fuzzy controller. At this time, the fan needs to be turned on to adjust the humidity in the house. At this time, according to the Ec situation, the fan is operated for dehumidification. When the fan is running, it will cause the temperature in the pigsty and the concentrations of NH3 to decrease. At this time, it is necessary to calculate the heat in the pigsty taken away by the fan, turn on the heater, and perform temperature compensation to ensure that the temperature remains basically constant during the operation of the fan. Therefore, U2 is ZO at this time, and U3 is calculated according to Equation (13).
When the predicted humidity is lower than the set threshold value, there are three situations of PS, PM, and PB in the E of the humidity fuzzy controller. At this time, the humidifier needs to be turned on to increase the humidity in the house. Therefore, at this time, according to the situation of E and EC, U2 selects between ZO, PS, PM and PB.
When E is ZO, the operating mode of U2 is selected according to Ec and the operating time of U3 is calculated. The principle is the same as that of temperature regulation;
(3) NH3 concentration regulation rules
When the predicted NH3 concentrations exceed the set threshold value, there are three situations of NB, NM, and NS in the NH3 fuzzy controller E. At this time, according to the situation of E and Ec, the fan needs to be turned on to reduce the NH3 concentrations in the house. As above, the operation of the fan will cause the temperature and humidity in the pigsty to decrease. In order to keep the temperature and humidity within the due threshold, the heater and humidifier need to be turned on according to the ventilation conditions to compensate for temperature and humidity.
When E is ZO, such as when EC is PB, PM, PS or ZO, no regulation is required. When EC is NB, NM, or NS, the NH3 concentrations are higher than the set standard value, we need to turn on the fan for ventilation. At this time, we need to turn on the humidifier and heater for temperature and humidity compensation.
Table 3.
Temperature fuzzy control table.
Table 3.
Temperature fuzzy control table.
| | E |
---|
| | NB | NM | NS | ZO | PS | PM | PB |
---|
Ec | NB | ZO | ZO | ZO | ZO | ZO | ZO | ZO |
NM | ZO | ZO | ZO | ZO | ZO | ZO | ZO |
NS | ZO | ZO | ZO | ZO | ZO | ZO | PS |
ZO | ZO | ZO | ZO | ZO | ZO | PS | PM |
PS | ZO | ZO | ZO | ZO | PS | PM | PM |
PM | ZO | ZO | ZO | PS | PM | PM | PB |
PB | ZO | ZO | PS | PM | PM | PB | PB |
Table 4.
Humidity fuzzy control table.
Table 4.
Humidity fuzzy control table.
| | E |
---|
| | NB | NM | NS | ZO | PS | PM | PB |
---|
Ec | NB | ZO | ZO | ZO | ZO | ZO | ZO | ZO |
NM | ZO | ZO | ZO | ZO | ZO | ZO | ZO |
NS | ZO | ZO | ZO | ZO | ZO | ZO | PS |
ZO | ZO | ZO | ZO | ZO | ZO | PS | PM |
PS | ZO | ZO | ZO | ZO | PS | PM | PM |
PM | ZO | ZO | ZO | PS | PM | PM | PB |
PB | ZO | ZO | PS | PM | PM | PB | PB |
Table 5.
Fuzzy control table of NH3 concentrations.
Table 5.
Fuzzy control table of NH3 concentrations.
| | E |
---|
| | NB | NM | NS | ZO | PS | PM | PB |
---|
Ec | NB | PB | PM | PM | PS | PS | ZO | ZO |
NM | PM | PM | PS | PS | ZO | ZO | ZO |
NS | PM | PS | PS | ZO | ZO | ZO | ZO |
ZO | PS | PS | ZO | ZO | ZO | ZO | ZO |
PS | PS | ZO | ZO | ZO | ZO | ZO | ZO |
PM | ZO | ZO | ZO | ZO | ZO | ZO | ZO |
PB | PB | PM | PM | PS | PS | ZO | ZO |