Operation on DS18B20

Source: Internet
Author: User

DS18B20

1 feature

1. One bus interface, only one port for communication;

2. parallel use of multiple sensor branches simplifies Distributed temperature sensing applications;

3. You do not need to connect to other devices;

4. It can be driven from a data cable. The power supply range is 5.5 V to V. It can also be connected from a dedicated pin;

5. Zero backup power supply requirements;

6. The temperature measurement range is-55 degrees to 125 degrees, and the error between-10 and + 85 degrees is 0.5 degrees;

7. The programmable resolution ranges from 9 to 12 bits. The maximum conversion time for 12 bits is 750 ms;

8. User-Defined non-volatile alarm temperature

9. The alarm SEARCH Command automatically identifies and addresses the devices whose temperature exceeds the preset temperature;

10. It can be used for constant temperature control, industrial systems, consumer products, thermometers or any thermal systems;

2 Overview

The following figure shows the main components of DS18B20:

1.64-bit optical Rom

2. temperature sensor,

3. non-volatile temperature alarm trigger, including high temperature trigger and low temperature trigger;

4. A configuration register.

 

Internal Structure

1. DS18B20 single-bus

One bus system has only one bus master and one or more slaves; DS is such a slave; there are usually three points to discuss and use such a bus system:

1. hardware configuration;

2Operation Sequence;

3 bus signal (including signal type and timing)

1. hardware configuration:

The first-line bus only defines a single signal line. Based on this, each device on the bus can drive the bus at the right time. This capability is even more important. To facilitate this (to do this), each device linked to a single bus should have an open circuit or a three-state output; the DQ pin of DS18B20 is an open circuit, for example, the cost model of the internal port circuit; the multi-station bus is usually composed of one bus and multiple slave. A single bus requires a pull resistance of approximately 5 k euros:

2 Operation processing sequence;

The Protocol for accessing the DS18B20 via the 1-Wire port is as follows:

The Protocol for accessing DS18B20 through a single bus port is as follows:

Initialization [initialization]

Rom Function Command [rom FUNCTION command]

Memory Function Command [Memory Function Command]

Transaction/data [data transmission command]

1.1 Initialization

All processing operations on a single bus should begin with an initialization sequence; the initialization sequence consists of a reset pulse transmitted by the bus masterFollowedPresence pulse (s) transmitted by the slave (s). The initialization sequence is composed of a reset pulse sent by the master, and slaves then transmits an existing pulse;

The purpose of pulse exists is to let the bus master know that the DS18B20 is on the bus and has been initialized successfully to prepare for the operation. For more details, see section "1-wire signaling"

Sequence diagram:

 

Initialization program:

Bit init_ds18b20 (void)

{

Bit dat = 0;

DQ = 1; // The most initial one. Set DQ to 1.

Delayus2x (5); // slightly delayed

DQ = 0; // the single-chip microcomputer lowers the DQ and completes one-person reset pulse;

Delayus2x (200); // latency greater than us and less than US based on the time series DQ low level

Delayus2x (200 );

DQ = 1; // time to pull the bus

Delayus2x (50); // wait for 15 ~ 60 us, receives the existence pulse of the DS18B20 for 60-US (0)

Dat = DQ; // receiving operation; dat notifies the initialization result of the general program, dat = 0 successful, dat = 1 failed

Delayus2x (25); // returns a delayed response.

Return dat;

}

1.2 Rom Function Command [rom FUNCTION command]

Once the bus master detects an existing signal, it can issue one of the following five Rom commands. All Rom function commands are 8 bytes in length. The command is as follows:

 

Read Rom [33 H]:This command allows the bus master to read the 8-bit product series code of DS18B20, the unique 48-bit serial number, and the 8-bit CRC verification code. This command can be used only on a single line. If you use this command, multiple slave instances are on the bus. When these slave instances transmit data at the same time, a data conflict occurs. (The result will be a line and a result ).

Match Rom [55 H]:Match the ROM command and add a 64-bit Rom sequence to allow the bus master to address a specific DS18B20 on the bus with multiple branch lines. Only the DS18B20 that correctly matches the sent 64-bit serial number will respond to subsequent Memory Operation commands. Slaves that do not match the 64-bit Rom sequence will wait for a reset pulse. This command can be used for single-line and single-channel operations.

Skip Rom [CCH]:Skip the ROM operation. In the single-point bus system, this command allows the bus master to directly execute the Memory Operation Command without sending a 64-bit Rom sequence. If you use this command in a multi-point bus system, if you subsequently send a READ command, there will be data conflicts on the bus. (The result will be a line and result)

Search Rom [f0h]:During initial operation, the mastr bus may not know how many devices or 64-bit Rom codes of these devices exist on the single-line bus. the search Rom command allows the bus master to identify all devices on the bus by using an elimination process.

Alarm search [Ech]:The process of this command is the same as that of the RoM SEARCH Command. However, DS18B20 only responds to this command when an alarm occurs during the last temperature measurement. The alarm condition is higher than th or lower than TL. As long as the DS18B20 is powered on, the alarm conditions remain in the set state ountil another temperature measurement reveals a non-alarming value. The trigger value of the alarm is stored in E2PROM. If the alarm conditions exist and th or TL is changed, a temperature conversion starts to verify whether the temperature sensor has an alarm.

 

 

1.3 MEMORY command functions [Memory Operation Command] 1.3.1 write scratchpad [4eh]

This command is written to the high-speed cache area of DS18B20. The next step is to write three bytes of data from th register to tl register to the configuration register, which must be written before the next reset signal.

1.3.2 read scratchpad [beh]

This command reads the content in the cache. A total of nine bytes from 0th bytes to byte8. If not all directions need to be read, the bus master can write a reset signal at any time to stop reading.

1.3.3 copy scratchpad [48 h]

This command copies the scratchpad of DS18B20 to E2 memory and stores it in non-volatile temperature trigger bytes.

1.3.4 Convert [44h]

Operation on DS18B20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.