DS18B20中英文资料外文翻译文献

更新时间:2024-04-25 18:39:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

外文翻译(原文)

中英文资料

The introduction to The DS18B20

1. DESCRIPTION

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line for communication with a central microprocessor. It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C. In addition, the DS18B20 can derive power directly from the data line (―parasite power‖), eliminating the need for an external power supply.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems.

2.FEATURES

? Unique 1-Wire? Interface Requires Only One Port Pin for Communication ? Each Device has a Unique 64-Bit Serial Code Stored in an On-Board ROM ? Multi-drop Capability Simplifies Distributed Temperature-Sensing Applications ? Requires No External Components

1

外文翻译(原文)

? Can Be Powered from Data Line; Power Supply Range is 3.0V to 5.5V ? Measures Temperatures from -55°C to +125°C (-67°F to +257°F) ? ±0.5°C Accuracy from -10°C to +85°C

? Thermometer Resolution is User Selectable from 9 to 12 Bits ? Converts Temperature to 12-Bit Digital Word in 750ms (Max) ? User-Definable Nonvolatile (NV) Alarm Settings

? Alarm Search Command Identifies and Addresses Devices Whose Temperature is

Outside Programmed Limits

? Software Compatible with the DS1822

? Applications Include Thermostatic Controls, Industrial Systems, Consumer

Products, Thermometers, or Any Thermally Sensitive System

3.OVERVIEW

Figure 1 shows a block diagram of the DS18B20, and pin descriptions are given in the Pin Description table. The 64-bit ROM stores the device’s unique serial code. The scratchpad memory contains the 2-byte temperature register that stores the digital output from the temperature sensor. In addition, the scratchpad provides access to the 1-byte upper and lower alarm trigger registers (TH and TL) and the 1-byte configuration register. The configuration register allows the user to set the resolution of the temperature to-digital conversion to 9, 10, 11, or 12 bits. The TH, TL, and configuration registers are nonvolatile (EEPROM), so they will retain data when the device is powered down.

The DS18B20 uses Maxim’s exclusive 1-Wire bus protocol that implements bus communication using one control signal. The control line requires a weak pull up resistor since all devices are linked to the bus via a 3-state or open-drain port (the DQ pin in the case of the DS18B20). In this bus system, the microprocessor (the master device) identifies and addresses devices on the bus using each device’s unique 64-bit code. Because each device has a unique code, the number of devices that can be addressed on one DS18B20 bus is virtually unlimited. The 1-Wire bus protocol,

2

外文翻译(原文)

including detailed explanations of the commands and “time slots,‖ is covered in the 1-Wire Bus System section.

Another feature of the DS18B20 is the ability to operate without an external power supply. Power is instead supplied through the 1-Wire pull up resistor via the DQ pin when the bus is high. The high bus signal also charges an internal capacitor (CPP), which then supplies power to the device when the bus is low. This method of deriving power from the 1-Wire bus is referred to as ―parasite power.‖ As an alternative, the DS18B20 may also be powered by an external supply on VDD.

Vpu4.7KPARASITE POWER CIRCUIT MEMORY CONTROLLOGICDQTEMPERATURE SENSOR GNDCppINTERNAL Vdd64-BIT ROMAND1-WIRE PORTSCRATCHPAD ALARM HIGH TRIGGER (TH) ALARM LOW TRIGGER (TL) CONFIGURATION REGISTER 8-BIT CRC GENERATOR VddPOWER-SUPPLY SENSE Figure 1.DS18B20 Block Diagram

4.OPERATION—MEASURING TEMPERATUR

The core functionality of the DS18B20 is its direct-to-digital temperature sensor. The resolution of the temperature sensor is user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively. The default resolution at power-up is 12-bit. The DS18B20 powers up in a low-power idle state. To initiate a temperature measurement and A-to-D conversion, the master must issue a Convert T [44h] command. Following the conversion, the resulting thermal data is stored in the 2-byte temperature register in the scratchpad memory and the DS18B20 returns to its idle state. If the DS18B20 is powered by an external supply, the master can issue ―read time slots‖ (see the 1-Wire Bus System section) after the Convert T command and the DS18B20 will respond by transmitting 0 while

3

外文翻译(原文)

the temperature conversion is in progress and 1 when the conversion is done. If the DS18B20 is powered with parasite power, this notification technique cannot be used since the bus must be pulled high by a strong pull up during the entire temperature conversion.

The DS18B20 output temperature data is calibrated in degrees Celsius; for Fahrenheit applications, a lookup table or conversion routine must be used. The temperature data is stored as a 16-bit sign-extended two’s complement number in the temperature register (see Figure 2). The sign bits (S) indicate if the temperature is positive or negative: for positive numbers S = 0 and for negative numbers S = 1. If the DS18B20 is configured for 12-bit resolution, all bits in the temperature register will contain valid data. For 11-bit resolution, bit 0 is undefined. For 10-bit resolution, bits 1 and 0 are undefined, and for 9-bit resolution bits 2, 1, and 0 are undefined. Table 1 gives examples of digital output data and the corresponding temperature reading for 12-bit resolution conversions.

bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 LS Byte 23 S 22 S 21 S 20 S 2-1 S 2-2 26 2-3 25 2-4 24 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 MS Byte Figure 2.Temperature Register Format TEMPERATURE DIGITAL OUTPUT DIGITAL OUTPUT (BINARY) (HEX) +125℃ 0000 0111 1101 0000 07D0H +25.0625℃ 0000 0001 1001 0001 0191H 0℃ 0000 0000 0000 0000 0000H -25.0625℃ 1111 1110 0110 1111 FE6FH -55℃ 1111 1100 1001 0000 FC90H Table 1.Temperature/Data Relationship

5.64-BIT LASERED ROM CODE

4

外文翻译(原文)

Each DS18B20 contains a unique 64–bit code (see Figure 3) stored in ROM. The least significant 8 bits of the ROM code contain the DS18B20’s 1-Wire family code: 28h. The next 48 bits contain a unique serial number. The most significant 8 bits contain a cyclic redundancy check (CRC) byte that is calculated from the first 56 bits of the ROM code. The 64-bit ROM code and associated ROM function control logic allow the DS18B20 to operate as a 1-Wire device using the protocol detailed in the 1-Wire Bus System section.

8-BIT CRC 48-BIT SERIAL NUMBER 8-BIT FAMILY CODE MSB LSB MSB LSB MSB Figure 3.64-Bit Lasered ROM Code

6.MEMORY

The DS18B20’s memory is organized as shown in Figure 4. The memory consists of an SRAM scratchpad with nonvolatile EEPROM storage for the high and low alarm trigger registers (TH and TL) and configuration register. Note that if the DS18B20 alarm function is not used, the TH and TL registers can serve as general-purpose memory.

Byte 0 and byte 1 of the scratchpad contain the LSB and the MSB of the temperature register, respectively. These bytes are read-only. Bytes 2 and 3 provide access to TH and TL registers. Byte 4 contains the configuration register data. Bytes 5, 6, and 7 are reserved for internal use by the device and cannot be overwritten. Byte 8 of the scratchpad is read-only and contains the CRC code for bytes 0 through 7 of the scratchpad. The DS18B20 generates this CRC using the method described in the CRC Generation section.

Data is written to bytes 2, 3, and 4 of the scratchpad using the Write Scratchpad [4Eh] command; the data must be transmitted to the DS18B20 starting with the least significant bit of byte 2. To verify data integrity, the scratchpad can be read (using the Read Scratchpad [BEh] command) after the data is written. When reading the scratchpad, data is transferred over the 1-Wire bus starting with the least significant

5

外文翻译(原文)

bit of byte 0. To transfer the TH, TL and configuration data from the scratchpad to EEPROM, the master must issue the Copy Scratchpad [48h] command.

Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 Temperature LSB Temperature MSB TH Register for high temperature TL Register for low temperature Configuration Register Reserved(FFH) Reserved(OCH) Reserved(IOH) Byte8 Cyclic Redundancy Checks(CRC) Figure 4.DS18B20 Memory Map

7.CONFIGURATION REGISTER

Byte 4 of the scratchpad memory contains the configuration register, which is organized as illustrated in Figure 5. The user can set the conversion resolution of the DS18B20 using the R0 and R1 bits in this register as shown in Table 2. The power-up default of these bits is R0 = 1 and R1 = 1 (12-bit resolution). Note that there is a direct tradeoff between resolution and conversion time. Bit 7 and bits 0 to 4 in the configuration register are reserved for internal use by the device and cannot be overwritten.

BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 TM R1 R0 1 1 1 1 1 Figure 5.Configuration Register

R0 R1 RESOLUTION(BITMAX CONVERSION S) TIME 6

外文翻译(原文)

0 0 1 1 0 1 0 1 9 10 11 12 93.75ms 187.5ms 375ms 750ms Table 2.Thermometer Resolution Configuration

8.1-WIRE BUS SYSTEM

The 1-Wire bus system uses a single bus master to control one or more slave devices. The DS18B20 is always a slave. When there is only one slave on the bus, the system is referred to as a ―single-drop‖ system; the system is ―multi-drop‖ if there are multiple slaves on the bus. All data and commands are transmitted least significant bit first over the 1-Wire bus. The following discussion of the 1-Wire bus system is broken down into three topics: hardware configuration, transaction sequence, and 1-Wire signaling (signal types and timing).

9.TRANSACTION SEQUENCE

The transaction sequence for accessing the DS18B20 is as follows: Step 1. Initialization

Step 2. ROM Command (followed by any required data exchange) Step 3. DS18B20 Function Command (followed by any required data exchange)

It is very important to follow this sequence every time the DS18B20 is accessed, as the DS18B20 will not respond if any steps in the sequence are missing or out of order. Exceptions to this rule are the Search ROM [F0h] and Alarm Search [ECh] commands. After issuing either of these ROM commands, the master must return to Step 1 in the sequence. (1)INITIALIZATION

All transactions on the 1-Wire bus begin with an initialization sequence. The initialization sequence consists of a reset pulse transmitted by the bus master followed

7

外文翻译(原文)

by presence pulse(s) transmitted by the slave(s). The presence pulse lets the bus master know that slave devices (such as the DS18B20) are on the bus and are ready to operate.

(2)ROM COMMANDS

After the bus master has detected a presence pulse, it can issue a ROM command. These commands operate on the unique 64-bit ROM codes of each slave device and allow the master to single out a specific device if many are present on the 1-Wire bus. These commands also allow the master to determine how many and what types of devices are present on the bus or if any device has experienced an alarm condition. There are five ROM commands, and each command is 8 bits long. The master device must issue an appropriate ROM command before issuing a DS18B20 function command. 1.SEARCH ROM [F0h]

When a system is initially powered up, the master must identify the ROM codes of all slave devices on the bus, which allows the master to determine the number of slaves and their device types. The master learns the ROM codes through a process of elimination that requires the master to perform a Search ROM cycle (i.e., Search ROM command followed by data exchange) as many times as necessary to identify all of the slave devices. If there is only one slave on the bus, the simpler Read ROM command can be used in place of the Search ROM process. 2.READ ROM [33h]

This command can only be used when there is one slave on the bus. It allows the bus master to read the slave’s 64-bit ROM code without using the Search ROM procedure. If this command is used when there is more than one slave present on the bus, a data collision will occur when all the slaves attempt to respond at the same time.

3.MATCH ROM [55h]

The match ROM command followed by a 64-bit ROM code sequence allows

8

外文翻译(原文)

the bus master to address a specific slave device on a multi-drop or single-drop bus. Only the slave that exactly matches the 64-bit ROM code sequence will respond to the function command issued by the master; all other slaves on the bus will wait for a reset pulse.

4.SKIP ROM [CCh]

The master can use this command to address all devices on the bus simultaneously without sending out any ROM code information. For example, the master can make all DS18B20s on the bus perform simultaneous temperature conversions by issuing a Skip ROM command followed by a Convert T [44h] command. Note that the Read Scratchpad [BEh] command can follow the Skip ROM command only if there is a single slave device on the bus. In this case, time is saved by allowing the master to read from the slave without sending the device’s 64-bit ROM code. A Skip ROM command followed by a Read Scratchpad command will cause a data collision on the bus if there is more than one slave since multiple devices will attempt to transmit data simultaneously. 5.ALARM SEARCH [ECh]

The operation of this command is identical to the operation of the Search ROM command except that only slaves with a set alarm flag will respond. This command allows the master device to determine if any DS18B20s experienced an alarm condition during the most recent temperature conversion. After every Alarm Search cycle (i.e., Alarm Search command followed by data exchange), the bus master must return to Step 1 (Initialization) in the transaction sequence. (3)DS18B20 FUNCTION COMMANDS

After the bus master has used a ROM command to address the DS18B20 with which it wishes to communicate, the master can issue one of the DS18B20 function commands. These commands allow the master to write to and read from the DS18B20’s scratchpad memory, initiate temperature conversions and determine the power supply mode.

9

外文翻译(原文)

1.CONVERT T [44h]

This command initiates a single temperature conversion. Following the conversion, the resulting thermal data is stored in the 2-byte temperature register in the scratchpad memory and the DS18B20 returns to its low-power idle state. If the device is being used in parasite power mode, within 10μs (max) after this command is issued the master must enable a strong pull up on the 1-Wire bus. If the DS18B20 is powered by an external supply, the master can issue read time slots after the Convert T command and the DS18B20 will respond by transmitting a 0 while the temperature conversion is in progress and a 1 when the conversion is done. In parasite power mode this notification technique cannot be used since the bus is pulled high by the strong pull up during the conversion. 2.READ SCRATCHPAD [BEh]

This command allows the master to read the contents of the scratchpad. The data transfer starts with the least significant bit of byte 0 and continues through the scratchpad until the 9th byte (byte 8 – CRC) is read. The master may issue a reset to terminate reading at any time if only part of the scratchpad data is needed. 3.WRITE SCRATCHPAD [4Eh]

This command allows the master to write 3 bytes of data to the DS18B20’s scratchpad. The first data byte is written into the TH register (byte 2 of the scratchpad), the second byte is written into the TL register (byte 3), and the third byte is written into the configuration register (byte 4). Data must be transmitted least significant bit first. All three bytes MUST be written before the master issues a reset, or the data may be corrupted. 4.COPY SCRATCHPAD [48h]

This command copies the contents of the scratchpad TH, TL and configuration registers (bytes 2, 3 and 4) to EEPROM. If the device is being used in parasite power mode, within 10μs (max) after this command is issued the master must enable a

10

外文翻译(原文)

strong pull-up on the 1-Wire bus. 5.RECALL E2 [B8h]

This command recalls the alarm trigger values (TH and TL) and configuration data from EEPROM and places the data in bytes 2, 3, and 4, respectively, in the scratchpad memory. The master device can issue read time slots following the Recall E2command and the DS18B20 will indicate the status of the recall by transmitting 0 while the recall is in progress and 1 when the recall is done. The recall operation happens automatically at power-up, so valid data is available in the scratchpad as soon as power is applied to the device. 6.READ POWER SUPPLY [B4h]

The master device issues this command followed by a read time slot to determine if any DS18B20s on the bus are using parasite power. During the read time slot, parasite powered DS18B20s will pull the bus low, and externally powered DS18B20s will let the bus remain high.

10.WIRE SIGNALING

The DS18B20 uses a strict 1-Wire communication protocol to ensure data integrity. Several signal types are defined by this protocol: reset pulse, presence pulse, write 0, write 1, read 0, and read 1. The bus master initiates all these signals, with the exception of the presence pulse.

(1)INITIALIZATION PROCEDURE—RESET AND PRESENCE PULSES All communication with the DS18B20 begins with an initialization sequence that consists of a reset pulse from the master followed by a presence pulse from the DS18B20. This is illustrated in Figure 6. When the DS18B20 sends the presence pulse in response to the reset, it is indicating to the master that it is on the bus and ready to operate.

During the initialization sequence the bus master transmits (TX) the reset pulse by pulling the 1-Wire bus low for a minimum of 480μs. The bus master then releases

11

外文翻译(原文)

the bus and goes into receive mode (RX). When the bus is released, the 5k? pull-up resistor pulls the 1-Wire bus high. When the DS18B20 detects this rising edge, it waits 15μs to 60μs and then transmits a presence pulse by pulling the 1-Wire bus low for 60μs to 240μs.

Master Rx480μs minimumMaster Tx Reset Pulse480μs minimumDS18B20 waits15~60μsDS18B20 presence pulse 60~240μsVpu1-Wire BusGNDDS18B20 Initialization Timing Bus master pulling low DS18B20 pulling low Resistor pullup

Figure 6.Initialization Timing (2)READ/WRITE TIME SLOTS

The bus master writes data to the DS18B20 during write time slots and reads data from the DS18B20 during read time slots. One bit of data is transmitted over the 1-Wire bus per time slot. 1.WRITE TIME SLOTS

There are two types of write time slots: ―Write 1‖ time slots and ―Write 0‖ time slots. The bus master uses a Write 1 time slot to write a logic 1 to the DS18B20 and a Write 0 time slot to write a logic 0 to the DS18B20. All write time slots must be a minimum of 60μs in duration with a minimum of a 1μs recovery time between individual write slots. Both types of write time slots are initiated by the master pulling the 1-Wire bus low (see Figure 7).

To generate a Write 1 time slot, after pulling the 1-Wire bus low, the bus master must release the 1-Wirebus within 15μs. When the bus is released, the 5k? pull-up resistor will pull the bus high. To generate a Write 0 time slot, after pulling the 1-Wire

12

外文翻译(原文)

bus low, the bus master must continue to hold the bus low for the duration of the time slot (at least 60μs).

The DS18B20 samples the 1-Wire bus during a window that lasts from 15μs to 60μs after the master initiates the write time slot. If the bus is high during the sampling window, a 1 is written to the DS18B20. If the line is low, a 0 is written to the DS18B20.

START OF SLOT MASTER WRITE ―0‖ SLOT START OF SLOT MASTER WRITE ―1‖ SLOT >1us>1usVcc1-wire BusGND15us60us

Figure 7.DS18B20 Write Time Slot

2.READ TIME SLOTS

The DS18B20 can only transmit data to the master when the master issues read time slots. Therefore, the master must generate read time slots immediately after issuing a Read Scratchpad [BEh] or Read Power Supply [B4h] command, so that the DS18B20 can provide the requested data. In addition, the master can generate read time slots after issuing Convert T [44h] or Recall E2 [B8h] commands to find out the status of the operation.

All read time slots must be a minimum of 60μs in duration with a minimum of a 1μs recovery time between slots. A read time slot is initiated by the master device pulling the 1-Wire bus low for a minimum of 1μs and then releasing the bus (see Figure 8). After the master initiates the read time slot, the DS18B20 will begin transmitting a 1 or 0 on bus. The DS18B20 transmits a 1 by leaving the bus high and

13

外文翻译(原文)

transmits a 0 by pulling the bus low. When transmitting a 0, the DS18B20 will release the bus by the end of the time slot, and the bus will be pulled back to its high idle state by the pull up resister. Output data from the DS18B20 is valid for 15μs after the falling edge that initiated the read time slot. Therefore, the master must release the bus and then sample the bus state within 15μs from the start of the slot.

>1usVcc1-wire busGND>1usMASTER READ ―0‖ SLOT MASTER READ ―1‖ SLOT Master samples 15us30us>1usMaster samples 15us15usDS18B20 read time slotBus master pulling low DS18B20 pulling low Resistor pullup

Figure 8.DS18B20 Read Time Slot

14

外文翻译(原文)

15

外文翻译(译文)

DS18B20介绍

1.说明

DS18B20数字式温度传感器提供9位到12位的摄氏温度测量,并且有用户可编程的、非易失性温度上下限告警出发点。DS18B20通过单总线通信,单总线被定义为只需要一根数据线与主微处理器相连进行通信。它的工作温度范围为-55°C到+12°C,且在-10到85范围内的精度为±0.5°C。另外,DS18B20能够从数据线中直接获得能量(寄生电源),消除了对外部供电的需求。 每一个DS18B20都有一个独一无二的64位序列码,这个序列码允许多个DS18B20在同一根单总线上工作。因此很容易用一片微处理器控制分布在较大领域的多个DS18B20。包括高压交流电环境控制、内置温度检测系统建筑,或者机器、处理器和控制系统在内的应用程序都会从这个特点中受益。

2.特点

? 独特的单线接口,只需要一个接口引脚即可通信

? 每个设备均由一个存储在板上ROM的独一无二的64位序列码 ? 多点能力使分布式温度检测应用得以简化 ? 不需要外部器件

? 可用数据线供电;电压范围是3.0V~5.5V ? 温度测量范围是-55°C到+12°C(-67°F到+257°F) ? -10°C 到85°C范围内测量精度为±0.5°C ? 传感器分辨率可从9位到12位由用户选择 ? 最大在750ms内转换12位数据的字节 ? 用户可定义的非易失性警报设置

? 告警搜索命令和寻址超出设定的温度界限的设备 ? 软件与DS1822兼容

16

外文翻译(译文)

? 应用范围包括温度调节控制器、工业系统、消费产品、温度计,或者任何热

敏感系统

3.概述

图1给出了DS18B20的方框图,并且在引脚说明表格中给出了引脚介绍。64位ROM存储了设备的独有的序列号。高速暂存器包含2个字节的温度寄存器,温度寄存器存储来自温度传感器的数字输出。另外高速暂存器提供功能访问一个字节的温度上限及下限告警触发寄存器(TH和TL)和一个字节的配置寄存器。配置寄存器允许用户设定9位、10位、11位和12位的温度分辨率。TH,TL和配置寄存器是非易失性的(EEPROM),所以掉电后仍然能保存数据。 DS18B20使用单总线独有的协议准则,使用某一控制信号进行设备总线通信。控制线需要一个较小的上拉电阻,因为所有的设备通过一个三态漏极开路端口(如DS18B20的DQ引脚)连在总线上。在这个总线系统中,微处理器(控制设备)利用每一个设备的唯一64位码识别和寻址总线上的设备。因为每个设备有唯一的序列码,因此能够被同一个DS18B20寻址的设备数量几乎无限的。单总线协议,包括详细的命令解释和时间时隙说明,被掩膜在在单总线系统中。 DS18B20的另一个特点是不需要再外部供电下即可工作。当总线高电平时能量由单线上拉电阻经过DQ引脚获得。高电平同时充电一个内部电容,当总线低电平时由此电容供应能量。这种供电方法被称为“寄生电源”。另外一种选择是DS18B20由接在VDD的外部电源供电。

Vpu4.7K寄生电源电路DQ存储器和控制器温度灵敏元件GNDCpp内部电源Vdd64位ROM和1-Wire总线接口温度上限触发器TH高速缓存存储器温度下限触发器TL配置寄存器Vdd电源检测8位CRC生成器 图1.DS18B20方框图

17

外文翻译(译文)

4.运用-测量温度

DS18B20的核心功能是它的数字式温度器。温度传感器的分辨率是用户可配置的9位、10位、11位或12位,分别对应的增量为0.5°C, 0.25°C, 0.125°C, 和0.0625°C。系统上电默认值是12位及分辨率。DS18B20上电后处于空闲状态。为了初始化温度测量和进行AD转换,控制器必须发出一个转换温度命令。转换命令后,采集的温度数据存储在暂存器的2字节的温度寄存器中,然后DS18B20恢复到空闲状态。如果DS18B20是有外部供电,主机能在转换命令后发出“读时隙”命令,当温度转换在进行时DS18B20传输0、当转换完成时DS18B20传输1来响应主机。如果DS18B20采用寄生电源,这个响应方法就不能使用,因为总线在整个温度转换环节中必须保持高电平。

DS18B20输出温度数据是摄氏度标准,若要转为华氏温度,必须使用查表或转换子程序。温度数据以16位扩展补码信号存储在温度寄存器中(见图2)。符号位S表明温度是正还是负:温度正值时S=0.温度负值时S=1。如果DS18B20被设定为12位分辨率,温度寄存器中的所有位均为有效数据;对11位分辨率,位0无定义。对10位分辨率,位1和位0无定义;对9位分辨率,位2、位1和位0无定义。表1给出了数字输出数据和相应的12位分辨率温度读取转换。

bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 低字节 23 S 22 S 21 S 20 S 2-1 S 2-2 26 2-3 25 2-4 24 bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 高字节 图2.温度寄存器格式

温度 数字输出(二进制) +125℃ 0000 0111 1101 0000 +25.0625℃ 0000 0001 1001 0001 0℃ 0000 0000 0000 0000 -25.0625℃ 1111 1110 0110 1111 -55℃ 1111 1100 1001 0000 表1.温度/数据关系

18

数字输出(十六进制) 07D0H 0191H 0000H FE6FH FC90H 外文翻译(译文)

5.64位激光ROM

每一个DS18B20包含一个存储在ROM中的独一无二的64位码(见图3)。ROM码的最低8位包含DS18B20的单总线产品系列码:28h。接着48位包含一个唯一的序列号。最高8位包含一个循环冗余校验(CRC)字节,由ROM码的前56位计算得来。64位ROM码和相关的ROM逻辑控制功能允许DS18B20使用单总线系统中详细协议来作为单总线设备运行。

8位CRC编号 48位序列号 图3.64位激光ROM码 8位产品系列编码 6.存储器

DS18B20的存储器如同图4中那样被组织。存储器由一个高速暂存RAM和一个非易失性电可擦除EEPROM组成,后者存储高温和低温触发器(TH和TL)和配置寄存器。如果DS18B20不使用告警功能,那么TH、TL和配置寄存器就作为通用寄存器使用。

暂存器的字节0和字节1分别包含温度寄存器的最低有效位和最高有效位。这些字节是只读的。字节2和字节3提供提供TH和TL寄存器的接口。字节4包含配置寄存器数据,字节5、6和7是为设备内部使用而预留的,不可以被重写。暂存器的字节8是只读的,包含暂存器从字节0到字节7的值。DS18B20使用CRC产生一节中的方法形成这个CRC码。

数据被写暂存器命令写在暂存器的字节2、3和4中,数据从字节2的最低有效位开始写入DS18B20。为了检验数据完整性,在数据被写入之后可以读取暂存器(使用读暂存器命令)。当读取暂存器时,数据通过单总线从字节0的最低有效位开始传输。为了把暂存器中的TH、TL和配置寄存器的数据传输到EEPROM中,主机必须发出复制暂存器命令。

Byte0 Byte1 Byte2

温度测量值低8位 LSB 温度测量值高8位 MSB TH高温寄存器 19

外文翻译(译文)

Byte3 Byte4 Byte5 Byte6 Byte7 TL低温寄存器 配置寄存器 预留(FFH) 预留(OCH) 预留(IOH) Byte8 循环冗余码校验(CRC) 图4.DS18B20存储器映射 7.配置寄存器

高速暂存存储器的字节4包含配置寄存器,正如图5中那样定义。用户能通过表2中寄存器R0和R1位来设置DS18B20的转换精度。这些位的上电默认值是R0=1和R1=1(12位分辨率)。在分辨率和转换时间之间有个直接的折衷。配置寄存器中位7和位0至位4为设备内部使用作预留,而且不能被重写。 位7 TM 位6 R1 位5 R0 位4 1 位3 1 位2 1 位1 1 位0 1 图5.配置寄存器

R0 0 0 1 1 R1 0 1 0 1 分辨率 9位 10位 11位 12位 温度最大转换时间(ms) 93.75 187.5 375 750 表2.温度分辨率配置

8.单总线系统

一线总线系统使用单总线主控来控制一个或多个从机设备。DS18B20一直是个从机。当总线上只有一个从机时,系统被称为“单站”体系,如果总线上有多个从机,系统就被称为“多站”体系。所有数据和命令通过单总线首先传输最低有效位。接下来的单总线系统讨论分为三个题目:硬件接法,处理顺序,和单线信号(信号类型与定时)。

9.处理顺序

访问DS18B20的处理顺序如下:

20

本文来源:https://www.bwwdw.com/article/096p.html

Top