【正文】
=80。 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 28 if(sdh80)sdh=80。 if(sdh80)sdh=80。 shedingok=1。 if(mode==1) { wendu[0]=wdh/100+39。 wendu[4]=temp%10+39。i++) { wrd(wendu[i])。039。 for(i=0。C39。 shidu[3]=0x2E。 } for(i=0。)。 shidu[2]=sdl%10+39。i6。 wrd(39。humisdh)||(tempwdlamp。 wrc(0x00+0x80)。 } } void display() { u8 i。039。 } wrd(0xdf)。039。i5。 wrd(39。 kai_display()。 keypros()。 delay(100)。 } 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 36 void main() { u8 error。)。 humi=*10。 wrc(0x46+0x80)。039。039。 } wrc(0x40+0x80)。shedingok==1) { sound()。H39。i++) { wrd(shidu[i])。 shidu[4]=humi%10+39。 } if(mode==4) { shidu[0]=sdl/100+39。%39。 wrc(0x80)。 shidu[1]=sdh%100/10+39。i5。 temp=*10。)。i6。 wendu[2]=wdh%10+39。 sbuf[2]=sdh。 if(sdh0)wdh=0。 if(sdh0)wdh=0。 if(wdh0)wdh=0。 if(wdh0)wdh=0。 if(mode==3)wrc(0x01)。 TR0=1。 wrc(0x01)。 e=0。 e=0。 void delay(u16 i) { while(i)。 u8 code d4[]=TempL:。 sbit led1=P1^7。 sbit rs=P1^0?;菊莆樟?Protel99SE 原理圖的方法,并設(shè)計(jì)了一個(gè)單片機(jī)最小系統(tǒng)。 Proteus 也是目前唯一能將電路的仿真及 PCB 設(shè)計(jì)和虛擬的模擬三個(gè)軟件相結(jié)合的一個(gè)大平臺(tái)。或者通過編譯生成的 HEX 文件燒寫到設(shè)計(jì)好的硬件仿真電路的單片機(jī)中,看具體的效果,直到效果無 誤即可 。 LCD1602 初始化子函數(shù)先設(shè)置其顯示參數(shù)和輸入方式,再清除屏幕顯示。 (閉合)抖動(dòng)階段:此時(shí)按鍵剛 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 15 剛按下,但按鍵信號(hào)還處于抖動(dòng)狀態(tài),這個(gè)時(shí)間一般為 5~20ms。具體電路如下: 圖 215 降溫去濕 電路 總電路設(shè)計(jì) 用 Protel畫圖 軟件繪制的完整電路圖如下: 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 13 圖 216 總電路圖 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 14 3 軟件設(shè)計(jì) 系統(tǒng)概述 電路實(shí)現(xiàn)的基本功能是溫濕度檢測(cè)。具體電路如下 圖 212 按鍵 電路 報(bào)警 電路 設(shè)計(jì)中需要設(shè)計(jì)一個(gè)超限報(bào)警裝置,當(dāng)檢測(cè)的溫濕度高于或低于設(shè)定值時(shí)就報(bào)警,設(shè)計(jì)中采用一個(gè)無源蜂鳴器,即只有觸發(fā)一定頻率的脈沖才能使蜂鳴器發(fā)聲。單片機(jī)電源: STC89C52 單片機(jī)的工作電壓范圍: — , 一般給 51單片機(jī)外接一個(gè) 5V 的直流穩(wěn)壓電源。我們的這個(gè)到單片機(jī)是高電平復(fù)位,低電平工作,當(dāng)按下去的時(shí)候,電容起到放電的作用,瞬間是 +5V 的高電平。當(dāng)我們的程序運(yùn)行中,遇到一些特殊情況造成系統(tǒng)奔潰了,我們把這種情況叫做死機(jī),類似我們的電腦的,這個(gè)時(shí)候我們可以手動(dòng)按下復(fù)位按鍵,單片機(jī)會(huì)重新運(yùn)行。只要單片機(jī)一上電,電容啟振,晶振工作,這樣單片機(jī)就有一個(gè)持續(xù)的時(shí)鐘信號(hào)。 13. PDIP 封裝 ,引腳圖如下: 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 7 圖 26 STC89C52 單片機(jī)管腳圖 系統(tǒng)電路設(shè)計(jì) 本設(shè)計(jì)中使用 51 內(nèi)核芯片單片機(jī)是 STC89C52,通過 2 個(gè) 20P 電容和 1個(gè) 12MHz 的晶振組成的晶振電路,系統(tǒng)的時(shí)鐘脈沖就是由它提供,還有通過 1 個(gè)電阻和 1 個(gè)電解電容和 1個(gè)按鍵組成的復(fù)位電路, 使用 1個(gè)數(shù)字溫濕度傳感器 DHT11 對(duì)機(jī)房?jī)?nèi)溫度及濕度的檢測(cè),通過 4個(gè)按鍵來設(shè)定溫濕度的上下限值,如果檢測(cè)溫度高于設(shè)定上限溫度 驅(qū)動(dòng)降溫電路,如果檢測(cè)溫度低于設(shè)定下限驅(qū)動(dòng)加熱電路,如果檢測(cè)濕度高于設(shè)定濕度上限驅(qū)動(dòng)去濕電路,如果檢測(cè)濕度低于設(shè)定下限驅(qū)動(dòng)加濕電路。 其他 3 個(gè)口都有內(nèi)部的上拉電阻 ,所以可以不用外接。 其特性有: 8K字節(jié)程序 存儲(chǔ)空間 ; 512 字節(jié)數(shù)據(jù)存儲(chǔ)空間; 內(nèi)帶 2K 字節(jié) EEPROM 存儲(chǔ)空 間 。 其內(nèi)部有一個(gè) PN 結(jié)組成,當(dāng)給發(fā)光二極管正極加上約 2V 電壓的時(shí)候就會(huì)發(fā)光,如果正負(fù)極接反的話不導(dǎo)通,電壓過大會(huì)燒壞發(fā)光二極管。超小的體積、極低的功耗,信號(hào)傳輸距離可達(dá)20 米以上,使其成為各類應(yīng)用甚至最為苛刻的應(yīng)用場(chǎng)合的最佳選則。通過控制 1602 的控制管腳 RS,RW,E 我們即可向 LCD1602 顯示器中寫入數(shù)據(jù),具體的顯示位子第一行起始地址是 0x80,第二行顯示的起始地址是 0x40+0x8。該設(shè)計(jì)使用它可以滿足我們的所有需求。所以本文研究基于單片機(jī)設(shè)計(jì)溫濕度檢測(cè)系統(tǒng)將是非常有意義和價(jià)值的。 LCD1602 crystal。隨著科學(xué)技術(shù)的快速發(fā)展,尤其是進(jìn)入 21世紀(jì)以來微處理器及傳感器的發(fā)展,使得單片機(jī)的應(yīng)用越來越廣泛,因此也將單片機(jī)技術(shù)應(yīng)用到機(jī)房溫濕度檢測(cè)控制系統(tǒng)上。 關(guān)鍵詞 : STC89C52 單片機(jī); DHT11 溫濕度傳感器 ; 蜂鳴器 ; LCD1602 液晶 ; KEIL 福建農(nóng)林大學(xué)金山學(xué)院本科畢業(yè)設(shè)計(jì)說明書 II Abstract This design based on MCU temperature and humidity testing system, in order to achieve automatic control of room temperature and humidity, solve the waste of human resources, management is not timely issues. With the rapid development of science and technology, especially the development of microprocessor and sensor since twentyfirst Century, making more and more extensive application of singlechip microcontroller, so will technology applied to room temperature and humidity measurement and control system. This paper first describes the background and significance of the subject, then the whole system hardware design and software design are emphatically analyzed, which in the hardware design of the selected device are described, such as LED, LCD1602, STC89C52 microcontroller, DHT11 temperature and humidity sensor and the buzzer button, then the this design is summarized. This design uses digital temperature and humidity sensor DHT11 to detect the temperature and humidity inside the room, through the button to set upper and lower values of temperature and humidity, the detected value is pared with the set value of the drive and corresponding cooling heating and humidifying dehumidifying device. The whole control process using passive buzzer as the alarm, select the system LCD1602 as a liquid crystal display, realtime display of temperature and humidity detection value. The hardware of this system has the advantages of simple structure, flexible operation, with the language C language development, KEIL4 application development software development tools and design