【正文】
圖溫度檢測電路由半導(dǎo)體集成傳感器AD590和電阻構(gòu)成,AD590輸出電流通過電阻進(jìn)入模擬地,產(chǎn)生相應(yīng)的電阻電壓。RS232接口電路與PC機(jī)的串行口聯(lián)接,實(shí)現(xiàn)下載程序等通訊功能。溫度檢測模塊主要是完成測溫電路所得電壓與實(shí)際溫度的轉(zhuǎn)換,和對溫度數(shù)據(jù)的存儲、顯示;相對濕度檢測模塊除了要實(shí)現(xiàn)對濕度數(shù)據(jù)的存儲 、顯示外,還要對濕度信號進(jìn)行溫度補(bǔ)償和線性化處理。167。STC12C5410AD 單片機(jī)采用增強(qiáng)型 8051 CPU,1T,單時(shí)鐘/ 機(jī)器周期,指令代碼完全兼容傳統(tǒng)8051的高速單片機(jī)。C1和C2是30pf。開關(guān)按下時(shí)是按鍵手動復(fù)位電路,RST端通過電阻與VCC電源接通,通過電阻的分壓就可以實(shí)現(xiàn)單片機(jī)的復(fù)位。167。即-273℃時(shí)AD590的輸出電流為0μA,0℃時(shí)輸出約為273μA。167。%RH);具有極好的線性輸出等特性。3℅RH,分辨力 ℅RH,使得相對濕度傳感器THS11的測量范圍大,長期穩(wěn)定性好,響應(yīng)時(shí)間短,溫度系數(shù)低,線性度較好,體積小。本設(shè)計(jì)中采用五個(gè)數(shù)碼管進(jìn)行靜態(tài)顯示,所以要用五個(gè)74HC164分別控制五個(gè)數(shù)碼管的顯示和選通,前一個(gè)74HC164的QH與后一個(gè)74HC164的輸入端相連,74HC164的輸出端QA~QH通過電阻連到數(shù)碼管上,控制數(shù)碼管選通的信號為P1。74HC164的CLEAR端都始終接高電平,74HC164的A、。其中的共陽極接法在設(shè)計(jì)中得以應(yīng)用,單片機(jī)信號通過移位寄存器74HC164輸出,經(jīng)過八個(gè)電阻在LED數(shù)碼管上顯示出來。26第2章 溫濕度檢測儀的軟件設(shè)計(jì)167。主程序初始化的具體內(nèi)容包括:時(shí)間中斷的初始化、外部中斷源的初始化、單片機(jī)I/O口初始化、RAM初始化、LED初始化、對各個(gè)子程序的調(diào)用,然后對溫度和濕度進(jìn)行檢測并將結(jié)果顯示在LED上。 溫度檢測模塊程序設(shè)計(jì)該檢測儀的溫度檢測部分使用的AD590是一種由所在環(huán)境溫度決定的恒流輸出器件,其輸出特性為:I=KtAD590輸出電流信號經(jīng)電阻R轉(zhuǎn)換為電壓信號,其電壓為:VR = KtR15)。為保證校準(zhǔn)精度,環(huán)境溫度應(yīng)在25℃左右變化,并且變化的范圍盡可能大一些。只需按照手冊中所說明的ADC的用法即可完成AD轉(zhuǎn)換功能。如果舍棄ADC_LOW2 的低2 位,只用ADC_DATA 寄存器的8 位,則A/D 轉(zhuǎn)換結(jié)果為8 位精度。上電復(fù)位后P1 口為弱上拉型I/O 口,用戶可以通過軟件設(shè)置將8 路中的任何一路設(shè)置為A/D 轉(zhuǎn)換,不需作為A/D 使用的口可繼續(xù)作為I/O 口使用。 本設(shè)計(jì)中為了使編程盡量簡潔所選取的阻值非常特殊:AD590變化的電流通過這個(gè)特定阻值的電阻時(shí),轉(zhuǎn)變?yōu)橐粋€(gè)變化的電壓,這個(gè)電壓變化一個(gè)毫安對應(yīng)溫度變化一度,這樣大大化簡了程序中對的溫度的算法。167。當(dāng)環(huán)境中的相對濕度不同時(shí),相同溫度條件下的振蕩頻率差異比較大,且這種差異是非線性的。(fRH/fRH0)式中Δf RH0的值為297/65(Hz/℃);fRH0是溫度為0℃時(shí)相對濕度為0%RH的振蕩頻率,其值為7588(Hz);fRHX是溫度為0℃時(shí)相對濕度為X%RH的振蕩頻率。當(dāng)相對濕度值升高時(shí),振蕩器輸出頻率會隨之降低,而且它們之間的這種變化是非線性的。由于振蕩頻率隨環(huán)境相對濕度變化是非線性的,這給濕度轉(zhuǎn)換帶來了困難,因此需要對其進(jìn)行線性化處理。對于頻率的測量,單片機(jī)由多種測量方法,大體由中斷測量和定時(shí)計(jì)數(shù)兩大方式。在濕度檢測模塊程序的開始,首先讀取經(jīng)過A/D轉(zhuǎn)換的相對濕度的振蕩頻率fo,并把得到的相對濕度頻率值存儲于STC12C5410AD的一個(gè)變量單元中。然后把頻率曲線上相鄰的兩點(diǎn)依次用直線相連,就得到一條新的濕度頻率曲線,它與實(shí)際曲線幾乎重合在一起,所以可以使用該曲線產(chǎn)生進(jìn)行線性化處理。線性化處理程序子程序流程圖如36所示。如果差值大于0,則說明測得頻率超出檢測儀的測量范圍,轉(zhuǎn)入報(bào)告出錯(cuò)子程序,告訴用戶出錯(cuò)。因?yàn)檫@一比較涉及到,檢測儀報(bào)錯(cuò)功能,更重要的是接下來的頻率比較必須以第一次比較為參考。如果前面比較的結(jié)果值還是小于零,說明該振蕩頻率f不在該段,就把比較次數(shù)f加1后,從表中再次取值,繼續(xù)進(jìn)行的比較,直至比較結(jié)果大于零。 鍵盤掃描鍵盤是人機(jī)交換的橋梁,一個(gè)好的鍵盤能夠讓用戶方便的使用儀表。由于74HC164是工作在上升沿,所以本設(shè)計(jì)可以在其數(shù)據(jù)端輸入一個(gè)等待送出的數(shù)字,然后通過在其時(shí)鐘輸入端送入一個(gè)上升沿,就可以實(shí)現(xiàn)把等待送出的數(shù)字發(fā)送出去。然后本設(shè)計(jì)再一列一列的掃描鍵值,具體過程如下:首先通過164輸出一個(gè)11111110B后,讀入鍵盤的行,如果為0,則表示是第一個(gè)鍵按下,如果不為0,則表示不是第一個(gè)鍵按下,然后再在164端輸出一個(gè)11111101B再進(jìn)行上述掃描過程直至行線為0即掃描到鍵值,即完成了鍵盤的掃描過程。(2).LED的靜態(tài)顯示 LED的靜態(tài)顯示就是在LED上送入待顯示的內(nèi)容后,LED的管腳的狀態(tài)一直保持不變,即在LED上穩(wěn)定靜止的顯示出待顯示的內(nèi)容,該種設(shè)計(jì)軟件編寫簡單,單片機(jī)軟件資源占用少,但相應(yīng)的在沒加輔助顯示芯片,使電路復(fù)雜,I/O口占用過多。本設(shè)計(jì)采用靜態(tài)顯示一次必須送完一幀5位數(shù)據(jù),這樣對單個(gè)數(shù)據(jù)的修改就比較麻煩,尤其是在碰到有小數(shù)點(diǎn)顯示的時(shí)候,不能夠只改變一位來實(shí)現(xiàn),必須得5位數(shù)據(jù)全部重新送數(shù)。 在進(jìn)行軟件設(shè)計(jì)時(shí),先寫完各個(gè)模塊的程序,當(dāng)每個(gè)模塊的程序都調(diào)試通過后,在根據(jù)設(shè)計(jì)的要求,按照最先實(shí)際的總的程序流程圖來完成子程序之間的相互協(xié)調(diào)調(diào)用來實(shí)現(xiàn)整個(gè)程序的調(diào)試工作,通過多次反復(fù)的調(diào)試修改,當(dāng)總程序能夠?qū)崿F(xiàn)設(shè)計(jì)要求時(shí),程序的設(shè)計(jì)才大體完成。但是STC12C5410AD單片機(jī)工作頻率較高,并且只有環(huán)境濕度較高時(shí)才會出現(xiàn)處理時(shí)間延長現(xiàn)象,因此并不影響檢測儀的實(shí)時(shí)檢測指標(biāo)。在指導(dǎo)老師的悉心輔導(dǎo)下和查閱大量資料之后,然后采用了STC12C5410AD數(shù)據(jù)采集芯片并配合其它一些元器件的硬件設(shè)計(jì)方案,使以上問題得到了很好解決 。:北京航空航天出版社,2002[13] :高等教育出版社,2002[14] 劉書明、[M] .西安:西安電子科技大學(xué)出版社,2000.[15] 涂玲英.肖俊武.張宇.智能型溫濕度測控儀研究與實(shí)踐.湖北工學(xué)院學(xué)報(bào).2002.[16] 蔡美琴.MCS一51系列單片機(jī)系統(tǒng)及其應(yīng)用.高等教育出版社.1992.[17] 閻石. 數(shù)字電子技術(shù)基礎(chǔ). 北京: 高等教育出版社, 2002[18] 劉同法, 陳忠平. 單片機(jī)基礎(chǔ)與最小系統(tǒng)實(shí)踐. 西安: 西安電子科技大學(xué)出版社, 2007.[19] 涂玲英, 肖俊武, 張宇. 智能型溫濕度測控儀研究與實(shí)踐. 湖北工學(xué)院學(xué)報(bào), 2002[20] 潘永雄. 新編單片機(jī)原理與應(yīng)用. 西安西安電子科技大學(xué)出版社, 200350致 謝本設(shè)計(jì)的題目是由孫言增導(dǎo)師根據(jù)實(shí)際工作和生產(chǎn)中的具體需要擬定的,花費(fèi)了許多時(shí)間和精力查詢資料,最終定出設(shè)計(jì)方案 。在此我衷心的感謝孫老師對我這次畢業(yè)設(shè)計(jì)指導(dǎo)和幫助。C in 176。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 addresses devices whose temperature is outside of programmed limits (temperature alarm condition)? Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally 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 places. Applications 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 ponents of 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 times of the 1–Wire line until it returns high to replenish the parasite (capacitor) supply. As an alternative, the DS1820 may also be powered from an external 5 volts supply. Communication to the DS1820 is via a 1–Wire port. With the 1–Wire port, the memory and control functions will not be available before the ROM function protocol has been established. The master must first provide one of five ROM function mands: 1) Read ROM, 2) Match ROM, 3) Search ROM, 4) Skip ROM, or 5) Alarm Search. These mands operate on the 64–bit lasered ROM portion of each device and can single out a specific device if many are present on the 1–Wire line as well as indicate to the Bus Master how many and what types of devices are present. After a ROM function sequence has been successfully executed, the memory and control functions are accessible and the master may then provide any one of the six memory and control function mands. One control function mand instructs the DS1820 to perform a temperature measurement. The result of this measurement will be placed in the DS1820’s scratchpad memory, and may be read by issuing a memory function mand which reads the contents of the scratchpad memory. The temperature alarm triggers TH and TL consist of one byte EEPROM each. If the alarm search mand is not applied to the DS1820, the