【正文】
更靈活、方便. DSl8820 內(nèi)部 ROM 中的 64 位序列號是出廠前用激光光刻寫好的,它可以看作是該 DSl8820 的地址序列碼. 64 位光刻 ROM 的排列是:開始 8 位是產(chǎn)品 類型標號,DSl8820 的產(chǎn)品系列碼固定為 28H;接著的 48 位是該 DSl8820 自身的序列號,而這 48 位序列號為全球唯一的,最后 8 位是前面 56 位的循環(huán)冗余校驗碼.利用 DSl8820 ROM 中的序列號作為 1 一 Wire 網(wǎng)絡(luò)中的地址,唯一標識一個傳感器,這樣就可以實現(xiàn)一根總線上掛接多個DSl8820 的目的. 根據(jù) Dallas 公司提供的 DSl8820 資料,每根單線總線上最多可以掛 248 個 l— Wire 器件tTl.但在試驗中發(fā)現(xiàn)并非如此.當一根單線總線上所掛的 DSl8820 超過 8 個時,就需要解決控制節(jié)點的單片機對單線總 線的驅(qū)動問題,否則單片機就不能正確實現(xiàn)對 DSl8820 的讀寫.同圖 3 控制節(jié)點的硬件結(jié)構(gòu)設(shè)計圖 共 4 頁 第 3 頁 時,連接 DSl8820 的總線電纜也是有長度限制的,當采用普通信號電纜作為總線傳輸測溫數(shù)據(jù)時,長度超過 50m 時,讀取的測溫數(shù)據(jù)就會發(fā)生錯誤.當將總線電纜改為雙絞線帶屏蔽電纜時,正常通信距離可達 150m.因此該系統(tǒng)每個控制節(jié)點一根單線總線最多接 8 個 DSl8820,這樣設(shè)計的目的既能保證單片機對總線的驅(qū)動,同時也能滿足通信距離不超過 150m,從而實現(xiàn)系統(tǒng)的穩(wěn)定運行. 系統(tǒng)構(gòu)成包括控制臺和控制節(jié)點兩部分,因此軟件設(shè)計主要包括控制臺程序 設(shè)計和節(jié)點程序設(shè)計兩個部分,控制臺程序結(jié)構(gòu)如圖 4 所示. 3. 1 控制臺軟件設(shè)計 控制臺程序從大模塊上劃分為初始化和主調(diào)度兩塊.初始化部分僅在上電啟動或復(fù)位時運行一次;主調(diào)度主要包括 CAN 信息幀處理、鍵盤按鍵處理、顯示處理和報警、數(shù)據(jù)和時間處理、中斷控制等部分 . 主調(diào)度主要負責(zé)協(xié)調(diào)和管理各個子任務(wù)的運行,主調(diào)度巡查各個子任務(wù)激活條件,當激活子任務(wù)的事件發(fā)生時,將激活該子任務(wù)運行,否則跳過這一子任務(wù);如果有多個激活條件出現(xiàn),主調(diào)度負責(zé)仲裁.系統(tǒng)初始化的功能是建立系統(tǒng)使用環(huán)境,包括 CAN 總線接口初始化、時鐘芯片 初始化等. CAN 信息幀處理模塊主要實現(xiàn)利用 CAN 總線實現(xiàn)控制臺和各控制節(jié)點之間的通信.鍵盤按鍵處理模塊主要用來實現(xiàn)鍵盤的輸入按鍵的識別及相關(guān)處理.顯示處理和報警模塊則實現(xiàn)根據(jù)數(shù)據(jù)時間處理模塊處理的結(jié)果傳送至 LCD 顯示,并控制報警系統(tǒng).數(shù)據(jù)和時間處理模塊主要是實現(xiàn)對從CAN 總線接口接受來的數(shù)據(jù)進行處理并保存到 AT24C128 中,并根據(jù)系統(tǒng)時間和溫度報警設(shè)定值做相應(yīng)的處理.最后的中斷控制模塊用實現(xiàn) CAN 總線接以口實時通信和鍵盤按鍵實時響應(yīng). 3. 2 控制節(jié)點軟件設(shè)計 控制節(jié)點的主要功能是和控制臺通信,檢測分布在每 個房問中的 DSl8820 的溫度值,如果超過限定值,則向控制臺報警并控制該房間的空調(diào)風(fēng)門.同時通過 CAN 總線向控制臺報告房間號和溫度值.根據(jù) DSl8820 的通信協(xié)議,節(jié)點單片機控制 DSl8820 完成溫度轉(zhuǎn)換必須經(jīng)過三個步驟:每一次讀寫之前都要對 DSl8820 進行復(fù)位,復(fù)位成功后發(fā)送~條 ROM 指令,最后發(fā)送 RAM 指令嘲,這樣才能對 DSl8820 進行預(yù)定的操作.復(fù)位要求單片機將數(shù)據(jù)線下拉500μs,然后釋放, DSl8820 收到信號后等待 16~ 60μs左右,后發(fā)出 60— 240μs 的存在低脈沖,單片機收到此信號表示復(fù) 位成功. 當單片機執(zhí)行 傳感器 DS18B20 測量溫度 程序的流程時,它會發(fā)出溫度變換命令。 4. 結(jié)論 實地測試后,該系統(tǒng)可 以有效的 實現(xiàn) 樓宇 溫度檢測與控制 .并且 該系統(tǒng)可以應(yīng)用到其他設(shè)備 的 檢測和控制,以實現(xiàn) 樓宇 智能化管理。 2。 In this foundation, the console set each pitch point temperature value setting for every room, and realize the entire building temperature realtime examination, by the LCD demonstration examination result, the unusual situation is reported by the warning through speech Property by the signal and controlled through the gate of air conditioning?s system , realization energy conservation goal. The system design goal is measure and control temperature in a building each room, because measured the temperate point and control point is dispersion, therefore the system uses the distributional structure, The console is connected each part of control pitch point distributing in the building through the CAN Bus. System structure diagram like figure 1 shows The console hardware design The AT89C52 MCU is the primarily controller in console, It connects with the 共 4 頁 第 6 頁 warning module, the memory module, the clock/calendar electric circuit and the keyboard module. its structure drawing see Figure 2. The control pitch point also is controlled by the MCU, connected temperature examination module and the CAN Bus interface module. The system has used the AT89S52, it is a section low power chip that is produced by ATMEL Corporation, has 4 KB insystem programmable (ISP) FLASH memory integrated. The scene programming debugging and the system function changing is much conveniently flexible, using AT89S52 to take the system the master controller. When system normal work. The console send a definite control temperature value to a designate pitch point Distributed in the building through the CAN Bus. The pitch point receive the console?s orders and read the temperature detector DS18B20 temperature value distributed in each room through 1Wire bus, transmits each room temperature data and the number of room to the console through the CAN Bus. According to the definite temperature value which receives from console control the air gate of airconditioning system in each room. After receive the data a pitch point send to, the console reads the time from realtime clock/calendar chip PCF