Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 8, No. 1, 2023 212 MCU-Based PID Temperature Control System for Linear Heating and Cooling Yiming Hu University of Science and Technology Beijing, Beijing 100083, China Abstract: In this study, we have designed and developed a PID temperature controller with the core control unit based on the STC12 microcontroller, along with AD conversion chips and LM2596 power modules. This system effectively maintains temperature stability within a set range, with a steady-state error of less than 0.1Β°C. Moreover, it allows for precise and near- linear temperature ramping from room temperature to 400Β°C, and subsequent linear fitting of the heating curve consistently yielded coefficient of determination exceeding 0.999. This innovative approach represents a heating method suitable for semiconductor sensors and holds significant promise for application in industrial settings. Keywords: PID temperature controller; Linear fitting; Semiconductor sensors. 1. Introduction The electrical resistance of metal oxide semiconductor materials is highly sensitive to temperature changes. Variations in temperature can lead to changes in the material's resistance. Moreover, temperature fluctuations can alter the adsorption states of gases on the material's surface, resulting in changes in resistance. Previous research has indicated that these changes are influenced by both the gas-sensitive material used and the type of gas involved. Therefore, by analyzing the dynamic information of material resistance during temperature changes, it is possible to obtain the adsorption characteristics of different gases. This, in turn, can be utilized to identify the types of gases and quantify the composition of gas mixtures. Previous studies have commonly employed temperature modulation patterns such as square waves, sine waves, triangular waves, and saw tooth waves. However, these methods are primarily influenced by parameters such as waveform, frequency, amplitude, and offset, making it necessary to process the information, and they may not provide an intuitive means of obtaining gas adsorption information. This paper attempts to utilize a linear temperature ramp modulation pattern and designs a PID control system to investigate how to achieve linear temperature ramping. 2. Experimental Methodology 2.1. Temperature Control System The core of our automatic temperature control system is a microcontroller. In this system, real-time temperature measurements are obtained from the temperature acquisition module, which monitors the temperature of the heating element. The microcontroller reads and computes the real- time temperature, using the temperature differential to control a digital potentiometer. This, in turn, adjusts the output voltage in the feedback loop of the module. By continuously comparing the real-time temperature with the set temperature, closed-loop control is achieved. The entire circuit diagram is presented in Figure 1, Figure 2 and Figure 3. Figure 1. Temperature Data Acquisition Circuit Diagram Figure 2. Circuit diagram for a CNC buck converter module Figure 3. Serial communication circuit diagram Due to the high performance and low power consumption 213 features of the STC12 series microcontroller, the processor chosen is the STC12C5A60S2. The analog-to-digital conversion chip selected is the ADS1115, and the digital voltage reduction module consists of an adjustable voltage reduction chip and a digital potentiometer X9C102. Figure 4. Heating Element Schematic As shown in Figure 4, the Pt100 temperature sensor, which is affixed to the back of the heating resistor using a thermally conductive adhesive, can be typically described as a first- order inertial process. The transfer function of the system is given by: 𝛷 𝑠 π‘Œ 𝑠 π‘ˆ 𝑠 𝐾 𝑇𝑠 1 1 If a step response of 1(t) is applied to the system, the system's output can be described as: 2 2.2. Principles of PID algorithms In contrast to analog control systems, computer control systems do not provide continuous control signal outputs. Instead, they rely on discrete sampled values to calculate control outputs. Consequently, traditional continuous analog PID control algorithms cannot be directly applied to computer control systems. They require discretization to accommodate the unique characteristics of computer-based control. The discrete expression for the position-based PID algorithm is given below: 𝑒 π‘˜ 𝐾 𝑒 π‘˜ 𝑇 𝑇 𝑒 𝑖 𝑇 𝑇 𝑒 π‘˜ 𝑒 π‘˜ 1 𝐾 𝑒 π‘˜ 𝐾 𝑒 𝑖 𝐾 𝑒 π‘˜ 𝑒 π‘˜ 1 3 where u(k) represents the voltage output of the controller during the k-th sampling instance, and e(k) signifies the deviation between the set temperature T and the temperature Tk recorded during the k-th sampling. When retrospectively stepping one iteration back, the expression for the k-1th step can be derived as follows: 𝑒 π‘˜ 1 𝐾 𝑒 π‘˜ 1 𝐾 𝑒 𝑖 𝐾 𝑒 π‘˜ 1 𝑒 π‘˜ 2 4 By subtracting the two aforementioned equations, the resulting expression is given by: π›₯𝑒 𝐾 𝑒 π‘˜ 𝑒 π‘˜ 1 𝐾 𝑒 π‘˜ 𝐾 𝑒 π‘˜ 2𝑒 π‘˜ 1 𝑒 π‘˜ 2 5 In the equation, where KP represents the proportional coefficient, KI stands for the integral coefficient, KD denotes the derivative coefficient, and Ξ”u signifies the change in voltage output of the controller at the nth sampling instance, the resulting expression defines the incremental form of the PID controller. 2.3. Determine the PID parameters After fitting and calculations, we can determine the voltage regulation accuracy (βˆ†V) of this system to be 0.035V. At 100Β°C, a change of 0.035V in voltage results in a temperature change of 1.92Β°C in the heating resistor. From this, we can compute a reference value for KI: When the heater operates at a steady-state condition, denoted as t∞: KI = (βˆ†V * (ess / βˆ†T)) / err In the equation, "ess" stands for steady-state error, "err" signifies the current error, and βˆ†T represents the temperature change resulting from a voltage change of βˆ†V. Notably, "ess" and "err" are equal in equilibrium conditions, so we can simplify it to KI = βˆ†V / βˆ†T. Substituting the parameters at 100Β°C, we obtain KI = 0.0182. In other words, at 100Β°C, when KI is greater than 0.0182, it can adjust the voltage to the correct position after one cycle. However, if KI is significantly less than 0.0182, it won't provide effective feedback for the output voltage, leading to unstable control. Under the condition of 1℃ each temperature, the PID parameters were obtained by trial and error, and the experimental results are shown in Figure 5. Figure 5. Performance Graph for Different Kp Conditions with 1Β°C Temperature Increments 0),1()( ο‚³ο€­ο€½ ο€­ teKtc T t 0 10 99.0 99.5 100.0 100.5 101.0 101.5 102.0 102.5 199.5 200.0 200.5 201.0 201.5 202.0 202.5 299.5 300.0 300.5 301.0 301.5 302.0 302.5 303.0 99.0 99.5 100.0 100.5 101.0 101.5 102.0 102.5 199.5 200.0 200.5 201.0 201.5 202.0 202.5 299.5 300.0 300.5 301.0 301.5 302.0 302.5 303.0 T em pe r at ur e ( ℃ ) Time (s) 3.0 4.0 5.0 6.0 7.0 8.0 9.0KP KI=0.02,KD=2.0 214 It can be observed that all parameters can stabilize at the target temperature. When the KP parameter is increased, the overshoot decreases, but the heating rate slows down. Additionally, the heating rate at higher temperatures also decreases. Therefore, we prioritize considerations for high- temperature conditions and adjust the KP value accordingly to maintain stable heating. The specific performance of the PID controller at 300Β°C is detailed in Table 1. Table 1. Performance Table for the PID Controller at 300Β°C Number KP KI KD ts tp tr ess Οƒ 1 5 0.02 2 0.7 0.7 0.7 0 9.88% 2 3 0.02 2 0.8 0.3 0.2 0 12.52% 3 4 0.02 2 0.9 0.4 0.3 0 9.88% 4 6 0.02 2 1 1 1 0 7.23% 5 7 0.02 2 1.4 1.4 1.4 0 9.88% 6 8 0.02 2 1.4 1.4 1.4 0 9.88% 7 9 0.02 2 1.7 1.6 1.6 0 7.23% 8 2 0.02 2 2 0.4 0.2 0 33.71% In the table above, "ts" represents the time it takes for the heating process to reach a steady state, "tp" is the time it takes for the heating process to reach its maximum value, "tr" is the time it takes for the heating process to reach its first steady- state value, "ess" denotes the steady-state error, and "Οƒ" stands for the overshoot. 3. Linear Heating Experiments We selected the PID parameters that offer good stability and faster heating rates and adopted a uniform heating method with a 1Β°C increment per step. The experimental results are depicted in Figure 6. Figure 6. Temperature Ramp Curves for Three Different Heating Rates As shown in the above figures, The PID parameters selected are as follows: KP = 8.0, KI = 0.02, and KD = 2.0,three rapid heating experiments were conducted, with heating rates of 0.67Β°C per second, 1Β°C per second, and 0.5Β°C per second, respectively. Observing the above figure, it becomes apparent that even when the heating intervals are shorter than the "ts" time, or even shorter than the "tr" time, the heating process can remain stable. Under identical PID parameters, when the temperature differential is small, the rate of temperature increase slows down. This deceleration is particularly evident during the initial heating phase, suggesting that in subsequent heating cycles, the temperature differential is likely to increase, leading to a corresponding acceleration in the heating rate. The integral component (KI) contributes to higher gains, resulting in a faster heating rate when compared to scenarios with a fixed heating interval. In the pursuit of achieving a more linear heating progression, we minimized the temperature differential to 0.1Β°C. Simultaneously, tests were conducted under various KP conditions, resulting in the heating curve illustrated in Figure 7. This adjustment not only enhances the heating rate in comparison to scenarios with a fixed heating interval but also brings the process into closer alignment with a quasi- linear trajectory. Figure 7. Linear heating curves under various KP parameters. Similarly, a cooling test was conducted with a temperature differential of 0.08Β°C. Due to the constraints on voltage provided by the proportional component (KP) during the heating process, the output voltage decreases. Conversely, during the cooling process, a voltage gain is provided, and lower values of KP surprisingly yield better linearity. The cooling process curve is illustrated in Figure 8. Figure 8. Linear cooling curves under various KP parameters. 0 50 100 150 200 250 300 350 400 450 100 150 200 250 300 350 400 450 100 150 200 250 300 350 400 450 Te m pe ra tu re /( ℃ ) time/(s) 0.667℃/s 1℃/s 0.5℃/s KP=8.0,KI=0.02,KD=2.0 215 Table 2. Pearson correlation coefficients for linear cooling curves under different KP parameters. Number KP KI KD Pearson 1 2 0.02 2 -0.999997749 2 4 0.02 2 -0.999993986 3 6 0.02 2 -0.999993226 4 8 0.02 2 -0.99997357 5 10 0.02 2 -0.999979891 6 15 0.02 2 -0.999906312 The results indicate a Pearson correlation coefficient of 1 between temperature and time during the heating phase, while during the cooling phase, the Pearson correlation coefficient is -0.9999, suggesting an extremely significant negative correlation. This implies that as time progresses, the temperature exhibits an almost perfect linear increase or linear decrease trend. 4. Summary This study primarily focuses on the design of an intelligent temperature control system based on the PID algorithm. The core of the system is a microcontroller, and hardware solutions were devised to achieve high-precision temperature maintenance and uniform heating. The control accuracy can reachΒ± 0.1Β°C, and the system exhibits excellent stability and repeatability. This system effectively meets the requirements of temperature control, offering advantages such as simplicity, flexibility, and has significant practical applications in industrial settings where temperature control for sensors is essential. References [1] DU Muqing:Optimized Design Of Thermostat Temperature Controller Based on Predictive Controll And Fuzzy PID Controll. (Master's Thesis, Central South University of Forestry &Technology, China, 2022) p.1. [2] Yiqing Chen: Research on the Calibration Technology of Temperature Sensor Based on Constant Speed Rising and Cooling Excitation Method. (Master's Thesis, China Academy of Launch Vehicle Technology, China, 2020) p.1. [3] Smart J H, Linden M, Wagner T, et al. Micrometer-sized nanoporous tin dioxide spheres for gas sensing [J]. Sens. Actuators B : Chem, (2011) No. 155: p.483–488. [4] CHEN Yijun, GUO Xingmin. Application of variable- coefficient PID temperature controlling system in semiconductor gas sensor[J]. Transducer and Microsystem Technologies, Vol. 36 (2017) No. 10, p. 154-160.