Design of hot and cold regulation of temperature control system based on DS18B20

Publisher:PeacefulWarriorLatest update time:2010-07-11 Source: 电子设计工程 Keywords:DS18B20 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the development of my country's economy and the in-depth advancement of scientific research, temperature monitoring and control systems are becoming more and more widely used in industrial design, smart instruments, daily household appliances and other fields. Electronic products based on single-chip microcomputer design have a broad application market and development prospects.

DS18B20 is a digital temperature sensor produced by Dallas Company, with ultra-small size, ultra-low hardware cost, strong anti-interference ability, high precision and strong additional functions. The temperature detection and digital data output of DS18B20 are integrated on one chip, with single bus data communication, binary output, resolution up to 12 bits, detection temperature range of -55~+125℃, and temperature limit alarm function. At the same time, DS18B20 has built-in EEPROM and 64-bit photolithography ROM, supports multi-point networking, and multiple DS18B20 can be connected in parallel on the only three buses as needed to realize multi-point temperature measurement in networking, which is convenient for the expansion and upgrade of temperature control system.

1 System Working Principle

In order to achieve the temperature regulation of the controlled object, the temperature control system designed uses AT89S51 single-chip microcomputer as the control core, including temperature sampling module, temperature display module, execution module, over-temperature indication module and keypad and other external circuits. The system clock frequency is 12MHz, and the intelligent integrated device DS18B20 is used to monitor the controlled object, convert the temperature value into a signed digital signal, and output it through a single bus, realizing the functions of temperature acquisition, conversion and transmission, which is conducive to simplifying the circuit. Considering the DC output driving capability of the single-chip microcomputer, triodes, 74LS244 and 74LS07 are used to drive the corresponding peripheral integrated circuits. The temperature data is dynamically displayed through 4 parallel common anode LEDs, and a keypad is built by itself to achieve the setting of the target temperature of the controlled object. The execution module uses solid-state relays SSR for photoelectric isolation to realize the control of 220V AC on and off by low-power DC, so that the relays that control the on and off of the heating tube and the start and stop of the fan are energized or de-energized, and high-power fans and heating tubes are used to achieve effective temperature regulation. The system uses LED lights of different colors to indicate the working status of the system. The red LED lights up to indicate an over-temperature or under-temperature alarm, and the green LED lights up to indicate that the system is working normally. The system composition is shown in Figure 1.

System composition

In the core control processing module AT89S51 microcontroller, in order to effectively suppress the random error of the temperature digital signal transmitted from DS18B20 and improve the measurement accuracy and anti-interference of the system, a digital filtering subroutine is added to the control program of the AT89S51 microcontroller. The digital filtering smoothing process eliminates the influence of the system random error as much as possible and improves the anti-interference ability of the system from the software aspect. MATLAB is used to fit the temperature measurement data to further correct the measured temperature value and make the measured value closer to the accurate value.

2 System Hardware Design

2.1 Power supply and temperature display module

To avoid crosstalk between signals, a 5V DC power supply is used to power the microcontroller, keyboard, solid-state relay control module, and 8-segment digital tube, and to provide a power-on reset voltage. At the same time, 220V AC power is provided for the fan and 400W heater.

The temperature display module uses four 8-segment digital tubes to display the temperature. In order to stabilize the display, a dynamic display method with bus delay is adopted. The drive circuit and bit selection are respectively composed of 74IS244 and 74LS07.

2.2 Keypad module

The keypad module is built by ourselves, which consists of four keys: reset key, confirmation key, plus 1 key and TAB key. The keyboard circuit is simple and clear, meeting the human-computer interaction requirements for setting the target temperature of the controlled object. The function description of each key is shown in Table 1.

Function description of each button

2.3 Temperature data collection

DS18B20 uses a single bus dedicated technology, connected to the microcontroller through the I/O port line, and can directly output the measured temperature value (12-bit binary number, including the sign bit) without going through other conversion circuits. Its pin functions are as follows: the VDD pin is connected to the working power supply, and when working in parasitic mode, this pin must be grounded; the DQ pin is used for data input/output; the GND pin is grounded.

In this system, the interface circuit between DS18B20 and the microcontroller is shown in Figure 2. VDD is connected to the external power supply through a 1kΩ pull-up resistor, GND is grounded, and DQ is connected to the microcontroller P0.0 port through a single bus.

Interface circuit between DSl8820 and single chip microcomputer

The relationship between the measured temperature and the output temperature of DS18B20 is shown in Table 2. The output temperature is a 12-bit binary number, which is stored in two 8-bit RAMs of DS18B20. The first 5 bits of the binary number are the sign bits.

The relationship between the measured temperature and the output temperature of DSl8820

2.4 Solid-state relay driver module

In this design, an AC solid-state relay SSR is selected, which is a contactless switch with a small input control current and a photoelectric isolator. By controlling the on and off of the DC power at the SSR input end, the on and off of the AC power at the output end can be controlled, and the starting performance is stable and the radiation interference to the power grid is small. The solid-state relay control circuit is shown in the system overall circuit diagram (Figure 2). At the load end, a series circuit consisting of 100Ω and 0.1μF is used to protect the fan and heating tube from overvoltage.

2.5 AT89S51 single-chip microcomputer control module

AT89S5l is the control core of the whole system, and it has built-in FlashROM for storing user programs. The temperature digital signal sensed by DS18B20 and the user's target temperature are used as input signals. After being processed by the control program, the corresponding control signal is issued to display the system working status, the temperature value of the controlled object, and control the power on and off of the SSR DC terminal, thereby controlling the power on and off of the fan and heating tube to achieve the temperature adjustment of the controlled object. Although the interface circuit between DS18B20 and the single-chip microcomputer and the solid-state relay control circuit are given in the overall circuit diagram (Figure 2), since DS18B20 and the execution equipment are set at the site of the controlled object, the corresponding signal transmission line must be reserved in practice.

3. System software design

The software part adopts program modular design to facilitate the debugging and implementation of various functions. The system software program mainly consists of three modules: main program, function implementation and operation control.

[page]

3.1 Main program module

The main program module uses a loop query until it exits to achieve the purpose of automatic hot and cold control of the temperature control system. The main program flow is shown in Figure 3.

Main program flow

3.2 Operation and control module

The operation control module includes three subroutines: digital filtering, PID algorithm, and temperature sensor control. Digital filtering is implemented by speed limit filtering, which can make full use of each sampling value to ensure the real-time sampling and the continuity of sampling value changes. The speed limit filtering subroutine flow is shown in Figure 4.

Speed ​​limit filter subroutine flow

The PID algorithm is implemented by the integral separation PID algorithm. The integral separation method is used to cancel the integral effect when the controlled quantity begins to be monitored, and the integral effect is generated when the temperature value approaches the target value, effectively reducing the oscillation caused by the frequent start and stop of the system. The integral separation PID algorithm is:

Integral separation PID algorithm

In the formula, Y(K) is the target setting value of temperature, C(K) is the temperature measurement value after digital filtering, and △Y is the set maximum allowable deviation value. According to this algorithm idea, the integral separation PID algorithm can be implemented by assembly language programming.

The DS18B20 control subroutine is compiled according to the DS18B20 communication protocol, including DDS18B20 initialization, DS18B20 read and write control subroutines, which are programmed and implemented according to the corresponding rules.

3.3 Function Implementation Module

The function realization module includes subroutines such as temperature value setting, temperature display, solid-state relay on-off control and system operation status display. In the temperature display subroutine, it is necessary to complete the calling of each position segment code, the selection of the digital tube and the stabilization of the data bus (generally achieved by delaying a few ms).

4 System Debugging

The system debugging mainly involves the setting of PID parameters and the correction of system errors of temperature values. The setting of PID parameters and other system parameters first adopts empirical values, and then fine-tunes them one by one to meet the control accuracy requirements. According to the experimental data in Table 3, MATLAB is used to perform one-dimensional curve fitting and correct the system errors, so as to obtain more accurate measurement data.

One-dimensional curve fitting

The MATLAB fitting process and results are shown in Figure 5. In Figure 5, "O" represents (test value, standard value), "*" represents (test value, fitting value), and the one-dimensional curve fitting equation is: y=0.9948x-0.3996. The sampling value after digital filtering can be processed by this equation to obtain a more accurate measurement value.

MATLAB fitting process and results

5 Conclusion

From the perspective of application, this paper gives the detailed hardware and software design of the temperature control system for hot and cold regulation, making full use of the accuracy and convenience of DS18B20 single bus temperature measurement, and using speed limit filtering, integral separation PID algorithm, MATLAB one-dimensional curve fitting and other methods to improve the reliability of the system and the accuracy of the measured value. However, the anti-interference of the signal transmission line and the de-jittering of the keyboard keys are not perfect enough, and the experimental data processing by MATLAB is not fully sampled, and the temperature drift when measuring too high or too low temperature is not considered. Therefore, the design of the system needs to be further deepened and improved.

Keywords:DS18B20 Reference address:Design of hot and cold regulation of temperature control system based on DS18B20

Previous article:ON Semiconductor's advanced motor control technology meets the demand for higher energy efficiency
Next article:Design of temperature alarm control system based on mobile phone text messages

Recommended ReadingLatest update time:2024-11-16 23:38

Application of DS18B20 in bridge concrete temperature measurement
Abstract: This article briefly introduces the new features of the single-wire digital temperature sensor DS18B20 of the American DALLAS company based on its predecessor product DS1820, as well as the more detailed interface circuit and read and write timing with the microcontroller, and its applica
[Test Measurement]
Digital Temperature Sensor DS18B20 Program
   ORG 0000H START: MOV SP,#60H ; power on initialization     MOV P0,#0FFH     MOV P1,#0FEH     MOV P2,#0FFH     MOV P3,#0FFH  MAIN: LCALL GET_TEMPER ; call the temperature reading subroutine     LCALL DISP ; call the digital tube display subroutine     AJMP MAIN ; Repeat loop ;----- Read the temperature v
[Microcontroller]
C language program using DS18B20 temperature sensor in single chip microcomputer (reference 7)
Hardware: 51 board      (1) Single-wire ds18b20 connected to P2.2      (2) Use external power to power ds18b20, no parasitic power Software:       Kei uVision 2 #include "reg52.h" #include "intrins.h" #define uchar unsigned char #define uint unsigned int sbit ds=P2^2; sbit dula=P2^6; sbit wela=P2^7; uchar
[Microcontroller]
Application of digital temperature sensor DS18B20 in satellite power supply system
  0 Preface    The satellite power supply system is mainly used to provide a stable power supply for the normal operation of the entire satellite. It is an important subsystem for satellite power generation, storage, conversion, regulation, transmission, distribution and management. Its basic function is to conver
[Microcontroller]
Application of digital temperature sensor DS18B20 in satellite power supply system
51 MCU ~ DS18B20 temperature sensor
1. Introduction: (ii) Wiring: 1. Internal structure: The first five digits of positive temperature are 0. The first five digits of negative temperature are 1. A four-digit hexadecimal number consisting of LS and MS, and a 16-digit binary number. (MS first, then LS) Combine the above and below graphs to get
[Microcontroller]
51 MCU ~ DS18B20 temperature sensor
Design of networked intelligent temperature sensor based on ARM and DS18B20
1 Introduction to Networked Intelligent Sensors Networked intelligent sensors enable sensors to develop from single function and single detection to multi-function and multi-point detection; from passive detection to active information processing; from on-site measurement to long-distance real-time online measurement
[Microcontroller]
Design of networked intelligent temperature sensor based on ARM and DS18B20
DS18B20+PIC temperature measurement using 1602 to display temperature C program
//Be familiar with using the MCU to test the temperature using the DS18B20 temperature sensor and display the temperature using the 1602 display //1. The first line displays: Temperature //2. The second line displays: the measured temperature value //************************************************** //***********
[Microcontroller]
STM8L controls the temperature sensor DS18B20
#define DS18B20_GPIO_PORT (GPIOC) #define DS18B20_GPIO_PIN (GPIO_Pin_2) #define DS18B20_PIN_SET_OUT() GPIO_Init(DS18B20_GPIO_PORT, (GPIO_Pin_TypeDef)DS18B20_GPIO_PIN, GPIO_Mode_Out_PP_High_Fast) #define DS18B20_PIN_SET_IN() GPIO_Init(DS18B20_GPIO_PORT, (GPIO_Pin_TypeDef)DS18B20_GPIO_PIN, GPIO_Mode_In_PU_No_IT) #def
[Microcontroller]
Latest Industrial Control 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号