Intelligent temperature controller with communication port based on 89C52 microcontroller
2026-04-06 05:13:22··#1
1. Introduction Temperature controllers are widely used in many fields such as industrial control. This paper introduces a novel intelligent temperature controller with computer communication capabilities. Based on the AT89C52 microcontroller, it employs voltage/frequency conversion technology and the RS-485 communication interface chip MAX487. It boasts advantages such as high measurement accuracy, high reliability, strong anti-interference performance, and the ability to achieve computer network control. It can be widely used in industries such as metallurgy, textiles, chemicals, and medicine. It features temperature measurement and automatic control within a range of -200 to +500°C, making it a replacement for older temperature controllers with broad market prospects. 2. System Hardware Design The system hardware block diagram is shown in Figure 1. After the system is connected to a 220V AC power supply, a ±5V DC operating power supply is generated through a voltage regulator circuit (7805, 7905) to meet the operating requirements of the integrated circuits in this system. The system's telemetry circuit then begins operation: In areas where personnel cannot or cannot easily access, the temperature change is converted into a voltage signal by a platinum resistance temperature sensor PT100 and an operational amplifier OP07. This voltage signal is then converted into a pulse signal by an LM331 and input to the T0 port of an 89C52 microcontroller for frequency counting. The frequency of this counting pulse reflects the magnitude of the measured temperature. The system performs PID calculations. If the measured temperature does not match the system's set temperature, the electromagnetic relay in the output circuit is activated via an optocoupler TIL117 based on the PID calculation results, thus controlling the temperature adjustment. Simultaneously, each sub-unit communicates and transmits data with the host via its MAX487 communication port. Temperature settings for all temperature controllers can be set by inputting parameters from the host. The system's set temperature data is stored in a watchdog chip X25045, and the system alarms when the detected temperature exceeds a certain set value. This system uses an 8155 chip as the interface for an 8-digit LED digital tube and a 4-digit keypad, simultaneously displaying the system's set temperature and the detected temperature value. The 4-digit keypad includes: digit selection, increment, decrement, and function keys. 2.1 Temperature Detection and Signal Amplification Circuit This system uses a platinum resistance thermometer (PT100) as the temperature sensing element. The PT100 has advantages such as stable performance, strong oxidation resistance, and high measurement accuracy. A bridge circuit composed of the PT100 and resistive elements converts the resistance change of the platinum resistance caused by temperature changes into a voltage signal input to the amplifier. Since the platinum resistance thermometer installed at the measurement site needs to be connected to the control console via connecting wires, a three-wire connection method is used to reduce the influence of lead resistance. The signal amplification circuit consists of an integrated operational amplifier (OP07). The OP07 has a peak-to-peak noise level of 0.6μV and a common-mode rejection ratio (CMRR) > 106dB. The pin functions of the OP07 are: IN+ and IN- are differential input terminals, pins 1 and 8 are zero-adjustment terminals, and pin 6 is the output terminal. 2.2 Voltage/Frequency Conversion Circuit (LM331) In control and measurement systems, analog-to-digital (AD) converters typically input electrical or non-electrical quantities via sensors and preamplifier circuits into subsequent circuits for processing. This system uses the LM331 V/F converter to convert temperature signal changes into frequency signals. The LM331 is a high-performance, low-cost integrated circuit manufactured by NS Microsystems, featuring simple peripheral circuitry, single-supply capability, and low power consumption. The LM331 boasts a wide dynamic range of up to 100dB, good linearity even at operating frequencies as low as 0.1Hz, and a digital resolution of 12 bits. The LM331's output driver uses an open-collector configuration, allowing for flexible adjustment of the output pulse logic level by selecting the logic current and external resistors, adapting to different logic circuits such as TTL, DTL, and CMOS. The LM331 can operate between 4.0V and 40V, with an output voltage up to 40V, and is protected against VCC short circuits. In this system, the LM331 converts the output frequency signal into a TTL level and sends it to the microcontroller's P3.4 port as the counting pulse for T0. This conversion circuit exhibits good linearity and strong anti-interference capability, with an output range exceeding 10Hz to 10kHz, which is beneficial for improving the system's measurement range. The main pin functions of the LM331 are: RC: Reference current input; CO: Current output; FO: Frequency output; CI: Voltage input. 2.3 CPU and Peripheral Circuits The AT89C52 is an MCS-51 series microcontroller manufactured by Atmel. It has an internal 8KB electrically erasable programmable EEPROM and 256 bytes of RAM. The internal program memory space is sufficient to meet the program storage needs of this system, eliminating the need for external EPROM program memory and address latches, thus simplifying the circuit structure. TXD, RXD, P1.5, and P1.6 are connected to DI, RO, and DE of the MAX487 for data communication control, respectively. Ports P1.0 to P1.4 and RESET are connected to the X25045ALE, and port P0, P2.0, and P2.1 are connected to the 8155. The input terminal of counter T0 at port P3.4 is connected to the frequency output terminal of LM331 for pulse counting. Port P1.7 is the control terminal of optocoupler TIL117. The system data storage and fault protection section is composed of X25045, which is a 512-byte EEPROM for serial communication, and also has watchdog and power monitoring functions. X25045 has three programmable watchdog cycles. When powered on and when VCC is lower than the detection threshold, a reset signal is output. The X25045 output reset is active high, and its reset output terminal is directly connected to the reset terminal of 89C52. X25045 pin functions: Chip select input; SO: Serial output; SI: Serial input; SCK: Serial clock input; WP: Write protect input; RESET: Reset output. 2.4 Communication Port (MAX487) This system uses the RS-485 interface chip MAX487 as the communication port. The MAX487 is a differential bus low-power transceiver manufactured by Maxim Integrated for RS-485 and RS-422 communication. It contains one driver and one receiver, features driver/receiver enable functionality, has an input impedance of 1/4 load (≥48kW), and a node count of 128, meaning each MAX487 driver can drive 128 standard loads. The MAX487's driver is designed with a limited slope to prevent excessively steep output signal edges, thus avoiding excessive high-frequency components on the transmission line and effectively suppressing interference. The MAX487 has a receiver sensitivity of ±200mV. This means that when the differential voltage at the receiver is ≥ +200mV, the receiver output is high; ≤ -200mV, the receiver output is low; and between ±200mV, the receiver output is indeterminate. Therefore, if a receiver at a node generates a low level when the bus is idle, the transmission line is open, or short-circuited, the serial receiver will not be able to find the start bit, causing communication abnormalities. To address this, the system implements hardware modifications: pull-up and pull-down resistors are added to the A and B outputs of the MAX487 to ensure that all receivers receive complete data when valid data is transmitted. The MAX487 has a data transmission rate of 0.25Mbps, a static operating current of 120μA, and operates on a single 5V power supply. In this system, the MAX487 uses half-duplex communication, with communication between nodes using a twisted pair as the transmission medium. Since the characteristic impedance of the twisted pair is 120Ω, a 120Ω resistor is connected at both the beginning and end of the MAX487 to reduce signal reflection on the line. Because the main unit and the extension units are far apart, and the power-on or reset of the extension units often do not occur at the same time, if a MAX487 is in transmit mode at this time, it will occupy the communication bus and prevent other extension units from communicating with the main unit. This system adds an optocoupler TIL117 between the P1.6 port of the 89C52 and the DE pin of the MAX487, ensuring that the DE pin of the MAX487 is "0" when the system is powered on and reset, effectively solving this problem. The main pin functions of the MAX487 are: RO: Receiver output; DI: Receiver output enable (RO is enabled when "0"); DE: Driver output enable; DI: Driver input; A: Receiver non-inverting input and driver non-inverting output; B: Receiver inverting input and driver inverting output. 3. Control Software Design The system software adopts a modular design, consisting of a main program, subroutines, and interrupt service routines. The main program flowchart is shown in Figure 2. The main subroutines include: display subroutine; keyboard scanning subroutine; and PID calculation subroutine. Due to space limitations, the specific procedure is omitted. 4 Conclusion This intelligent temperature controller boasts high measurement accuracy and stable, reliable performance. It can not only replace older temperature controllers but also achieve efficient data management via computer networks, making it a practical intelligent instrument in modern industrial control. [b]References[/b] 1 Cao Qiaoyuan. Principles and Applications of Single-Chip Microcomputers. Beijing: Electronic Industry Press, 1997