【正文】
37 } /*******************************************************************/ void ds1820disp3() //4 號(hào)溫度值顯示 { uchar flagdat3。 ds1820rst3()。i) { 36 DQ3 = 0。 //顯示個(gè)位 wr_(0x80+0x44)。 disdata2[0]=tvalue2/1000+0x30。 ds1820wr2(0xcc)。 //給脈沖信號(hào) dat2=1。 wr_dat(0x2e)。 //百位數(shù) disdata1[1]=tvalue1%1000/100+0x30。 //跳過(guò)讀序列號(hào) ds1820wr1(0x44)。 DQ1 = 1。 //顯示小數(shù)點(diǎn) 31 wr_(0x80+0x05)。 //十位數(shù) disdata[2]=tvalue%100/10+0x30。 //啟動(dòng)溫度轉(zhuǎn)換 ds1820rst()。 //給脈沖信號(hào) if(DQ) dat|=0x80。 wr_(0x80+0x4A)。 } void lcd_init() //LCD 初始化設(shè)置 { 28 wr_(0x38)。j110。 uchar code str4[]={set low }。 //二號(hào) ds18b20 與單片機(jī)連接口 sbit DQ2=P1^2。由于整個(gè)系統(tǒng)使用的信號(hào)全部為數(shù)字量,可以直接將底線接在電源的負(fù)極,而不用去考慮模擬接地。 2) 寫時(shí)隙 寫“ 0”時(shí),主機(jī)把 DQ 單總線直接下拉為點(diǎn)電平,并保持 60μs 以上(且小于 120μs),完成寫 0 時(shí)隙。 14 圖 34 LCD1602 接口電路 鍵盤電路 控制電路是一個(gè)單片機(jī)系統(tǒng)必不可少組成部分,本系統(tǒng)在運(yùn)行的過(guò)程中會(huì)根據(jù)外部環(huán)境的變化對(duì)溫度報(bào)警的上下限進(jìn)行設(shè)置,故把單片機(jī)的 ~ 口作為控制按鈕的輸入端,它們?cè)谶\(yùn)行中對(duì)應(yīng)的功能分別為設(shè)置溫度報(bào)警上限、設(shè)置溫度報(bào)警下限、溫度值加 溫度值減 1 和退出。 11 單片機(jī)最小系統(tǒng)的設(shè)計(jì) 單片機(jī)最小系統(tǒng),是組成一個(gè)獨(dú)立工作的單片機(jī)系統(tǒng)是,芯片和連接各芯片之間的總線少的不能再少。 S/C:為 1 時(shí)移動(dòng)屏幕內(nèi)容,為 0時(shí)移動(dòng)光標(biāo)。 其外形如圖 24所示。 寫寄存器 4EH 用于使主機(jī)向 DS18B20 片內(nèi)暫存器寫入 3 個(gè)字節(jié)的數(shù)據(jù),寫入過(guò)程必須從低字節(jié)向高字節(jié)順序進(jìn)行。 DS18B20 是美國(guó) MAXIM 半導(dǎo)體公司的全資子公司 Dallas 生產(chǎn)的一種單數(shù)據(jù)總線數(shù)字輸出型全集成式智能 溫度傳感器。 3 系統(tǒng)概述 單片機(jī)系統(tǒng)的設(shè)計(jì),關(guān)鍵是系統(tǒng)內(nèi)信號(hào)傳輸?shù)膯?wèn)題。 關(guān)鍵詞 單片機(jī),溫度傳感器,多點(diǎn)溫度檢測(cè) ABSTRACT The practical application of largescale development of the integrated circuit chip control circuit has a tremendous role in promoting. MCU with a small size, light weight, inexpensive, lowpower, control and puting speed, has a wider use in the monitoring and control systems, intelligent instruments, mechanical and electrical integration products, intelligent interface. With the single chip processor as the core, the application of temperature sensor for temperature acquisition can be pleted, and carry on corresponding processing. This system, using four slices of DS18B20, sent the temperature measured by the temperature sensor DS18B20 to AT89C52 singlechip puter, through the MCU processing, the temperature is sent to the display unit to display. The system uses the MCU to set upper and lower temperature, to measure and control the point temperature and alarm. At the same time, use the main distributed thought to achieve remote control of the temperature, and to constitute a multipoint temperature detection system. Key Words: MCU, Slice, Multipoint temperature detection 目 錄 ............................................................................................................................................ 1 課題背景 ............................................................................................................................ 1 國(guó)內(nèi)外發(fā)展現(xiàn)狀 ................................................................................................................. 1 本設(shè)計(jì)的內(nèi)容及任務(wù) .......................................................................................................... 2 設(shè)計(jì)內(nèi)容 .................................................................................................................. 2 設(shè)計(jì)任務(wù) .................................................................................................................. 2 計(jì) .............................................................................................................................. 3 系統(tǒng)概述 ............................................................................................................................ 3 系統(tǒng)工作原理 ..................................................................................................................... 3 系統(tǒng)器件的選擇 ................................................................................................................. 4 單片機(jī)的選擇 ........................................................................................................... 4 溫度傳感器的選擇 .................................................................................................... 5 顯示器的選擇 ........................................................................................................... 8 ..........................................................................................................................10 單片機(jī)最小系統(tǒng)的設(shè)計(jì) ...................................................................................................... 11 時(shí)鐘電路的設(shè)計(jì) ...................................................................................................... 11 復(fù)位電路的設(shè)計(jì) ....................................................................................................... 11 溫度采集模塊的設(shè)計(jì) .........................................................................................................12 LCD 顯示電路 ...................................................................................................................13 鍵盤電路 ..........................................................................................................................14 聲光報(bào)警電路 ...................................................................................................................15 ..........................................................................................................................16 工作方案簡(jiǎn)介 ....................................................................................................................16 主程序流程圖 ....................................................................................................................16 溫度讀取轉(zhuǎn)換模塊 .............................................................................................................17 液晶顯示模塊 .............................................................................................................19 按鍵處理模塊 .....................................................