Design of a temperature control system based on an LM35 temperature sensor
2026-04-06 08:25:54··#1
Abstract: This paper introduces a temperature control system developed using the LM35 temperature sensor, focusing on the system structure, working principle, and quantization of sampled values. The characteristics of the LM35 sensor, system hardware circuit design, and software design are also described. This system is small in size, low in cost, and reliable in operation, possessing high engineering application value. With slight modifications or expansions, the system can also perform functions such as temperature measurement. Keywords: Temperature sensor, working principle, hardware design, software design 1. Introduction Temperature measurement and control are widely used in various civilian control, industrial control, and aerospace technologies. In many working environments, the operating temperature specifications of components do not meet industrial or military-grade temperature requirements, which can be solved by designing heating circuits. Small, low-power, highly reliable, and low-cost temperature sensors are increasingly attracting the attention of designers. This paper introduces the hardware circuit and software design of a temperature control system developed based on the LM35 temperature sensor. 2. LM35 Temperature Sensor The LM35 is one of the integrated circuit temperature sensor series products manufactured by NS Company. It has high operating accuracy and a wide linear operating range. The output voltage of this device is linearly proportional to the Celsius temperature. Therefore, from a usage perspective, the LM35 is superior to linear temperature sensors using the Kelvin standard. The LM35 requires no external calibration or fine-tuning and provides a commonly used room temperature accuracy of ±1/4°C. • Operating voltage: DC 4~30V; • Operating current: less than 133μA; • Output voltage: +6V~-1.0V; • Output impedance: 0.1Ω with a 1mA load; • Accuracy: 0.5°C accuracy (at +25°C); • Leakage current: less than 60μA; • Scale factor: linear +10.0mV/°C; • Nonlinearity: ±1/4°C; • Calibration method: direct Celsius temperature calibration; • Package: hermetically sealed TO-46 transistor package or plastic TO-92 transistor package; • Operating temperature range: -55~+150°C rated range. Pin description: ① Positive power supply Vcc; ② Output; ③ Output ground/Power supply ground. 3. System Structure and Working Principle The temperature control circuit consists of a sensor circuit, a signal conditioning circuit, an A/D sampling circuit, a microcontroller system, an output control circuit, and a heating circuit. The basic working principle is as follows: The sensor circuit outputs the sensed temperature signal as a voltage to the signal conditioning circuit. After conditioning, the signal is input to the A/D sampling circuit. The A/D converter sends the digital value to the microcontroller system, which determines whether the heating circuit needs to be activated based on the designed temperature requirements. In this design, 0℃ is used as the criterion. When the temperature value is below or equal to 0℃, the heating circuit is activated. When the temperature value is above 0℃, the heating circuit stops working. Figure 1 shows the block diagram of the temperature control system. As can be seen from Figure 1, regardless of the reason for the ambient temperature falling below 0℃, the microcontroller system will output a corresponding logic level (designed as low level in this example). After being driven, this controls the relay in the output circuit to close, enabling the heating circuit to operate. This system is an open-loop control system. 4. Core Hardware Circuit Design and Sample Value Quantization The core component of the sensor circuit is the LM35AH. With a DC supply voltage of 15V, it operates at a current of 120mA, exhibiting extremely low power consumption and minimal current variation across the entire temperature range. The voltage output uses a differential signal method, directly outputting from pins 2 and 3. Resistor R is an 18K standard resistor, and D1 and D2 are 1N4148 diodes. (See Figure 2). This circuit is suitable for temperature measurement ranges from -55℃ to +150℃. Adjustments can be made to the circuit if the temperature range changes. The author conducted a temperature test on this circuit separately, placing the sensor in a temperature-changing cycling chamber, with each 5℃ interval serving as a test point, observing and recording the output voltage (test data and UT curves are omitted due to space limitations). The test results show that the linearity of the LM35AH is satisfactory. The signal conditioning circuit mainly amplifies and limits the sensor signal, conditioning the DC voltage output of the sensor circuit, which varies from approximately 2V, to ±10V DC. The operational amplifier used is the LF412. The A/D sampling circuit uses a 12-bit AD converter AD574. The microcontroller system uses an AT89C55 as the CPU, with external latches and output driver circuits. The output circuit uses a Panasonic PhotoMOS relay AQZ202 to control the on/off state of the heating circuit. The heating circuit uses a power resistor heating method, with a separate heating plate designed. The resistors are connected in series and parallel, with a total resistance of approximately 14Ω. The power supply voltage is DC 28V, and the total heating power of the plate is 50W. Figure 2 shows the schematic diagram of the sensor circuit. Accurate quantization of the sampled value is crucial for the normal operation of the temperature control circuit. The following conversion method is used for quantization. Let the voltage after signal conditioning be Ui, then -10V ≤ Ui ≤ 10V. It is known that the temperature corresponding to -10V is -55℃, and the temperature corresponding to 10V is 125℃. The proportionality factor Kt = 0.111V/℃ can be easily obtained. When the temperature is 0℃, ΔT = 55℃ (i.e., the change relative to -55℃). Ui = -10V + ΔT•Kt = -10V + 55℃ × 0.111V/℃ = -3.895 V. After Ui is converted to a digital value, each digital value corresponds to a voltage value of 4.883mV (obtainable from a 12-bit AD converter with a full-scale range of 20V), denoted by Ks. The correspondence between the digital value change and the temperature change can be obtained: Kt/Ks = (0.111V/℃) / (4.883mV/digital value) = 22.73 digital value/℃. At 0℃, the digital value D0 output by the AD converter = 0 + 55℃ × 22.73 digital value/℃ = 1250 = 04E2H. The digital values corresponding to other temperatures can also be calculated using the above method. 5. System Software Design The software adopts a mixed programming approach using PLM/51 language and ASM, and uses a modular structure. It mainly consists of a main module, an AD sampling module, an initialization module, a timer module, and an error handling module, making modification and maintenance very convenient. The AD converter is connected to the AT89C55 microcontroller system via interrupt. After the AD conversion is complete, the CPU reads the converted digital value and compares it. If the digital value is greater than the digital value 04E2H corresponding to 0℃, the logic output port P1 is refreshed and sent low. Otherwise, P1 is high. The software workflow is shown in Figure 3: Figure 3: System Software Flowchart. To avoid malfunctions due to interference, the software employs some redundancy and fault-tolerant measures. When the AD module processes the sampled data, software filtering is used to filter out potential spike interference in the circuit. The method is to sample five times consecutively, compare and remove the maximum and minimum values. The remaining three values are summed and averaged. This average is used as the valid data for the CPU to judge, and then compared with 04E2H (the digital value corresponding to 0℃). Part of the AD module code is as follows: $DEBUG $ROM (LARGE) AD_mod:DO; $INCLUDE (REG51.DCL) $INCLUDE (WKEXT.DCL) $INCLUDE (WKPRO.DCL) AD_zl: PROCEDURE PUBLIC; DECLARE max WORD; DECLARE mini WORD; DECLARE AD_S WORD; DECLARE (dtime,i,j) BYTE; DECLARE adtemp(5) STRUCTURE(x BYTE,y BYTE); DECLARE temp(5) WORD AT(.adtemp(0).x); DO j=0 TO 4; DO i=0 TO 20; dtime=dtime+1; END; END; temp(j)=SHR(temp(j),4); END; max=temp(0); mini=temp(0); DO j=1 TO 4; IF temp(j)>max THEN max=temp(j); IF temp(j) 6. Conclusion The temperature control system developed based on the LM35 sensor has undergone repeated experiments and tests, demonstrating stable and reliable operation. It features small size, high sensitivity, short response time, and strong anti-interference capabilities. The system is low-cost, using only common components, and has high engineering value. It is currently applied to the flight control system of a certain type of unmanned aerial vehicle (UAV). With slight modifications, this system can be easily expanded into a product integrating temperature measurement and control. Furthermore, the small-range nonlinearity of the LM35 sensor can be corrected using software algorithms.