"God carved learn programming" DIY Arduino (39) - DS18B20 temperature sensor

Paragraph 37 and reference sensor module, widely circulated on the Internet, in fact, compatible with Arduino sensor module must be more than 37 species. Since I am on hand accumulated a number of sensors and modules, in accordance with the practice makes perfect (be sure to DIY) concept, learning and communication for the purpose of preparing here one by one to try to do hands-on experiments, whether successful or not, will be recorded --- little progress or can not handle the problem, hoping to initiate. 

[] Arduino series of experiments, the sensor module 108 kinds (information + + graphics + Simulation Code)

Experiment thirty-nine: DS18B20 wire digital temperature sensor module

 

DS18B20

It is the world's first chip to support "bus line" interface, temperature sensor, a unique bus line and economical features, allowing users to easily set up a sensor network, the build system for the introduction of a new system to measure the concept.

 

DS18B20 internal structure mainly composed of 64-bit ROM, a temperature sensitive element, and an internal memory configuration register part 4, as shown in FIG.
(1) 64-bit ROM. Its content is 64-bit serial number, which may be regarded as the address of the DS18B20 sequence code, its role is to have each DS18B20 are different, so that you can achieve the purpose articulated on a plurality of DS18B20 bus.
(2) the temperature sensitive element. It completion of the measurement of temperature, the temperature result is stored in two registers 8 b in the measurement.
(3) an internal memory. Internal memory includes a scratchpad RAM and a non-volatile electrically erasable E2 PROM, which high temperature and low temperature storage triggers TH, TL, and configuration registers.
 
 
 

Temperature measurement principle

Determining a gate period with a high temperature coefficient of the oscillator, the oscillator internal counter a low temperature coefficient of pulses is counted during this period to obtain a temperature value gate. The counter is preset to a value corresponding to -55 degrees Celsius. If the added value of the counter reaches zero, the temperature register before the end of cycle gate (also initialized to -55 ° C), indicating that the measured temperature is greater than -55 degrees Celsius.

1. Refers to a temperature coefficient of the oscillator is an oscillator, there is a specific relationship between the oscillation frequency and its temperature, i.e. different temperatures corresponding to different oscillation frequencies. Conversely, to measure the output frequency of the oscillator, the temperature can be measured.

2. High temperature coefficient of the oscillator: its oscillation frequency is greatly affected by temperature, a slight change in temperature, the frequency will change a lot, i.e. sensitive to temperature used for the temperature sensor.

3. Low temperature coefficient of the oscillator: its oscillation frequency is affected by temperature is small, even if the temperature changes greatly, its frequency is also substantially constant. 

  At the same time, the counter is reset to a value that is determined by the ramp accumulator circuit, ramp accumulator circuit parabolic characteristic compensator for temperature-sensing oscillator. Then start counting until the counter 0, the cycle if the door has not ended, the process is repeated. The nonlinear compensating accumulator to ramp the temperature sensitive oscillator, in order to obtain a relatively high temperature at the time of resolution. This is achieved by changing the value of the counter once for each of the required increase in temperature counted. Thus, in order to obtain the desired resolution, you must know the value of the counter and the count value of the temperature of each of a given.

Key Features

(1) a unique single-wire interface mode, one need only connect to the outlet line of the microcontroller;

(2) temperature range of - 55 ~ + 125 ℃, in - an accuracy of ± 0 5 ℃ in the range of 10 ~ + 85 ℃;.

(3) can be achieved by 9 to 12 programmed digital readout mode;

(4) the user can set the alarm from the upper and lower limits of the nonvolatile;

(5) a peripheral circuit is simple, does not require the use of external components, data bus available supply voltage range of 3. 0 ~ 5. 5 V without backup power supply;

(6) no external components, a unique line interface, power and signals are mixed together;

(7) a unique coding each chip, support network address, waiting for a zero power;

(8) DS18B20 has TO 92, SOIC packages and CSP, where VDD is the external power supply input terminal, GND to the common ground, DQ is a digital signal output terminal;

(9) applies to the freezer, silos, storage tanks, GPS satellite positioning systems, telecommunications room, power room, cable ducts and the like temperature control.

Component Description

--- the DS18B20 memory comprising a memory cache memory RAM and electrically erasable RAM, electrically erasable RAM in turn triggers include temperature TH and TL, and a configuration register. Memory can determine the complete communication, digital line port begins with the command write register written into the register, then you can also use the register read command to confirm these figures. When the acknowledgment can use the command to copy the register to be transferred to these figures electrically erasable RAM. When the number of registers in the modified, the process to ensure the integrity of numbers. The cache memory of RAM is composed of 8 bytes of memory; read with the ninth byte register read command, the byte is eight bytes in front of the check.

A ROM 64-bit front lithographic DS18B20 --- 8 is its own code, the next 48 consecutive digital code, the last 8 bits are a CRC check on the first 56 bits. 64-bit lithography ROM also includes a ROM function command 5: Read ROM, matching ROM, jumping ROM, ROM and find the police to find. 

--- the DS18B20 external power source can be connected an external power supply VDD, may be used inside the parasitic power. When the port connected to a voltage VDD is 3.0V-5.5V external power supply; using internal parasitic power supply VDD when the port is grounded. Whether internal or external parasitic power supply, I / O port lines to be connected to the pull-up resistor of about 5KΩ.

--- different configuration register configured to determine the number of bits of the digital conversion and temperature. Can know R1, R0 bit temperature is determined by the different combinations of R1, R0 may be configured to 9, 10, 11, 12 the temperature display. This conversion can know the time at different temperatures corresponding bit conversion, the resolution of four configurations were 0.5 ℃, 0.25 ℃, 0.125 ℃ and 0.0625 deg.] C, in the factory configured as 12 bits.

Reading the temperature of the DS18B20 --- configured at the factory to 12, a total of 16-bit read when reading the temperature, the first 5 bits as a sign bit, the current 5 is 1, the temperature reading is negative; Current 5 is 0, the temperature reading is positive. Temperature reading timing method: to convert into a hexadecimal number to a decimal. Temperature reading is negative method: adding 1 to the inverted hex, decimal can be converted to 10. Example: 0550H = +85 degrees, FC90H = -55 degrees.

 

Use Points

DS18B20 uses bi-directional single-wire bus protocol transmission mode, i.e., for data in a data line, and the bus protocol does not support single-chip computer hardware, software methods must be used to simulate a single bus protocol sequence to complete the chip DS18B20 access. Since the read and write data in a DS18B20 I / O lines, it is to read and write data bits strict timing requirements, it has strict protocols to ensure the correctness and completeness of the bit data transfer. The agreement defines several signal timing: initialization sequence, read timing, write timing. All timings are the MCU as the master device, DS18B20 as a slave device, and each command and transmit data write timing is active starting from the beginning of the host, if required DS18B20 loopback data, during the write command, the host needs to start reading timing completion of data reception.

Several application circuit

 

DS18B20 wire digital temperature sensor module

A, dimensions: Height length 28mm X 12mm X 10mm width

Second, the main chip: 18B20 temperature sensor

Third, the working voltage: DC 5V

Module Features

1, resolution adjustment range: 9-12 bits

2, with mounting holes to facilitate installation, pore size: 2.5

3, temperature range: -55 ~ + 125 ℃

4, the temperature measurement accuracy: 0.5 ℃

5, the working voltage: DC5V

6, the digital signal output

 

Terminal pin
Arduino Uno <------> 18B20 temperature sensor module  
Pin. 3 <------> OUT (S)      
5V <------> the VCC   
the GND <------> GND  

Search, download libraries -DallasTemperature

And later installed a library -OneWire

/ * 

[] Arduino series of experiments, the sensor module 108 kinds (information + + graphics + Simulation Code) 

experiments thirty-nine: DS18B20 wire digital temperature sensor module 

* / 

 

#include <OneWire.h> 

#include <DallasTemperature.h> 

 

#define . 3 ONE_WIRE_BUS 

OneWire OneWire (ONE_WIRE_BUS); 

DallasTemperature Sensors (& OneWire); 

 

void Setup (void) 

{ 

  Serial.begin (9600); 

  Serial.println ( "the IC Dallas Temperature Control Library Demo"); 

 

  sensors.begin (); 

} 

 

void Loop (void) 

{ 

  Serial.print ( "Requesting ... Temperatures"); 

  sensors.requestTemperatures (); 

  Serial.println ( "the DONE"); 

 

  Serial.print ( "Temperature Device for IS. 1:"); 

  Serial.print ( sensors.getTempCByIndex (0));  

  

  delay(500);

}

  

Touch DS18B20, temperature rise

 

 

Guess you like

Origin www.cnblogs.com/eagler8/p/11618248.html