【正文】
then each module design process, with C language to achieve, to bine the various parts of coordination, and eventually realize the environmental temperature and humidity in the realtime detection. The temperature and humidity detector can basically plete the temperature and humidity testing, but because of personal factors such as lack of experience, the design of some deficiencies, there are certain practical products from the gap, there are some aspects need to be improved.KEYWORDS:AT89S52MCU,A/Dconversion, Sensor, LCD, Temperature and humidity目 錄前 言 1第1章 溫濕度檢測(cè)儀總體技術(shù)方案 2167。 溫濕度檢測(cè)儀的硬件設(shè)計(jì)總體結(jié)構(gòu)方案 3167。 溫度檢測(cè)電路 7167。 溫濕度檢測(cè)模塊程序設(shè)計(jì) 12167。 鍵盤(pán)掃描 19167。本文介紹的濕度檢測(cè)儀就是以AT89S52單片機(jī)作為核心控制器設(shè)計(jì)的,它具有體積小、操作簡(jiǎn)單、性能穩(wěn)定、測(cè)量精度高和抗干擾能力強(qiáng)等優(yōu)點(diǎn),可廣泛應(yīng)用于需要對(duì)溫濕度進(jìn)行測(cè)控的領(lǐng)域中。第1章 溫濕度檢測(cè)儀總體技術(shù)方案溫濕度作為環(huán)境中的兩項(xiàng)重要參數(shù),在很多方面都起著重要的作用。該設(shè)計(jì)主要分為硬件設(shè)計(jì)和軟件部分的設(shè)計(jì),下面先總體介紹設(shè)計(jì)的性能指標(biāo)和軟硬件的總體設(shè)計(jì)方案。5%,檢測(cè)范圍0~100%;2. 溫度測(cè)量精度: 177。溫濕度上下限顯示和當(dāng)前顯示都由LCD12864顯示屏顯示,可通過(guò)鍵盤(pán)電路來(lái)選擇檢測(cè)濕度或者檢測(cè)溫度。鍵盤(pán)輸入電路與LCD顯示電路實(shí)現(xiàn)人機(jī)對(duì)話(huà)的功能。主程序的內(nèi)容包括:主程序的起始地址,中斷服務(wù)程序的起始地址,有關(guān)內(nèi)存單元及相關(guān)部件的初始化和一些子程序相互調(diào)用,主程序是整個(gè)程序的框架,決定了檢測(cè)儀的工作性能。 溫濕度檢測(cè)儀AT89S52單片機(jī)電路的設(shè)計(jì)At89S52 是一種低功耗、高性能CMOS8位微控制器,具有 8K 在系統(tǒng)可編程Flash 存儲(chǔ)器。 AT89S52具有以下標(biāo)準(zhǔn)功能: 8k字節(jié)Flash,256字節(jié)RAM, 32 位I/O 口線(xiàn),看門(mén)狗定時(shí)器,2 個(gè)數(shù)據(jù)指針,三個(gè)16 位 定時(shí)器/計(jì)數(shù)器,一個(gè)6向量2級(jí)中斷結(jié)構(gòu),全雙工串行口, 片內(nèi)晶振及時(shí)鐘電路。8 位微控制器 8K 字節(jié)在系統(tǒng)可編程 Flash AT89S52 P0 口:P0口是一個(gè)8位漏極開(kāi)路的雙向I/O口。在這種模式下, P0不具有內(nèi)部上拉電阻。對(duì)P1 端口寫(xiě)“1”時(shí),內(nèi)部上拉電阻把端口拉高,此時(shí)可以作為輸入 口使用。 引腳號(hào)第二功能 T2(定時(shí)器/計(jì)數(shù)器T2的外部計(jì)數(shù)輸入),時(shí)鐘輸出 T2EX(定時(shí)器/計(jì)數(shù)器T2的捕捉/重載觸發(fā)信號(hào)和方向控制) MOSI(在系統(tǒng)編程用) MISO(在系統(tǒng)編程用) SCK(在系統(tǒng)編程用) P2 口:P2 口是一個(gè)具有內(nèi)部上拉電阻的8 位雙向I/O 口,P2 輸出緩沖器能驅(qū)動(dòng)4 個(gè) TTL 邏輯電平。在這種應(yīng)用中,P2 口使用很強(qiáng)的內(nèi)部上拉發(fā)送1。對(duì)P3 端口寫(xiě)“1”時(shí),內(nèi)部上拉電阻把端口拉高,此時(shí)可以作為輸入 口使用。 端口引腳 第二功能 RXD(串行輸入口) TXD(串行輸出口) INTO(外中斷0) INT1(外中斷1) TO(定時(shí)/計(jì)數(shù)器0) T1(定時(shí)/計(jì)數(shù)器1) WR(外部數(shù)據(jù)存儲(chǔ)器寫(xiě)選通) RD(外部數(shù)據(jù)存儲(chǔ)器讀選通) 此外,P3口還接收一些用于FLASH閃存編程和程序校驗(yàn)的控制信號(hào)。一般情況下,ALE仍以時(shí)鐘振蕩頻率的1/6輸出固定的脈沖信號(hào),因此它可對(duì)外輸出時(shí)鐘或用于定時(shí)目的。該位置位后,只有一條MOVX和MOVC指令才能將ALE激活。需注意的是:如果加密位LB1被編程,復(fù)位時(shí)內(nèi)部會(huì)鎖存EA端狀態(tài)。 溫濕度檢測(cè)儀的硬件電路設(shè)計(jì)該溫濕度檢測(cè)儀的硬件系統(tǒng)由以下部分組成:溫度測(cè)量電路、相對(duì)濕度度測(cè)量電路、鍵盤(pán)掃描電路、LCD顯示電路、ISP下載電路,各部分設(shè)計(jì)如下。 DS18B20產(chǎn)品的特點(diǎn) (1)、只要求一個(gè)端口即可實(shí)現(xiàn)通信。C到+125。DS18B20的引腳介紹 引腳功能描述1 GND 地信號(hào)2 DQ 數(shù)據(jù)輸入/輸出引腳。 濕度檢測(cè)電路 濕敏電阻是利用濕敏材料吸收空氣中的水分而導(dǎo)致本身電阻值發(fā)生變化這一原理而制成的。 4)測(cè)濕范圍(%RH):指濕敏電阻器的濕度測(cè)量范圍。特性濕敏電阻器特性:是一種對(duì)環(huán)境濕度敏感的元件,它的電阻值能隨著環(huán)境的相對(duì)濕度變化而變化。本設(shè)計(jì)中采用兩個(gè)數(shù)碼管進(jìn)行動(dòng)態(tài)顯示,用三極管C8550驅(qū)動(dòng)來(lái)顯示相對(duì)濕度的電壓。當(dāng)鎖存使能端LE為高時(shí),這些器件的鎖存對(duì)于數(shù)據(jù)是透明的(也就是說(shuō)輸出同 步)。任何從總線(xiàn)接收數(shù)據(jù)的器件為接收器。 SDA 串行數(shù)據(jù)/地址 AT24C02 雙向串行數(shù)據(jù)/地址管腳用于器件所有數(shù)據(jù)的發(fā)送或接收,SDA 是一個(gè)開(kāi)漏輸出管腳,可與其它開(kāi)漏輸出或集電極開(kāi)路輸出進(jìn)行線(xiàn)或(wireOR)。 WP 寫(xiě)保護(hù) 如果WP管腳連接到Vcc,所有的內(nèi)容都被寫(xiě)保護(hù)只能讀。主程序設(shè)計(jì)框圖如上圖31。 溫濕度檢測(cè)模塊程序設(shè)計(jì)167。//整屏不移動(dòng) write_zl(0x0C)。 delay(80)。 k=dat。 DQ=kamp。 k=1。j8。 date=date1。} return(date)。//只對(duì)一個(gè)操作就跳過(guò)讀序列號(hào)操作 write_dat(0x44)。 write_dat(0xcc)。//讀取溫度高位MSB if(tempHamp。 //共16位 tem=tem|tempL。tem=((tempH*256)+tempL)*。 ge=temp%10。)。 write_sj(0x00)。)。 write_sj(0x30+shi)。 write_sj(0x00)。 //個(gè)位公用總的顯示write_sj(0x30+ge)。i++) {sounder=~sounder。P26=0。 ET1=1。 shuma=0。 yejing=0。 shuma=1。 sdxs()。_nop_()。 //轉(zhuǎn)換結(jié)束OE置高電平 數(shù)據(jù)出現(xiàn)在 D7D0引腳上 a=P0。P21=0。P20=0。 P20=0。}167。 if(button1==0) { while(button1==0)。switch(kk) { case 1:write_zl(0x80+10)。break。break。 write_zl(0x0c)。 } } } if(button2==0){ delay2(5)。if(Ush9)Ush=3。if(Ushi9)Ushi=1。 case 2:write_zl(0x80+11)。write(13,Ug)。write(9,Uge)。if(Dsh2)Dsh=0。 if(Dshi2)Dshi=0。 case 4:write_zl(0x80+0x40+11)。write(15,Dg)。 write(11,Dge)。 switch(kk) { case 1: write_zl(0x80+10)。write(8,Ushi)。 write(12,Ush)。 if(Uge0)Uge=9。 if(Ug0)Ug=9。 case 3: write_zl(0x80+0x40+10)。 write(10,Dshi)。write(14,Dsh)。 if(Dge0)Dge=9。if(Dg0)Dg=9。 } } } if(button4==0) { delay2(5)。write_zl(0x01)。 display_shidu()。write_zl(0x01)。 break。 delay(5)。 delay(2)。 delay(4)。 while(sda==1amp。 delay(5)。 sck=0。j++) { temp=temp1。 sck=0。 sck=0。k++) { n=(n1)|sda。 delay(5)。 response()。 delay(2)。 stop()。 response()。 delay(2)。 delay(2)。} 結(jié) 論該檢測(cè)儀適用于需要對(duì)溫濕度實(shí)時(shí)檢測(cè)的多種場(chǎng)合。在這次設(shè)計(jì)中本設(shè)計(jì)也遇到不少問(wèn)題,也正是對(duì)這些問(wèn)題的逐步解決該檢測(cè)儀順利設(shè)計(jì)完成。此檢測(cè)儀還可以與溫度濕度發(fā)生裝置連接來(lái)實(shí)現(xiàn)對(duì)溫度濕度的調(diào)整功能,加上報(bào)警裝置后就可以對(duì)環(huán)境溫度超過(guò)上下限時(shí)發(fā)出警報(bào),本設(shè)計(jì)序能夠?qū)崿F(xiàn)溫濕度的同時(shí)檢測(cè)功能。:北京航空航天出版社,2002 致謝 本設(shè)計(jì)的完成是在我們的導(dǎo)師李美麗老師的細(xì)心指導(dǎo)下進(jìn)行的。C in176。F increments? Temperature is read as a 9–bit digital value.? Converts temperature to digital word in 200 ms (typ.)? User–definable, nonvolatile temperature alarm settings? Alarm search mand identifies and addressesdevices whose temperature is outside of programmedlimits (temperature alarm condition)? Applications include thermostatic controls, industrialsystems, consumer products, thermometers, or anythermally sensitive systemDESCRIPTIONThe DS1820 Digital Thermometer provides 9–bit temperature readings which indicate the temperature of the device. Information is sent to/from the DS1820 over a 1–Wire interface, so that only one wire (and ground) needs to be connected from a central microprocessor to a DS1820. 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 DS1820 contains a unique silicon serial number, multiple DS1820s can exist on the same 1–Wire bus. This allows for placing temperature sensors in many different where this feature is useful include HVAC environmental controls, sensing temperatures inside buildings, equipment or machinery, and in process monitoring and control.DETAILED PIN DESCRIPTIONOVERVIEWThe block diagram of Figure 1 shows the major ponentsof the DS1820. The DS1820 has three main data ponents: 1) 64–bit lasered ROM, 2) temperature and sensor, 3) nonvolatile temperature alarm triggers TH and TL. The device derives its power from the 1–Wire munication 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 tim