搜档网
当前位置:搜档网 › DS18B20中英文数据手册

DS18B20中英文数据手册

DS18B20

可编程分辨率的单总线.数字温度计

特征

● 独特的单线接口仅需一个端口引脚进行通讯

● 每个器件有唯一的64 位的序列号存储在内部存储器中

● 简单的多点分布式测温应用

● 无需外部器件

● 可通过数据线供电。供电范围为3.0V到5.5V

● 测温范围为-55~+125℃(-67~+257℉)

● 在-10~+85℃范围内精确度为±5℃

● 温度计分辨率可以被使用者选择为9~12位

● 最多在750ms 内将温度转换为12 位数字

● 用户可定义的非易失性温度报警设置

● 报警搜索命令识别并标志超过程序限定温度(温度报警条件)的器件

● 与DS1822兼容的软件

● 应用包括温度控制、工业系统、消费品、温度计或任何热感测系统

引脚排列

说明

DS18B20数字温度计提供9至12位的摄氏温度测量,并具有易失性的用户可编程触发点的上限和下限报警功能。DS18B20单总线通信按定义只需要一条数据线

(和地线)与中央微处理器进行通信。它具有工作温度范围55°C + 125°C和准确±0.5°C范围- 10°C + 85°C.此外,DS18B20可以导出功率直接从数据线(“寄生虫”),消除了外部电源需要。

每个DS18B20都有一个唯一的64位串行码,它允许多个DS18B20在同一根总线功能。因此,它是用一个简单的微处理器控制,大面积分布的许多DS18B20s。应用程序可以受益于这个功能包括空调环境控制,建筑物内的温度监控系统,设备,或机械,和过程监控控制系统。

概览

图1 是表示DS18B20 的方框图,表1 已经给出了引脚说明。64 位只读存储器储存器件的唯一片序列号。高速暂存器含有两个字节的温度寄存器,这两个寄存器用来存储温度传感器输出的数据。除此之外,高速暂存器提供一个直接的温度报警值寄存器(TH和TL),和一个字节的的配置寄存器。配置寄存器允许用户将温度的精度设定为9,10,11 或12 位。TH,TL 和配置寄存器是非易失性的可擦除程序寄存器(EEPROM),所以存储的数据在器件掉电时不会消失。DS18B20通过达拉斯公司独有的单总线协议依靠一个单线端口通讯。当全部器件经由一个3态端口或者漏极开路端口(DQ引脚在DS18B20上的情况下)与总线连接的时候,控制线需要连接一个弱上拉电阻。在这个总线系统中,微控制器(主器件)依靠每个器件独有的64位片序列号辨认总线上的器件和记录总线上的器件地址。由于每个装置有一个独特的片序列码,总线可以连接的器件数目事实上是无限的。单总线协议,包括指令的详细解释和“时序”见单总线系统节。DS18B20的另一个功能是可以在没有外部电源供电的情况下工作。当总线处于高电平状态,DQ与上拉电阻连接通过单总线对器件供电。同时处于高电平状态的总线信号对内部电容(Cpp)充电,在总线处于低电平状态时,该电容提供能量给器件。这种提供能量的形式被称为“寄生电源”。作为替代选择,DS18B20同样可以通过VDD引脚连接外部电源供电。

DS18B20方框图图1

测温操作

DS18B20的核心功能是它的直接读数字的温度传感器。温度传感器的精度为用户可编程的9,10,11或12位,分别以0.5℃,0.25℃,0.125℃和0.0625℃增量递增。在上电状态下默认的精度为12位。DS18B20启动后保持低功耗等待状态;当需要执行温度测量和AD转换时,总线控制器必须发出[44h]命令。在那之后,产生的温度数据以两个字节的形式被存储到高速暂存器的温度寄存器中,

DS18B20继续保持等待状态。当DS18B20由外部电源供电时,总线控制器在温度转换指令之后发起“读时序”(见单总线系统节),DS18B20正在温度转换中返回0,转换结束返回1。如果DS18B20由寄生电源供电,除非在进入温度转换时总线被一个强上拉拉高,否则将不会由返回值。寄生电源的总线要求在

DS18B20 供电节详细解释。

报警操作信号

DS18B20完成一次温度转换后,就拿温度值与和存储在TH和TL中一个字节的用户自定义的报警预置值进行比较。标志位(S)指出温度值的正负:正数S=0,

负数S=1。TH和TL寄存器是非易失性的,所以它们在掉电时仍然保存数据。在存储器节将解释TH和TL是怎么存入高速暂存器的第2和第3个字节的。

TH 和TL 寄存器格式图3

当TH和TL为8位寄存器时,4位温度寄存器中的11个位用来和TH、TL进行比较。如果测得的温度高于TH 或低于TL,报警条件成立,DS18B20 内部就会置位一个报警标识。每进行一次测温就对这个标识进行一次更新;因此,如果报警条件不成立了,在下一次温度转换后报警标识将被移去。

总线控制器通过发出报警搜索命令[ECh]检测总线上所有的DS18B20 报警标识。任何置位报警标识的DS18B20将响应这条命令,所以总线控制器能精确定位每一个满足报警条件的DS18B20。如果报警条件成立,而TH或TL的设置已经改变,另一个温度转换将重新确认报警条件。

DS18B20 供电

DS18B20可以通过从VDD引脚接入一个外部电源供电,或者可以工作于寄生电源模式,该模式允许DS18B20工作于无外部电源需求状态。寄生电源在进行远距离测温时是非常有用的。寄生电源的控制回路见图1,当总线为高电平时,寄生电源由单总线通过VDD引脚。这个电路会在总线处于高电平时偷能量,部分汲取的能量存储在寄生电源储能电容(Cpp)内,在总线处于低电平时释放能量以提供给器件能量。当DS18B20处于寄生电源模式时,VDD引脚必须接地。

寄生电源模式下,单总线和Cpp在大部分操作中能提供充分的满足规定时序和电压的电流(见直流电特性和交流电特性节)给DS18B20。然而,当DS18B20正在执行温度转换或从高速暂存器向EPPROM传送数据时,工作电流可能高达1.5mA。这个电流可能会引起连接单总线的弱上拉电阻的不可接受的压降,这需要更大的电流,而此时Cpp无法提供。为了保证DS18B20由充足的供电,当进行温度转换或拷贝数据到EEPROM操作时,必须给单总线提供一个强上拉。用漏极开路把I/O直接拉到电源上就可以实现,见图4。在发出温度转换指令[44h]或拷贝暂存器指令[48h]之后,必须在至多10us之内把单总线转换到强上拉,并且在温度转换时序(tconv)或拷贝数据时序(ter=10 ms)必须一直保持为强上拉状态。当强上拉状态保持时,不允许有其它的动作。

对DS18B20供电的另一种传统办法是从VDD引脚接入一个外部电源,见图5。这样做的好处是单总线上不需要强上拉。而且总线不用在温度转换期间总保持高电平。

温度高于100℃时,不推荐使用寄生电源,因为DS18B20在这种温度下表现出的漏电流比较大,通讯可能无法进行。在类似这种温度的情况下,强烈推荐使用DS18B20的VDD引脚。

对于总线控制器不直到总线上的DS18B20是用寄生电源还是用外部电源的情况,DS18B20 预备了一种信号指示电源的使用意图。总线控制器发出一个Skip ROM指令[CCh],然后发出读电源指令[B4h],这条指令发出后,控制器发出读时序,寄生电源会将总线拉低,而外部电源会将总线保持为高。如果总线被拉低,

总线控制器就会知道需要在温度转换期间对单总线提供强上拉。

DS18B20 温度转换期间的强上拉供电图4

外部电源给DS18B20 供电图5

64 位(激)光刻只读存储器

每只DS18B20 都有一个唯一存储在ROM 中的64 位编码。最前面8 位是单线系列编码:28h。接着的48 位是一个唯一的序列号。最后8 位是以上56 位的CRC 编码。CRC的详细解释见CRC 发生器节。64位ROM和ROM操作控制区允许DS18B20作为单总线器件并按照详述于单总线系统节的单总线协议工作。

64 位(激)光刻只读存储器图6

存储器

DS18B20的存储器结构示于图7。存储器有一个暂存SRAM和一个存储高低报警触发值TH 和TL 的非易失性电可擦除EEPROM 组成。注意当报警功能不使用时,TH和TL 寄存器可以被当作普通寄存器使用。所有的存储器指令被详述于DS18B20功能指令节。

位0和位1为测得温度信息的LSB和MSB。这两个字节是只读的。第2和第3字

节是TH和TL的拷贝。位4 包含配置寄存器数据,其被详述于配置寄存器节。位5,6 和7被器件保留,禁止写入;这些数据在读回时全部表现为逻辑1。

高速暂存器的位8是只读的,包含以上八个字节的CRC码,CRC的执行方式如CRC发生器节所述。

数据通过写暂存器指令[4Eh]写入高速暂存器的2,3和4位;数据必须以位2为

最低有效位开始传送。为了完整的验证数据,高速暂存器能够在数据写入后被读取(使用读暂存器指令[BEh])。在读暂存器时,数据以位0为最低有效位从单总线移出。总线控制器传递从暂存器到EEPROMTH,TL和配置数据必须发出拷贝暂存器指令[48h]。

EEPROM 寄存器中的数据在器件掉电时仍然保存;上电时,数据被载入暂存器。

数据也可以通过召回EEPROM命令从暂存器载入EEPROM。总线控制器在发出这条

命令后发出读时序,DS18B20返回0表示正在召回中,返回1表示操作结束。DS18B20 存储器图图7

*上电状态依赖于EEPROM中的值

配置寄存器

存储器的第4位为配置寄存器,其组织见图8。用户可以通过按表3所示设置R0 和R1位来设定DS18B20的精度。上电默认设置:R0=1,R1=1(12位精度)。注意:

精度和转换时间之间有直接的关系。暂存器的位7和位0-4被器件保留,禁止写入;在读回数据时,它们全部表现为逻辑1。

配置寄存器图8

温度计精确度配置表3

CRC 发生器

CRC字节作为DS18B2064 位ROM的一部分存储在存储器中。CRC码由ROM的前56位计算得到,被包含在ROM的重要字节当中。CRC由存储在存储器中的数据计算得到,因此当存储器中的数据发生改变时,CRC的值也随之改变。

CRC能够在总线控制器读取DS18B20时进行数据校验。为校验数据是否被正确读取,总线控制器必须用接受到的数据计算出一个CRC 值,和存储在DS18B20 的64 位ROM 中的值(读ROM 时)或DS18B20 内部计算出的8 位CRC 值(读存储器时)进行比较。如果计算得到的CRC值和读取出来的CRC值相吻合,数据被无错传输。CRC 值的比较以及是否进行下一步操作完全由总线控制器决定。当在DS18B20中存储的或由其计算到CRC值和总线控制器计算的值不相符时,DS18B20内部并没有一个能阻止命令序列进行的电路。

CRC的计算等式如下:

CRC = X8 + X5 + X4 + 1

单总线CRC可以由一个由移位寄存器和XOR门构成的多项式发生器来产生,见图9。这个回路包括一个移位寄存器和几个XOR 门,移位寄存器的各位都被初始化为0。从ROM中的最低有效位或暂存器中的位0开始,一次一位移入寄存器。在传输了56位ROM中的数据或移入了暂存器的位7后,移位寄存器中就存储了CRC值。下一步,CRC的值必须被循环移入。此时,如果计算得到的CRC是正确的,移位寄存器将复0。

CRC 发生器图9

单总线系统

单总线系统包括一个总线控制器和一个或多个从机。DS18B20总是充当从机。当只有一只从机挂在总线上时,系统被称为“单点”系统;如果由多只从机挂在总线上,系统被称为“多点”。

所有的数据和指令的传递都是从最低有效位开始通过单总线。

关于单总线系统分三个题目讨论:硬件结构、执行序列和单总线信号(信号类型和时序)。

硬件结构

单总线系统只有一条定义的信号线。每一个总线上的器件必须是漏极开路或三态输出。这样的系统允许每一个挂在总线上的区间都能在适当的时间驱动它。

DS18B20的单总线端口(DQ引脚)是漏极开路式的,内部等效电路见图10

单总线需要一个约5KΩ的外部上拉电阻;单总线的空闲状态是高电平。无论任何理由需要暂停某一执行过程时,如果还想恢复执行的画,总线必须停留在空闲状态。在恢复期间,如果单总线处于非活动(高电平)状态,位与位间的恢复时间可以无限长。如果总线停留在低电平超过480us,总线上的所有器件都将被复位。

硬件结构图10

执行序列

通过单线总线端口访问DS18B20的协议如下:

步骤1. 初始化

步骤2. ROM操作指令

步骤3. DS18B20功能指令

每一次DS18B20的操作都必须满足以上步骤,若是缺少步骤或是顺序混乱,器件将不会返回值。例如这样的顺序:发起ROM搜索指令[F0h]和报警搜索指令[ECh]之后,总线控制器必须返回步骤1。

初始化

通过单总线的所有执行操作处理都从一个初始化序列开始。初始化序列包括一个由总线控制器发出的复位脉冲和其后由从机发出的存在脉冲。存在脉冲让总线控制器知道DS18B20在总线上且已准备好操作,详见单总线信号节。

ROM 指令

一旦总线控制器探测到一个存在脉冲,它就发出一条ROM指令。如果总线上挂有多只DS18B20,这些指令将基于器件独有的64 位ROM 片序列码使得总线控制器选出特定要进行操作的器件。这些指令同样也可以使总线控制器识别有多少只,什么型号的器件挂在总线上,同样,它们也可以识别哪些器件已经符合报警条件。ROM指令有5条,都是8 位长度。总线控制器在发起一条DS18B20功能指令之前必须先发出一条ROM指令。ROM指令操作流程图见图11。

Search ROM [F0h] (搜索ROM 指令)

当系统上电初始化的时候,总线控制器必须通过识别总线上所有ROM片序列码去得到从机的数目和型号。总线控制器通过搜索ROM指令多次循环搜索ROM编码,以确认所有从机器件。如果总线上只有一只从机,那么可以用较为简单的读取ROM 指令(见下文)代替搜索ROM 指令,关于iButton Book of Standards 见https://www.sodocs.net/doc/348543428.html,/ibuttons/standard.pdf。在每次搜索ROM指令之后,总线控制器必须返回步骤1。

READ ROM [33h] (读取ROM 指令)

只有在总线上存在单只DS18B20的时候才能使用这条命令。该命令允许总线控制器在不使用搜索ROM 指令的情况下读取从机的64 位片序列码。如果总线上有不止一只从机,当所有从机试图同时传送信号时就会发生数据冲突。

MATH ROM [55h] (匹配ROM 指令)

匹配ROM 指令,后跟64 位ROM 编码序列,让总线控制器在多点总线上定位

一只特定的DS18B20。只有和64 位ROM 片序列码完全匹配的DS18B20 才能响应随后的存储器操作指令;所有和64位ROM片序列码不匹配的从机都将等待复位脉冲。

SKIP ROM [CCh] (忽略ROM 指令)

这条指令允许总线控制器不用提供64 位ROM 编码就使用功能指令。例如,总线控制器可以先发出一条忽略ROM 指令,然后发出温度转换指令[44h],从而完成温度转换操作。注意:当只有一只从机在总线上时,无论如何,忽略ROM指令之后只能跟着发出一条读取暂存器指令[BEh]。在单点总线情况下使用该命令,器件无需发回64 位ROM 编码,从而节省了时间。如果总线上有不止一只从机,若发出忽略ROM指令,由于多只从机同时传送信号,总线上就会发生数据冲突。ALARM SEARCH [ECH] (报警搜索指令)

这条命令的流程和搜索ROM指令相同,然而,只有满足报警条件的从机才对该命令作出响应。只有在最近一次测温后遇到符合报警条件的情况,DS18B20才会响应这条命令。在每次报警搜索指令周期之后,总线控制器必须返回步骤1。关于报警操作流程见报警信号操作节。

DS18B20 功能指令

在总线控制器发给欲连接的DS18B20一条ROM命令后,跟着可以发送一条

DS18B20功能指令。这些命令允许总线控制器读写DS18B20的暂存器,发起温度转换和识别电源模式。DS18B20 的功能指令详见下文,同时被概括于表4,并用流程图示于图12。

CONVERT T [44h] (温度转换指令)

这条命令用以启动一次温度转换。温度转换指令被执行,产生的温度转换结果数据以2个字节的形式被存储在高速暂存器中,而后DS18B20保持等待状态。如果寄生电源模式下发出该命令后,在温度转换期间(tconv),必须在10us(最多), 内给单总线一个强上拉,见DS18B20 供电节。如果DS18B20以外部电源供电,总线控制器在发出该命令后跟着发出读时序,DS18B20如处于转换中,将在总线上返回0,若温度转换完成,则返回1。寄生电源模式下,总线被强上拉拉高前这样的通讯技术不会被使用。

WRITE SCRATCHPAD [4Eh] (写暂存器指令)

这条命令向DS18B20 的暂存器写入数据,开始位置在TH 寄存器(暂存器的第2个字节),接下来写入TL 寄存器(暂存器的第3 个字节),最后写入配置寄存器(暂存器的第4 个字节)。数据以最低有效位开始传送。上述三个字节的写入必须发生在总线控制器发出复位命令前,否则会中止写入。

READ SCRATCHPAD [BEh] (读暂存器指令)

这条命令读取暂存器的内容。读取将从字节0 开始,一只进行下去,知道第9字节(字节8,CRC)读完,如果不想读完所有字节,控制器可以在任何时间发出复位命令来中止读取。

COPY SCRATCHPAD [48h] (拷贝暂存器指令)

这条命令把TH,TL 和配置寄存器(第2、3、4 字节)的内容拷贝到EEPROM 中。如果使用寄生电源总线控制器必须在发出这条命令的10us 内启动强上拉并最

少保持10ms,见DS18B20 供电节所述。

RECALL E2 [B8H] (召回EEPROM 指令)

这条命令把报警触发器的值(TH和TL)以及配置数据从EEPROM拷回暂存器。总线控制器在发出该命令后读时序,DS18B20会输出拷回标识:0标识正在拷回,

1标识拷回结束。这种拷回操作在DS18B20上电时自动执行,这样器件一上电暂存器里马上就存在有效的数据了。

READ POWER SUPPLY [B4h] (读电源模式指令)

总线控制器在这条命令发给DS18B20后发出读时序,若是寄生电源模式,

DS18B20将拉低总线,若是外部电源模式,DS18B20将会把总线拉高。关于这条指令的用法信息详述于DS18B20 供电节。

DS18B20 功能指令表表4

备注:

1. 对于寄生电源模式下的DS18B20,在温度转换和拷贝数据到EEPROM期间,必须给单总线一个强上拉。总线上在这段时间内不能有其它活动。

2. 总线控制器在任何时刻都可以通过发出复位信号中止数据传输。

3. TH,TL和配置寄存器这3个字节的写入必须在复位信号发起之前。

ROM 指令流程图图11

DS18B20 功能指令流程图图12

单总线信号

DS18B20需要严格的单总线协议以确保数据的完整性。协议包括集中单总线信号类型:复位脉冲、存在脉冲、写0、写1、读0 和读1。所有这些信号,除存在脉冲外,都是由总线控制器发出的。

复位序列:复位和存在脉冲

和DS18B20 间的任何通讯都需要以初始化序列开始,初始化序列见图13。一个复位脉冲跟着一个存在脉冲表明DS18B20已经准备好发送和接收数据。

在初始化序列期间,总线控制器拉低总线并保持480us以发出(TX)一个复位脉

冲,然后释放总线,进入接收状态(RX)。单总线由5K上拉电阻拉到高电平。当DS18B20探测到I/O引脚上的上升沿后,等待15-60us,然后发出一个由

60-240us低电平信号构成的存在脉冲。

初始化时序图13

读/写时序

DS18B20的数据读写是通过时序处理位来确认信息交换的。

写时序

由两种写时序:写1 时序和写0 时序。总线控制器通过写1 时序写逻辑1 到DS18B20,写0 时序写逻辑0 到DS18B20。所有写时序必须最少持续60us,包括两个写周期之间至少1us的恢复时间。当总线控制器把数据线从逻辑高电平拉到低电平的时候,写时序开始(见图14)。

总线控制器要生产一个写时序,必须把数据线拉到低电平然后释放,在写时序开始后的15us释放总线。当总线被释放的时候,5K的上拉电阻将拉高总线。总控制器要生成一个写0时序,必须把数据线拉到低电平并持续保持(至少60us)。总线控制器初始化写时序后,DS18B20在一个15us到60us的窗口内对I/O线采样。如果线上是高电平,就是写1。如果线上是低电平,就是写0。

读/写时序图图14

读时序

总线控制器发起读时序时,DS18B20仅被用来传输数据给控制器。因此,总线控制器在发出读暂存器指令[BEh]或读电源模式指令[B4H]后必须立刻开始读时序,DS18B20可以提供请求信息。除此之外,总线控制器在发出发送温度转换指令[44h]或召回EEPROM指令[B8h]之后读时序,详见DS18B20 功能指令节。所有读时序必须最少60us,包括两个读周期间至少1us的恢复时间。当总线控制器把数据线从高电平拉到低电平时,读时序开始,数据线必须至少保持1us,然后总线被释放(见图14)。在总线控制器发出读时序后,DS18B20 通过拉高或拉低总线上来传输1或0。当传输逻辑0结束后,总线将被释放,通过上拉电阻回到上升沿状态。从DS18B20输出的数据在读时序的下降沿出现后15us 内有效。因此,总线控制器在读时序开始后必须停止把I/O脚驱动为低电平15us,以读取I/O脚状态。

图15 标识TINIT,TRC 和TSAMPLE 之和必须小于15us。图16 指出,系统时间可以用下面办法达到最大:TINIT和TRC保持时间尽可能校;把控制器采样时间放到15us周期的最后。

控制器读1 的详细时序图15

推荐控制器读1 时序图16

DS18B20

Programmable Resolution 1-Wire Digital Thermometer 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

● Multidrop Capability Simplifies Distributed Temperature-Sensing Applications

●Requires No External Components

● 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 (Temperature

Alarm Condition)

● Software Compatible with the DS1822

●Applications Include Thermostatic Controls, Industrial Systems, Consumer Products,

Thermometers, or Any Thermally Sensitive

System

PIN CONFIGURATIONS

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 (and ground) 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.

PIN DESCRIPTION

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 un ique 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 (T H and T L) and the 1-byte configuration register. The configuration register allows the user to set the resolution of the temperatureto-digital conversion to 9, 10, 11, or 12 bits. The T H, T L, 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 pullup 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 bus is virtually unlimited. The 1-Wire bus protocol, 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 pullup resistor via the DQ pin when the bus is high. The high bus signal also charges an internal capacitor (C PP),

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 V DD.

Figure 1. DS18B20 Block Diagram

OPERATION—MEASURING TEMPERATURE

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 the1-Wire Bus System section) after the Convert T command and the DS18B20 will respond by transmitting 0 while 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 pullup during the entire temperature conversion. The bus requirements for parasite power are explained in detail in the Powering the DS18B20 section.

Figure 2. Temperature Register Format

Table 1. Temperature/Data Relationship

*The power-on reset value of the temperature register is +85°C.

OPERATION—ALARM SIGNALING

After the DS18B20 performs a temperature conversion, the temperature value is compared to the userdefined two’s complement alarm trigger values stored in the

1-byte T H and T L registers (see Figure 3). The sign bit (S) indicates if the value is positive or negative: for positive numbers S = 0 and for negative numbers S = 1. The T H and T L registers are nonvolatile (EEPROM) so they will retain data when the device is powered down. T H and T L can be accessed through bytes 2 and 3 of the scratchpad as explained in the Memory section.

Figure 3. T H and T L Register Format

Only bits 11 through 4 of the temperature register are used in the T H and T L comparison since T H and T L are 8-bit registers. If the measured temperature is lower than or equal to T L or higher than or equal to T H,an alarm condition exists and an alarm flag is set inside the DS18B20. This flag is updated after every temperature measurement; therefore, if the alarm condition goes away, the flag will be turned off after the next temperature conversion.

The master device can check the alarm flag status of all DS18B20s on the bus by issuing an Alarm Search [ECh] command. Any DS18B20s with a set alarm flag will respond to the command, so the master can determine exactly which DS18B20s have experienced an alarm condition. If an alarm condition exists and the T H or T L settings have changed, another temperature conversion should be done to validate the alarm condition.

POWERING THE DS18B20

The DS18B20 can be powered by an external supply on the V DD pin, or it can operate

in “parasite power” mode, which allows the DS18B20 to function without a local external supply. Parasite power is very useful for applications that require remote temperature sensing or that are very space constrained. Figure 1 shows the

DS18B20’s parasite-power control circuitry, which “steals” power from the 1-Wire bus via the DQ pin when the bus is high. The stolen charge powers the DS18B20 while the bus is high, and some of the charge is stored on the parasite power capacitor (C PP) to provide power when the bus is low. When the DS18B20 is used in parasite power mode, the V DD pin must be connected to ground.

In parasite power mode, the 1-Wire bus and C PP can provide sufficient current to the DS18B20 for most operations as long as the specified timing and voltage requirements are met (see the DC Electrical Characteristics and AC Electrical Characteristics). However, when the DS18B20 is performing temperature conversions or copying data from the scratchpad memory to EEPROM, the operating current can be as high as 1.5mA. This current can cause an unacceptable voltage drop across the weak 1-Wire pullup resistor and is more current than can be supplied by

C PP. To assure that the DS18B20 has sufficient supply current, it is necessary to provide a strong pullup on the 1-Wire bus whenever temperature conversions are taking place or data is being copied from the scratchpad to EEPROM. This can be accomplished by using a MOSFET to pull the bus directly to the rail as shown in Figure 4. The 1-Wire bus must be switched to the strong pullup within 10μs (max) after a Convert T [44h] or Copy Scratchpad [48h] command is issued, and the bus must be held high by the pullup for the duration of the conversion (t CONV) or data transfer (t WR = 10ms). No other activity can take place on the 1-Wire bus while the pullup is enabled.

The DS18B20 can also be powered by the conventional method of connecting an external power supply to the V DD pin, as shown in Figure 5. The advantage of this method is that the MOSFET pullup is not required, and the 1-Wire bus is free to carry other traffic during the temperature conversion time.

The use of parasite power is not recommended for temperatures above +100°C since the DS18B20 may not be able to sustain communications due to the higher leakage currents that can exist at these temperatures. For applications in which such temperatures are likely, it is strongly recommended that the DS18B20 be powered by an external power supply.

In some situations the bus master may not know whether the DS18B20s on the bus are parasite powered or powered by external supplies. The master needs this information to determine if the strong bus pullup should be used during temperature conversions. To get this information, the master can issue a Skip ROM [CCh] command followed by a Read Power Supply [B4h] command followed by a “read time slot”. During the read time slot, parasite powered DS18B20s will pull the bus low, and externally powered DS18B20s will let the bus remain high. If the bus is pulled low, the master knows that it must supply the strong pullup on the 1-Wire bus during temperature conversions.

Figure 4. Supplying the Parasite-Powered DS18B20 During Temperature Conversions

相关主题