基于單片機的環(huán)境檢測系統(tǒng)設(shè)計
基于單片機的環(huán)境檢測系統(tǒng)設(shè)計,基于,單片機,環(huán)境,檢測,系統(tǒng),設(shè)計
畢 業(yè) 設(shè) 計(論 文)外 文 參 考 資 料 及 譯 文
譯文題目: Temperature and Humidity Control System
of Smart Home Based on SCM
基于單片機的智能家居溫濕度控制系統(tǒng)
學(xué)生姓名:
專 業(yè):
所在學(xué)院:
指導(dǎo)教師:
職 稱:
年 3 月 8 日
Temperature and Humidity Control System of Smart Home Based on SCM
Lihua Deng Electrical Engineering and Renewable Energy School China Three Gorges University Yichang
Tinglong Tang College of computer and information technology China Three Gorges University Yichang
Abstract: Smart Home is one currently hot issues of automatic control research field. In the paper, temperature and humidity control system of smart home was designed based on STC89S52 SCM. SHT10 digital temperature and humidity sensor DB112 was used in the control system design. The temperature and humidity were measured by temperature and humidity sensor. You can set the temperature and humidity limit and lower limit value on the keyboard. If temperature and humidity in the indoor is upper than or lower the set limit, the SCM will drive the corresponding household work and these setting and measurement value can be displayed by LCD.
Keywords: Smart Home; Temperature; Humidity; Control System component; STC89S52 SCM; LCD
I. INTRODUCTION
With the improvement of living standards, higher and higher requirements were requested to living environment. Home environment automation has been becoming a trend of the global home design. The rapid development of science and technology may be provided conditions for the realization of Smart Home. So Smart Home control system has gradually matured. Electronic device performance optimization and lower prices make function of smart home more fully, lower cost and smart home life gradually to the masses. Smart Home control system is to combine a variety of smart home appliances together to form a core component of the perfect whole. Home temperature and humidity control system is essential for smart home control system as a subsystem .
II. SYSTEM FUNCTION DESIGN
The system include: SCM, LCD, keyboard input, temperature and humidity measurements and drivers of the implementation device. System structure is shown in figure 1. Upper and lower limits of temperature and humidity can be modified by keyboard input. LCD shows the measured temperature and humidity. SCM drives corresponding home appliances to act based on the comparison. If the temperature is less than the lower limit of the measured temperature, SCM will drive the air conditioning to work. If the humidity is exceeded the upper limit, SCM will drive the humidifier to work. Output drive signal of SCM parallel port will control switch of appliances through transistor amplification control relay.
III. SYSTEM HARDWARE DESIGN
A. Power Circuit: The system uses STC89S52 microcontroller. Operating voltage range of STC89S52 SCM is from 3.4 to 5.5V and three terminal integrated circuit voltage regulators 1N7805 was used. The regulator can convert 7.5-12V DC input voltage to DC output voltage of 5V .
B. Minimum System of SCM: Minimum system circuit of SCM is shown in Figure 3. Clock circuits and power on reset circuits are to form minimum system of SCM. 12MHz and high stability passive crystal oscillator passive is applied. Capacitors C2, C3 can play a role in frequency tuning and the circuit is 27pF. Capacitor C5 and resistor R3 constitute a power-on reset circuit. When power is on, the capacitor C5 will be charged and then be discharged through resistor R3, the reset of CPU will generate a high pulse .As long as the maintenance time of high level is longer than two machine cycles, CPU can be a normal reset. Buttons S1 and resistor R2 form button reset circuit .
C. Keyboard Input Circuit: When the system inputs the upper and lower limit of temperature and humidity, 0 to 9 needs to be input. At first, we can enter the setup interface and press the setup button, then choose the settings to edit, in the end we press the enter key after we has been choose. Therefore, the system needs 16 keys. If each key access a control line, 16 control lines will be needed. The design will waste a lot I/O port resource of the SCM [4]. To save the SCM resources of I/O port, the system uses 4× 4 determinant keyboard. It only needs 8 I/O ports and port P1 of SCM is used as keyboard input. P1.0-P1.3 will connect the keyboard's four-line determinant line 1-4 line in order. P1.4-P1.7 will connect the keyboard's four columns determinant line 4-1 column in order.The first four column lines are scanned and P1 can be supposed to 0xf0. If any key is pressed, the high four bit of P1 port is not equal to 0 at least one bit, so P1 is not equal to 0xf0, otherwise P1 is equal to 0xf0. But sometimes due to the jitter of keys or interference, it may be judged that any keys are pressed several times. It needs to use technology of Elimination of Jitter and P1 port will be read each time interval of 50MS. If the continuous three values are different, we can think that a key has been pressed. When key is pressed, four rows line are detected and the corresponding row line is 0. So we can judge which button has been pressed. Corresponding relations of the button and the key code is shown in Table 1. Table1. Keys and key code corresponding to the table
D. Liquid Crystal Display Circuit: LCD modules use Chinese character graphics Dot Matrix LCD Module JM12864M of 128× 64 dot matrix character and ST7920 driver. The LCD module can display Chinese characters and graphics, and built-in 8192 Chinese characters (16X16 dots), 128 characters (8X16 lattice) and 64X256 dot matrix display RAM (GDRAM). Data ports D0-D7 is connect with P0 port of SCM. Port P0 of SCM is 8-bit open drain bi-directional I/O port. It is connected with data port of LCD, an external 10K pull up resistor of 8× 10K need. P3.4, P3.5 P3.6 port of SCM are used to control the LCD module and enables E, RS-port, R/W port and deflection device W1 can change the LCD contrast.
E. Actuator drives circuit and temperature and humidity sensor circuit: Since the implementation device is 220V city electric start household appliances, Darlington Arrays ULN2003 of high voltage and high current is used to drive the relay switch. SCM gives commands to household based on measured values exceed the set range. The command will come from the P2.1-P2.7 port output, amplified by the ULN2003 to control the relay switch. Drive circuit is shown in Figure 6. Air conditioners, humidifiers and other household appliances are connected with the right port of the relay. Temperature and humidity sensor use digital temperature and humidity sensor probe DB112 within the package SHT10. Temperature and humidity sensor measures temperature and humidity, if the indoor temperature and humidity than the set upper and lower limits, the SCM will drive the corresponding household work.
IV. SYSTEM SOFTWARE DESIGN
System software is modular design, including the main interface program module and set interface program modules. The control system total flow is shown in Figure 7; the main interface program flow chart is shown in Figure 8. Set the interface program flow chart is shown in Figure 9. Two program modules called a number of small program modules, including the keyboard scanning program module, the temperature and humidity measurement and calculation program modules, liquid crystal display program module and relay driver module.
V. CONCLUSIONS
Temperature and humidity control system of smart home not only can be used as an independent control system, but also can be integrated together with other control systems to form a part of smart home control system based on SCM. The system has been running several independent tests, easy to use and fast response. The automatic control operation mode eliminates the trouble of manual switching devices and achieves a good energy saving effect, so it is a good prospect.
基于單片機的智能家居溫濕度控制系統(tǒng)
鄧?yán)A,電氣工程與可再生能源學(xué)院,中國長江三峽大學(xué),中國宜昌
唐廷朗,計算機與信息技術(shù)學(xué)院,中國長江三峽大學(xué),中國宜昌
摘要: 智能家居是目前自動控制研究領(lǐng)域中的一個熱點問題。本論文所述及的溫濕度控制系統(tǒng)是在 STC89S52 單片機的基礎(chǔ)上進(jìn)行設(shè)計的。 在該智能家居自動控制系統(tǒng)的設(shè)計中用到了 SHT10 數(shù)字溫度傳感器和 DB112 濕度傳感器。溫度和濕度分別由溫度和濕度傳感器測得。我們可以在鍵盤上設(shè)置溫度和濕度的檢測范圍以及溫濕度的上下限。如果室內(nèi)的溫度和濕度高于或者低于設(shè)定 值時, 單片機將會驅(qū)動相應(yīng)器件進(jìn)行工作, 這些設(shè)置量和檢測值則可以通過液晶顯示器顯示出來。
關(guān)鍵詞:智能家居;溫度;濕度;控制系統(tǒng)組件;STC89S52 單片機; 液晶顯示器
一.引言
隨著當(dāng)今消費者生活水平的不斷提高,人們對生活環(huán)境的要求也在變得越來越 高?,F(xiàn)如今,家庭環(huán)境的自動化已經(jīng)成為全球家居設(shè)計的一種趨勢??茖W(xué)技術(shù)的飛速 發(fā)展也為智能家居更好的實現(xiàn)提供了非常有利的條件。因此,智能家居控制系統(tǒng)也正 在逐漸變得成熟。而且,不斷優(yōu)化的電氣性能和逐漸降低的價格也正在使智能家居的 功能變得更加全面,價格變得更加低廉。智能家居生活正在逐步地走向大眾群體。智 能家居控制系統(tǒng)作為一個核心部件與各種智能家電一起構(gòu)成了一個非常完美的整體。 家居溫度和濕度控制系統(tǒng)是智能家居控制系統(tǒng)中一個至關(guān)重要的必備子系統(tǒng)。
二.系統(tǒng)功能設(shè)計
該系統(tǒng)(智能家居自動控制系統(tǒng))主要包括:單片機,液晶顯示,鍵盤輸入,溫 度和濕度的測量以及電氣設(shè)備驅(qū)動。系統(tǒng)結(jié)構(gòu)如圖 1 所示。溫度和濕度的上下限可以 通過鍵盤進(jìn)行輸入與修改,而溫濕度測量值則由液晶顯示器予以顯示,單片機則將溫濕度的檢測值與設(shè)定值進(jìn)行比對后驅(qū)動相應(yīng)電器進(jìn)行運作。 如果溫度低于所測溫度的下限值,那么單片機將驅(qū)動空調(diào)工作。如果濕度超過上限值,單片機將驅(qū)動加濕器工作。單片機并行端口輸出的驅(qū)動信號將通過三極管放大控制繼電器來控制電器開關(guān)。
三.系統(tǒng)硬件設(shè)計
A. 電源電路 該智能家居自動控制系統(tǒng)采用了 STC89S52 微控制器。STC89S52 單片機的工作電 壓范圍為 3.4 至 5.5V。此外,還用到了 1N7805 三端集成電路穩(wěn)壓器。該穩(wěn)壓器可將 7.5 -12V 的直流輸入電壓轉(zhuǎn)換為 5V 的直流輸出電壓。
B.單片機最小系統(tǒng)
單片機最小系統(tǒng)電路示于圖 3。時鐘電路和上電復(fù)位電路組成單片機最小系統(tǒng)。 單片機最小系統(tǒng)采用了 12MHz 的高穩(wěn)定性無源晶振振蕩器。容值 27pF 的電容器 C2, C3 起到頻率調(diào)諧作用。電容器 C5 和電阻 R3 構(gòu)成上電復(fù)位電路。電源接通時,電容 器 C5 充電,后經(jīng)電阻 R3 放電,CPU 復(fù)位將會產(chǎn)生一個高脈沖。只要高電平的維持時 間長于兩個機器周期, CPU 就可正常復(fù)位。 按鈕 S1 和電阻 R2 組成按鍵復(fù)位電路 。
C.鍵盤輸入電路
用鍵盤上 0-9 的數(shù)字組合將溫濕度上下限輸入系統(tǒng)。首先我們進(jìn)入設(shè)置界面,然后 按下設(shè)置按鈕,接著選擇設(shè)置編輯,選完后按回車鍵退出。因此系統(tǒng)需要 16 個按鍵。 如果每個按鍵訪問一條控制線,就要用到 16 條控制線,會浪費大量的單片機 I / O 口資源。為節(jié)省 I / O 口資源,本系統(tǒng)將采用 4 × 4 行列式鍵盤,它只需 8 個 I / O 端口和單片機的 P1 口就能實現(xiàn)鍵盤輸入功能。 P1.0- P1.3 口順次連接鍵盤 1- 4 行 的行線。 P1.4 - P1.7 口則依次連接鍵盤 4-1 列的列線。初始狀態(tài)下系統(tǒng)自動掃描鍵盤的四列列線,此時 P1 口值應(yīng)為 0xf0。若有按鍵按 下, P1 口的高 4 位至少有一位不為 0, 所以 P1 口就不等于 0XF0, 否則 P1 口值為 0XF0。 但有時由于鍵盤抖動和干擾,系統(tǒng)無法判別到底是哪何鍵按下以及被按下幾次。因此 須采用消抖技術(shù),且 P1 口每隔 50MS 讀取一次數(shù)據(jù)。若連續(xù)三個值均不同,我們就可 認(rèn)為有按鍵被按下。按鍵被按下時,系統(tǒng)對四行行線進(jìn)行檢測并讀取相應(yīng)行線的值為 0。這樣我們就可以判定按下的到底是哪個鍵了。
D.液晶顯示電路
液晶顯示模塊采用 128×64 的漢字字符圖形點陣液晶顯示模塊和和 ST7920 驅(qū)動。 液晶顯示模塊可顯示漢字和圖形,且內(nèi)置 8192 個中國漢字(16X16 點陣) ,128 個字 符(8X16 點陣)及 64X256 點陣顯示 RAM(GDRAM) 。數(shù)據(jù)端口 D0-D7 口用于連接單片 機的 P0 口。單片機的 P0 口是 8 位開漏雙向 I/O 口,它與液晶顯示器的數(shù)據(jù)端口相連 接時需外加 8×10K 的 10K 上拉電阻。單片機的 P3.4,P3.5 和 P3.6 端口用于控制液 晶顯示模塊、激活 ERS 端口與 R/W 端口,并且偏轉(zhuǎn)裝置 W1 還可以改變 LCD 的對比度。
E.執(zhí)行器驅(qū)動電路和溫濕度傳感器電路
由于實施設(shè)備是 220V 市電啟動家電,所以,驅(qū)動繼電器開關(guān)是由高電壓和高電 流控制的達(dá)林頓陣列 ULN2003 來驅(qū)動。當(dāng)測量值超出設(shè)定范圍時,單片機就向家電發(fā) 出指令,該指令由 P2.1 - P2.7 口輸出,經(jīng) ULN2003 放大后去控制繼電器開關(guān)。驅(qū)動 電路如圖 6 所示??照{(diào)、加濕器等家用電器應(yīng)正確連接繼電器的相應(yīng)端口。溫濕度傳 感器采用 STH10 系列的數(shù)字式溫濕度傳感器探頭 DB112 。溫濕度傳感器用于測量溫 度和濕度, 如果室內(nèi)溫度和濕度高于設(shè)定的上下限, 則單片機就驅(qū)動相應(yīng)的家電工作。
四.系統(tǒng)軟件設(shè)計
系統(tǒng)軟件采用模塊化設(shè)計,其中包括主界面程序模塊和接口的設(shè)置程序模塊。該 控制系統(tǒng)的總流程圖如圖 7 所示,主要的接口程序流程圖如圖 8 所示。設(shè)定接口程序 流程圖如圖 9 所示。其中兩個程序模塊調(diào)用到了一些小的子程序模塊,包括鍵盤掃描程序模塊,溫濕度的測量和計算的程序模塊,液晶顯示程序模塊和繼電器驅(qū)動模塊。
五.結(jié)論
智能家居的溫濕度控制系統(tǒng)不僅可以作為一個獨立的控制系統(tǒng), 而且也可以連同 其他控制系統(tǒng)一起集成基于單片機的智能家居控制系統(tǒng)。 該系統(tǒng)已經(jīng)運行了幾個獨立 的測試,應(yīng)用方便,響應(yīng)迅速。自動控制操作模式消除了手動開關(guān)器件的麻煩,很好 的達(dá)到了高效節(jié)能的目的,所以,智能家居的溫濕度控制系統(tǒng)具有很好的應(yīng)用前景。
收藏