Distributed temperature measurement system designed based on DS18B20 and AT89C2051

Publisher:二进制游侠Latest update time:2023-09-27 Source: elecfansKeywords:DS18B20 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Temperature monitoring is an important link in industrial production. Especially in industrial sites with harsh and complex environments, temperature monitoring plays an irreplaceable role. However, because the output of the temperature sensor used in many current temperature monitoring systems is a changing analog voltage, it cannot be directly interfaced with the computer acquisition system. It needs to be collected, processed and transformed before it can be sent to the computer-based monitoring system. This makes it inconvenient for multi-point distributed temperature measurement. With the development of computer, communication, network control and other technologies, industrial measurement and control systems have become a very important part of many industrial enterprises. Coupled with the increasing maturity of fieldbus technology and the emergence of digital temperature sensors, fieldbus technology and digital temperature sensors are more used in industrial monitoring systems, making the functions of industrial monitoring systems more powerful and the scope of monitoring wider. At the same time, improving the accuracy of temperature measurement is also one of the important goals.


Therefore, the system designed in this article uses digital temperature sensor DS18B20 and AT89C2051 microcontroller to collect and store temperature data, and transmit it through the RS485 bus. The upper computer performs parameter estimation based on the least squares method of the error regression model for each measured error compensation amount. The mathematical equations of the linear error compensation model are used to compensate for the data measured at normal temperature. Under the measurement range of -55e to +125e and the measurement accuracy of 0.2, the transmission distance can reach 500m, and the improvement of the transmission distance is given according to engineering practice. and key technologies for measurement accuracy.


1.System design

The system consists of PC and AT89C2051 microcontroller system, forming a small distributed measurement and control system. Among them, the task of the single-chip computer system is to complete the collection and storage of industrial site temperature values, and to connect to the PC through the RS485 bus. The main task of the PC is to undertake centralized measurement, control and management. Since the RS485 bus is used for communication, and the PC only has an RS232 interface, it needs to be connected through an RS232/RS485 adapter. The system structure is shown in Figure 1.

pIYBAGAXxVSANj8PAAERh1BTo1s728.png

Figure 1 System structure diagram

Temperature measurement points composed of the system's microcontrollers can be added. Each microcontroller has its own unique address. The master-slave communication method is adopted during communication. The host computer determines which microcontroller to communicate with. Figure 2 shows the communication interface between DS18B20 and Hardware design circuit. Figure 3 is the data acquisition and sending program flow chart of DS18B20.

o4YBAGAXxVuAEedzAAGkBXu1TIM366.png

Figure 2 Sensor data acquisition circuit

o4YBAGAXxWOAW4FzAAIAlRIYN4o282.png

Figure 3 Data collection and transmission flow chart

The upper computer mainly consists of five functional modules: monitoring window, temperature point query (lower computer), temperature report generation, help and exit system. The functional modules are shown in Figure 4.

o4YBAGAXxWqAARnCAAB0DO8TRzY326.png

Figure 4 PC system software module

2. Collection data processing

In the temperature measurement test, the 0.1 grade standard thermometer is used as a reference and is conducted in a normal temperature and pressure environment. The measurement environments adopted are room temperature, body temperature, ice-water mixture, hot water and boiling water.

After obtaining measurement data through actual measurement, calculation, analysis, and processing of the measured data are often important means to improve measurement accuracy. First calculate the average of each set of measurement data. like:

o4YBAGAXxXGADUi5AABt9xFKib4389.png

In processing the measurement results, it is necessary to find the best functional relationship between the variables x and y, y = f (x), based on the data. The most commonly used criterion to solve this problem is the least squares principle. For equal-accuracy, independent measurements, the basic principle is that the sum of squares of the deviations of each data point from the fitted straight line is minimum. Assume that the best-fitting straight line equation for this set of experimental data is: y = A+ Bx, where A is the intercept of the straight line and B is its slope.

o4YBAGAXxXiAcqKQAABXyZYqfdo405.png

According to the principle of least squares and the usual method of finding extreme values, removing the partial derivatives with respect to A and B and setting them to 0, we can derive two equations, which have unique solutions for the two unknowns A and B. By solving this system of equations we get:

o4YBAGAXxX-AMIOSAABzTImGInA555.png

Calculate the measured data according to equations (1) and (2). For example, the A and B values ​​are 1.078 and 0.97 respectively, and the straight line equation of the straight line fitting is y=1.078+ 0.97x. The distribution of its data points in the straight line fitting graph is shown in Figure 5.

pIYBAGAXxYiAZpsKAACAhDC8VPs835.png

Figure 5 Distribution of measurement data points around the fitted straight line

According to the corrected straight line equation, such as y=1.078+0.97x, linear correction is performed on the measured values ​​of the measuring points, so that the correction table can be obtained. Due to space limitations, only the result data before and after the correction of room temperature are given, as shown in the table 1 shown.

o4YBAGAXxY-AWZ4rAAI5yGeXbpM263.png

The corrected average temperature is 26.041e, and the average value measured by the reference thermometer is 25.94e. The measurement error of the two is reduced to 0.100e, which is 0.39e smaller than the error before correction.

It can be clearly seen from the correction results that the measurement accuracy has been greatly improved. Using the method introduced above, the author successfully applied it to the urban construction archives management information system of Huai'an City and the automatic temperature and humidity control system of the ammunition depot of the 15th Branch of the Chinese People's Liberation Army, and achieved very good accuracy and control effects.

3. Key technologies for precision control in multi-point long-distance transmission

Although the temperature measurement system composed of DS18B20 sensor has the advantages of simple system structure, high temperature measurement accuracy, convenient connection, and occupying few interface lines, the following issues should also be paid attention to in practical applications:

(1) Small hardware overhead requires relatively complex software to compensate. Since serial data transmission is used between DS18B20 and the microcontroller, when reading and writing programming for DS18B20, the reading and writing timing must be strictly guaranteed, otherwise the test results will not be read. When using high-level languages ​​such as PL/M and C for system programming, it is best to use assembly language for the DS18B20 operating part.

(2) None of the relevant information on DS18B20 mentions the issue of the number of DS18B20s on the bus. In practical applications, if there are more than 8 DS18B20s on the bus, it is necessary to add a microcontroller bus driver.

(3) The bus cable connected to DS18B20 has a length limit. When the transmission length of ordinary signal cable exceeds 50m, errors will occur in the temperature measurement data read. When the bus cable is changed to a shielded twisted pair, the communication distance can reach 500m. Therefore, when designing a long-distance temperature measurement system using DS18B20, multi-strand shielded twisted pair cables should be selected. Experiments have proven that when the distance is greater than 500m and less than 100m, the measurement accuracy can be guaranteed to be at level 0.2.

(4) When the distance exceeds 500m, the transmission rate and anti-interference measures must be fully considered. In actual engineering use, a 120 ohm resistor needs to be connected in parallel at the far end (when the interference is strong, a 120 ohm resistor also needs to be connected in parallel at the near end) in order to absorb interference such as echo. In addition, reducing the signal transmission rate is a very effective measure. In practice, the transmission distance can reach 1000m using 9600 baud rate.


in conclusion

The RS485 bus multi-point distributed temperature measurement system composed of DS18B20 is discussed in detail. The system strictly follows the calibration specifications of measurement products , analyzes and processes multi-point long-distance measurement data, and corrects errors, with an accuracy of 0.2. Experiments have proven that this system design can realize network monitoring of multi-point temperatures in industrial sites, and has the characteristics of low cost, multiple functions, high reliability and high accuracy.


Keywords:DS18B20 Reference address:Distributed temperature measurement system designed based on DS18B20 and AT89C2051

Previous article:Design of power transformer anti-theft system based on stc89c52 microcontroller and gsm module
Next article:Design of intelligent system based on STC89C58RD+ microcontroller and SC1128

Recommended ReadingLatest update time:2024-11-23 12:39

C language program using DS18B20 temperature sensor in single chip microcomputer (reference 6)
/******************************************/ // // DS18B20 thermometer C program // 2007.06.08 /******************************************/ //Use AT89C2051 microcontroller, 12MHZ crystal oscillator, common anode LED digital tube //P1 port outputs segment code, P3 port scans, P3.4 connects to DS18B20 #include "r
[Microcontroller]
DHT11 and DS18B20 temperature and humidity control microcontroller program
Based on 51 single chip microcomputer, the sensor uses dht11 and ds18b20. The temperature measurement accuracy of dht11 is limited, and 18b20 can make up for it. The first line shows the humidity and temperature collected by dht11, as well as the relay status. The second line shows the temperature and THI collected by
[Microcontroller]
DHT11 and DS18B20 temperature and humidity control microcontroller program
AT89C2051 controls the voice chip recording and playback system circuit
This article introduces the computer voice system composed of Flash single-chip microcomputer AT89C2051 and digital voice chip ISD2560. The hardware circuit of the system is designed, and the practical source program for recording and playing is given. At present, the application of voice system based on single-chip mi
[Microcontroller]
AT89C2051 controls the voice chip recording and playback system circuit
Digital voltmeter circuit composed of 74ls138 and AT89C2051
We use AD574 and ATMEL's low-priced and high-performance microcontroller AT89C2051 to form a high-precision digital voltmeter. The electrical schematic diagram is shown in Figure 1. AD574 is a 12-bit sequential comparison A/D converter with a total of 12 data lines. AT89C2051 P1 is directly connected to the high 8-bit
[Microcontroller]
Digital voltmeter circuit composed of 74ls138 and AT89C2051
DS18B20 assembly program and C program
ds18b20 c program //DS1820 C51 subroutine //Here we take 11.0592M crystal as an example. Different crystal speeds may require adjustment of the delay time //sbit DQ = P2^1; //Define the port according to actual conditions  typedef unsigned char byte; typedef unsigned int word; //delay void delay(word useconds) { for
[Microcontroller]
51 single-chip multi-channel DS18B20 temperature measurement display and serial number reading
/**************************************************** Function: Read serial number and match serial number, and read temperature value Multifunctional test board showing multi-channel temperature acquisition Normally display the temperature of 2 DS18B20 Read the DS18B20 serial number normally Microcontroller: STC1
[Microcontroller]
51 single-chip multi-channel DS18B20 temperature measurement display and serial number reading
DS18B20 temperature measurement and display program
#include #include intrins.h sbit TSOR=P2^0; #define Busy 0x80; #define uchar unsigned char #define uint unsigned int #define reset() {WDT=0x1e;WDT=0xe1;} sfr WDT=0xa6; bit ON_OFF; bit outflag; sbit en =P1^7; /*DTLED-6 display chip enable terminal*/  sbit dout=P1^6; /*DTLED-6 display chip data reading termi
[Microcontroller]
Wireless Monitoring System Based on AT89C2051 and nRF401
introduction At present, doctors often use nighttime sleep breathing multiple physiological monitors to diagnose sleep apnea, recording a whole night's sleep cycle, including the number of apneas and shallow breathing, patterns, hypoxia index, number of times, changes in electrocardiogram, oral and nasal airflow, ch
[Microcontroller]
Wireless Monitoring System Based on AT89C2051 and nRF401
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号