Fuzzy PID Temperature Control System Design Based on Single Chip Microcomputer

—To solve equipment problems related to the failure of air conditioning units in VFD (Variable Frequency Drive) rooms to restart after interruptions in the power supply, this paper introduces a hardware and software design based on the constant temperature system of STC89C52 SCM and carries out the simulation through MATLAB to compare and analyze the fuzzy self-turning PID control results and traditional PID control simulation results. The experimental results show that this design can realize the SCM constant temperature control of a fuzzy PID algorithm


INTRODUCTION
The Variable Frequency Drive (VFD) room is the power supply and transformation control part of the overall well site and station.
Sometimes power generation or operation stoppage is caused by the malfunction of the diesel generator, which results in power failure in the VFD room. After power restoration, the indoor air conditioning equipment does not automatically start. It can be started manually by the operator, but due to negligence and other reasons, the operator often forgets to start the air conditioner in the VFD room. If the air conditioner has not been used for a long time, the large heat dissipating capacity of the equipment in the VFD room will cause the rise of the room temperature to result in a malfunction of some components and even damage a whole set of equipment, causing significant economic losses. On this basis, this paper examines using a fuzzy PID algorithm to control the air conditioner after adjusting parameters through measurement of the temperature sensor, based on the STC89C52 SCM, to automatically start the air conditioner after power restoration and keep the room at a constant temperature.

A. SCM (Single Chip Microcomputer)
STC89C52, produced by the STC Company, is a CMOS 8-bit microcontroller with low power consumption and high performance. The power of the 5V SCM adopted by this design can be supplied by the UPS in the VFD room and can also be supplied separately. Therefore, when power failure occurs in the VFD room, real-time monitoring of the temperature can be continued until the air conditioner is controlled to keep the room at a constant temperature after power restoration.

B. Temperature Sensor
This design adopts the DS18B20 temperature sensor produced by Dallas Semiconductor Corporation. As the DS18B20 temperature sensor adopts the single bus data transmission mode, there are time sequence requirements on the read-write data. The setup steps are as follows: (1)Initialization procedure. All communication with the DS18B20 begins with an initialization sequence that consists of a reset pulse from the master, followed by a presence pulse from the DS18B20.
(2) Read time slots. All read time slots must be a minimum of 60µs in duration, with a minimum of a 1µs recovery time between slots. A read timeslot is initiated by the master device pulling the 1-Wire bus low for a minimum of 1µs and then releasing the bus.
(3) Convert the read bits into bytes. DS18B20 first reads the lower bits, and therefore the read bit "j" is moved left by 7 bits to carry out the OR operation with the value obtained through moving "k" right by 1 bit. For instance, if the bit read by j is 1 for the first time, "10000000" will be obtained after moving it left by 7 bits. If the initial value of k is "00000000", "00000000" will still be obtained after moving it right by 1 bit; k is "10000000" after the OR operation between j and k is carried out. The read of a byte will be completed after eight cycle times.
(4) Write time slots. There are two types of write time slots: "Write 1" time slots and "Write 0" time slots. The bus master uses a Write 1 time slot to write a logic 1 to the DS18B20 and a Write 0 time slot to write a logic 0 to the DS18B20.
(5) Read temperature. During calculation, the actual temperature will be obtained through converting the read hexadecimal digit into the decimal digit multiplied by 0.625; the result plus 0.5 is convenient for the round-off. Therefore, the temperature sensor can be used to measure the actual temperature in the VFD room.

C. Digital Tube
The digital tube adopts the common-cathode connection method. The first three bits of the digital tube display the measurement temperature of the temperature sensor, and its last three bits display the set temperature.

D. Buttons
This design adopts four independent buttons for temperature setting, namely a "ones place" button, "tens place" button, "decimal place" button, and "OK" button. The temperature is set properly through the first three buttons so that the SCM starts to carry out the temperature control program after pressing the "OK" button. In addi-PAPER FUZZY PID TEMPERATURE CONTROL SYSTEM DESIGN BASED ON SINGLE CHIP MICROCOMPUTER tion, the jitter phenomenon of contacts occurs when the button is closed or opened, and therefore, the jitter elimination program shall be added during programming.

E. Infrared Decoding and Encoding Module
There are an infrared receiver and a transmitter on the infrared decoding module adopted by this design. The remote control is aligned with the infrared receiver to press the button so that the SCM on the module automatically decodes the received infrared ray and displays it in the form of hexadecimal digit through the serial assistant.
The transmitter transmits the infrared decoding through the software programming to control the air conditioner.

A. SCM Software Design and Simulation
The system software design is programmed mainly by C programming language in the Keil software. After no running errors, the hex file generated by the software will be burned onto the STC-ISP-V480 software to carry out the hardware operation in the SCM. The system flowchart is shown in Fig. 1 Figure 1. System Flowchart

A. System Modeling
This design takes the room temperature as the controlled object, and the differential equation can be established according to the energy conservation law. It is often replaced with the purely hysteretic first-order model in the control, and the simulation results show that the description of the hysteretic model on the controlled object can fully meet the practical application [1].
The empirical transfer function is as follows. (1) Set the length (!), width ("), and height (#) of the airconditioning room respectively as 7.5m, 4.4m and 3.5m. The ventilation rate is X=5 times/hour, and the following formulas can be obtained according to the empirical formula [2]. 1) System PID Tuning K S is determined through the constant modification of proportional gain so that the transition process curve attenuation ratio of system output is approximate to 4:1. According to the attenuation curve method empirical formula, the tuning parameters of PI and PID controllers can be obtained. The empirical method is shown in Table 1. Wherein, Through the empirical method, the final debugging is determined as follows.

B. Design of Fuzzy Self-adaptive PID Controller
Fuzzy control is the control strategy summarized based on the rich experience and expressed by natural language. The control rule is summarized through a large number of practical operation data or the automatic control is realized through the computer [6].

1) Fuzzy Self-adaptive PID Principle
The fuzzy PID controller under this design adopts twodimension input (e, ec) and three-dimension input (K P , K I, , K D ). It finds the fuzzy relationship between the PID controller output parameters and the e and ec, constantly detects the e and ec during operation, and modifies the three control parameters through the fuzzy control principle to meet the different requirements of different e and ec on the control parameters and makes the controlled object have good dynamic characteristics. The fuzzy PID structure chart is shown in Fig. 2.

2) Fuzzy Self-adaptive PID Algorithm a) Fuzzification
Take the e and ec as the input quantity of the PID controller and take the parameter adjustment variations (K P , K I , K D ) of the PID controller as the output quantity. Their respective basic discourse domain, fuzzy discourse domain, scale factor and fuzzy subset are shown in Table 2, and all membership functions are selected as triangles.
The fuzzy control table of !K P , !K I , !K D can be established through summarizing the design knowledge and actual operation experience of engineering designer and experts. The 49 fuzzy rules obtained are as follows:
Input 49 fuzzy rules into the Mamdani fuzzy controller in MATLAB and input the basic discourse domain, fuzzy discourse domain and fuzzy subset into each module of the FIS editor.

b) Clearness
After the fuzzy logic reasoning, the fuzzy set is output, which is the integration of the conclusions obtained from multiple fuzzy control rules. The purpose of clearness is to make them equivalent to a clearness value to transform it into the representative value. Common methods include the area period method, maximum membership degree method, area center method, etc. This design adopted the area center method.
Define the parameters K P , K I , K D and adjust the formula as follows: In the formula, !K P , !K I , !K D are the output parameters of the fuzzy self-tuning controller; K' P , K' I , K' D are the initial values of the PID controller, which are obtained through the tuning of a 4:1 attenuation ratio method. !K P , !K I , !K D are the output quantity of the fuzzy controller,

V. SYSTEM SIMULATION
Under the Simulink environment of MATLAB, the fuzzy self-adaptive PID controller was designed according to the above ideas. The simulation structure diagram of the system is shown in Fig. 3.
After the debugging under the effect of the step signal, let K' P =30, K' I =1.655, K' D =1 and set all fuzzy factors according to Table 1; the system output waveform is shown in Fig. 4. Figure 3. System Simulation Diagram of Fuzzy Self-adaptive PID Controller When changing the amplification coefficient and letting K=0.35, the output waveform is shown in Fig. 5. When changing the time constant and letting T=7, the simulation waveform is shown in Fig. 6. When changing the hysteresis time and letting !=4, the simulation waveform is shown in Fig. 7.

VI. CONCLUSION
According to the above figures, when the parameters are changed, the conventional PID control curve overshoot is larger, sawtooth fluctuation occurs, and the initial curve of the traditional PID curve is steeper. But the up curve of the fuzzy self-tuning PID curve is smooth. When the parameters are changed, the fuzzy PID curve overshoot is smaller compared to the conventional PID control curve, and the adjusting time is short. When the characteristics of the controlled object are unchanged or changed slightly, a very good control effect can be obtained if the traditional PID controller is used. But in most situations, the fuzzy self-tuning PID controller will show strong robustness if the system model is difficult to establish accurately or the parameters of the controlled object are changed constantly.