DS18B20温度传感器资料
- 格式:pdf
- 大小:391.50 KB
- 文档页数:27
达拉斯DS18B20半导体可编程分辨率的单总线®数字温度计特征引脚排列l独特的单线接口仅需一个端口引脚进行通讯l每个器件有唯一的64位的序列号存储在内部存储器中l简单的多点分布式测温应用l无需外部器件l可通过数据线供电。
供电范围为3.0V到5.5V。
l测温范围为-55~+125℃(-67~+257℉)l在-10~+85℃范围内精确度为±5℃l温度计分辨率可以被使用者选择为9~12位l最多在750ms内将温度转换为12位数字l用户可定义的非易失性温度报警设置l报警搜索命令识别并标志超过程序限定温度(温度报警条件)的器件l与DS1822兼容的软件l应用包括温度控制、工业系统、消费品、温度计或任何热感测系统引脚说明GND -地DQ -数据I/OVDD -可选电源电压NC -无连接说明DS18B20数字温度计提供9-12位摄氏温度测量而且有一个由高低电平触发的可编程的不因电源消失而改变的报警功能。
DS18B20通过一个单线接口发送或接受信息,因此在中央处理器和DS18B20之间仅需一条连接线(加上地线)。
它的测温范围为-55~+125℃,并且在-10~+85℃精度为±5℃。
除此之外,DS18B20能直接从单线通讯线上汲取能量,除去了对外部电源的需求。
每个DS18B20都有一个独特的64位序列号,从而允许多只DS18B20同时连在一根单线总线上;因此,很简单就可以用一个微控制器去控制很多覆盖在一大片区域的DS18B20。
这一特性在HVAC环境控制、探测建筑物、仪器或机器的温度以及过程监测和控制等方面非常有用。
详细的引脚说明表18引脚SOIC封装* TO-9封装符号说明5 1 GND 接地。
4 2 DQ 数据输入/输出引脚。
对于单线操作:漏极开路。
当工作在寄生电源模式时用来提供电源(建“寄生电源”节)。
3 3 VDD 可选的VDD引脚。
工作与寄生电源模式时VDD必须接地。
*所有上表未提及的引脚都无连接。
DS18B20 单线温度传感器一.特征:●独特的单线接口,只需 1 个接口引脚即可通信●每个设备都有一个唯一的64位串行代码存储在光盘片上●多点能力使分布式温度检测应用得以简化●不需要外部部件●可以从数据线供电,电源电压范围为3.0V至5.5V●测量范围从-55 ° C至+125 ° C(-67 ° F至257 ° F),从-10℃至+85 ° C的精度为0.5 °C●温度计分辨率是用户可选择的9至12位●转换12位数字的最长时间是750ms●用户可定义的非易失性的温度告警设置●告警搜索命令识别和寻址温度在编定的极限之外的器件(温度告警情况)●采用8引脚SO(150mil),8引脚SOP和3引脚TO - 92封装●软件与DS1822兼容●应用范围包括恒温控制工业系统消费类产品温度计或任何热敏系统二.简介该DS18B20的数字温度计提供9至12位的摄氏温度测量,并具有与非易失性用户可编程上限和下限报警功能。
信息单线接口送入 DS1820 或从 DS1820 送出,因此按照定义只需要一条数据线(和地线)与中央微处理器进行通信。
它的测温范围从-55 °C到 +125 ° C,其中从-10 °C至+85 °C可以精确到0.5°C 。
此外,DS18B20可以从数据线直接供电(“寄生电源”),从而消除了供应需要一个外部电源。
每个 DS18B20 的有一个唯一的64位序列码,它允许多个DS18B20s的功能在同一1-巴士线。
因此,用一个微处理器控制大面积分布的许多DS18B20s是非常简单的。
此特性的应用范围包括 HVAC、环境控制、建筑物、设备或机械内的温度检测以及过程监视和控制系统。
三.综述64位ROM存储设备的独特序号。
存贮器包含2个字节的温度寄存器,它存储来自温度传感器的数字输出。
此外,暂存器可以访问的1个字节的上下限温度告警触发器(TH和TL)和1个字节的配置寄存器。
DS18B20是一种单总线数字温度传感器,测试温度范围-55℃-125℃,具有体积小,硬件开销低,抗干扰能力强,精度高的特点。
单总线,意味着没有时钟线,只有一根通信线。
单总线读写数据是靠控制起始时间和采样时间来完成,所以时序要求很严格,这也是DS18B20驱动编程的难点。
一.DS18B20温度传感器1.引脚图2.DS18B20内部结构图主要由2部分组成:64位ROM、9字节暂存器,如图所示。
(1) 64 位ROM。
它的内容是64 位序列号,它可以被看作是该DS18B20 的地址序列码,其作用是使每个DS18B20 都各不相同,这样就可以实现一根总线上挂接多个DS18B20 的目的。
(2) 9字节暂存器包含:温度传感器、上限触发TH高温报警器、下限触发TL低温报警器、高速暂存器、8位CRC产生器。
3.64位ROM结构图8位CRC:是单总线系列器件的编码,DS18B20定义为28H。
48位序列号:是一个唯一的序列号。
8位系列码:由CRC产生器生产,作为ROM中的前56位编码的校验码。
4.9字节暂存器结构图以上是内部9 个字节的暂存单元(包括EEPROM)。
字节0~1 是温度存储器,用来存储转换好的温度。
字节2~3 是用户用来设置最高报警和最低报警值。
这个可以用软件来实现。
字节4 是配置寄存器,用来配置转换精度,让它工作在9~12 位。
字节5~7 保留位。
字节8 CRC校验位。
是64位ROM中的前56位编码的校验码。
由CRC发生器产生。
5.温度寄存器结构图温度寄存器由两个字节组成,分为低8位和高8位。
一共16位。
其中,第0位到第3位,存储的是温度值的小数部分。
第4位到第10位存储的是温度值的整数部分。
第11位到第15位为符号位。
全0表示是正温度,全1表示是负温度。
表格中的数值,如果相应的位为1,表示存在。
如果相应的位为0,表示不存在。
6.配置寄存器精度值:9-bit 0.5℃10-bit 0.25℃11-bit 0.125℃12-bit 0.0625℃7.温度/数据关系注意:如果温度是一个负温度,要将读到的数据减一再取反二.单总线协议1.单总线通信初始化初始化时序包括:主机发出的复位脉冲和从机发出的应答脉冲。
一、DS18B20特点1.单线结构,只需一根信号线和CPU相连。
2. 不需要外部元件,直接输出串行数据。
3. 可不需要外部电源,直接通过信号线供电,电源电压范围为3.3V~5V。
4.测温精度高,测温范围为:一55℃~+125℃,在-10℃~+85℃范围内,精度为±O.5℃。
5.测温分辨率高,当选用12位转换位数时,温度分辨率可达0.0625℃。
6.数字量的转换精度及转换时间可通过简单的编程来控制:9位精度的转换时间为93.75 ms:10位精度的转换时间187.5ms:12位精度的转换时间750ms。
7.具有非易失性上、下限报警设定的功能,用户可方便地通过编程修改上、下限的数值。
8.可通过报警搜索命令识别哪片DS18820采集的温度超越上、下限。
二、DS18B20引脚及管脚功能介绍DS18B20的常用封装有3脚、8脚等几种形式,如图1所示。
各脚含义如下:DQ:数字信号输入/输出端。
GND:电源地端。
VDD:外接供电电源输入端(在寄生电源接线时此脚应接地)。
三、DS18B20内部结构简要介绍:DS18820的内部结构如图3所示:主要有64位光刻ROM、温度传感器、非易失性温度报警触发器TH和TL、配置寄存器等组成。
1.64位光刻ROM是生产厂家给每一个出厂的DS18820命名的产品序列号,可以看作为该器件的地址序列号。
其作用是使每一个出厂的DS18820地址序列号都各不相同,这样,就可以实现一根总线上挂接多个DS18820的目的。
2.DS18820中的温度传感器完成对温度的测量,输出格式为:16位符号扩展的二进制补码。
当测温精度设置为12位时,分辨率为O.0625℃,即O.0625℃/LSB。
其二进制补码格式如图2所示。
其中,S为符号位,S=1,表示温度为负值;S=0,表示温度为正值。
例如+125℃的数字输出为07D0H,-55℃的数字输出为FC90H。
一些温度值对应的数字输出如图4所示。
DS18B20中文资料DS18B20是一种数字温度传感器,采用单总线数据传输协议进行通信。
它能够高精度地测量环境温度,并且具有体积小、价格低廉、使用方便等特点。
本文将介绍DS18B20传感器的原理、特性以及应用场景。
一、传感器原理DS18B20传感器采用基于硅的温度传感技术。
其内部集成了温度传感器、模数转换器等电路,以及一组ROM(只读存储器)和RAM(随机存储器)。
传感器通过感应环境温度引起的半导体温度变化,将温度值转换为数字信号输出。
二、传感器特性1. 高精度:DS18B20传感器具有最高精度为±0.5°C的温度测量能力,适用于对于精度要求较高的应用场景。
2. 大量程:传感器可在-55°C至+125°C的温度范围内进行测量,适用于广泛的温度监测需求。
3. 单总线接口:传感器采用单总线接口进行数据传输,仅需要一根数据线,方便集成和使用。
4. 低功耗:传感器工作时的电源电压范围为3V至5.5V,具有低功耗的特点,适用于需要长时间连续监测温度的场景。
5. 独特的硬件地址:每个DS18B20传感器都有一个独特的64位硬件地址,可以通过该地址进行单独的识别和通信。
三、传感器应用由于DS18B20传感器具有小巧、精确、方便等特点,因此在很多领域得到了广泛应用。
1. 温度监测系统:传感器可以应用于各种温度监测系统,如气象站、冷链物流、温度报警器等。
通过使用多个DS18B20传感器,可以实现对不同位置的温度进行监测和记录。
2. 温度控制系统:传感器可以用于控制温度的系统,例如恒温器、温室控制系统等。
通过实时监测环境温度,并根据需求进行温度控制,可以提供更舒适的生活和工作环境。
3. 工业自动化:在工业环境中,温度监测也是很重要的一项任务。
DS18B20传感器可以与PLC、SCADA等系统集成,用于工业自动化控制和监测。
4. 物联网应用:随着物联网的发展,温度传感器在物联网应用中的需求越来越大。
单总线温度传感器DS18B20简介DS18B20是DALLAS公司生产的单总线式数字温度传感器,它具有微型化、低功耗、高性能、搞干扰能力强、易配处理器等优点,特别适用于构成多点温度测控系统,可直接将温度转化成串行数字信号(提供9位二进制数字)给单片机处理,且在同一总线上可以挂接多个传感器芯片。
它具有3引脚TO-92小体积封装形式,温度测量范围为-55℃~+125℃,可编程为9位~12位A/D转换精度,测温分辨率可达0.0625℃,被测温度用符号扩展的16位数字量方式串行输出,其工作电源既可在远端引入,也可采用寄生电源方式产生,多个DS18B20可以并联到3根或2根线上,CPU只需一根端口线就能与多个DS18B20通信,占用微处理器的端口较少,可节省大量的引线和逻辑电路。
以上特点使DS18B20非常适用于远距离多点温度检测系统。
DS18B20外形及引脚说明外形及引脚如图2所示:图2 管脚排列图在TO-92和SO-8的封装中引脚有所不同,具体差别请查阅PDF手册,在TO-92封装中引脚分配如下:1(GND):地2(DQ):单线运用的数据输入输出引脚3(VDD):可选的电源引脚DS18B20工作过程及时序DS18B20内部的低温度系数振荡器是一个振荡频率随温度变化很小的振荡器,为计数器1提供一频率稳定的计数脉冲。
高温度系数振荡器是一个振荡频率对温度很敏感的振荡器,为计数器2提供一个频率随温度变化的计数脉冲。
初始时,温度寄存器被预置成-55℃,每当计数器1从预置数开始减计数到0时,温度寄存器中寄存的温度值就增加1℃,这个过程重复进行,直到计数器2计数到0时便停止。
初始时,计数器1预置的是与-55℃相对应的一个预置值。
以后计数器1每一个循环的预置数都由斜率累加器提供。
为了补偿振荡器温度特性的非线性性,斜率累加器提供的预置数也随温度相应变化。
计数器1的预置数也就是在给定温度处使温度寄存器寄存值增加1℃计数器所需要的计数个数。
ds18b20中文资料介绍DS18B20是一种数字温度传感器,由Maxim Integrated公司设计和制造。
它采用单总线接口和独特的数字编码技术,可直接测量环境温度。
DS18B20的小尺寸、低功耗和数字接口使其成为智能设备、电子设备和工业自动化等领域中广泛应用的理想选择。
特点1.单总线接口:DS18B20通过单一的总线进行数据传输和通信。
这种设计简化了电路连接,降低了硬件成本。
2.数字编码技术:DS18B20使用独特的数字编码技术将温度信息转换为12位二进制数据。
这种方式大大提高了测量的准确性和稳定性。
3.多种封装:DS18B20可提供不同的封装形式,包括TO-92,SOT-223和TDFN等,以适应不同的应用场景。
4.宽工作温度范围:DS18B20可在-55°C至+125°C的温度范围内工作,适应各种极端环境。
5.低功耗:DS18B20在测量温度时,功耗非常低,这对于电池供电的应用非常重要。
电气特性DS18B20的电气特性如下:•输入电压:3V至5.5V•测量范围:-55°C至+125°C•分辨率:可配置为9到12位•精度:±0.5°C(-10°C至+85°C范围内)•电流消耗:750μA(测量),千分之一微安(静态)•输出模式:数字•温度转换时间:750ms至10ms,取决于分辨率•封装形式:TO-92、SOT-223、TDFN等应用DS18B20广泛应用于以下领域:1.温度监控系统:DS18B20可以用于实时监测环境温度,例如室内温度、水温、土壤温度等。
这在农业、工业和家庭自动化等领域非常有用。
2.智能家居:DS18B20可用于智能恒温控制系统,通过检测室内温度并自动调节暖气、空调等设备,提供舒适的居住环境。
3.电子设备:DS18B20可用于电子设备的温度监测和保护。
例如,当电子元件过热时,可以触发警报或自动关闭设备以防止损坏。
DS18B20中文资料在现代电子技术领域,温度测量是一项非常重要的任务。
而DS18B20 作为一款常用的数字温度传感器,以其出色的性能和简单的接口,在各种温度测量应用中得到了广泛的应用。
DS18B20 是由美国达拉斯半导体公司(Dallas Semiconductor)推出的一款单线数字温度传感器。
它具有体积小、硬件开销低、抗干扰能力强、精度高等优点。
从外观上看,DS18B20 通常采用小型的TO-92 封装或者SOP 封装,这使得它能够轻松集成到各种电路中,占用极小的空间。
在性能方面,DS18B20 的测量范围非常广泛,从-55℃到+125℃,能够满足大多数实际应用场景的温度测量需求。
其测量精度在-10℃到+85℃范围内可达到 ±05℃,这对于很多对温度精度要求较高的场合来说,是非常出色的表现。
DS18B20 之所以能够在众多温度传感器中脱颖而出,很大程度上得益于其独特的单线接口。
这意味着它只需要一根数据线就可以与微控制器进行通信,大大简化了电路设计和布线工作。
在使用 DS18B20 进行温度测量时,首先需要将其正确连接到微控制器。
通常,将 DS18B20 的数据线连接到微控制器的一个通用输入输出引脚(GPIO)上。
然后,通过微控制器发送特定的指令来启动温度转换,并读取转换后的温度值。
DS18B20 的工作原理基于其内部的温度敏感元件和模数转换电路。
当接收到温度转换指令后,传感器内部的温度敏感元件会感知当前环境温度,并将其转换为对应的数字信号,然后通过单线接口传输给微控制器。
在编程方面,不同的微控制器平台可能会有一些差异,但基本的流程大致相同。
一般来说,需要先初始化单线接口,然后发送复位脉冲和搜索 ROM 指令来识别总线上的 DS18B20 设备。
接着,发送启动温度转换指令,并等待转换完成。
最后,读取转换后的温度数据,并进行相应的处理和显示。
为了确保测量的准确性和稳定性,在实际应用中还需要注意一些问题。
FEATURES Unique 1-Wire interface requires only one port pin for communicationMultidrop capability simplifies distributed temperature sensing applications Requires no external componentsCan be powered from data line. Power supply range is 3.0V to 5.5VZero standby power requiredMeasures temperatures from -55°C to +125°C. Fahrenheit equivalent is -67°F to +257°F±0.5°C accuracy from -10°C to +85°C Thermometer resolution is programmable from 9 to 12 bitsConverts 12-bit temperature to digital word in 750 ms (max.)User-definable, nonvolatile temperature alarm settingsAlarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)Applications include thermostatic controls,industrial systems, consumer products,thermometers, or any thermally sensitive systemPIN ASSIGNMENTPIN DESCRIPTIONGND - Ground DQ - Data In/OutV DD - Power Supply Voltage NC- No ConnectDESCRIPTIONThe DS18B20 Digital Thermometer provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device.Information is sent to/from the DS18B20 over a 1-Wire interface, so that only one wire (and ground)needs to be connected from a central microprocessor to a DS18B20. Power for reading, writing, and performing temperature conversions can be derived from the data line itself with no need for an external power source.Because each DS18B20 contains a unique silicon serial number, multiple DS18B20s can exist on the same 1-Wire bus. This allows for placing temperature sensors in many different places. Applications where this feature is useful include HVAC environmental controls, sensing temperatures inside buildings,equipment or machinery, and process monitoring and control.DS18B20Programmable Resolution 1-Wire ®Digital ThermometerG N D D Q V DDDS18B20 To-92PackageNC NC NC GNDNC NCV DD DQDS18B20Z8-Pin SOIC (150 mil)DETAILED PIN DESCRIPTION Table 1PIN8PIN SOICPINTO92SYMBOL DESCRIPTION51GND Ground.42DQ Data Input/Output pin. For 1-Wire operation: Opendrain. (See “Parasite Power” section.)33V DD Optional V DD pin. See “Parasite Power” section fordetails of connection. V DD must be grounded foroperation in parasite power mode.DS18B20Z (8-pin SOIC): All pins not specified in this table are not to be connected.OVERVIEWThe block diagram of Figure 1 shows the major components of the DS18B20. The DS18B20 has four main data components: 1) 64-bit lasered ROM, 2) temperature sensor, 3) nonvolatile temperature alarm triggers TH and TL, and 4) a configuration register. The device derives its power from the 1-Wire communication line by storing energy on an internal capacitor during periods of time when the signal line is high and continues to operate off this power source during the low times of the 1-Wire line until it returns high to replenish the parasite (capacitor) supply. As an alternative, the DS18B20 may also be powered from an external 3 volt - 5.5 volt supply.Communication to the DS18B20 is via a 1-Wire port. With the 1-Wire port, the memory and control functions will not be available before the ROM function protocol has been established. The master must first provide one of five ROM function commands: 1) Read ROM, 2) Match ROM, 3) Search ROM, 4) Skip ROM, or 5) Alarm Search. These commands operate on the 64-bit lasered ROM portion of each device and can single out a specific device if many are present on the 1-Wire line as well as indicate to the bus master how many and what types of devices are present. After a ROM function sequence has been successfully executed, the memory and control functions are accessible and the master may then provide any one of the six memory and control function commands.One control function command instructs the DS18B20 to perform a temperature measurement. The result of this measurement will be placed in the DS18B20’s scratch-pad memory, and may be read by issuing a memory function command which reads the contents of the scratchpad memory. The temperature alarm triggers TH and TL consist of 1 byte EEPROM each. If the alarm search command is not applied to the DS18B20, these registers may be used as general purpose user memory. The scratchpad also contains a configuration byte to set the desired resolution of the temperature to digital conversion. Writing TH, TL, and the configuration byte is done using a memory function command. Read access to these registers is through the scratchpad. All data is read and written least significant bit first.DS18B20 BLOCK DIAGRAM Figure 1PARASITE POWERThe block diagram (Figure 1) shows the parasite-powered circuitry. This circuitry “steals” power whenever the DQ or V DD pins are high. DQ will provide sufficient power as long as the specified timing and voltage requirements are met (see the section titled “1-Wire Bus System”). The advantages of parasite power are twofold: 1) by parasiting off this pin, no local power source is needed for remote sensing of temperature, and 2) the ROM may be read in absence of normal power.In order for the DS18B20 to be able to perform accurate temperature conversions, sufficient power must be provided over the DQ line when a temperature conversion is taking place. Since the operating current of the DS18B20 is up to 1.5 mA, the DQ line will not have sufficient drive due to the 5k pullup resistor.This problem is particularly acute if several DS18B20s are on the same DQ and attempting to convert simultaneously.There are two ways to assure that the DS18B20 has sufficient supply current during its active conversion cycle. The first is to provide a strong pullup on the DQ line whenever temperature conversions or copies to the E 2 memory are taking place. This may be accomplished by using a MOSFET to pull the DQ line directly to the power supply as shown in Figure 2. The DQ line must be switched over to the strong pull-up within 10 µs maximum after issuing any protocol that involves copying to the E 2 memory or initiates temperature conversions. When using the parasite power mode, the V DD pin must be tied to ground.Another method of supplying current to the DS18B20 is through the use of an external power supply tied to the V DD pin, as shown in Figure 3. The advantage to this is that the strong pullup is not required on the DQ line, and the bus master need not be tied up holding that line high during temperature conversions.This allows other data traffic on the 1-Wire bus during the conversion time. In addition, any number of DS18B20s may be placed on the 1-Wire bus, and if they all use external power, they may all simultaneously perform temperature conversions by issuing the Skip ROM command and then issuing the Convert T command. Note that as long as the external power supply is active, the GND pin may not be floating.The use of parasite power is not recommended above 100°C, since it may not be able to sustain communications given the higher leakage currents the DS18B20 exhibits at these temperatures. For applications in which such temperatures are likely, it is strongly recommended that V DD be applied to the DS18B20.DQVFor situations where the bus master does not know whether the DS18B20s on the bus are parasite powered or supplied with external V DD, a provision is made in the DS18B20 to signal the power supply scheme used. The bus master can determine if any DS18B20s are on the bus which require the strong pullup by sending a Skip ROM protocol, then issuing the read power supply command. After this command is issued, the master then issues read time slots. The DS18B20 will send back “0” on the 1-Wire bus if it is parasite powered; it will send back a “1” if it is powered from the V DD pin. If the master receives a “0,” it knows that it must supply the strong pullup on the DQ line during temperature conversions. See “Memory Command Functions” section for more detail on this command protocol. STRONG PULLUP FOR SUPPLYING DS18B20 DURING TEMPERATURE CONVERSION Figure 2USING V DD TO SUPPLY TEMPERATURE CONVERSION CURRENT Figure 3TO OTHER 1-WIRE DEVICESOPERATION - MEASURING TEMPERATUREThe core functionality of the DS18B20 is its direct-to-digital temperature sensor. The resolution of the DS18B20 is configurable (9, 10, 11, or 12 bits), with 12-bit readings the factory default state. This equates to a temperature resolution of 0.5°C, 0.25°C, 0.125°C, or 0.0625°C. Following the issuance of the Convert T [44h] command, a temperature conversion is performed and the thermal data is stored in the scratchpad memory in a 16-bit, sign-extended two’s complement format. The temperature information can be retrieved over the 1-Wire interface by issuing a Read Scratchpad [BEh] command once the conversion has been performed. The data is transferred over the 1-Wire bus, LSB first. The MSB of the temperature register contains the “sign” (S) bit, denoting whether the temperature is positive or negative.Table 2 describes the exact relationship of output data to measured temperature. The table assumes 12-bit resolution. If the DS18B20 is configured for a lower resolution, insignificant bits will contain zeros. For Fahrenheit usage, a lookup table or conversion routine must be used.Temperature/Data Relationships Table 2232221202-12-22-32-4LSBMSb(unit = °C)LSbS S S S S262524MSBTEMPERATURE DIGITAL OUTPUT(Binary)DIGITAL OUTPUT (Hex)+125°C0000 0111 1101 000007D0h+85°C0000 0101 0101 00000550h*+25.0625°C0000 0001 1001 00010191h+10.125°C0000 0000 1010 001000A2h+0.5°C0000 0000 0000 10000008h0°C0000 0000 0000 00000000h-0.5°C1111 1111 1111 1000FFF8h-10.125°C1111 1111 0101 1110FF5Eh-25.0625°C1111 1110 0110 1111FF6Fh-55°C1111 1100 1001 0000FC90h*The power on reset register value is +85°C.OPERATION - ALARM SIGNALINGAfter the DS18B20 has performed a temperature conversion, the temperature value is compared to the trigger values stored in TH and TL. Since these registers are 8-bit only, bits 9-12 are ignored for comparison. The most significant bit of TH or TL directly corresponds to the sign bit of the 16-bit temperature register. If the result of a temperature measurement is higher than TH or lower than TL, an alarm flag inside the device is set. This flag is updated with every temperature measurement. As long as the alarm flag is set, the DS18B20 will respond to the alarm search command. This allows many DS18B20s to be connected in parallel doing simultaneous temperature measurements. If somewhere the temperature exceeds the limits, the alarming device(s) can be identified and read immediately without having to read non-alarming devices.64-BIT LASERED ROMEach DS18B20 contains a unique ROM code that is 64-bits long. The first 8 bits are a 1-Wire family code (DS18B20 code is 28h). The next 48 bits are a unique serial number. The last 8 bits are a CRC of the first 56 bits. (See Figure 4.) The 64-bit ROM and ROM Function Control section allow the DS18B20 to operate as a 1-Wire device and follow the 1-Wire protocol detailed in the section “1-Wire Bus System.” The functions required to control sections of the DS18B20 are not accessible until the ROM function protocol has been satisfied. This protocol is described in the ROM function protocol flowchart (Figure 5). The 1-Wire bus master must first provide one of five ROM function commands: 1) Read ROM, 2) Match ROM, 3) Search ROM, 4) Skip ROM, or 5) Alarm Search. After a ROM function sequence has been successfully executed, the functions specific to the DS18B20 are accessible and the bus master may then provide one of the six memory and control function commands.CRC GENERATIONThe DS18B20 has an 8-bit CRC stored in the most significant byte of the 64-bit ROM. The bus master can compute a CRC value from the first 56-bits of the 64-bit ROM and compare it to the value stored within the DS18B20 to determine if the ROM data has been received error-free by the bus master. The equivalent polynomial function of this CRC is:CRC = X8 + X5 + X4 + 1The DS18B20 also generates an 8-bit CRC value using the same polynomial function shown above and provides this value to the bus master to validate the transfer of data bytes. In each case where a CRC is used for data transfer validation, the bus master must calculate a CRC value using the polynomial function given above and compare the calculated value to either the 8-bit CRC value stored in the 64-bit ROM portion of the DS18B20 (for ROM reads) or the 8-bit CRC value computed within the DS18B20 (which is read as a ninth byte when the scratchpad is read). The comparison of CRC values and decision to continue with an operation are determined entirely by the bus master. There is no circuitry inside the DS18B20 that prevents a command sequence from proceeding if the CRC stored in or calculated by the DS18B20 does not match the value generated by the bus master.The 1-Wire CRC can be generated using a polynomial generator consisting of a shift register and XOR gates as shown in Figure 6. Additional information about the Dallas 1-Wire Cyclic Redundancy Check is available in Application Note 27 entitled “Understanding and Using Cyclic Redundancy Checks with Dallas Semiconductor Touch Memory Products.”The shift register bits are initialized to 0. Then starting with the least significant bit of the family code, 1 bit at a time is shifted in. After the 8th bit of the family code has been entered, then the serial number is entered. After the 48th bit of the serial number has been entered, the shift register contains the CRC value. Shifting in the 8 bits of CRC should return the shift register to all 0s.64-BIT LASERED ROM Figure 48-BIT CRC CODE48-BIT SERIAL NUMBER 8-BIT FAMILY CODE(28h)MSB LSB MSB LSB MSB LSBROM FUNCTIONS FLOW CHART Figure 51-WIRE CRC CODE Figure 6MEMORYThe DS18B20’s memory is organized as shown in Figure 8. The memory consists of a scratchpad RAM and a nonvolatile, electrically erasable (E 2) RAM, which stores the high and low temperature triggers TH and TL, and the configuration register. The scratchpad helps insure data integrity when communicating over the 1-Wire bus. Data is first written to the scratchpad using the Write Scratchpad [4Eh] command.It can then be verified by using the Read Scratchpad [BEh] command. After the data has been verified, a Copy Scratchpad [48h] command will transfer the data to the nonvolatile (E 2) RAM. This process insures data integrity when modifying memory. The DS18B20 EEPROM is rated for a minimum of 50,000writes and 10 years data retention at T = +55°C.The scratchpad is organized as eight bytes of memory. The first 2 bytes contain the LSB and the MSB of the measured temperature information, respectively. The third and fourth bytes are volatile copies of TH and TL and are refreshed with every power-on reset. The fifth byte is a volatile copy of the configuration register and is refreshed with every power-on reset. The configuration register will be explained in more detail later in this section of the datasheet. The sixth, seventh, and eighth bytes are used for internal computations, and thus will not read out any predictable pattern.It is imperative that one writes TH, TL, and config in succession; i.e. a write is not valid if one writes only to TH and TL, for example, and then issues a reset. If any of these bytes must be written, all three must be written before a reset is issued.There is a ninth byte which may be read with a Read Scratchpad [BEh] command. This byte contains a cyclic redundancy check (CRC) byte which is the CRC over all of the eight previous bytes. This CRC is implemented in the fashion described in the section titled “CRC Generation”.Configuration RegisterThe fifth byte of the scratchpad memory is the configuration register.It contains information which will be used by the device to determine the resolution of the temperature to digital conversion. The bits are organized as shown in Figure 7.DS18B20 CONFIGURATION REGISTER Figure 70R1R011111MSbLSbBits 0-4 are don’t cares on a write but will always read out “1”.Bit 7 is a don’t care on a write but will always read out “0”.R0, R1: Thermometer resolution bits. Table 3 below defines the resolution of the digital thermometer,based on the settings of these 2 bits. There is a direct tradeoff between resolution and conversion time, as depicted in the AC Electrical Characteristics. The factory default of these EEPROM bits is R0=1 and R1=1 (12-bit conversions).Thermometer Resolution Configuration Table 3R1R0Thermometer Resolution Max ConversionTime009 bit 93.75 ms (t conv/8)0110 bit 187.5 ms (t conv /4)1011 bit 375 ms (t conv /2)1112 bit750 ms (t conv )DS18B20 MEMORY MAP Figure 8SCRATCHPADBYTE012345678E 2RAM1-WIRE BUS SYSTEMThe 1-Wire bus is a system which has a single bus master and one or more slaves. The DS18B20 behaves as a slave. The discussion of this bus system is broken down into three topics: hardware configuration, transaction sequence, and 1-Wire signaling (signal types and timing).HARDWARE CONFIGURATIONThe 1-Wire bus has only a single line by definition; it is important that each device on the bus be able to drive it at the appropriate time. To facilitate this, each device attached to the 1-Wire bus must have open drain or 3-state outputs. The 1-Wire port of the DS18B20 (DQ pin) is open drain with an internal circuit equivalent to that shown in Figure 9. A multidrop bus consists of a 1-Wire bus with multiple slaves attached. The 1-Wire bus requires a pullup resistor of approximately 5 kΩ.HARDWARE CONFIGURATION Figure 9The idle state for the 1-Wire bus is high. If for any reason a transaction needs to be suspended, the bus MUST be left in the idle state if the transaction is to resume. Infinite recovery time can occur between bits so long as the 1-Wire bus is in the inactive (high) state during the recovery period. If this does not occur and the bus is left low for more than 480 µs, all components on the bus will be reset. TRANSACTION SEQUENCEThe protocol for accessing the DS18B20 via the 1-Wire port is as follows:InitializationROM Function CommandMemory Function CommandTransaction/DataINITIALIZATIONAll 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 by presence pulse(s) transmitted by the slave(s).The presence pulse lets the bus master know that the DS18B20 is on the bus and is ready to operate. For more details, see the “1-Wire Signaling” section.ROM FUNCTION COMMANDSOnce the bus master has detected a presence, it can issue one of the five ROM function commands. All ROM function commands are 8 bits long. A list of these commands follows (refer to flowchart in Figure 5):Read ROM [33h]This command allows the bus master to read the DS18B20’s 8-bit family code, unique 48-bit serial number, and 8-bit CRC. This command can only be used if there is a single DS18B20 on the bus. If more than one slave is present on the bus, a data collision will occur when all slaves try to transmit at the same time (open drain will produce a wired AND result).Match ROM [55h]The match ROM command, followed by a 64-bit ROM sequence, allows the bus master to address a specific DS18B20 on a multidrop bus. Only the DS18B20 that exactly matches the 64-bit ROM sequence will respond to the following memory function command. All slaves that do not match the 64-bit ROM sequence will wait for a reset pulse. This command can be used with a single or multiple devices on the bus.Skip ROM [CCh]This command can save time in a single drop bus system by allowing the bus master to access the memory functions without providing the 64-bit ROM code. If more than one slave is present on the bus and a Read command is issued following the Skip ROM command, data collision will occur on the bus as multiple slaves transmit simultaneously (open drain pulldowns will produce a wired AND result). Search ROM [F0h]When a system is initially brought up, the bus master might not know the number of devices on the 1-Wire bus or their 64-bit ROM codes. The search ROM command allows the bus master to use a process of elimination to identify the 64-bit ROM codes of all slave devices on the bus.Alarm Search [ECh]The flowchart of this command is identical to the Search ROM command. However, the DS18B20 will respond to this command only if an alarm condition has been encountered at the last temperature measurement. An alarm condition is defined as a temperature higher than TH or lower than TL. The alarm condition remains set as long as the DS18B20 is powered up, or until another temperature measurement reveals a non-alarming value. For alarming, the trigger values stored in EEPROM are taken into account. If an alarm condition exists and the TH or TL settings are changed, another temperature conversion should be done to validate any alarm conditions.Example of a ROM SearchThe ROM search process is the repetition of a simple three-step routine: read a bit, read the complement of the bit, then write the desired value of that bit. The bus master performs this simple, three-step routine on each bit of the ROM. After one complete pass, the bus master knows the contents of the ROM in one device. The remaining number of devices and their ROM codes may be identified by additional passes.The following example of the ROM search process assumes four different devices are connected to the same 1-Wire bus. The ROM data of the four devices is as shown:ROM100110101...ROM210101010...ROM311110101...ROM400010001...The search process is as follows:1.The bus master begins the initialization sequence by issuing a reset pulse. The slave devices respondby issuing simultaneous presence pulses.2.The bus master will then issue the Search ROM command on the 1-Wire bus.3.The bus master reads a bit from the 1-Wire bus. Each device will respond by placing the value of thefirst bit of their respective ROM data onto the 1-Wire bus. ROM1 and ROM4 will place a 0 onto the 1-Wire bus, i.e., pull it low. ROM2 and ROM3 will place a 1 onto the 1-Wire bus by allowing the line to stay high. The result is the logical AND of all devices on the line, therefore the bus master sees a 0. The bus master reads another bit. Since the Search ROM data command is being executed, all of the devices on the 1-Wire bus respond to this second read by placing the complement of the first bit of their respective ROM data onto the 1-Wire bus. ROM1 and ROM4 will place a 1 onto the 1-Wire, allowing the line to stay high. ROM2 and ROM3 will place a 0 onto the 1-Wire, thus it will be pulled low. The bus master again observes a 0 for the complement of the first ROM data bit. The bus master has determined that there are some devices on the 1-Wire bus that have a 0 in the first position and others that have a 1.The data obtained from the two reads of the three-step routine have the following interpretations:00There are still devices attached which have conflicting bits in this position.01All devices still coupled have a 0-bit in this bit position.10All devices still coupled have a 1-bit in this bit position.11There are no devices attached to the 1-Wire bus.4.The bus master writes a 0. This deselects ROM2 and ROM3 for the remainder of this search pass,leaving only ROM1 and ROM4 connected to the 1-Wire bus.5.The bus master performs two more reads and receives a 0-bit followed by a 1-bit. This indicates thatall devices still coupled to the bus have 0s as their second ROM data bit.6.The bus master then writes a 0 to keep both ROM1 and ROM4 coupled.7.The bus master executes two reads and receives two 0-bits. This indicates that both 1-bits and 0-bitsexist as the 3rd bit of the ROM data of the attached devices.8.The bus master writes a 0-bit. This deselects ROM1, leaving ROM4 as the only device stillconnected.9.The bus master reads the remainder of the ROM bits for ROM4 and continues to access the part ifdesired. This completes the first pass and uniquely identifies one part on the 1-Wire bus.10.The bus master starts a new ROM search sequence by repeating steps 1 through 7.11.The bus master writes a 1-bit. This decouples ROM4, leaving only ROM1 still coupled.12.The bus master reads the remainder of the ROM bits for ROM1 and communicates to the underlyinglogic if desired. This completes the second ROM search pass, in which another of the ROMs was found.13.The bus master starts a new ROM search by repeating steps 1 through 3.14.The bus master writes a 1-bit. This deselects ROM1 and ROM4 for the remainder of this search pass,leaving only ROM2 and ROM3 coupled to the system.15.The bus master executes two Read time slots and receives two 0s.16.The bus master writes a 0-bit. This decouples ROM3 leaving only ROM2.17.The bus master reads the remainder of the ROM bits for ROM2 and communicates to the underlyinglogic if desired. This completes the third ROM search pass, in which another of the ROMs was found.18.The bus master starts a new ROM search by repeating steps 13 through 15.19.The bus master writes a 1-bit. This decouples ROM2, leaving only ROM3.20.The bus master reads the remainder of the ROM bits for ROM3 and communicates to the underlyinglogic if desired. This completes the fourth ROM search pass, in which another of the ROMs was found.NOTE:The bus master learns the unique ID number (ROM data pattern) of one 1-Wire device on each ROM Search operation. The time required to derive the part’s unique ROM code is:960 µs + (8 + 3 x 64) 61 µs = 13.16 msThe bus master is therefore capable of identifying 75 different 1-Wire devices per second.I/O SIGNALINGThe DS18B20 requires strict protocols to insure data integrity. The protocol consists of several types of signaling on one line: reset pulse, presence pulse, write 0, write 1, read 0, and read 1. All of these signals, with the exception of the presence pulse, are initiated by the bus master.The initialization sequence required to begin any communication with the DS18B20 is shown in Figure 11. A reset pulse followed by a presence pulse indicates the DS18B20 is ready to send or receive data given the correct ROM command and memory function command.The bus master transmits (TX) a reset pulse (a low signal for a minimum of 480 µs). The bus master then releases the line and goes into a receive mode (RX). The 1-Wire bus is pulled to a high state via the 5k pullup resistor. After detecting the rising edge on the DQ pin, the DS18B20 waits 15-60 µs and then transmits the presence pulse (a low signal for 60-240 µs).MEMORY COMMAND FUNCTIONSThe following command protocols are summarized in Table 4, and by the flowchart of Figure 10.Write Scratchpad [4Eh]This command writes to the scratchpad of the DS18B20, starting at the TH register. The next 3 bytes written will be saved in scratchpad memory at address locations 2 through 4. All 3 bytes must be written before a reset is issued.Read Scratchpad [BEh]This command reads the contents of the scratchpad. Reading will commence at byte 0 and will continue through the scratchpad until the ninth (byte 8, CRC) byte is read. If not all locations are to be read, the master may issue a reset to terminate reading at any time.Copy Scratchpad [48h]This command copies the scratchpad into the E2memory of the DS18B20, storing the temperature trigger bytes in nonvolatile memory. If the bus master issues read time slots following this command, the DS18B20 will output 0 on the bus as long as it is busy copying the scratchpad to E2; it will return a 1 when the copy process is complete. If parasite-powered, the bus master has to enable a strong pullup for at least 10 ms immediately after issuing this command. The DS18B20 EEPROM is rated for a minimum of 50,000 writes and 10 years data retention at T=+55°C.Convert T [44h]This command begins a temperature conversion. No further data is required. The temperature conversion will be performed and then the DS18B20 will remain idle. If the bus master issues read time slots following this command, the DS18B20 will output 0 on the bus as long as it is busy making a temperature conversion; it will return a 1 when the temperature conversion is complete. If parasite-powered, the bus master has to enable a strong pullup for a period greater than t conv immediately after issuing this command.Recall E2 [B8h]This command recalls the temperature trigger values and configuration register stored in E2 to the scratchpad. This recall operation happens automatically upon power-up to the DS18B20 as well, so valid data is available in the scratchpad as soon as the device has power applied. With every read data time slot issued after this command has been sent, the device will output its temperature converter busy flag: 0=busy, 1=ready.Read Power Supply [B4h]With every read data time slot issued after this command has been sent to the DS18B20, the device will signal its power mode: 0=parasite power, 1=external power supply provided.。