【正文】
taneously 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 1Wire bus or their 64bit ROM codes The search ROM mand allows the bus master to use a process of elimination to identify the 64bit ROM codes of all slave devices on the bus Alarm Search [ECh] The flowchart of this mand is identical to the Search ROM mand However the DS18B20 will respond to this mand 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 nonalarming 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 Search The ROM search process is the repetition of a simple threestep routine read a bit read the plement of the bit then write the desired value of that bit The bus master performs this simple threestep routine on each bit of the ROM After one plete 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 1Wire bus The ROM data of the four devices is as shown ROM1 00110101 ROM2 10101010 ROM3 11110101 ROM4 00010001 The search process is as follows 1 The bus master begins the initialization sequence by issuing a reset pulse The slave devices respond by issuing simultaneous presence pulses 2 The bus master will then issue the Search ROM mand on the 1Wire bus 3 The bus master reads a bit from the 1Wire bus Each device will respond by placing the value of the first bit of their respective ROM data onto the 1Wire bus ROM1 and ROM4 will place a 0 onto the 1Wire bus ie pull it low ROM2 and ROM3 will place a 1 onto the 1Wire 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 mand is being executed all of the devices on the 1Wire bus respond to this second read by placing the plement of the first bit of their respective ROM data onto the 1Wire bus ROM1 and ROM4 will place a 1 onto the 1Wire allowing the line to stay high ROM2 and ROM3 will place a 0 onto the 1Wire thus it will be pulled low The bus master again observes a 0 for the plement of the first ROM data bit The bus master has determined that there are some devices on the 1Wire bus that have a 0 in the first position and others that have a 1 The data obtained from the two reads of the threestep routine have the following interpretations 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 1Wire bus 5 The bus master performs two more reads and receives a 0bit followed by a 1bit This indicates that all 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 0bits This indicates that both 1bits and 0bits exist as the 3rd bit of the ROM data of the attached devices 8 The bus master writes a 0bit This deselects ROM1 leavin。C Fahrenheit equival ent is 67176。 F 以 9 到 12 位數(shù)字值方式讀出溫度 在 750 毫秒內(nèi)把 12 位溫度變換為數(shù)字 用戶可定義的非易失性的溫度警告設(shè)置 告警搜索命令識別和尋址溫度在編定的極限之外的器件溫度告警情況 應(yīng)用范圍包括恒溫控制工業(yè)系統(tǒng)消費類產(chǎn)品溫度計或任何熱敏系統(tǒng) 引腳排列 引腳說明 GND – 地 DQ – 數(shù)字輸入輸出 VDD – 可選的 VDD NC – 不連接 詳細(xì)引腳說明 綜述 圖 1 的方框圖表示 DS18B20 的主要部件 DS18B20 有三個主要的數(shù)據(jù)部件 164為激光 ROM2 溫度靈敏元件 3 非易失性溫度告警觸發(fā)器 TH 和 TL 器件從單線的通信線取得其電源在信號線為高電平的時間周期內(nèi)把能量貯存在內(nèi)部的電容器中在單信號線為低電平的時間期內(nèi)斷開此電源直到信號線變?yōu)楦唠娖街匦陆由霞纳娙蓦娫礊橹棺鳛榱硪环N可供選擇的方法 DS18B20 也用外部 5V 電源供電 與 DS18B20的通信經(jīng)過一個單線接口在單線接口情況下在 ROM操作未定建立之前不能使用存貯器和控制操作主機必須首先提供五種 ROM 操作命令之一 1 讀ROM2 符合 ROM3 搜索 ROM4 跳過 ROM5 告警搜索這些命令對每一個器件的 64 位激光 ROM 部分進(jìn)行操作如果在單線上有許多器件那么可以挑選出一個特定的器件并給總線上的主機指示存在多少器件及其類型在成功地執(zhí)行了 ROM 操作序列之后可使用貯存 2 器和控制操作然后主機可以提供六種存貯器和操作命令之一 一個操作命令指示 DS18B20完成溫度測量改測量的結(jié)果放入 DS18B20的高速暫存存貯器通過發(fā)出讀暫存存儲器內(nèi)容的存儲器操作命令可以讀出此結(jié)果每一溫度告警觸發(fā)器 TH和 TL構(gòu)成一個字節(jié)的 EPROM如果不對 DS18B20施加告警搜索命令這些寄存器用作通用用戶存儲器使用存 儲器操作命令可以寫 TH和 TL對這些寄存器的讀訪問通過便簮存儲器所以數(shù)據(jù)均以最低有效位在前的方式被讀寫 單線總線系統(tǒng) 單線總線是一種具有一個總線主機和一個或若干個從機的系統(tǒng) DS18B20 起從機的作用這種總線系統(tǒng)的討論分為三個題目硬件接法處理順序以及單線信號信號類型與定時 硬件接法 根據(jù)定義單線總線只有一根線這一點很重要的即線上的第一個器件能在適當(dāng)?shù)臅r間驅(qū)動該總線為了做到這一點第一個連接到總線上的器件必須具有漏極開路或三態(tài)輸出 DS18B20 的單線接口多站總線由單線總線和多個與之相連的從屬器件組成單線總線要求近似 等于 5 k 單線總線的空閑狀態(tài)是高電平不管任何原因如果執(zhí)行需要被掛起那么若要重新恢復(fù)執(zhí)行總線必須保持在空閑狀態(tài)如果不滿足這一點且總線保持在低電平時間大于 480 微秒那么總線上所有的器件均被復(fù)位 硬件連接圖 處理順序 經(jīng)過單線總線接口訪問 DS18B20 的協(xié)議如下 初始化 ROM 操作命令 存貯器操作命令 處理數(shù)據(jù) 初始化 單線總線上的所有處理均從初始化序列開始初始化序列包括總線主機發(fā)出一復(fù)位脈沖接著由從屬器件送出存在脈沖 ROM 操作命令 一旦總線主機檢測到從屬器件的存在他便可以發(fā)出器件 ROM 操作命令之一所有 ROM 操作命令均由 8 位長這些命令列表如下 讀 ROM [33H] 此命令允許總線主機讀 DS18B20 的 8 位產(chǎn)品系列編碼唯一的 48 位序列號以及 8位的 CRC此命令只能在總線上僅有一個 DS18B20得情況下可以使用如果總線上存在多于一個得從屬器件那么所有從片企圖同時發(fā)送時將發(fā)生數(shù)據(jù)沖突的現(xiàn)象 符合 ROM [55h] 符合 ROM 命令后繼以 64 位的 ROM 數(shù)據(jù)序列允許總線主機對多點總線上的DS18B20 尋址只有與 64 位 ROM 序列嚴(yán)格相符的 DS18B20 才能對后繼的存貯器操作命令作出響應(yīng)所有與 64 位 ROM 序列不符的從片將等待復(fù) 位脈沖此命令在總線數(shù)據(jù)上有單個或多個器件的情況下均可使用 跳過 ROM[CCh] 在單點總線系統(tǒng)中此命令通過允許總線主機不提供 64 位 ROM 編碼而訪問存儲器操作來節(jié)省時間如果在總線上存在多于一個得從屬器件而且在跳過 ROM 命令之后發(fā)出讀命令那么由于多個從片同時發(fā)送數(shù)據(jù)會在總線上發(fā)生數(shù)據(jù)沖突 搜索 ROM[F0h] 當(dāng)系統(tǒng)開始工作時總線主機可能不知道單線總線上的器件個數(shù)或者不知道其 64 位 ROM 編碼搜索 ROM 命令允許總線主機使用一種消去處理來識別總線上的所有從片的 64 位 ROM 編碼 5 告警搜索 [ECh] 此命令的流程與搜 索 ROM 命令相同但是僅在最近一次溫度測量出現(xiàn)告警的情況下 DS18B20 才對此命令作出響應(yīng)告警的條件定義為溫度高于 TH 或低于 TL只要 DS18B20 一上電告警條件就保持在設(shè)置狀態(tài)直到另一次溫度測量告警 6ROM 搜索舉例 ROM 搜索過程是簡單三步過程的重復(fù)讀一位讀核位的補碼然后寫所需的那一位的值總線主機在 ROM 的每一位上完成這一簡