DS18b20温度传感器
第31课温度传感器DS18B20详解
![第31课温度传感器DS18B20详解](https://img.taocdn.com/s3/m/346a9247ba68a98271fe910ef12d2af90242a8b5.png)
实验现象
通过对DS18B20的控制,读取出DS18B20所采集的温度数据并在 数码管的第4、5、6、7位进行显示,温度精确到小数点后一位。
显示方式为:020.5(温度为正)或-10.4(温度为负)。
DS18B20的命令
ROM操作命令
(1)读ROM--33H (2)匹配ROM--55H (3)跳过ROM--CC
功能命令
(1)写暂存寄存器命令--4EH (2)读暂存寄存器指令--BEH (3)复制暂存寄存器命令—48H (4)启动温度转换命令—44H (5)回传EEPROM内容指令--B8H (6)读电源类型指令--B4H
如何用DS18B20来采集温度
访问一个DS18B20必须经过初始化、ROM命令和功能命令这三个步骤 。 单个DS18B20发命令顺序 第一步: DS18B20初始化----跳过ROM命令(CCH)----启动温度转换命令(44H) 第二步: DS18B20初始化----跳过ROM命令(CCH)----读暂存寄存器指令(BEH)
DS18B20简介
DS18B20是DALLS公司推出的“1-WIRE”接口的 数字温度传感器,可以直接将温度转换为9~12位串行 数字信号供单片机处理。它具有体积小、功耗低、精度 高、抗干扰能力强等优点。
DS18B20引脚和封装
DS18B20的内部结构
DS18B20当分辨率为9,10,11,和12位时,分别对应与0.5℃, 0.25℃,0.125℃,0.0625℃的温度增量
DS18B20写数据时序图分析
①首先给DQ赋值低电平。 ②延时确定时间15us。 ③对DQ赋值,向DS18B20写入相应的高低 电平。 ④再延时时间为45us。 ⑤最后给DQ置高电平。
DS18B20读数据时序分析
DS18B20温度传感器
![DS18B20温度传感器](https://img.taocdn.com/s3/m/8590d3493a3567ec102de2bd960590c69ec3d8be.png)
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
![智能数字温度传感器DS18B20](https://img.taocdn.com/s3/m/8f1eeea21a37f111f1855b8b.png)
智能数字温度传感器DS18B20
由美国dallas 半导体公司生产的ds18b20型单线智能温度传感器,属于新一代适配微处理器的智能温度传感器,可把温度信号直接转换成串行数字信号供微机处理。
采用严格的焊接及封装等工艺,芯片每个引脚均用热缩管隔开,防止短路,内部封胶,防水防潮提高了测量精度,延长了使用寿命。
产品应用
1 该产品适用于冷冻库,粮仓,储罐,电讯机房,电力机房,电缆线槽等测温和控制领域.
2 轴瓦,缸体,纺机,空调,等狭小空间工业设备测温和控制。
3 汽车空调、冰箱、冷柜、以及中低温干燥箱等。
4 供热/制冷管道热量计量,中央空调分户热能计量和工业领域测温和控制.
5 冷藏库温度监测、药厂GMP 监测系统、电信机房监控、啤酒生产、楼宇自控、仓库温度监测、环境监测、过程温度监测、空调监测、孵化温度控制、养殖业温度测量、温室大棚温度监测、家用冰箱、温度报警器、温度监控系统等。
参数介绍
工作电源电压(V )
DC 3~5V 测温分辨率(%)
+0.006% 工作温度范围(℃)
-55℃~ +125℃ 测量数据传送方式
9~12位数字量串行传送 输出线连接方式
黑色:GND 黄色:DATA 红色:VDD+
线长
1米 探头尺寸
不锈钢探头6*50mm ;线耳传感器;M10*1.5mm 螺纹传感器
线耳传感器螺纹传感器
深圳嘉智捷电子技术有限公司是一家以产品研发,生产加工,销售为服务的技术型公司,拥有完整、科学的质量管理体系,主要产品有温度报警器、温湿度报警器、综合报警设备、传感器、语音拨号器等。
深圳嘉智捷电子技术有限公司以诚信、实力和产品质量获得业界的认可。
欢迎各界朋友莅临参观、指导和业务洽谈。
温度传感器DS18B20中文资料
![温度传感器DS18B20中文资料](https://img.taocdn.com/s3/m/55b07032b90d6c85ec3ac6a0.png)
以 0.5 的增量值 在 0.5 至+125 的范围内测量温度 对于应用华氏温度的场合 必须使用查
找表或变换系数
注意 在 DS1820 中 温度是以 1/2 LSB 最低有效位 形式表示时 产生以下 9 位格式
MSB 最高有效位 1
最低有效位 LSB 11001110
= -25 最高有效 符号 位被复制到存储器内两字节的温度寄存器中较高 MSB 的所有位 这种 符号扩展
4
PD om
PD om
er ww
er ww
F-XChange View !
Click to buy NOW
w.docu-track.c
TARGETECH®
DS1820
F-XChange View !
Click to buy NOW
w.docu-track.c
图 3 使用 VDD 提供温度变换所需电流
钭率累加器用于补偿振荡器温度特性的非线性 以产生高分辩率的温度测量 通过改变温度每 升高一度 计数器必须经历的计数个数来实行补偿 因此 为了获得所需的分辩率 计数器的数值
5
PD om
PD om
er ww
er ww
F-XChange View !
Click to buy NOW
w.docu-track.c
Click to buy NOW
w.docu-track.c
到这一点 当使用寄生电源方式时 VDD 引脚必须连接到地 向 DS1820 供电的另外一种方法是通过使用连接到 VDD 引脚的外部电源 如图 3 所示 这种方法
的优点是在 I/O 线上不要求强的上拉 总线上主机不需向上连接便在温度变换期间使线保持高电
3
单总线温度传感器DS18B20简介
![单总线温度传感器DS18B20简介](https://img.taocdn.com/s3/m/c9d7388d85868762caaedd3383c4bb4cf7ecb7e5.png)
单总线温度传感器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工作原理](https://img.taocdn.com/s3/m/85a04b4f854769eae009581b6bd97f192279bfe6.png)
ds18b20工作原理
DS18B20温度传感器是一种数字温度传感器,采用"1-wire"
(单总线)接口通信,其工作原理如下:
1. 传感器结构:DS18B20传感器由温度传感器芯片、电源线
和数据线组成。
芯片内部包含温度传感器、模数转换器和存储器。
2. 电源供电:传感器通过电源线从计算机、微控制器或其他设备中获取供电。
传感器的VDD和GND引脚用于供电。
3. 温度测量:传感器使用其内部温度传感器测量环境温度。
当温度变化时,传感器内部的温度传感器会产生电压变化。
4. 模数转换:传感器内部的模数转换器将温度传感器测量到的电压转换为数字信号。
转换后的数字信号可以在数据线上传输。
5. 通信协议:传感器使用1-wire接口协议进行通信。
该协议
允许使用单根数据线进行数据传输。
传感器通过数据线将温度数据发送给主控设备。
6. 数据读取:主控设备发送读取指令给传感器,传感器将温度数据通过数据线返回给主控设备。
主控设备可以通过读取传感器返回的数据来获取环境温度。
总结:DS18B20温度传感器工作原理基于温度传感器芯片和
模数转换器的结构,在供电后,传感器通过测量温度传感器的
电压变化来获取环境温度,并通过1-wire接口协议将温度数据传输给主控设备。
DS18B20温度传感器
![DS18B20温度传感器](https://img.taocdn.com/s3/m/5ebc572be2bd960590c67753.png)
数字温度传感器 DS18B20DS18B20 数字式温度传感器,使用集成芯片,采用单总线技术,其能够有效的减小外界的干扰,提高测量的精度,同时,它可以直接将被测温度转化成串行数字信号供微机处理,接口简单,使数据传输和处理简单化。
部分功能电路的集成,使总体硬件设计更简洁,能有效地降低成本,搭建电路和焊接电路时更快,调试也更方便简单化,这也就缩短了开发的周期。
DS18B20 单线数字温度传感器,即“一线器件”,其具有独特的优点:(1)采用单总线的接口方式与微处理器连接时仅需要一条口线即可实现微处理器与 DS18B20 的双向通讯。
单总线具有经济性好,抗干扰能力强,适合于恶劣环境的现场温度测量,使用方便等优点,使用户可轻松地组建传感器网络,为测量系统的构建引入全新概念。
(2)测量温度范围宽,测量精度高 DS18B20 的测量范围为 -55 ℃ ~+ 125 ℃;在 -10~+ 85°C 范围内,精度为± 0.5°C 。
(3)在使用中不需要任何外围元件。
(4)持多点组网功能多个 DS18B20 可以并联在惟一的三线上,实现多点测温。
(5)供电方式灵活 DS18B20 可以通过内部寄生电路从数据线上获取电源。
因此,当数据线上的时序满足一定的要求时,可以不接外部电源,从而使系统结构更趋简单,可靠性更高。
(6)测量参数可配置 DS18B20 的测量分辨率可通过程序设定 9~12 位。
(7)负压特性电源极性接反时,温度计不会因发热而烧毁,但不能正常工作。
(8)掉电保护功能 DS18B20 内部含有 EEPROM ,在系统掉电以后,它仍可保存分辨率及报警温度的设定值。
DS18B20 具有体积更小、适用电压更宽、更经济、可选更小的封装方式,更宽的电压适用范围,适合于构建自己的经济的测温系统,因此也就被设计者们所青睐。
DS18B20的内部结构DS18B20测温原理:DS18B20 的内部测温电路框图低温度系数晶振的振荡频率受温度的影响很小,用于产生固定频率的脉冲信号送给减法计数器 1 ,为计数器提供一频率稳定的计数脉冲。
DS18B20温度传感器资料
![DS18B20温度传感器资料](https://img.taocdn.com/s3/m/7fadb023482fb4daa58d4bf2.png)
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.。
DS18B20中文资料
![DS18B20中文资料](https://img.taocdn.com/s3/m/e9a2fb4411a6f524ccbff121dd36a32d7375c7f4.png)
DS18B20中文资料在现代电子技术领域,温度测量是一项非常重要的任务。
而DS18B20 作为一款常用的数字温度传感器,以其出色的性能和简单的接口,在各种温度测量应用中得到了广泛的应用。
DS18B20 是由美国达拉斯半导体公司(Dallas Semiconductor)推出的一款单线数字温度传感器。
它具有体积小、硬件开销低、抗干扰能力强、精度高等优点。
从外观上看,DS18B20 通常采用小型的TO-92 封装或者SOP 封装,这使得它能够轻松集成到各种电路中,占用极小的空间。
在性能方面,DS18B20 的测量范围非常广泛,从-55℃到+125℃,能够满足大多数实际应用场景的温度测量需求。
其测量精度在-10℃到+85℃范围内可达到 ±05℃,这对于很多对温度精度要求较高的场合来说,是非常出色的表现。
DS18B20 之所以能够在众多温度传感器中脱颖而出,很大程度上得益于其独特的单线接口。
这意味着它只需要一根数据线就可以与微控制器进行通信,大大简化了电路设计和布线工作。
在使用 DS18B20 进行温度测量时,首先需要将其正确连接到微控制器。
通常,将 DS18B20 的数据线连接到微控制器的一个通用输入输出引脚(GPIO)上。
然后,通过微控制器发送特定的指令来启动温度转换,并读取转换后的温度值。
DS18B20 的工作原理基于其内部的温度敏感元件和模数转换电路。
当接收到温度转换指令后,传感器内部的温度敏感元件会感知当前环境温度,并将其转换为对应的数字信号,然后通过单线接口传输给微控制器。
在编程方面,不同的微控制器平台可能会有一些差异,但基本的流程大致相同。
一般来说,需要先初始化单线接口,然后发送复位脉冲和搜索 ROM 指令来识别总线上的 DS18B20 设备。
接着,发送启动温度转换指令,并等待转换完成。
最后,读取转换后的温度数据,并进行相应的处理和显示。
为了确保测量的准确性和稳定性,在实际应用中还需要注意一些问题。
DS18B20温度传感器资料
![DS18B20温度传感器资料](https://img.taocdn.com/s3/m/d10022a63c1ec5da50e270ff.png)
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个字节的温度寄存器,它存储来自温度传感器的数字输出。
DS18B20温度传感器资料
![DS18B20温度传感器资料](https://img.taocdn.com/s3/m/b9e7c4225f0e7cd18525362e.png)
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温度传感器工作原理
![ds18b20温度传感器工作原理](https://img.taocdn.com/s3/m/3e37d678b80d6c85ec3a87c24028915f804d8421.png)
ds18b20温度传感器工作原理
DS18B20温度传感器是一种数字温度传感器,它基于热电效
应来测量温度。
该传感器由一个精密的温度传感器和一个数字转换器组成。
以下是DS18B20温度传感器的工作原理:
1. 热电效应:DS18B20温度传感器利用热电效应来测量温度。
当两个不同材料的接触点形成温度梯度时,就会产生电动势。
传感器中的温度传感器部分采用的材料对温度变化非常敏感,因此产生的电动势可以反映出温度的变化。
2. 温度传感器:DS18B20温度传感器中的温度传感器部分是
由一个特殊的材料制成的。
该材料具有温度敏感性,当温度变化时,该材料会产生电动势。
这个电动势可以通过传感器的引脚进行读取和转换。
3. 数字转换器:DS18B20温度传感器具有内置的数字转换器。
这个数字转换器可以将从温度传感器获得的电压信号转换为数字信号。
数字信号可以直接读取和处理,而无需进行模拟信号转换。
4. 串行总线通信:DS18B20温度传感器通过一种称为One-
Wire总线的串行通信协议与主控制器进行通信。
传感器和主
控制器之间只需使用单一的数据线进行通信,使得传感器的连接变得简单方便。
总结起来,DS18B20温度传感器工作原理是利用热电效应测
量温度,并通过温度传感器和数字转换器来转换和读取温度信号。
该传感器通过One-Wire总线与主控制器进行通信。
51单片机DS18B20温度传感器原理及实验
![51单片机DS18B20温度传感器原理及实验](https://img.taocdn.com/s3/m/4c71a700a9956bec0975f46527d3240c8447a19a.png)
51单片机DS18B20温度传感器原理及实验一、引言温度传感器是一种常用的传感器器件,它的作用是将物体的温度变化转换为电信号输出,以实现温度的监测和控制。
DS18B20是一种数字温度传感器,采用数字信号输出,具有体积小、精度高、线性度好等特点,被广泛应用于各种温度控制系统中。
本文将介绍DS18B20的工作原理及实验方法。
二、DS18B20的工作原理DS18B20是一种基于一线传输协议的数字温度传感器,其工作原理如下:1.接口电路:DS18B20具有三个引脚,分别是VDD、DQ和GND。
其中,VDD是供电引脚,DQ是数据引脚,GND是地引脚。
2.传感器原理:DS18B20内部包含一个温度传感器和一个数字转换器。
温度传感器采用热敏电阻的原理,通过测量热敏电阻的电阻值来反映物体的温度变化。
数字转换器将传感器测得的电阻值转换为数字信号输出。
三、实验流程以下是使用51单片机对DS18B20温度传感器进行实验的详细流程:1.硬件准备:-将DS18B20的VDD引脚连接到单片机的VCC引脚,DQ引脚连接到单片机的任意IO引脚,GND引脚连接到单片机的GND引脚。
-确保DS18B20的供电电压和单片机的工作电压一致。
2.初始化:-在程序中定义DS18B20的DQ引脚所对应的单片机的IO引脚。
-初始化DS18B20,即发送初始化指令给DS18B20。
3.温度转换:-发送温度转换指令给DS18B20,DS18B20开始测量温度。
-等待一定的延时,确保DS18B20完成温度转换。
4.读取温度:-发送读取温度指令给DS18B20,DS18B20将温度的原始数据发送给单片机。
-单片机通过计算将原始数据转换为温度值。
-温度值可以通过串口或LCD等方式进行显示。
5.循环实验:-以上步骤需要不断重复,以便实时监测温度的变化。
四、总结DS18B20温度传感器是一种常用的数字温度传感器,具有精度高、体积小、线性度好等特点,适用于各种温度控制系统。
温度传感器DS18B20
![温度传感器DS18B20](https://img.taocdn.com/s3/m/6aafd0cd8bd63186bcebbc76.png)
注: (1)温度以补码形式 存放; (2)9位分辨率时, 得到的十进制数乘 以0.5;10位分辨率 乘0.25;11位分辨率 乘0.125
温度/数据关系表
DS18B20的配置寄存器
通过设置配置寄存器的R0、R1来确定精度。
DS18B20的主要部件
1)64位光刻ROM 2)温度灵敏元件 3)非易失性温度告警触发器TH和TL
64位光刻ROM
出厂前被光刻好。 低8位为产品类型号:单线系列编码(DS18B20为 19H) 中间48位为产品唯一的序列号 高8位是前面56位的CRC循环冗余校验码 光刻ROM的作用:使每一个DS18B20各不相同,这 样可以实现一个总线上挂接多个DS18B20。
温度传感器DS18B20
DS18B20器件引脚
DS18B20是美国DALLAS公司推出的第一片支持 “一线总线”接口的温度传感器。 引脚:
八脚贴片式封装
引脚 GND
DQ VDD
定义 电源负极
信号输入输出 电源正极 空
三脚直插式封装
NC
DS18B20的主要特性
独特的单线接口方式,只需一个引脚即可通信 不需要外部元件 可用数据线供电,不需备份电源(寄生电源工作方式) 测温范围:-55 ℃~+125 ℃ 可编程分辨率为9~12位,对应的可分辨温度分别为0.5 ℃、0.25 ℃、0.125 ℃、0.0625 ℃。 内置EEPROM,限温报警功能 64位光刻ROM,内置产品序列号,方便多机挂接 负压特性。电源接反时,芯片不会烧毁,但不能正常工 作
友台半导体有限公司 DS18B20H 单总线温度传感器说明书
![友台半导体有限公司 DS18B20H 单总线温度传感器说明书](https://img.taocdn.com/s3/m/c0762eded1d233d4b14e852458fb770bf68a3b68.png)
特点 ● 单总线接口,节约布线资源● 应用简单,无需额外器件● 转换温度时间500ms● 可编程9~12位数字输出●宽供电电压范围● 每颗芯片有可编程的ID 序列号 ● 用户可自行设置报警值 ● 超强ESD 保护能力(HBM>8000V )● 典型待机电流功耗1µA @3V ●典型换电流功耗0.6mA@3V典型应用● 便携应用,手机与穿戴设备● 温度监控 ●粮情监测● 智能家电系统 ● 水温测量● 建筑、设备或机房内部温度监测系统● 过程监测和控制系统概述是一款高精度的单总线温度测量芯片。
温度传感器的测温范围为-55°C 到+125°C ;根据用户需要通过配置寄存器可以设定数字转换精度和测温速度。
芯片内置4byte 非易失性存储单元供用户使用,2byte 用于高低温报警,另外2byte 用于保存用户自定义信息。
在-10°C 到+85°C 范围内最大误差为±°C 。
用户可自主选择电源供电模式和寄生供电模式。
单总线接口允许多个设备挂在同一总线,该特性使得也非常便于部署分布型温度采集系统。
管脚图和管脚描述34167852GNDDQ VDD MSOP82.5V-5.5V DS18B20H DS18B200.4DS18B20图1 DS18B20框图结构框图图1是DS18B20的原理框图。
64位ROM存储了器件的唯一序列码。
暂存器包含了两个字节的温度寄存器,存储来自于温度传感器的数字输出。
另外,暂存器提供了一高一低两个报警触发阈值寄存器(TH和TL)。
配置寄存器允许用户设定温度数字转换的分辨率为9,10,11或12位。
2个字节的用户可编程E2PROM是非易失性存储,器件掉电时数据不会失去。
DS18B20使用单总线协议,总线通讯通过一根控制信号线实现。
控制线需要一个弱上拉电阻这样所有的器件都通过三态或者开漏极端口(就是DS18B20的DQ引脚)连接到总线上。
DS18B20-温度传感器
![DS18B20-温度传感器](https://img.taocdn.com/s3/m/f2895ed21ed9ad51f11df271.png)
系统方案框图
• 系统方案框图
DS18B20与单片机接口电路设计
知识回顾 Knowledge Review
祝您成功!
• 方案采用STC89C52八位单片机实现。单片机 软件编程的自由度大,可通过编程实现各种 各样的算术算法和逻辑控制。而且体积小, 硬件实现简单,安装方便。既可以单独对多 DS18B20控制工作,还可以与PC机通信.运用 主从分布式思想,由一台上位机(PC机), 下位机(单片机)多点温度数据采集,组成 两级分布式多点温度测量的巡回检测系统,实 现远程控制。另外STC89C52在工业控制上也 有着广泛的应用,编程技术及外围功能电路 的配合使用都很成熟。
• DS18B20内部结构及功能
• DS18B20采用3脚PR—35封装或8脚SOIC封 装,其内部结构主要包括:寄生电源,温度 传感器,64位ROM和单总线接口,存放中间 数据的高速暂存器RAM,用于存储用户设定 温度上下限值的TH和TL触发器,存储与控制 逻辑,8位循环冗余校验码(CRC)发生器 等7部分。
DS18B20内部结构图
DS18B20的测温原理
• 低温度系数振荡器的振荡频率受温度影响很 小,用于产生固定频率的脉冲信号送给减法 计数器1;高温度系数振荡器随温度变化其 振荡频率明显改变,所产生的信号作为减法 计数器2的脉冲输入。当计数门打开 时,DS18B20就对低温度系数振荡器产生的 时钟脉冲进行计数,进而完成温度测量。
• 下位机采用的是STC89C52单片机基于数字 温度传感器DS18B20的系统。由于 STC89C52可以带多个DSB1820,因此可以 非常容易实现多点测量.轻松的组建传感器
网络,并且单片机可以同时进行数码显示 与键盘控制,也可以通过RS232串口与上 位机(PC机)进行数据通讯,达到全方位 立体监控的效果。
温度传感器ds18b20
![温度传感器ds18b20](https://img.taocdn.com/s3/m/9196cb6bae45b307e87101f69e3143323868f518.png)
温度传感器ds18b20温度传感器DS18B201. 简介温度传感器DS18B20是一种数字温度传感器,可用于测量环境温度。
该传感器由Maxim Integrated公司生产,并在许多应用中得到了广泛的应用,如家庭自动化、气象站、工业控制等。
DS18B20采用了数字化接口,并具有高精度、可编程分辨率和低功耗等特点。
2. 技术规格DS18B20的技术规格如下:- 工作电源:3.0V至5.5V- 测量范围:-55°C至+125°C- 分辨率:可编程为9、10、11或12位- 精度:±0.5°C(在-10°C至+85°C范围内)- 通信接口:一线式数字接口3. 工作原理DS18B20采用了一线式数字接口,这意味着它只需要一根数据线进行通信。
传感器从控制器接收命令,并通过数据线将温度数据发送回控制器。
传感器的数据线同时起到了供电的作用。
DS18B20通过内部的精密温度传感器测量环境温度。
传感器将温度转换为数字信号,并通过数据线将其发送给控制器。
传感器的分辨率可以根据需要进行编程,从而在精度和响应速度之间进行平衡。
4. 使用方法使用DS18B20温度传感器非常简单。
首先,将传感器的电源引脚连接到可用的电源引脚,并将数据线连接到控制器的GPIO引脚。
然后,通过控制器向传感器发送命令,请求温度数据。
传感器将在一段时间后将温度数据发送回控制器,控制器可以读取这些数据并进行相应的处理。
DS18B20还具有一些特殊的命令,如启动温度转换、复位传感器和读取ROM代码等。
这些命令可以通过与控制器的通信来实现。
5. 应用领域温度传感器DS18B20在许多应用中得到了广泛的应用。
以下是一些常见的应用领域:- 家庭自动化:DS18B20可以用于监测室内温度,从而实现智能化的温控系统。
- 气象站:DS18B20可以用于监测室外温度,并将数据发送到气象站系统进行分析和显示。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
最小的温度显示程序-c51
(2010-12-07 00:45:27)
转载
分类:51单片机
标签:
杂谈
#include<reg52.h>
#include<math.h>
sbit DQ=P2^0;
bit presence;
unsigned char templ,temph;
char array[10]={0x7e,0x48,0x3d,0x6d,0x4b,0x67,0x73,0x4c,0x7f,0x4f}; void Delay(unsigned int num)//可定义延时
{
while( --num );
}
bit Init_DS18B20(void)
{
DQ = 1; //DQ复位
Delay(8); //稍做延时
DQ = 0; //单片机将DQ拉低
Delay(90); //精确延时大于 480us
DQ = 1; //拉高总线
Delay(8);
presence = DQ; //如果=0则初始化成功 =1则初始化失败
Delay(100);
DQ = 1;
return(presence); //返回信号,0=presence,1= no presence
}
unsigned int ReadOneChar(void)
{
unsigned char i = 0;
unsigned char dat = 0;
for (i = 8; i > 0; i--)
{
DQ = 0; // 给脉冲信号
dat >>= 1; //位右移
DQ = 1; // 给脉冲信号等待传感器返回脉冲
if(DQ)
dat |= 0x80;
Delay(4);
}
return (dat);
}
void WriteOneChar(unsigned char dat)
{
unsigned char i = 0;
for (i = 8; i > 0; i--)
{
DQ = 0;
DQ = dat&0x01;
Delay(5);
DQ = 1;
dat>>=1;
}
}
void Read_Temperature(void)
{
Init_DS18B20();
WriteOneChar(0xcc); // 跳过读序号列号的操作
WriteOneChar(0x44); // 启动温度转换
Init_DS18B20();
WriteOneChar(0xCC); //跳过读序号列号的操作
WriteOneChar(0xBE); //读取温度寄存器
templ = ReadOneChar(); //温度低8位
temph = ReadOneChar(); //温度高8位
}
void main()
{
float temp;
char a;
Init_DS18B20();
WriteOneChar(0xcc);
WriteOneChar(0x44); // 启动温度转换
Init_DS18B20();
WriteOneChar(0xcc);
WriteOneChar(0xbe); //读取温度寄存器
templ = ReadOneChar(); //温度低8位
temph = ReadOneChar(); //温度高8位
temph&=0x07;
temp=((templ>>4)|(temph<<4));
temp+=(templ&0x0f)*0.0625;
a= temp/10;
P1=array[a];
a=temp-10*a;
P0=array[a];
}
/*DS18b20温度传感器
p3.4作为数据传输口
晶振:11.0592M
*/
#include<reg51.H>
sbit DQ= P3^4;
int temperature ;
void delay(int us)
{ int s;
for ( s=0; s<us; s++);
}
void rst(void)
{
DQ = 1;
delay(2);
DQ = 0;
delay(30); //精确延时480~960us DQ = 1;
delay(8);
}
unsigned int read(void)
{
int i=0;
unsigned int u=0;
for (i=0;i<16;i++)
{
DQ=0;
u>>=1;
DQ=1;
if(DQ) u|=0x8000;
delay(4);
}
return (u);
}
void write(unsigned char ku) {
int i=0;
for (i=0;i<8;i++)
{
DQ=0;
DQ =ku&0x01;
delay(3);
DQ=1;
ku>>=1;
}
}
void read0(void)
{
//int temperature ;
unsigned int tp;
unsigned int lsb;
rst();
write(0xCC);
write(0x44);
rst();
write(0xCC);
write(0xBE);
tp=read();
lsb=(unsigned int)(tp*6.25); // temperature=lsb/100;
}
void main(void)
{
while(1)
{
read0(); //读温度子程序读到的温度放在全局变量temperature 中可以直接显示这个的内容
}
}。