Home > Detection Circuits >Test Measurement Circuits > Design of Multi-point Temperature Measurement System Based on DS18B20

Design of Multi-point Temperature Measurement System Based on DS18B20

Source: InternetPublisher:萌面大虾 Keywords: Temperature measurement DS18B20 Updated: 2024/07/22

introduction

In the design of traditional temperature measurement systems, analog technology is often used for design, which inevitably encounters problems such as lead error compensation, switching error in multi-point measurement and error in signal conditioning circuit; and improper handling of any link may cause the performance of the entire system to decline. With the rapid development of modern science and technology, especially the development of large-scale integrated circuit design technology, miniaturization, integration and digitization are becoming an important direction for the development of sensors [1]. The digital temperature sensor DSl8820 launched by Dallas Semiconductor in the United States has a unique single bus interface and only needs to occupy a general I/O port to complete the communication with the microprocessor; it has an accuracy of ±0.5℃ in the temperature range of -10 to +85℃; the user can programmably set a resolution of 9 to 12 bits. The above characteristics make DSl8820 very suitable for building high-precision, multi-point temperature measurement systems.

1 DS18B20 Introduction

1.1 Features of DS18B20

DS18820 is an improved intelligent digital temperature sensor launched by Dallas Semiconductor Corporation in the United States after DS1820 [2]. Compared with traditional thermistors, it can directly read the measured temperature and can realize 9-12-bit digital value reading mode through programming according to actual requirements; it can complete 9-bit and 12-bit digital quantities within 93.75 ms and 750 ms respectively; it only needs one line (single-line interface) to read information from DS18820 or write information to DS18820; the temperature conversion power comes from the data bus, and the bus itself can also supply power to the connected DS18820 without the need for an additional power supply. Using DS18820 can make the system structure simpler and more reliable. DS18B20 has made great improvements over DS1820 in terms of temperature measurement accuracy, conversion time, transmission distance, resolution, etc.

1.2 DSl8B20 internal structure and working principle

The internal structure of DS18B20 is shown in Figure 1, which mainly includes parasitic power supply circuit, 64-bit read-only memory (ROM) and single-wire interface, memory and control logic, high-speed temporary storage memory for storing intermediate data, temperature sensor, alarm upper limit register TH, alarm lower limit register TL, configuration register and 8-bit CRC (cyclic redundancy check code) generator.

The core of DS18B20 is its digital temperature sensor, the accuracy of which can be configured to 9, 10, 11 and 12 bits through user programming, which correspond to 0.5℃, 0.25℃, 0.125℃ and 0.0625℃ respectively, and can meet various resolution requirements. When starting a temperature conversion, the microprocessor needs to send a Convert T instruction to DS18B20. After the conversion is completed, the temperature data is stored in the temperature register of the high-speed temporary memory, occupying 2 bytes, and DS18B20 returns to the idle state. When DS18B20 uses external power supply, the host can initiate a read time slot after sending the temperature conversion instruction. If the DS18820 has completed the temperature conversion at this time, it will return "1", otherwise it will return "0".

2 Temperature measurement system design

The block diagram of the high-precision, multi-point temperature measurement system composed of DS18B20, PIC18F8620 launched by Microchip and related peripheral circuits is shown in Figure 2. The system uses 6 DS18820 chips to form a small temperature sensor network, which is connected to the general I/O port RBO of the microprocessor through a single-line connection. The resolution of DS18B20 is 11-bit mode, that is, 0.125℃. The microprocessor communicates with the temperature sensor network through a single-line protocol. After the microprocessor obtains the temperature information, it transmits the processed temperature information to the host computer through the USB port or RS485 interface through a specific algorithm.

2.1 DS18820 automatic search algorithm [4]

Since multiple DS18B20s are used in the system to form a temperature sensor network, how to accurately and effectively address each temperature sensor becomes a core issue in the design of the system. Combining the actual characteristics of DS18B20 and the needs of the system, the following solution is proposed: First, the internal alarm upper limit register of DS18B20 (as shown in Figure 1, hereinafter referred to as "TH register") is used to store the number of the temperature sensor, and its number is pasted on the surface of the temperature sensor. Since the TH register has the function of not losing data when power is off, the unique 64-bit registration code of each DS18B20 and its number are matched one by one. This process requires the DS18B20 to be programmed separately. Then, the temperature sensor with the determined number is connected to the single-line network, and the registration code of each DS18B20 can be searched by using the unique single-line network automatic search function of DS18B20. Then, the corresponding set number can be read from the TH register of each DS18B20 by using the registration code and the corresponding ROM operation instruction, so as to realize the addressing function of each DS18820. The following focuses on the automatic search function.

Each DS18B20 has a unique 64-bit registration code, which is stored in the read-only memory (ROM). Its structure is as follows:

The lower 8 bits are the factory code of the product (28H for DS18B20), followed by the unique serial number of each device, a total of 48 bits, and the highest 8 bits are the cyclic redundancy check code of the first 56 bits. This allows the bus host to address a specific DS18B20 on the bus. Only the DS18B20 that strictly matches the 64-bit registration code can respond to subsequent operations. All DS18B20s that do not match the 64-bit registration code will wait for a reset pulse.

The search algorithm first resets all DS18B20s on the single-wire bus through reset and online presence pulse time slots. After successfully executing this operation, a 1-byte search command is sent to make all DS18B20s connected to the single bus ready to start the search operation. After the search command is issued, the actual search process begins.

First, all DS18B20s on the bus simultaneously send the first bit of the registration code (the least significant bit, see the above 64-bit registration code structure inside the DS18B20). According to the characteristics of the single bus, when all DS18B20s respond to the host at the same time, the result is equivalent to the logical "AND" of all the data bits sent. After the DS18B20 sends the first bit of its registration code, the host starts the next bit operation, and then the DS18B20 sends the complement of the first bit of data. Several judgments can be made on the first bit of the registration code from the data bits read twice, as listed in Table 1.

Then, the host sends back a specified bit to all devices on the bus. If the value of the current bit of the registration code in the DS18B20 matches the data bit, it continues to participate in the search process; if the current bit of the DS18B20 does not match it, the device switches to the waiting state and remains in the waiting state until the next reset signal arrives. The search for the remaining 63-bit registration codes is still repeated in this mode of reading 2 bits and writing 1 bit. According to this search algorithm, all DS18B20s except the only DS18B20 will enter the waiting state. After the last round of detection, the registration code of the last DS18B20 that has not entered the waiting state can be obtained. In the subsequent search process, different paths or branches are selected to find the registration codes of other devices, and the identification of the registration codes of all devices can be completed.

2.2 Software System Design

The system software is written in C language. In the interrupt service program, user input and the interface function with the host computer are realized; in the main program, the temperature sensor network is automatically searched, numbered and sorted, and temperature information is obtained, and the corresponding alarm function is realized according to the preset upper and lower limits of the temperature. In this system, according to different resolution requirements, the resolution of DSl8B20 can be set by programming. The highest resolution is 12 bits, that is, 0.062 5℃, which can meet the high-precision design requirements. At the same time, since the automatic search algorithm of the sensor network is used in the design, when the temperature sensor in the network is adjusted (such as replacement, addition, deletion, etc.), the system has a strong adaptive ability. The system software flow is shown in Figure 3

3 Conclusion

In traditional temperature measurement systems, analog temperature sensors are often used for design, which must be converted by A/D before they can be recognized and processed by the microprocessor. This design method not only puts higher requirements on the front-end analog signal processing circuit, but also does not have digital communication and network functions. In this paper, combining the new features of DS18B20 and the new requirements of modern temperature measurement systems, a high-precision, multi-point temperature measurement system design based on the intelligent digital temperature sensor DS18B20 is proposed. This solution has the characteristics of easy installation, high degree of digitization, high precision, strong adaptability, etc., and has broad application prospects in various temperature detection.

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号