Introduction Due to its balanced differential transmission characteristics, the RS-485 bus possesses strong anti-interference capabilities, long transmission distances, and strong cascading capabilities. It enables multi-station long-distance communication, facilitates networking, and is cost-effective, thus finding widespread application in industrial control. This system is a remote multi-channel temperature monitoring and control system based on the RS-485 bus. The host computer is a PC, and the slave computers are multiple temperature sensors using AT98S51 microcontrollers. During operation, the slave sensors send their local address and a request for preset temperatures to the host computer. After obtaining the slave addresses, the host computer knows which slave sensors are running and sends the corresponding preset temperatures to them according to the requests. Subsequently, it queries the temperature information measured by each running slave sensor at regular intervals, obtains the temperature values, stores them in the database, and displays the current measured temperatures of each sensor in real time. An alarm is triggered when the temperature is too high. After obtaining the preset temperature, the slave sensors begin data acquisition and temperature measurement. When the temperature is below the preset temperature, the heater is activated to raise the temperature; when the temperature is too high, the cooling equipment is activated to accelerate cooling. Simultaneously, the temperature information is transmitted back to the host computer. If the temperature exceeds the set range, an alarm will sound. The host computer receives the measured temperature from the slave device, stores it in the database, and displays it in real time. The system also has database management and temperature change curve plotting functions. After the slave device powers off and restarts, it will query the host computer again to obtain the preset temperature before the power failure. The temperature monitoring system consists of a sensor circuit, a signal adjustment circuit, an A/D sampling circuit, a control circuit, and a monitoring host. The basic working principle is as follows: the sensor circuit outputs the sensed temperature signal as a voltage, which is converted to TTL level by the adjustment circuit, sampled by the A/D converter, and sent to the microcontroller control circuit. The microcontroller determines what control to perform based on the set temperature transmitted from the host computer at power-on. If the temperature has not reached the set temperature, the drive control relay closes to activate the heater; if the temperature is too high, the cooling equipment is activated to accelerate cooling. The microcontroller also displays the measured temperature on a digital tube and sends the measured temperature to the host computer for storage when queried. The system block diagram is shown in Figure 1. System ImplementationHardware Design: The AT89S51 is an in-system programmable microcontroller from Atmel. It is inexpensive and supports in-system programming (ISP), facilitating development and debugging. The temperature sensor selected is the L=M35 from NS, which has high accuracy and good linearity, with a temperature measurement range of -55℃ to +150℃, perfectly suitable for general temperature measurement applications. Its output voltage is linearly proportional to the Celsius temperature, providing a measurement accuracy of 1/4℃ without external calibration. The signal adjustment circuit adjusts the DC voltage output of the sensor circuit, which varies from approximately 2V, to TTL level for A/D compatibility. Due to the limited number of microcontroller I/O ports, when real-time temperature measurement requirements are not too high, the A/D conversion uses an 8-bit serial A/D converter ADC0832, which has only three I/O connections to the microcontroller, reducing I/O usage. The data terminals of all four digital tubes are connected to the P1 port of the microcontroller, and the control terminals are controlled by P2[3..0]. A timer interrupt triggers the display, activating only one digital tube at a time to show the corresponding value. A time-division multiplexing method is used to display the temperature value on the digital tubes. When the temperature changes, the A/D acquisition and adjustment circuit outputs a voltage value, which is sent to the microcontroller. The microcontroller determines the temperature based on the sampled value, displays the temperature value on the digital tubes, and feeds it back to the host computer. The schematic diagram is shown in Figure 2. Software Design Lower-level software design: The lower-level software was developed using C language under Keil uVisiml2. The software design mainly addresses three issues: First, writing the control bits of the ADC0832. According to the datasheet, the configuration word should be written on the rising edge of the clock, but this method consistently failed to read the data correctly. After experimentation, it was found that after writing each bit of the configuration word, the data must be flipped before the negative transition for the configuration word to be written correctly. Second, displaying the temperature value on the digital tubes. Finally, an interrupt scheme is adopted, entering the interrupt program every 10ms to cyclically select each digital tube and display the corresponding digital value in a time-division manner. Thirdly, the A/D sampling data is processed. To avoid instability caused by interference, a software filtering method is used to filter out possible spike interference. The method involves sampling seven times consecutively, removing the highest and lowest values, and averaging the remaining five to obtain the digital quantity from the A/D sample. Measurements show that 0V corresponds to 0℃, and 5V corresponds to 125℃, therefore the scaling factor K = 0.04V/℃. Each digital quantity corresponds to a voltage of 20mV, so the ratio of digital quantity change to temperature change is K1 = 2digits/℃. Using this scaling factor, the current temperature can be obtained from the digital quantity. The host computer software design of this system is a master-slave monitoring system. After the host computer sends a preset temperature to the slave computer to start it, it polls the slave computers with different address codes to obtain the temperature value, stores it in the database, and displays it on the main interface. The slave device starts after receiving the preset temperature from the host. It sends back the measured temperature value each time the host queries it. In the event of a power outage and restart, the slave device sends a reset request to the host, requesting the host to resend the preset temperature. The communication software for the host computer is developed using Borland's C++Builder 5.0. Its integrated RAD development environment helps developers quickly and efficiently develop high-quality programs. Serial port programming in C++Builder can use the Mscomm control to speed up development. It is an ActiveX component not included in C++Builder. It is provided during installation and can be obtained on a PC with VC6.0 installed. After copying it to the local machine and registering it, in C++Builder, first import the ActiveX control in the Components menu, then install Packages. It will then appear and be usable in the ActiveX panel. The database used is Microsoft's ACC:ESS database, using the ADO data engine. C++Builder provides complete ADO development controls in the ADO panel, enabling basic database operations such as connecting to the database, editing data content, and displaying data through mouse operations. The program can also plot historical temperature change curves for easy operator management. Bus Communication Format Settings Serial communication between the host computer and the slave computer uses the RS-485 standard interface. Connecting an RS232/485 converter to the PC enables RS485 bus control. At a communication frequency of 1200bps, the effective communication distance is 1.2km. Since multiple slave devices are connected in parallel on the 485 bus, a strict communication format must be defined. Table 1 shows the communication protocols used. Conclusion This author designed a temperature control system based on the RS485 bus. This system requires low investment, is simple to set up, and has strong scalability, greatly reducing the burden on managers and realizing industrial control automation. It has been applied in multiple locations, with a temperature measurement accuracy within 0.5℃. The system operates reliably and stably without communication failures.