【正文】
基于DS18B20的溫度采集系統(tǒng)設(shè)計(jì) 課 程 設(shè) 計(jì) 任 務(wù) 書題 目 基于DS18B20的溫度采集系統(tǒng)(數(shù)碼管顯示)的設(shè)計(jì)系 (部) 信息科學(xué)與電氣工程學(xué)院 專 業(yè) 電子信息工程 班 級(jí) 電信091 學(xué)生姓名 學(xué) 號(hào) 12 月 26 日至 12 月 30 日 共 1 周指導(dǎo)教師(簽字) 系 主 任(簽字) 年 月 日 目錄摘要 2一、設(shè)計(jì)任務(wù)和要求 4二、芯片資料 4DS18B20 4 DS18B20的工作原理 4 DS18B20的使用方法 6AT89C51 8 AT89C51簡(jiǎn)介 8 AT89C51功能 8 AT89C51引腳 9三、系統(tǒng)流程 10讀轉(zhuǎn)換溫度子程序 10讀、寫DS18B20的子程序 11四、電路與程序設(shè)計(jì) 12程序 12電路圖 17五、系統(tǒng)調(diào)試與分析 19六、設(shè)計(jì)體會(huì)及參考文獻(xiàn) 19 摘要隨著人們生活水平的不斷提高,單片機(jī)技術(shù)已經(jīng)普及到我們生活,工作,科研等各個(gè)領(lǐng)域。單片機(jī)控制無疑是人們追求的目標(biāo)之一,它所給人帶來的方便是不可否定的,其中數(shù)字溫度計(jì)就是一個(gè)典型的例子,但人們對(duì)它的要求越來越高,要為現(xiàn)代人工作、科研、生活提供更好的更方便的設(shè)施就需要從數(shù)單片機(jī)技術(shù)入手,一切向著數(shù)字化控制,智能化控制方向發(fā)展。本文利用單片機(jī)結(jié)合傳感器技術(shù)開發(fā)設(shè)計(jì),把傳感器理論與單片機(jī)實(shí)際應(yīng)用有機(jī)結(jié)合,詳細(xì)地講述了利用溫度傳感器DS18B20測(cè)量環(huán)境溫度,設(shè)置上下報(bào)警溫度,當(dāng)溫度不在設(shè)置范圍內(nèi)是,可以報(bào)警。同時(shí)51單片機(jī)在現(xiàn)代電子產(chǎn)品中廣泛應(yīng)用以及其技術(shù)已經(jīng)非常成熟,DS18B20可以直接讀出被測(cè)溫度值,而且采用一線制與單片機(jī)相連,減少了外部的硬件電路,具有低成本和易使用的特點(diǎn) 關(guān)鍵詞: 單片機(jī)控制、溫度檢測(cè)、溫度傳感器、溫度報(bào)警、低成本、易使用 Abstract With the continuous improvement of living standard, single chip technology has spread to our lives, work, research and other is undoubtedly one of the goals people pursue, the convenience it brings is not negative, in which digital thermometer is a typical example, but it requires more and more people to work for the modern man, research, provide a better life, more convenient facilities need to start from a few microcontroller technology, all toward the digital control, intelligent control this paper, bined with sensor technology development and design of single chip, the sensor application of theory and practical bination of SCM in detail about the use of temperature sensors measure the ambient temperature DS18B20, set the upper and lower alarm temperature range when the temperature is not set is for the police. 51 Micro also widely used in modern electronic products and its technology is well established. DS18B20 can directly read the measured temperature, and the use of frontline system is connected with the microcontroller, reducing the external hardware circuit, the characteristics of low cost and ease of use.Keywards: SCM control 、temperature measure、temperature sensors temperature alarming 、low cost 、 ease of use 一、設(shè)計(jì)內(nèi)容及要求利用DS18B20實(shí)現(xiàn)溫度采集,并用數(shù)碼管顯示(用proteus實(shí)現(xiàn))。二、芯片資料DS18B20 DS18B20的工作原理DS18B20的讀寫時(shí)序和測(cè)溫原理與DS1820相同,只是得到的溫度值的位數(shù)因分辨率不同而不同,且溫度轉(zhuǎn)換時(shí)的延時(shí)時(shí)間由2s 減為750ms。 DS18B20測(cè)溫原理如圖3所示。圖中低溫度系數(shù)晶振的振蕩頻率受溫度影響很小,用于產(chǎn)生固定頻率的脈沖信號(hào)送給計(jì)數(shù)器1。高溫度系數(shù)晶振 隨溫度變化其振蕩率明顯改變,所產(chǎn)生的信號(hào)作為計(jì)數(shù)器2的脈沖輸入。計(jì)數(shù)器1和溫度寄存器被預(yù)置在-55℃所對(duì)應(yīng)的一個(gè)基數(shù)值。計(jì)數(shù)器1對(duì) 低溫度系數(shù)晶振產(chǎn)生的脈沖信號(hào)進(jìn)行減法計(jì)數(shù),當(dāng)計(jì)數(shù)器1的預(yù)置值減到0時(shí),溫度寄存器的值將加1,計(jì)數(shù)器1的預(yù)置將重新被裝入,計(jì)數(shù)器1重 新開始對(duì)低溫度系數(shù)晶振產(chǎn)生的脈沖信號(hào)進(jìn)行計(jì)數(shù),如此循環(huán)直到計(jì)數(shù)器2計(jì)數(shù)到0時(shí),停止溫度寄存器值的累加,此時(shí)溫度寄存器中的數(shù)值即 為所測(cè)溫度。圖3中的斜率累加器用于補(bǔ)償和修正測(cè)溫過程中的非線性,其輸出用于修正計(jì)數(shù)器1的預(yù)置值。 DS18B20有4個(gè)主要的數(shù)據(jù)部件: (1)光刻ROM中的64位序列號(hào)是出廠前被光刻好的,它可以看作是該DS18B20的地址序列碼。64位光刻ROM的排列是:開始8位(28H)是產(chǎn)品類型標(biāo)號(hào),接著的48位是該DS18B20自身的序列號(hào),最后8位是前面56位的循環(huán)冗余校驗(yàn)碼(CRC=X8+X5+X4+1)。光刻ROM的作用是使每一個(gè)DS18B20都各不相同,這樣就可以實(shí)現(xiàn)一根總線上掛接多個(gè)DS18B20的目的。(2)DS18B20中的溫度傳感器可完成對(duì)溫度的測(cè)量,以12位轉(zhuǎn)化為例:用16位符號(hào)擴(kuò)展的二進(jìn)制補(bǔ)碼讀數(shù)形式提供,℃/LSB形式表達(dá),其中S為符號(hào)位。表1: DS18B20溫度值格式表這是12位轉(zhuǎn)化后得到的12位數(shù)據(jù),存儲(chǔ)在18B20的兩個(gè)8比特的RAM中,二進(jìn)制中的前面5位是符號(hào)位,如果測(cè)得的溫度大于0,這5位為0,;如果溫度小于0,這5位為1。例如+125℃的數(shù)字輸出為07D0H,+℃的數(shù)字輸出為0191H,℃的數(shù)字輸出為FF6FH,55℃的數(shù)字輸出為FC90H。表2: DS