当前位置:网站首页>DS18B20 details

DS18B20 details

2022-06-26 06:25:00 Bitongo


One 、 brief introduction

DS18B20 It is a commonly used digital temperature sensor , Its output is a digital signal , Small size , Low hardware overhead , Strong anti-interference ability , Features of high precision . [1] DS18B20 The digital temperature sensor is easy to connect , The package can be used in many occasions , Such as pipe type , Screw type , Magnet adsorption type , Stainless steel package , There are many models , Yes LTM8877,LTM8874 wait .

It changes its appearance mainly depending on the application . After the encapsulation DS18B20 It can be used for temperature measurement of cable trench , Temperature measurement of blast furnace water circulation , Boiler temperature measurement , Temperature measurement in the computer room , Temperature measurement greenhouse , Clean room temperature measurement , Ammunition depot temperature measurement and other non limit temperature occasions . It's wear-resistant and impact resistant , Small volume , Easy to use , There are many forms of encapsulation , It is suitable for digital temperature measurement and control of various narrow space equipment .
 Insert picture description here

Two 、 working principle

DS18B20 Reading and writing sequence and temperature measurement principle of DS1820 identical , Only the number of digits of the obtained temperature value varies with the resolution , And the delay time during temperature conversion is determined by 2s Reduced to 750ms. DS18B20 The principle of temperature measurement is shown in the figure 3 Shown . Fig. the oscillation frequency of crystal oscillator with low and medium temperature coefficient is little affected by temperature , A pulse signal for generating a fixed frequency is sent to the counter 1. The oscillation frequency of high temperature coefficient crystal oscillator changes obviously with temperature , The generated signal acts as a counter 2 Pulse input . Counter 1 And the temperature register are preset in -55℃ Corresponding to a base value . Counter 1 The pulse signal generated by the crystal oscillator with low temperature coefficient is counted by subtraction , When counter 1 The preset value of is reduced to 0 when , The value of the temperature register will be increased by 1, Counter 1 Will be reloaded , Counter 1 Start counting the pulse signal generated by the crystal oscillator with low temperature coefficient again , This cycle continues until the counter 2 Count to 0 when , Stop the accumulation of temperature register values , At this time, the value in the temperature register is the measured temperature . The slope accumulator is used to compensate and correct the nonlinearity in the process of temperature measurement , Its output is used to correct the counter 1 The preset value of .
 Insert picture description here

Two 、 Technical performance

Technical performance description :
①、 Unique single line interface mode ,DS18B20 When connecting with the microprocessor, only one port line is required to realize the connection between the microprocessor and the microprocessor DS18B20 Two way communication between .
② 、 Temperature measurement range -55℃~+125℃, Inherent temperature measurement error ( Be careful , It's not resolution , This was wrong before )1℃.
③、 Support multi-point networking function , Multiple DS18B20 It can be connected in parallel on the only three lines , It can only be connected in parallel at most 8 individual , Realize multi-point temperature measurement , If there are too many , The power supply voltage will be too low , Thus, the signal transmission is unstable .
④、 Working power supply : 3.0~5.5V/DC ( The parasitic power supply of the data line can be )
⑤ 、 No peripheral components are required in use
⑥、 The measurement results are as follows 9~12 Digital word quantity mode serial transmission
⑦ 、 Diameter of stainless steel protective tube Φ6
⑧ 、 Apply to DN15~25, DN40~DN250 Temperature measurement of industrial pipelines and narrow space equipment with various media
⑨、 Standard mounting thread M10X1, M12X1.5, G1/2” Optional
⑩ 、PVC Direct cable outlet or German ball junction box outlet , Easy to connect with other electrical equipment .
 Insert picture description here

3、 ... and 、 Range of application

This product is suitable for freezers , granary , Storage tank , Telecommunications room , Power room , Temperature measurement and control fields such as cable trunking .
bearing bush , Cylinder block , Spinning machine , Air conditioner , Temperature measurement and control of industrial equipment in narrow space .
Car air conditioning 、 The refrigerator 、 freezer 、 And medium and low temperature drying oven, etc .
Heat supply / Cooling pipe heat metering , Household heat energy measurement of central air conditioning and temperature measurement and control in industrial field .

Four 、 Model and specification

type Number Temperature measurement range Install the thread Cable length Applicable pipeline
TS-18B20 -55~125 nothing 1.5 m
TS-18B20A -55~125 M10X1 1.5m DN15~25
TS-18B20B -55~125 1/2”G Junction box DN40~ 60

5、 ... and 、 Wiring instructions

wiring method

Facing the flat side , Left minus right positive , Once the connection is reversed, it will immediately get hot , It may burn down ! meanwhile , The reverse connection also causes the sensor to always display 85℃ Why . In actual operation, the positive and negative are inversely connected , The sensor heats up immediately , The LCD screen cannot display the reading , After the positive and negative are connected, it shows 85℃. in addition , If you use 51 In the case of MCU , Then the middle pin must be connected 4.7K—10K The pull-up resistance of , otherwise , Because the high level cannot be input normally / Output , Or display immediately after power on 85℃, Or use the temperature in a few months 85℃ Jump around the normal value .

characteristic

Unique one-line interface , Only one port line is required for communication Multi point capability , Simplifies distributed temperature sensing applications No external elements are required The data bus can be used for power supply , The voltage range is 3.0 V to 5.5 V No backup power supply is required The measuring temperature range is -55 ° C to +125 ℃ . Fahrenheit is equivalent to -67 ° F To 257° F. At centigrade -10 ° C to +85 ° C The accuracy within the range is ±0.5 ° C

The programmable resolution of the temperature sensor is 9~12 position , The temperature is converted to 12 The maximum value of the bit number format is 750 millisecond , User definable non-volatile temperature alarm settings , Applications include thermostatic control 、 Industrial system 、 Consumer electronics thermometer 、 Or any heat sensitive system
Describe the DS18B20 The digital thermometer provides 9 to 12 position ( Programmable device temperature reading ). because DS18B20 It is an interface line communication , So the central microprocessor and DS18B20 Only one port line is connected . Energy can be obtained from the data line itself for reading, writing and temperature conversion , No external power supply is required . Because every one of them DS18B20 Of contains a unique serial number , Multiple ds18b20s Can exist on one bus at the same time . This allows the temperature sensor to be placed in many different places . It has many uses , Including air conditioning environment control , A device or machine that senses the temperature inside a building , And process monitoring and control .

DS18B20 Using a one-line communication interface . Because the first-line communication interface , Must be completed first ROM Set up , Otherwise, the memory and control functions will not be available . It mainly provides one of the following function commands first : 1 ) read ROM, 2 )ROM matching , 3 ) Search for ROM, 4 ) skip ROM, 5 ) Alarm check . These instructions operate on... Without a single device 64 Bit lithography ROM Serial number , You can select a device from multiple devices on the same line , meanwhile , The bus can also know how many are attached to the bus , What kind of equipment .

If the instruction succeeds in DS18B20 Complete the temperature measurement , The data is stored in DS18B20 The memory of . A control function command instruction DS18B20 The performance of temperature measurement . The measurement results will be placed in DS18B20 In the memory , And it can make reading send out the command of memory function , On chip memory for reading content . Temperature alarm trigger TH and TL There is a byte EEPROM The data of . If DS18B20 Do not use the alarm check command , These registers can be used for general user memory purposes . The chip also contains configuration bytes to ideally solve the temperature digital conversion . Write TH,TL Instructions and configuration bytes are completed by using a memory function instruction . Read register through buffer . Read of all data , Write from the lowest position .

6、 ... and 、 Component description

Memory
DS18B20 The memory of includes high-speed registers RAM And electrically erasable RAM, Electrically erasable RAM Including temperature trigger TH and TL, And a configuration register . The memory can completely determine the communication of one-line port , Numbers begin to be written into registers using the write register command , Then you can use the command to read the register to confirm these numbers . After confirmation, you can use the copy register command to transfer these numbers to electrically erasable RAM in . When the number in the register is modified , This process ensures the integrity of the numbers .
High speed register RAM By 8 A memory of bytes ;. The ninth byte can be read with the command of reading register , This byte is used to verify the first eight bytes .

64- Bit lithography ROM
64 Bit lithography ROM Before 8 Is it DS18B20 Its own code , Next 48 Bits are consecutive numeric codes , final 8 Bit is right before 56 Bit CRC check .64- Bit lithography ROM It also includes 5 individual ROM Function commands for : read ROM, matching ROM, jumping ROM, lookup ROM And alarm lookup .

Connection of external power supply
DS18B20 External power supply can be used VDD, Internal parasitic power supply can also be used . When VDD Port connection 3.0V—5.5V When using external power supply ; When VDD The internal parasitic power supply is used when the port is grounded . Whether it is internal parasitic power supply or external power supply ,I/O The port line should be connected 5KΩ Left and right pull-up resistors .

Configuration register
The configuration register is configured with different bits to determine the temperature and digital conversion .
You can know R1,R0 Is the determinant of temperature , from R1,R0 Different combinations of can be configured as 9 position ,10 position ,11 position ,12 Bit temperature display . In this way, we can know the conversion time corresponding to different temperature conversion positions , The resolutions of the four configurations are 0.5℃,0.25℃,0.125℃ and 0.0625℃, Factory configured as 12 position .

Temperature reading
DS18B20 It is configured as 12 position , When reading the temperature, a total of 16 position , front 5 A bit is a sign bit , At present 5 Position as 1 when , The temperature read is negative ; At present 5 Position as 0 when , The temperature read is positive . When the temperature is positive, the reading method is : take 16 Convert the base number to 10 It can be done in decimal . When the temperature is negative, the reading method is : take 16 Base negate and add 1, To convert 10 It can be done in decimal . example :0550H = +85 degree ,FC90H = -55 degree .

7、 ... and 、 Control method

DS18B20 There are six control commands

Temperature conversion 44H start-up DS18B20 Perform temperature conversion
Read Scratchpad BEH Read Scratchpad 9 Byte binary digit
Write register 4EH Write data to the register TH、TL byte
Copy register 48H Put the... Of the register TH、TL Bytes are written to E2PROM in
Readjust E2PROM B8H hold E2PROM Medium TH、TL Bytes are written to the register TH、TL byte
Power supply mode of reading power supply B4H start-up DS18B20 Send the signal of power supply mode to the master CPU

initialization
(1) Set the data line to high level first “1”.
(2) Time delay ( The time requirement is not very strict , But as short as possible )
(3) Pull the cable to low level “0”.
(4) Time delay 750 Microsecond ( The time range of the time can be from 480 To 960 Microsecond ).
(5) Pull the data line to high level “1”.
(6) Delay waiting for ( If the initialization is successful, the 15 To 60 In microseconds, a single event is generated by DS18B20 The low level returned “0”. According to this state, we can determine its existence , But it should be noted that you can't wait indefinitely , Otherwise, it will cause the program to enter an endless loop , So it's time-out control ).
(7) if CPU Read the low level on the data line “0” after , And we have to delay , The delay time is calculated from the high level sent out ( The first (5) It's time to start ) At least 480 Microsecond .
(8) Pull the data line high again “1” After that .
Write operations
(1) Data line set low level first “0”.
(2) The time determined by the delay is 15 Microsecond .
(3) Send bytes in low to high order ( Send only one at a time ).
(4) The delay time is 45 Microsecond .
(5) Pull the data cable to high level .
(6) Repeat (1) To (6) Until all the bytes are sent .
(7) Finally, pull up the data line .

Read operations
(1) Pull the data line up “1”.
(2) Time delay 2 Microsecond .
(3) Pull the cable down “0”.
(4) Time delay 3 Microsecond .
(5) Pull the data line up “1”.
(6) Time delay 5 Microsecond .
(7) Read the status of the data line to get 1 Status bits , And data processing .
(8) Time delay 60 Microsecond .

8、 ... and 、 Main features

1、DS18B20 The main characteristics of
1.1、 Wider voltage range , Voltage range :3.0~5.5V, In the parasitic power supply mode, the number of Power supply according to the line
1.2、 Unique single line interface mode ,DS18B20 When connecting with the microprocessor, only one port line is required to realize the connection between the microprocessor and the microprocessor DS18B20 Two way communication between
1.3、 DS18B20 Support multi-point networking function , Multiple DS18B20 It can be connected in parallel on the only three lines , Realize networking and multipoint temperature measurement
1.4、DS18B20 No peripheral components are required in use , All The sensing element and the conversion circuit are integrated in an integrated circuit shaped like a triode
1.5、 Temperature range -55℃~+125℃, stay -10~+85℃ The accuracy is ±0.5℃
1.6、 A programmable The resolution is 9~12 position , The corresponding resolvable temperatures are 0.5℃、0.25℃、0.125℃ and 0.0625℃, High precision temperature measurement can be realized
1.7、 stay 9 Bit resolution is at most 93.75ms Convert the temperature into numbers ,12 Bit resolution is at most 750ms Convert the temperature value into a number , Faster
1.8、 The measurement result directly outputs the digital temperature signal , With " One Line bus " Serial transmission to CPU, At the same time, it can transmit CRC Check code , It has strong anti-interference and error correction ability
1.9、 Negative pressure characteristics : When the polarity of the power supply is reversed , The chip will not burn due to heat , But it doesn't work .

2、DS18B20 The shape and internal structure of
DS18B20 The internal structure is mainly composed of four parts :64 Bit lithography ROM 、 Temperature sensor 、 Non volatile temperature alarm trigger TH and TL、 Configuration register .
DS18B20 The shape and pin arrangement of the are as follows :
 Insert picture description here

DS18B20 Pin definition :
(1)DQ For digital signal input / Output terminal ;
(2)GND For the power supply ;
(3)VDD For external power input ( Grounding in parasitic power connection mode ).

3、DS18B20 working principle
DS18B20 Reading and writing sequence and temperature measurement principle of DS1820 identical , Only the number of digits of the obtained temperature value varies with the resolution , And the delay time during temperature conversion is determined by 2s Reduced to 750ms. The oscillation rate of high temperature coefficient crystal oscillator changes obviously with the change of temperature , The generated signal acts as a counter 2 Pulse input . Counter 1 And the temperature register are preset in - 55C Corresponding to a base value . Counter 1 The pulse signal generated by the crystal oscillator with low temperature coefficient is counted by subtraction , When counter 1 The preset value of is reduced to 0 when , The value of the temperature register will be increased by 1, Counter 1 Will be reloaded , Counter 1 Start counting the pulse signal generated by the crystal oscillator with low temperature coefficient again , This cycle continues until the counter 2 Count to O when , Stop the accumulation of temperature register values , At this time, the value in the temperature register is the measured temperature . chart 3 The slope accumulator in is used to compensate and correct the nonlinearity in the process of temperature measurement , Its output is used to correct the counter 1 The preset value of .

DS18B20 Yes 4 Three main data components :
(1) Photolith ROM Medium 64 The bit serial number is lithographed before leaving the factory , It can be seen as the DS18B20 Address sequence code .64 Bit lithography ROM The arrangement is : Start 8 position (28H) Is the product type label , And then 48 Bit is the DS18B20 Its own serial number , Last 8 Bit is the front 56 Bit cyclic redundancy check code (CRC=X8+X5+X4+1). Photolith ROM The function of is to make every DS18B20 They're all different , In this way, multiple can be connected to one bus DS18B20 Purpose .
(2)DS18B20 The temperature sensor in the can measure the temperature , With 12 The bit is converted to an example : use 16 Bit sign extended binary complement reading form is provided , With 0.0625C/LSB In the form of expression , among S Symbol bit .

This is a 12 After bit conversion 12 Bit data , Stored in 18B20 Of the two 8 Bit RAM in , Front in binary 5 Bits are sign bits , If the measured temperature is greater than 0, this 5 Position as 0, Just multiply the measured value by 0.0625 You can get the actual temperature ; If the temperature is less than 0, this 5 Position as 1, The measured value needs to be added inversely 1 Multiply again 0.0625 You can get the actual temperature . Such as +125℃ The digital output of is 07DOH,+25.0625℃ The digital output of is 0191H,-25.0625°C The digital output of is FE6FH,-55°C The digital output of is FC90H.

(3)DS18B20 Memory of temperature sensor DS18B20 The internal memory of the temperature sensor includes a high-speed temporary storage RAM And a nonvolatile electrically erasable EEPRAM, The latter stores high temperature and low temperature triggers TH、TL And structure register .
(4) The meaning of this byte bit of the configuration register is as follows :
The lower five have always been "1",TM Is the test mode bit , Used for setting up DS18B20 In working mode or in test mode . stay DS18B20 This bit is set to at the factory 0, use Don't change it .R1 and R0 Used to set the resolution , As shown in the following table :(DS18B20 It is set to... At the factory 12 position )
 Insert picture description here

4、 Cache cache cache from 9 Byte composition , Its distribution is shown in the table 5 Shown . When the temperature conversion command is issued , The converted temperature value is stored in the form of two byte complement The... Of the cache 0 And the 1 Bytes . Single chip microcomputer can read the data through single line interface , When reading, the low order is in the front , High position behind , The data format is shown in table 1 Shown . Corresponding temperature calculation : The equivalent sign S=0 when , Directly convert binary bits to decimal ; When S=1 when , First change the complement to the original code , Then calculate the decimal value . surface 2 Is the corresponding part of the temperature value . The ninth byte is Redundancy check byte .

according to DS18B20 Communication protocol of , host ( Single chip microcomputer ) control DS18B20 There are three steps to complete the temperature conversion : Every time you read and write, you should correct DS18B20 Conduct Reset operation , Send a message after the reset succeeds ROM Instructions , Last send RAM Instructions , That's how it works DS18B20 Perform scheduled operations . Reset requires master CPU Pull down the data line 500 Microsecond , then Release , When DS18B20 Wait after receiving the signal 16~60 About microseconds , Post issue 60~240 Microsecond presence of low pulses , Lord CPU Receiving this signal indicates that the reset is successful .

 Insert picture description here
5、DS18B20 Application circuit of DS18B20 The temperature measuring system is simple 、 High temperature measurement accuracy 、 Easy to connect 、 It has the advantages of less occupation of port lines . The following is DS18B20 Under several different application modes Temperature measurement circuit diagram :

5.1、DS18B20 The circuit diagram of parasitic power supply mode is shown in the figure 4 Shown , Under parasitic power supply mode ,DS18B20 Draw energy from a single line signal line : On the signal line DQ Store energy internally during high level Capacitance inside , When the signal line is at the low level, it consumes the electric energy on the capacitor to work , The parasitic power supply will not be supplied until the high level arrives ( capacitance ) Charge .
The unique parasitic power supply mode has three advantages :
1) For remote temperature measurement , No local power supply is required
2) It can be read without conventional power supply ROM
3) The circuit is more concise , Use only one I/O Temperature measurement is realized at the port

To make DS18B20 Carry out accurate temperature conversion ,I/O The line must ensure that sufficient energy is provided during temperature conversion , from In each DS18B20 The operating current reaches... During the temperature conversion 1mA, When several temperature sensors are hung on the same I/O When conducting multi-point temperature measurement on the line , Only by 4.7K The pull-up resistor cannot provide enough energy , It will cause failure to convert temperature or great temperature error .
therefore , chart 4 The circuit is only suitable for the use of a single temperature sensor , It is not suitable to use battery power supply system . and And the working power supply VCC Must be guaranteed 5V, When the supply voltage drops , The parasitic power supply can absorb less energy , It will make the temperature error larger .

5.2、DS18B20 Circuit diagram of parasitic power supply strong pull-up power supply mode the improved parasitic power supply mode is shown in the figure 5 Shown , In order to make DS18B20 Obtain sufficient current supply during the dynamic switching cycle , When performing temperature conversion or copying to E2 Memory operation , use MOSFET hold I/O The line is pulled directly to VCC It can provide enough current , Before sending anything that involves copying to E2 After memory or instruction to start temperature conversion , Must be at the most many 10μS Inner handle I/O The line switches to the strong pull-up state . In the strong pull-up mode, the problem that the current supply does not go can be solved , Therefore, it is also suitable for multi-point temperature measurement applications , Lack of Point is to occupy one more I/O Perform strong pull-up switching on the port line .
 Insert picture description here

Be careful : In the figure 4 Sum graph 5 Parasitic power supply mode ,DS18B20 Of VDD The pin must be grounded

5.3、DS18B20 External power supply mode

Under the external power supply mode ,DS18B20 The working power supply is provided by VDD Pin access , here I/O The wire does not need to be pulled up , There is no problem of insufficient power supply current , Can guarantee Conversion accuracy , At the same time, any number of can be connected to the bus theoretically DS18B20 sensor , Form a multi-point temperature measurement system . Be careful : Under the mode of external power supply ,DS18B20 Of GND The pin cannot be suspended , Otherwise, the temperature cannot be changed , The temperature read is always 85℃.

The external power supply mode is DS18B20 The best way to work , The work is stable and reliable , Strong anti-interference ability , And the circuit is relatively simple , It can develop stable and reliable multi-point temperature The monitoring system . The stationmaster recommends that you use the external power supply mode in the development , After all, there is only one more connection than the parasitic power supply mode VCC Lead wire . In the mode of external power supply , Can give full play to DS18B20 Advantages of wide power supply voltage range , Even if the supply voltage VCC drop to 3V when , The accuracy of temperature measurement can still be guaranteed .

6、DS1820 Precautions in use
DS1820 Although having a temperature measurement system is simple 、 High temperature measurement accuracy 、 Easy to connect 、 It has the advantages of less occupation of port lines , However, the following problems should be paid attention to in practical application :

6.1、 Small hardware overhead requires relatively complex software to compensate , because DS1820 Serial data transmission is adopted with microprocessor , therefore , In the face of DS1820 During read / write programming , The timing of reading and writing must be strictly guaranteed , Otherwise, the temperature measurement results cannot be read . In the use of PL/M、C And other high-level languages for system programming , Yes DS1820 The operation part is best realized by assembly language .
6.2、 stay DS1820 There is no mention in the relevant documents of the DS1820 The question of quantity , It is easy to make people mistakenly think that any number of can be hung DS1820, This is not the case in practical applications . When a single bus is attached DS1820 exceed 8 Time , It is necessary to solve the problem of microprocessor bus driver , This can be seen in the design of multi-point temperature measurement system Pay attention .
6.3、 Connect DS1820 The bus cable is limited in length . In trial , When the transmission length of ordinary signal cable exceeds 50m when , Read the The temperature measurement data will be wrong . When the bus cable is changed to twisted pair cable with shielding , The normal communication distance can reach 150m, When shielded twisted pair cables with more stranding times per meter are used , just The normal communication distance is further extended . This situation is mainly caused by the distortion of the signal waveform caused by the bus distributed capacitance . therefore , In use DS1820 The design of long-distance temperature measurement system should be fully considered Consider bus distributed capacitance and impedance matching .
6.4、 stay DS1820 Temperature measurement program design , towards DS1820 After the temperature conversion command is issued , The program always waits DS1820 The return signal , once Some DS1820 Poor contact or broken wire , When the program reads this DS1820 when , There will be no return signal , The program goes into an endless loop . This is going on DS1820 Hardware connection and software design shall also be provided A certain amount of attention . It is recommended to use shielding for temperature measuring cables 4 Core twisted pair , One pair of wires is the grounding wire and the signal wire , The other group is connected to VCC And ground , The shielding layer is grounded at a single point at the source end .
 Insert picture description here

Nine 、 Application, for example,

Temperature alarm ( Please move to the next section for specific implementation )

原网站

版权声明
本文为[Bitongo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260603394067.html