Share this

Design of a Temperature Measurement and Processing Transmitter

2026-04-06 05:51:53 · · #1
Abstract: This paper details a temperature measurement system based on the AT89C52 microcontroller. The system's signal input channels, signal processing, and data display are described from both hardware and software perspectives, with corresponding theoretical analyses. The system can achieve multi-point temperature cyclic acquisition, processing, and transmission. Keywords: Transmitter, Sensor, Microcontroller I. Overview When lime is burned in a lime kiln, the temperature may vary at different points within the kiln. The production process requires obtaining the average temperature at four points within the kiln, understanding the temperature values ​​at each point, and performing alarm processing on the average value and the temperature at each measurement point. If the signal at a certain point is abnormal (sensor damage or disconnection), an alarm should be triggered promptly, and the temperature should be excluded from data processing. This system can perform the above functions, detecting and processing the temperature of the lime kiln, and transmitting the average temperature or the temperature of the highest point remotely in 4-20mA format. The working schematic diagram of this product is shown in Figure 1. Four thermocouples are placed at four points within the lime kiln, and these four thermocouples are the four input signal sources of the system. The system measures the temperature as shown in Figure 1. II. System Hardware Design 1. System Structure Diagram and Human-Machine Interface The system structure diagram is shown in Figure 2. The system hardware mainly consists of a front-end input circuit, A/D and D/A circuits, a human-machine interface circuit, a CPU, and peripheral circuits. The system's main function is to allow four signal inputs. Users can select the thermocouple type through parameter settings. Normally, it displays the average temperature. If needed, the operator can press buttons on the panel to view the temperature of any signal. The four signals are independent; a short circuit or open circuit in one signal will not affect the operation of the others. The instrument has over-limit alarm functions and thermocouple open circuit indication functions. The average temperature or the highest temperature signal is transmitted as a 4-20mA current signal output. The system has power-off protection; when power is lost, the set data is saved. The system features a user-friendly human-machine interface. The operation display panel is shown in Figure 3, with two rows of digital tubes and four buttons for displaying system operation and modifying parameters. The system operates in two states: programming and running. The state switching key (K1) allows switching between these two states. In programming mode, the top row of digital tubes displays the parameter codes, and the bottom row displays the corresponding parameters. In this mode, key K2 (shift key) can be used to sequentially change different parameter codes and parameters. Keys K3 (increase key) and K4 (decrease key) can be used to modify the parameters. In running mode, the top row of digital tubes displays the sequence numbers of each signal loop (1 to 5), and the bottom row displays the corresponding temperatures. Lots 1 to 4 display the four loop numbers and their temperatures, and loop 5 displays the average temperature of the four loops. These five loops are displayed automatically in a cycle, and key K4 (position key) can be used to stop the display on the current loop. Pressing K1 at any time during programming or running mode will switch to the initial stage of another state. The circuit design does not include an expansion bus, program memory, or I/O ports. The CPU's four parallel ports are used as ordinary I/O ports. The CPU and peripheral circuits use standard methods. This section focuses on the uniquely designed A/D and D/A circuits, the human-machine interface circuit, and the power supply circuit. 2. Data Acquisition Circuit and Amplification Circuit The data acquisition circuit is shown in Figure 4. A current-limiting resistor R1 and a Zener diode TL431 generate a 2.5V standard voltage. The system has 7 analog input signals: 4 thermocouple signal inputs (EXT1-EXT4), 1 cold junction compensation signal, 1 reference signal, and 1 ground signal (EXT5). The 2.5V voltage is applied to the series branch of a 10K resistor and an external diode, forming the thermocouple cold junction compensation circuit. This circuit uses the voltage-temperature characteristic of the diode in forward operation to measure the cold junction temperature. The reference signal is generated using the 2.5V voltage and a voltage divider resistor. Therefore, an 8-to-1 analog switch CD4051 is used, with the analog channel selection controlled by the high and low levels of the microcontroller's P2.0, P2.1, and P2.2 pins. Since the input thermocouple calibration number is set by the user, and the signal magnitude varies for different calibration numbers, a programmable amplifier composed of OP07 and 4051 (U2) is designed. The input signal is amplified and then enters the A/D converter. After acquisition and processing, the signal values ​​of each channel are obtained. Programmable amplifiers utilize a microcontroller to control the 4051 microcontroller, selecting different channels and thus different amplification factors. The external resistors for the 4051 are: R25=20K, R26=47K, R27=2.4K, R28=3.9K, and R29=1.9K. There are four different amplification factors: Amplification factor 1 = (20+47+2.4+3.9+1.6)/(47+2.4+3.9+1.6)≈1.3 times, Amplification factor 2 = (20+47+2.4+3.9+1.6)/(2.4+3.9+1.6)≈10 times, Amplification factor 3 = (20+47+2.4+3.9+1.6)/(3.9+1.6)≈14 times, and Amplification factor 4 = (20+47+2.4+3.9+1.6)/1.6≈46 times. The 1.3x amplification factor is mainly used for acquiring the cold junction compensation diode signal. Four 22MΩ pull-up resistors in the circuit complete the thermocouple disconnection detection function. Four thermocouples are placed at four points inside the lime furnace, serving as the four mV signal input terminals of the system. After the thermocouple signals are selected, they enter the programmable amplifier circuit. Different signal graduations result in different mV values. Different amplification factors are selected by software to make the maximum value of these amplified signals close to the maximum allowable value of the A/D converter, thus fully utilizing the A/D resources and ensuring measurement accuracy. Let the amplification factor be A, then the signal amplified by the programmable amplifier is AX. The determination of the amplification factor for various signals is related to the analog input of the subsequent A/D device. This circuit uses a 7135 (5.5-bit) A/D converter with a reference voltage of 0.5V. The analog input range of the 7135 is 0-1V. For example, for standard B and S thermocouples, the amplification factor should be 46, and for standard K and E thermocouples, the amplification factor should be 14. The cold junction compensation diode signal is approximately 0.65V, and a 1.3x amplification factor is used. Taking the conversion calculation of one signal as an example, when measuring a thermocouple input, the external thermocouple input millivolt value, the cold junction compensation diode voltage drop, the reference voltage, and analog ground are sequentially acquired. The voltage V<sub>base</sub> input from the X2 terminal of the 4051 is a known voltage, embedded in the program. D<sub>base</sub>, D<sub>zero</sub>, and D<sub>x</sub> are the real-time A/D acquisition values ​​of the reference, zero point, and input thermocouple signal, respectively. Zero-point and full-scale self-calibration can be performed using the following formula to calculate the V<sub>x</sub> value. Since the three signals V<sub>base</sub>, V<sub>x</sub>, and ground pass through the same hardware input channel, the hardware's discrete error and zero-point/full-scale drift have the same impact on all three. The following formula can correct the errors in the zero point, amplification factor, and A/D stages, ensuring the system's measurement accuracy when using general components. D<sub>base</sub> - D<sub>zero</sub> / D<sub>x</sub> - D<sub>zero</sub> = V<sub>x</sub> / V<sub>base</sub>. Since the relationship between thermocouple mV and temperature is non-linear, we used a piecewise linear method for non-linear correction. V<sub>x</sub>, through piecewise non-linear data processing, can be used to calculate the corresponding temperature CX. Adding this to the cold junction compensation temperature C<sub>0</sub> obtained by measuring the cold junction compensation diode voltage, we obtain the actual measured temperature C for this circuit, i.e., C = CX + C<sub>0</sub>. Simultaneously, due to the thermocouple, the voltage value at the measuring end will be partially canceled out. This situation causes a significant error. Cold junction compensation is necessary. Because the forward conduction voltage of the diode changes stably with temperature variations (-2mV/℃), we use a diode to measure the cold junction humidity for compensation. The specific procedure is as follows: First, we input a standard voltage of 0.7V to the cold junction compensation input terminal to obtain an AD sampling value D<sub>0</sub>. Then, we input another standard voltage of 0.6V to obtain another AD sampling value D<sub>1</sub>. Subtracting the two values ​​yields a value ΔD. Based on the diode's characteristics, the voltage changes by 2mV for every 1°C change. The difference between the first and second standard input signals is 100mV, equivalent to a 100mV change in the diode's forward voltage, corresponding to a 50°C change in the cold junction temperature. Therefore, we can calculate the coefficient K = ΔD/50 for the change in the AD value for every 1°C change in the cold junction temperature. Since the cold junction temperature range is small (0-50°C) and the accuracy requirement is not high, this coefficient is directly embedded in the program during mass production. When the 1N4148 cold junction compensation diode is connected to the input, as described above, the magnitude of the cold junction temperature change can be calculated based on this coefficient and the change in the cold junction AD acquisition value. Step 2: In the instrument settings, input the current ambient temperature Ta and immediately measure the voltage across the diode 1N4148 terminal, amplified and converted to AD value Da. Store Ta and Da in the EEPROM. Later, when the instrument is operational, measure the diode's AD conversion value Db in real time, and subtract the two to get ΔDab = Da - Db. Divide ΔDab by K (representing the magnitude of each 1°C AD sampling value) to obtain a temperature difference Y. Then add the initial ambient temperature Ta to Y to obtain the actual cold junction temperature C0 = Y + Ta. This cold junction compensation has a certain error. When the ambient temperature changes, the measured actual cold junction temperature C0 will change accordingly. Within a certain period, the change in ambient temperature is small, so the error it causes is very small compared to thermocouples and can be ignored. However, when the environmental change is large, such as from winter to summer (a change of tens of°C), if the cold junction compensation error is greater than 1 degree, we can re-enter the reference Ta for correction. 3. A/D Circuit: The A/D circuit mainly consists of 74LS157 and ICL7135 chips. The 7135 uses a 0.5V reference signal, and the analog voltage input range is 0-1V. The ICL7135 uses a dynamic scanning BCD code output method, where the BCD codes for each digit (ten thousands, thousands, hundreds, tens, and ones) appear alternately on terminals B8, B4, B2, and B1, with digit selection pulses appearing synchronously on terminals D5-D1. The acquired weak signal is amplified by a programmable controller and then converted into a digital signal via AD conversion. A 74LS157 quad 2-to-1 selector is used, allowing the "ten thousands" digit data output and the other three flag signals (over-range, under-range, and polarity output) to share the four I/O lines P0.0-P0.3 of the C52 with the BCD code data output (B8, B4, B2, and B1). Time-division multiplexing is achieved by controlling the SEL selector terminal of the 74LS157 via D5. When the SEL input is low, it selects the 1A-4A output; when the input is high, it selects the 1B-3B output. Since the "ten thousand" digit can only output 0 or 1, it is a half-digit. Therefore, it forms a four-digit data output with OR (overrange), UR (underrange), and POL (positive/negative polarity) for the microcontroller to read. The hardware interface with the C52 is polling, and the software uses D5, D4, D3, D2, and D1 to output the "ten thousand," "thousand," "hundred," "ten," and "one" digits. 4. Control Panel Circuit This circuit consists of two parts: a button control circuit and a display circuit. See Figure 5 for the specific circuit. The circuit uses the ZLG7289 as the core chip, connected to the microcontroller through three pins. The microcontroller can perform dynamic display scanning and button polling, saving microcontroller I/O port hardware resources and time resources. In the actual circuit, the Zlg7289's select/CS ground clock line (CLK) is connected to port P2.7, the data line (DIO) is connected to port P2.6, and the key signal line (KEY) is connected to port P2.5. The Zlg7289 is an intelligent display driver chip with an SPI serial interface that can simultaneously drive an 8-digit common-cathode LED display (or 64 independent LEDs). It can directly drive an eight-digit LED display without external components and can simultaneously connect to a keyboard matrix with up to 64 keys, enabling single-chip expansion of LED display and keys. The Zlg7289 contains an internal decoder that can directly accept BCD or hexadecimal codes, and supports both decoding modes. It also has various control commands, such as blanking, blinking, left shift, right shift, and segment addressing. This system uses two rows of 4-digit LED displays, which are dynamically displayed. According to the requirements of ZLG7289, a common cathode seven-segment display is selected. Pins 18-25 of ZLG7289 are connected to the digit drive terminals of the seven-segment display, and pins 10-17 are connected to the segment drive terminals. The content to be displayed can be sent to the 7289 through the data line and clock line. This circuit only has four buttons. When a button is pressed, the level of the KEY pin changes, notifying the CPU to read the key value through the data line and clock line. 5. Alarm Circuit and Signal Output Circuit There are two types of alarms: upper limit alarm and lower limit alarm. Two alarm relays are connected to P0.5 and P0.7 of the microcontroller through PNP driving transistors, respectively, active low. Software Design When the four signals and their average value exceed their respective upper limits, the relay will sound an alarm, and the letter "H" will be displayed on the last digit of the upper row of seven-segment displays on the control panel; similarly, when the four signals and their average value are below the set lower limit, the relay will also sound an alarm, and the letter "L" will be displayed in the same position. The circuit diagram of the analog output section is shown in Figure 6. The microcontroller selects the average temperature or the highest temperature measurement point signal according to the set parameters and sends it to the 7520 10-bit D/A chip, which works with the LM741 amplifier to obtain the voltage output. Finally, after passing through a V/I conversion circuit composed of another LM741, the analog current output of 4-20mA and voltage output of 1-5V are obtained. 6. Switching Power Supply Circuit This transmitter uses a 24V DC power supply from the DDZ-Ⅲ type electric unit combination instrument. The advantage of this power supply method is that each unit eliminates the need for a power supply voltage converter, and no mains frequency power enters the unit instrument, which solves the instrument overheating problem and provides favorable conditions for the explosion protection of the instrument. Since ±5V is required internally, the system uses a DC/DC switching power supply to generate 5V and -5V voltages. The power supply circuit is shown in Figure 7. The MC34063 used in the power supply circuit is a chip that integrates the main functions of DC-DC conversion. It can be designed to perform boost (buck) and polarity conversion functions, and requires few external components. An external 24V input voltage is converted to +5V via the MC34063, and then converted to -5V via the ICL7660. The 24V voltage can simultaneously power the internal 4-20mA output circuit. During circuit operation, the maximum current is 0.4 Amps at 5V and 0.02 Amps at -5V. III. Software Design and Debugging The software design mainly includes the main program, ICL7135 A/D conversion program, BCD code conversion program, arithmetic comparison program, 24C02 read/write subroutines, table lookup program, and function key subroutines. The main program flowchart is shown in Figure 8. The main program mainly includes two branches: programming state and running state. The microcontroller first initializes, and the initial program state is set to running state. Except when initially powered on and entering running state, the program must subsequently check the status flag bit and enter either programming or running state based on the check result. In running mode, parameters cannot be edited. Instead, various operating parameters are read from the 24C02 microcontroller. Input signals are measured in a cycle, and the temperature values ​​at each measurement point are obtained through zero-point and full-scale self-calibration, cold junction compensation calculation, and table lookup. In this mode, the left arrow key (←) can be used to select and display various operating parameters, including measurement, alarm, and fault information. When editing parameters, the system does not perform measurements. Upon entering programming mode, a programming permission password is required. With the correct password, parameters can be selected using the left arrow key (←) and modified using the up and down arrow keys (↑↓). The settings are stored in the 24C02 microcontroller. After 5 minutes of inactivity, the system automatically returns to running mode regardless of whether the status key is pressed. In running mode, the upper four digits display the circuit number (the last two digits display alarm and fault information), and the lower four digits display the corresponding data. The K4 key can be used to switch between different circuits and their parameters. Circuit numbers 1-4 represent four different signals, with the average value displayed on the fifth channel. The largest signal and the average value of the four channels can be selected and transmitted as a 4-20mA signal through parameter settings. The software determines the selection level of the four signals connected to the 4051 and AT89C52. The selected analog input signal is amplified by the programmable 4051 and operational amplifier, and then enters the ICL7135 for A/D conversion, converting the voltage signal into BCD code (from ten-thousands place to units place, with a five-bit address output). The conversion subroutine converts the BCD code into a hexadecimal number, and finally performs various data processing to obtain the temperature value, calculate the maximum and average values, and perform alarm and signal fault detection processing.
Read next

The hazards of vacuum circuit breaker closing bounce and countermeasures

Abstract: The "General Technical Conditions for 35kV Indoor High-Voltage Vacuum Circuit Breakers" (ZBK97004-89...

Articles 2026-02-22