基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計_第1頁
基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計_第2頁
基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計_第3頁
基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計_第4頁
基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計_第5頁
已閱讀5頁,還剩44頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計————————————————————————————————作者:————————————————————————————————日期:題目基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計學(xué)生姓名張大陸學(xué)號1213014089所在學(xué)院物理與電信工程學(xué)院專業(yè)班級電子信息工程專業(yè)12級3班指導(dǎo)教師帥春江完成地點陜西理工學(xué)院2016年6月5日基于單片機的糧倉溫濕度控制系統(tǒng)設(shè)計作者:張大陸(陜西理工學(xué)院物理與電信工程學(xué)院電子信息工程專業(yè)12級3班,陜西漢中723001)指導(dǎo)老師:帥春江[摘要]影響糧食安全儲存的主要參數(shù)是糧倉的溫度和濕度,糧倉溫濕度測量方法以及相應(yīng)的智能控制一直是糧食儲存的一個重要問題。本設(shè)計采用STC89C52單片機最小系統(tǒng)對檢測、報警、顯示、調(diào)控等模塊進行多點控制,傳統(tǒng)的溫濕度控制利用溫度計、濕度表、濕度試紙等測試器材,通過人工進行檢測,對不符合溫濕度要求的庫房進行通風(fēng)、降溫、去濕等操作。這種方法費時費力,效率低,隨機性大,誤差大,不能及時的解決問題。本設(shè)計則通過自動檢測、即時報警、自動調(diào)控等功能很好的解決了。并且,本設(shè)計不僅針對糧倉,對于大多譬如蔬菜大棚、花圃、實驗室、醫(yī)院等需要溫濕度檢測控制的各個領(lǐng)域都是適用的。[關(guān)鍵詞]糧倉;溫濕度;多點檢測控制;單片機DesignoftemperatureandhumiditycontrolsystemforgrananybasedonsinglechipmicrocomputerAuthor:DaluZhang(Grade12,Class3,Majorelectronic1sandinformationengineering,SchoolofPhysicsandElectrInformationEngineering,ShaanxiUniversityofTechnology,Hanzhong723001,Shaanxi)Tutor:ChunjiangShuaiAbstract:Grainisanecessityforhuman,thegrainstorageisveryessentialtothemaintenanceofsocialandkeeptheeconomysustainabledevelopmented.Andthemainparameterstothegrainsafestorageisthetemperatureandhumidity.ThisdesignusestheSTC89C52systemofsinglechipmicrocomputertocotrolthemodulesaboutthedetection,alarm,controlandthekey.Anditcouldautomaticmeasurementandcontrolwithoutpeople,andimproveeffciencyandqualityofworkverywell.DHT11temperatureandhumiditysensorsandOLEDdisplayshowsrealtimedataandpasstothestaffwithinstantandaccurate.WhilethetraditionaltemandhumiditycontrolisuseofThermometer,humiditytable,humiditydipsticktestequipment.Throughtheartificialtesting.Notinconformitywiththerequirementsofthetemperatureandhumiditysupplycooling,ventilation,towetoperation.Thisartificialtestingtime-consuming,theefficiencyislow.Thisdesignisbyautomaticdetectalarm,automaticregulationoffunctionssuchasagoodsolutiontotheseproblems.Atlast,thisdesignnotthegranary,butalsoformostsuchasvegetablegreenhouses,flowersgarden,laboratories,hospitalscouldalsobeapplicabled.Keywords:Granary;automaticdetectionandcontrol;temperatureandhumidity;Singlechip目錄1引言.....................................................01.1.............................................背景及意義01.2現(xiàn)狀及發(fā)展趨勢........................................01.3研究內(nèi)容.............................................02系統(tǒng)總體方案設(shè)計.........................................12.1設(shè)計要求.............................................12.2系統(tǒng)基本方案.........................................12.2.1傳感器方案......................................12.2.2顯示器方案........................................12.2.3單片機主芯片方案..................................12.3總體設(shè)計框圖.........................................23系統(tǒng)硬件設(shè)計.............................................33.1主控模塊.............................................33.1.1STC89C52芯片.....................................33.1.2STC89C52芯片的管腳、引線與功能...................33.1.3主控模塊電路原理圖................................43.2溫濕度檢測模塊........................................53.2.1DHT11傳感器簡介..................................53.2.2DHT11傳感器模塊電路..............................73.3顯示模塊................................................73.3.1OLED顯示屏簡介...................................73.4報警模塊.............................................83.4.1蜂鳴器介紹........................................83.4.2蜂鳴器工作原理....................................83.5溫濕度調(diào)控模塊..........................................83.5.1繼電器............................................83.5.2溫濕度調(diào)控模塊....................................94系統(tǒng)軟件設(shè)計............................................104.1主程序設(shè)計.............................................104.2傳感器模塊設(shè)計.......................................114.3軟件調(diào)試...............................................115系統(tǒng)的安裝與調(diào)試........................................136結(jié)論與展望..............................................15致謝.....................................................16參考文獻.................................................17附錄A英文文獻...........................................18附錄B中文譯文...........................................23附錄C系統(tǒng)原理圖.........................................26附錄D實物圖.............................................27附錄E元器件清單.........................................29附錄FC語言程序.........................................30

系統(tǒng)總體方案設(shè)計設(shè)計要求(1)本設(shè)計給出糧倉溫濕度控制系統(tǒng)的總體方案設(shè)想,智能項目,和設(shè)計結(jié)構(gòu)規(guī)劃。(2)硬件設(shè)計:實現(xiàn)對糧倉溫濕度采集、控制,以單片機為主的控制器,擴展必要的外部電路,設(shè)計制作一個控制系統(tǒng)。(3)軟件設(shè)計:各項功能的設(shè)計流程。(4)發(fā)揮部分:多點分布式。系統(tǒng)基本方案2.2.1傳感器方案方案一:選用DS18B20溫度傳感器作為溫度檢測模塊。DS18B20是一線式數(shù)字溫度傳感器。具有獨特的單線式接口方式。測量范圍在—10℃~85℃,誤差范圍在-\+0.5℃。最高精度可達0.0625℃。選用HS1101濕度傳感器作為濕度檢測模塊,HS1101是電容式濕度傳感器??蓽y量相對濕度范圍在0%~100%RH。誤差為-\+2%RH。方案二:選用DHT11作為設(shè)計的溫濕度檢測模塊。DHT11是一款集成型的數(shù)字溫濕度一體傳感器。它應(yīng)用專用的溫濕度傳感技術(shù)以及數(shù)字模塊采集技術(shù),具有很高的可靠性能與長期的穩(wěn)定性。電阻式感濕元件和NTC測溫元件是傳感器的基本組成部分。因此該產(chǎn)品品質(zhì)優(yōu)良、響應(yīng)速度快、抗干擾能力強、性價比極高。測量范圍20%~90%RH,0℃~50℃。測溫精度為-\+2℃,測濕精度為-\+5%RH。完全符合本次畢業(yè)設(shè)計的要求。經(jīng)上述分析,方案一雖然精度更精確。卻稍顯復(fù)雜。方案二即便不能實現(xiàn)方案一的高精度測量。卻也能滿足設(shè)計要求。且簡便易行。可靠穩(wěn)定。具有超高的性價比。故選擇方案二。2.2.2顯示器方案方案一:采用12864OLED屏。顯示模塊是128×64點陣的漢字圖形型OLED顯示模塊,可顯示漢字及圖形,內(nèi)置8192個中文漢字(16X16點陣)、128個字符(8X16點陣)及64X256點陣顯示RAM(GDRAM),可與CPU直接接口。方案二:采用HJ1602液晶顯示屏。HJ1602A是一種工業(yè)字符型液晶,能夠同時顯示16x02即32個字符。(16列2行)。1602只能顯示字母、數(shù)字和符號能顯示16*2個字符,但寄存器不止32個,有一些顯示效果,如字符一個個顯示、字符從左到右或從右到左顯示等等,顯示效果簡單??偨Y(jié):在編程使用方面,兩者難度差異較小,OLED屏幕略復(fù)雜。但相比于1602液晶屏,OLED12864所占用單片機管腳少,屏幕亮度高、顯示更加清晰、并且顯示的內(nèi)容更多,能更形象具體的實現(xiàn)顯示功能。2.2.3單片機主芯片方案方案一:AT89C51是美國ATMEL公司生產(chǎn)的低電壓,高性能CMOS型8位單片機,器件采用ATMEL公司的高密度、非易失性存儲技術(shù)生產(chǎn),兼容標準MCS-51指令系統(tǒng),片內(nèi)置通用8位中央處理器(CPU)和Flash存儲單元,功能強大。其片內(nèi)的4K程序存儲器是FLASH工藝的,這種單片機對開發(fā)設(shè)備的要求很低,開發(fā)時間也大大縮短。寫入單片機內(nèi)的程序還可以進行加密,這又很好地保護我們的勞動成果。再者,AT89C51目前的售價比8031還低,市場供應(yīng)也很充足。AT89C51可構(gòu)成真正的單片機最小應(yīng)用系統(tǒng),縮小系統(tǒng)體積,增加系統(tǒng)的可靠性,降低系統(tǒng)的成本。只要程序長度小于4K,四個I/O口全部提供給用戶??捎?V電壓編程,而且擦寫時間僅需lOms[1]。方案二:STC89C52是STC公司生產(chǎn)的功耗低、性能高CMOS8位微控制器,具有8K可編程Flash存儲器。STC89C52使用的MCS-51內(nèi)核,做了很大的提高使芯片具有傳統(tǒng)的51單片機所不具備的功能。在芯片上,擁有8位CPU和可編程Flash,使得STC89C52為嵌入式控制系統(tǒng)提供靈活和有效的解決方案。具有以下的標準功能:8k字節(jié)Flash,512字節(jié)RAM,看門狗定時器,32位I/O口線,內(nèi)置4KBEEPROM,MAX810復(fù)位電路,3個16位定時器/計數(shù)器,2個外部中斷,全雙工串行口。另外STC89C52可降至0Hz靜態(tài)邏輯操作,支持2種軟件可選擇節(jié)電模式??臻e模式下,CPU停止工作,允許RAM、定時器/計數(shù)器、串口、中斷繼續(xù)工作。斷電保

制報警系統(tǒng)。如圖3.2制報警系統(tǒng)。如圖3.2所示。圖3.2STC89C52模塊電路原理圖3.2溫濕度檢測模塊3.2.1DHT11傳感器簡介DHT11傳感器是一種由可校準并且輸出數(shù)字信號的溫濕度傳感器。它采用了數(shù)字式的模塊采集和溫濕度傳感技術(shù),具有非常高的可靠性與長期的使用穩(wěn)定性。傳感器由一個電阻式感濕元件和一個NTC測溫元件組成。因此該產(chǎn)品品質(zhì)卓越、響應(yīng)速度快、抗干擾能力強、性價比極高[8]。每一個DHT11傳感器都在非常嚴格的校驗室中進行校驗。校驗系數(shù)則通過程序的方式存儲在OTP內(nèi)存中,在傳感器的內(nèi)部在檢測和處理信號時需要調(diào)用這些校驗系數(shù)。而其采用的單線制串行接口,則使系統(tǒng)集成快捷簡單。體積小、功耗低,信號傳輸距離較長,使其成為各類應(yīng)用場合的極佳選則。產(chǎn)品為4針單排引腳封裝。連接方便,特殊封裝形式可根據(jù)用戶需求而提供。DHT11傳感器實物圖如圖3.3所示:

即數(shù)據(jù)口。連接傳感器的Pin2即數(shù)據(jù)口。連接傳感器的Pin2(單總線,串行數(shù)據(jù))。由于測量范圍電路小于20米,建議加一個5K的上拉電阻,因此在傳感器的Pin2口與電源之間連接一個5K電阻。而傳感器的電源端口Pin1和Pin4分別接單片機的VDD和GND端。傳感器的第三腳懸浮放置。DHT11傳感器原件的電路圖如圖3.5所示:圖3.5DHT11電路圖3.3顯示模塊3.3.1OLED顯示屏簡介OLED是一種機發(fā)光二極管,它可以自發(fā)光,不需背光源,屏幕對比度高、厚度較薄、可視角度廣、有很快的響應(yīng)速度、使用環(huán)境溫度范圍較大。該屏有以下特點:⑴0.96寸OLED有黃藍,白,藍三種顏色可選;其中黃藍是屏上1/4部分為黃光,下3/4為藍;而且是固定區(qū)域顯示固定顏色,顏色和顯示區(qū)域均不能修改;白光則為純白,也就是黑底白字;藍色則為純藍,也就是黑底藍字。⑵分辨率為128*64⑶多種接口方式;OLED裸屏總共種接口包括:6800、8080兩種并行接口方式、3線或4線的串行SPI接口方式、IIC接口方式(只需要2根線就可以控制OLED),這五種接口是通過屏上的BS0~BS2來配置的。⑷兩種接口的Demo板,接口分別為七針的SPI/IIC兼容模塊,四針的IIC模塊。如圖3.6所示為IIC四針OLED屏幕圖3.6OLED圖3.6OLED屏正面、反面IICOLED引腳說明如表3.3表3.3IICOLED12864顯示屏管腳說明管腳名稱管腳說明GND電源地VCC電源正(3~5.5V)SCLOLED的D0腳,在IIC通信中為時鐘管腳SDAOLED的D1腳,在IIC通信中為數(shù)據(jù)管腳3.4報警模塊3.4.1蜂鳴器介紹蜂鳴器是一體化結(jié)構(gòu)的電子式訊響器。由直流電壓供電,廣泛應(yīng)用于電話機、報警器、復(fù)印機、計算機、打印機、汽車電子設(shè)備、定時器等產(chǎn)品中作發(fā)聲器[9]。其主要分為電磁式蜂鳴器和壓電式蜂鳴器兩種類型。3.4.2蜂鳴器工作原理如圖3.8所示為蜂鳴器工作原理圖。圖3.8蜂鳴器工作原理圖因為單片機的IO口驅(qū)動能力不夠讓蜂鳴器發(fā)出聲音,所以我們通過三極管放大驅(qū)動電流,從而讓蜂鳴器發(fā)出聲音,如果程序控制單片機輸出高電平,三極管導(dǎo)通,集電極電流通過蜂鳴器讓蜂鳴器發(fā)出聲音;當輸出低電平時,三極管截止,沒有電流流過蜂鳴器,所以蜂鳴器不會發(fā)出聲音[10]。3.5溫濕度調(diào)控模塊3.5.1繼電器電磁式繼電器一般由鐵芯、線圈、銜鐵、觸點等組成。本設(shè)計所用五角繼電器為直流輸入28-30V,最大輸入電流為10A。如圖為3.9為5角繼電器實物圖,圖3.10為原理圖。圖3.9圖3.9五角繼電器實物圖圖3.10五角繼電器原理圖當4、5兩端加上相應(yīng)電壓時,線圈就會有電流,產(chǎn)生電磁效應(yīng),銜鐵將會在磁力吸引的作用下克服彈簧拉力吸向鐵芯,而帶動銜鐵的動觸點與2點吸合。當線圈斷電后,電磁的吸力也隨之消失,銜鐵就會在彈簧的反作用力下返回3點,使1點與原來的3點吸合。這樣吸合、釋放從而達到開關(guān)的目的[11]。3.5.2溫濕度調(diào)控模塊如圖3.10位溫濕度調(diào)控模塊原理圖圖3.10溫濕度調(diào)控模塊原理圖當單片機IO口輸出高電平時,通過三極管放大,集電極電流通過4、5點的電磁圈從而產(chǎn)生磁場,會將1點的單刀雙擲開關(guān)吸引到3點常開點上導(dǎo)通從而實現(xiàn)繼電器的功能,外部用電器P1開始正常工作。當單片機IO口輸出低電平時,三極管截止,4、5點的電磁圈沒有電流經(jīng)過不會產(chǎn)生磁場,1點開關(guān)由于自身彈性形變而彈回2點常閉點。4系統(tǒng)軟件設(shè)計4.1主程序設(shè)計在對本設(shè)計硬件部分做好認識后,需要建立程序框架的流程圖,對整個設(shè)計劃分軟件模塊,逐個模塊實現(xiàn)其功能,最終把各個子模塊合理的連接起來,構(gòu)成總的程序。主程序首先要對整個系統(tǒng)進行初始化,然后將采集到的溫濕度指令傳給系統(tǒng)的主流程圖如圖4.1所示:YNNYYNNY初始化延時溫濕度顯示屏溫度高蜂鳴器蜂鳴器蜂鳴器溫度低濕度低濕度高蜂鳴器開始圖4.1主程序流程圖4.2傳感器模塊設(shè)計DHT11傳感器模塊的軟件流程圖如圖4.2所示圖11DHT4.2傳感器模塊程序流程圖4.3軟件調(diào)試本設(shè)計是在KeilC環(huán)境下開發(fā)的,KeilC軟件支持C語言的編程及調(diào)試,運用方便,是做C語言單片機設(shè)計的首選[12]。設(shè)計的首要任務(wù)是安裝和學(xué)習(xí)使用這個軟件,在簡單的學(xué)習(xí)和了解KeilC后,便可在此環(huán)境下開始了對本設(shè)計所需軟件程序進行設(shè)計工作。在編譯完KeilC后,再運用STC_ISP_V480軟件燒錄到開發(fā)板上,實現(xiàn)實物與程序的連接[13]。在燒錄前要對STC_ISP_V480進行一些必要的設(shè)置。第一步:設(shè)置MCUType為STC89C52RC;第二步:打開編寫好并編譯的程序文件,它是以.hex為后綴的文件;第三步:選擇對應(yīng)的COM端口,可在我的電腦的設(shè)備管理處查看COM選項;第四步:點擊Download/下載,等提示請給MCU上電時,打開開發(fā)板上的開關(guān),它就自行燒錄了[14]。給延保持高檢測記輸出低電延時輸出低電數(shù)據(jù)KeilC程序運行如圖KeilC程序運行如圖4.3和4.4所示圖4.3keilC運行圖圖4.4程序燒錄運行圖在完成對程序的調(diào)試及燒錄之后,將燒洗好的單片機放入硬件電路板中進行軟硬件組合調(diào)試。

重新調(diào)整電路后,以上問題得以解決。重新調(diào)整電路后,以上問題得以解決。在基礎(chǔ)部件組合調(diào)試完成后,開始進行系統(tǒng)功能最終調(diào)試。在調(diào)試過程中發(fā)現(xiàn),當檢測數(shù)據(jù)超過預(yù)設(shè)上限數(shù)據(jù),報警模塊和調(diào)控模塊開始工作,存在調(diào)控模塊全部工作時主電路板會出現(xiàn)跳閘斷電情況。在對硬件電路和程序過程進行多次檢查與調(diào)整試驗后發(fā)現(xiàn),主電路板電源輸入線由于過熱導(dǎo)致輸入VCC不穩(wěn)定引起主電路板跳閘,在更換材質(zhì)更好的電源連線后該問題得到解決。經(jīng)過組合調(diào)試后,系統(tǒng)可以按照設(shè)計功能正常工作,本設(shè)計安裝調(diào)試結(jié)束。如圖5.2為系統(tǒng)正常工作時的屏幕顯示狀態(tài)圖5.2正常工作的屏顯狀態(tài)當溫度超過設(shè)定值時,報警模塊與調(diào)控模塊開始工作,蜂鳴器報警,相應(yīng)繼電器工作,風(fēng)扇工作模擬降溫,并且紅色二極管發(fā)光指示。如圖5.3所示,1、2、3、4號檢測端溫度超限,對應(yīng)風(fēng)扇全部工作。圖5.3溫度控制工作當濕度超過設(shè)定值時,報警模塊與調(diào)控模塊開始工作,蜂鳴器報警,相應(yīng)繼電器工作,加熱片工作模擬除濕,并且黃色二極管發(fā)光指示。如圖5.4所示,1、2、3、4號檢測端濕度超限,對應(yīng)加熱片全部工作。圖圖5.4濕度控制工作當溫濕度超過設(shè)定值時,報警模塊與調(diào)控模塊開始工作,蜂鳴器長鳴報警,相應(yīng)繼電器工作,風(fēng)扇工作模擬降溫,加熱片工作模擬除濕,并且二極管發(fā)光指示。如圖5.5所示。圖5.5溫濕度控制同時工作6結(jié)論與展望在經(jīng)過了多次驗證與調(diào)試后,本設(shè)計完成。本系統(tǒng)以單片機為核心部件,利用軟件編程,最終實現(xiàn)了設(shè)計要求。雖然系統(tǒng)還存在一些不足,比如溫濕度測量不夠精確,特別是濕度,波動誤差較大。嘗試了各種改進方法。仍然不太理想,不過能反映出設(shè)計的目的和要求,與預(yù)期的結(jié)果相差不多。經(jīng)過近兩個月的奮斗,從確定題目,到后來查找資料,理論學(xué)習(xí),實驗編程調(diào)試,這一切都使我的理論知識和動手能力有了很大的提高。了解了單片機的硬件結(jié)構(gòu)和軟件編程方法,對單片機的工作方式有了很大的認知。同時,對一些外圍設(shè)備比如傳感器、顯示屏、鍵盤、蜂鳴器、繼電器等有了一定的了解。學(xué)會了對一項工程應(yīng)該如何設(shè)計:首先,要分析需要設(shè)計的系統(tǒng)要實現(xiàn)什么功能,需要什么器件;然后,針對設(shè)計購買相應(yīng)的硬件,選用硬件時不僅要選用經(jīng)濟的,更重要的是如何能更精確更方便的完成系統(tǒng)的要求;再次,對各個硬件的驅(qū)動軟件實現(xiàn)要弄清楚,如何更好的實現(xiàn)各個硬件的協(xié)調(diào),更好的通過主控制器件實現(xiàn)硬件的功能。最后,通過各種測試

沒有你們,我的畢業(yè)設(shè)計就堅持不下來。感謝你們,有了你們,我受益匪淺。沒有你們,我的畢業(yè)設(shè)計就堅持不下來。感謝你們,有了你們,我受益匪淺。參考文獻[1]陳明熒.8051單片機課程設(shè)計實訓(xùn)教材[M].北京:清華大學(xué)出版社,2003.[2]徐新艷.單片機原理、應(yīng)用與實踐[M].北京:高等教育出版社,2005.[3]吳金戌,沈慶陽,郭庭吉.8051單片機實踐與應(yīng)用[M].北京:清華大學(xué)出版社,2002..[4]張毅剛.MCS-51單片機應(yīng)用設(shè)計[M].哈爾濱工業(yè)大學(xué)出版社,2004[5]馮博琴.微型計算機原理與接口技術(shù)[M].北京:清華大學(xué)出版社,2004.[6]張毅剛.MCS-51單片機應(yīng)用設(shè)計[M].哈爾濱工業(yè)大學(xué)出版社,2004.[7]張淑清,姜萬錄等.單片微型計算機接口技術(shù)及應(yīng)用[M].國防工業(yè)出版社,2003.[8]吳金戌,沈慶陽,郭庭吉.8051單片機實踐與應(yīng)用[M].北京:清華大學(xué)出版社,2001.[9]馮博琴.微型計算機原理與接口技術(shù)[M].清華大學(xué)出版社,2004..[10][10]王振紅,李洋,郝承祥.ISD4004語音芯片的工作原理及其在智能控制系統(tǒng)中的應(yīng)用[J].電子器件2002,25(1).[11]王千.實用電子電路大全[M].電子工業(yè)出版社,2001[12]趙亮,侯國銳.單片機C語言編程與實例[M].北京:人民郵電出版社,2003.[13]R.L.Geiger,P.E.Allen,N.R.Strader.VLSI.DesignTechniquesforAnalogAndDigitialCiruits,McGraw-HillInc.1990.[14]ANALOGDEVICES.ThetechnologyofAT89C51[EB/OL].WhitePaper,Spe.28.2000.[15]V.K.Gryzhov,V.G.Korol’kov,E.V.Gryzhov,A.D.Akshinsky.FlexibleConverterofAnalogSignalintoDiscreteDigitalOnewiththeExampleofDoubleIntegrationVoltmeter[J].AutomationandRemoteControl,2014,75(4).附錄A英文文獻TemperatureControlUsingaMicrocontroller:AnInterdisciplinaryUndergraduateEngineeringDesignProjectJamesS.McDonaldDepartmentofEngineeringScienceTrinityUniversitySanAntonio,TX78212AbstractThispaperdescribesaninterdisciplinarydesignprojectwhichwasdoneundertheauthor’ssubyagroupoffourseniorstudentsintheDepartmentofEngineeringScienceatTrinityUniversity.objectiveoftheprojectwastodevelopatemperaturecontrolsystemforanair-filledchamber.Thwastoallowentryofadesiredchambertemperatureinaprescribedrangeandtoexhibitovershootsteady-statetemperatureerroroflessthan1degreeKelvinintheactualchambertemperaturestepThedetailsofthedesigndevelopedbythisgroupofstudents,basedonaMotorolaMC68HC05familymicrocontroller,aredescribed.Thepedagogicalvalueoftheproblemisalsodiscussedthroughadescriptionofsomeofthekeystepsinthedesignprocess.Itisshownthatthesolutionrequiresknowledgedrawnfromseveralengineeringdisciplinesincludingelectrical,mechanical,andcontrolsystemsengineering.IntroductionThedesignprojectwhichisthesubjectofthispaperoriginatedfromareal-worldapplicationprototypeofamicroscopeslidedryerhadbeendevelopedaroundanOmegaTMmodelCN-390temperaturecontroller,andtheobjectivewastodevelopacustomtemperaturecontrolsystemtoreOmegasystem.Themotivationwasthatacustomcontrollertargetedspecificallyfortheapplicatiobeabletoachievethesamefunctionalityatamuchlowercost,astheOmegasystemisunnecessariversatileandequippedtohandleawidevarietyofapplications.ThemechanicallayoutoftheslidedryerprototypeisshowninFigure1.Themainelementoftdryerisalarge,insulated,air-filledchamberinwhichmicroscopeslides,eachwithatissuesaminparaffin,canbesetoncaddies.Inorderthattheparaffinmaintaintheproperconsistency,thtemperatureintheslidechambermustbemaintainedatadesired(constant)temperature.Asecondchamber(theelectronicsenclosure)housesaresistiveheaterandthetemperaturecontroller,andmountedontheendofthedryerblowsairacrosstheheater,carryingheatintotheslidechamber.designprojectwascarriedoutduringacademicyear1996–97byfourstudentsundertheauthor’ssupervisionasaSeniorDesignprojectintheDepartmentofEngineeringScienceatTrinityUniversThepurposeofthispaperistodescribetheproblemandthestudents’solutioninsomedetail,adiscusssomeofthepedagogicalopportunitiesofferedbyaninterdisciplinarydesignprojectofthThestudents’ownreportwaspresentedatthe1997NationalConferenceonUndergraduateResearchSection2givesamoredetailedstatementoftheproblem,includingperformancespecifications,anSection3describesthestudents’design.Section4makesupthebulkofthepaper,anddiscussesidetailseveralaspectsofthedesignprocesswhichofferuniquepedagogicalopportunities.Finallyofferssomeconclusions.ProblemStatementThebasicideaoftheprojectistoreplacetherelevantpartsofthefunctionalityofanOmegaCNtemperaturecontrollerusingacustom-designedsystem.Theapplicationdictatesthattemperaturesareusuallykeptconstantforlongperiodsoftime,butit’snonethelessimportantthatstepchangesbetrackedina“reasonable”manner.Thusthemainrequirementsboildownto·allowingachambertemperatureset-pointtobeentered,·displayingbothset-pointandactualtemperatures,and·trackingstepchangesinset-pointtemperaturewithacceptablerisetime,steady-stateerror,overshoot.AlthoughnotexplicitlyapartofthespecificationsinTable1,itwasclearthatthedesireddigitaldisplaysofset-pointandactualtemperatures,andthatset-pointtemperatureentrdigitalaswell(asopposedto,say,throughapotentiometersetting).SystemDesignTherequirementsfordigitaltemperaturedisplaysandsetpointentryaloneareenoughtodictamicrocontrollerbaseddesignislikelythemostappropriate.Figure2showsablockdiagramofthestuddesign.Themicrocontroller,aMotorolaMC68HC705B16(6805forshort),istheheartofthesystem.Itacceptsinputsfromasimplefour-keykeypadwhichallowspecificationoftheset-pointtemperaturdisplaysbothset-pointandmeasuredchambertemperaturesusingtwo-digitseven-segmentLEDdisplacontrolledbyadisplaydriver.AlltheseinputsandoutputsareaccommodatedbyparallelportsonChambertemperatureissensedusingcalibratedthermistorandinputviaoneofthe6805’spreanalog-to-digitalinputs.Finally,apulse-widthmodulation(PWM)outputonthe6805isusedtodrrelaywhichswitcheslinepowertotheresistiveheateroffandon.Figure3showsamoredetailedschematicoftheelectronicsandtheirinterfacingtothe6805.keypad,aStorm3K041103,hasfourkeyswhichareinterfacedtopinsPA0{PA3ofPortA,configureinputs.Onekeyfunctionsasamodeswitch.Twomodesaresupported:setmodeandrunmode.Insetmodetwooftheotherkeysareusedtospecifytheset-pointtemperature:oneincrementsitandondecrements.Thefourthkeyisunusedatpresent.TheLEDdisplaysaredrivenbyaHarrisSemiconduICM7212displaydriverinterfacedtopinsPB0{PB6ofPortB,configuredasoutputs.Thetemperature-sensingthermistordrives,throughavoltagedivider,pinAN0(oneofeightanaloginpFinally,pinPLMA(oneoftwoPWMoutputs)drivestheheaterrelay.Softwareonthe6805implementsthetemperaturecontrolalgorithm,maintainsthetemperaturedisplays,andalterstheset-pointinresponsetokeypadinputs.Becauseitisnotcompleteatthisoftwarewillnotbediscussedindetailinthispaper.Thecontrolalgorithminparticularhasnodetermined,butitislikelytobeasimpleproportionalcontrollerandcertainlynotmorecomplexSomecontroldesignissueswillbediscussedinSection4,however.4TheDesignProcessAlthoughessentiallytheprojectisjusttobuildathermostat,itpresentsmanynicepedagogiopportunities.Theknowledgeandexperiencebaseofaseniorengineeringundergraduatearejustenbringhimorhertothebrinkofasolutiontovariousaspectsoftheproblem.Yet,ineachcase,considerationscomplicatethesituationsignificantly.Fortunatelythesecomplicationsarenotinsurmountable,andtheresultisaverybeneficialdeexperience.Theremainderofthissectionlooksatafewaspectsoftheproblemwhichpresentthelearningopportunityjustdescribed.Section4.1discussessomeofthefeaturesofasimplifiedmamodelofthethermalpropertiesofthesystemandhowitcanbeeasilyvalidatedexperimentally.S4.2describeshowrealisticcontrolalgorithmdesignscanbearrivedatusingintroductoryconceptcontroldesign.Section4.3pointsoutsomeimportantdeficienciesofsuchasimplifiedmodeling/cdesignprocessandhowtheycanbeovercomethroughsimulation.Finally,Section4.4givesanoverofsomeofthemicrocontroller-relateddesignissueswhichariseandlearningopportunitiesoffere4.1MathematicalModelLumped-elementthermalsystemsaredescribedinalmostanyintroductorylinearcontrolsystemstexjustthissortofmodelisapplicabletotheslidedryerproblem.Figure4showsasecond-orderlumped-elementthermalmodeloftheslidedryer.ThestatevariablesarethetemperaturesTaofththeboxandTboftheboxitself.Theinputstothesystemarethepoweroutputq(t)oftheheaterambienttemperatureT¥.maandmbarethemassesoftheairandthebox,respectively,andCaandCbspecificheats.μ1andμ2areheattransfercoefficientsfromtheairtotheboxandfromtheboxtothexternalworld,respectively.It’snothardtoshowthatthe(linearized)stateequationscorrespondingtoFigure4TakingLtransformsof(1)and(2)andsolvingforTa(s),whichistheoutputofinterest,givesthefollowopen-loopmodelofthethermalsystem:whereKisaconstantandD(s)isasecond-orderpolynomial.K,tz,andthecoefficientsofD(sfunctionsofthevariousparametersappearingin(1)and(2).Ofcoursethevariousparametersin(1arecompletelyunknown,butit’snothardtoshowthat,regardlessofs)hastworealzeros.theirvalues,D(Thereforethemaintransferfunctionofinterest(whichistheonefromQ(s),sincewe’llassumeconstantambienttemperature)canbewrittenMoreover,it’snottoohardtoshowthat1=tp1<1=tz<1=tp2,i.e.,thatthezeroliesbetweenthetwopoles.Bothoftheseareexcellentexercisesforthestudent,andththeopenlooppole-zerodiagramofFigure5.Obtainingacompletethermalmodel,then,isreducedtoidentifyingtheconstantKandthethreunknowntimeconstantsin(3).Fourunknownparametersisquiteafew,butsimpleexperimentsshow1=tp1_1=tz;1=tp2sothattz;tp2_0aregoodapproximations.Thustheopen-loopsystemisessentfirst-orderandcanthereforebewrittenwherethesubscriptp1hasbeendropped.Simpleopen-loopstepresponseexperimentsshowthat,forawiderangeofinitialtemperaturesheatinputs,K_0:14_=Wandt_295s.14.2ControlSystemDesignUsingthefirst-ordermodelof(4)fortheopen-looptransferfunctionGaq(s)andassumingformomentthatlinearcontroloftheheaterpoweroutputq(t)ispossible,theblockdiagramofFigurrepresentstheclosed-loopsystem.Td(s)isthedesired,orset-point,temperature,C(s)isthecomtransferfunction,andQ(s)istheheateroutputinwatts.Giventhissimplesituation,introductorylinearcontroldesigntoolssuchastherootlocusmbeusedtoarriveataC(s)whichmeetsthestepresponserequirementsonrisetime,steady-stateovershootspecifiedinTable1.Theupshot,ofcourse,isthataproportionalcontrollerwithsuffcanmeetallspecifications.Overshootisimpossible,andincreasinggainsdecreasesbothsteady-sandrisetime.Unfortunately,sufficientgaintomeetthespecificationsmayrequirelargerheatoutputsthaniscapableofproducing.Thiswasindeedthecaseforthissystem,andtheresultisthattherisespecificationcannotbemet.Itisquiterevealingtothestudenthowusefulsuchanoversimplifiecarefullyarrivedat,canbeindeterminingoverallperformancelimitations.4.3SimulationModelGrossperformanceanditslimitationscanbedeterminedusingthesimplifiedmodelofFigure6thereareanumberofotheraspectsoftheclosed-loopsystemwhoseeffectsonperformancearenotsimplymodeled.Chiefamongtheseare·quantizationerrorinanalog-to-digitalconversionofthemeasuredtemperatureand·theuseofPWMtocontroltheheater.Bothofthesearenonlinearandtime-varyingeffects,andtheonlypracticalwaytostudythemthroughsimulation(orexperiment,ofcourse).Figure7showsaSimulinkTMblockdiagramoftheclosed-loopsystemwhichincorporatestheseeffecA/DconverterquantizationandsaturationaremodeledusingstandardSimulinkquantizerandsaturablocks.ModelingPWMismorecomplicatedandrequiresacustomS-functiontorepresentit.Thissimulationmodelhasprovenparticularlyusefulingaugingtheeffectsofvaryingthebasparametersandhenceselectingthemappropriately.(I.e.,thelongertheperiod,thelargertheteerrorPWMintroduces.Ontheotherhand,alongperiodisdesirabletoavoidexcessiverelay“chatter,”amongotherthings.)PWMisoftendifficultforstudentstograsp,andthesimulationmodelallowsexplorationofitsoperationandeffectswhichisquiterevealing.4.4TheMicrocontrollerSimpleclosed-loopcontrol,keypadreading,anddisplaycontrolaresomeoftheclassicapplicmicrocontrollers,andthisprojectincorporatesallthree.Itisthereforeanexcellentall-aroundmicrocontrollerapplications.Inaddition,becausetheprojectistoproduceanactualpackagedprwon’tdotouseasimpleevaluationboardwiththeI/Opinsjumperedtothetargetsystem.Insteanecessarytodevelopacompleteembeddedapplication.Thisentailsthechoiceofanappropriatepathebroadrangeofferedinatypicalmicrocontrollerfamilyandlearningtouseafairlysophisticdevelopmentenvironment.Finally,acustomprinted-circuitboardforthemicrocontrollerandperipmustbedesignedandfabricated.MicrocontrollerSelection.Inviewofexistinglocalexpertise,theMotorolalineofmicrocontrollwaschosenforthisproject.Still,thisdoesnotnarrowthechoicedownmuch.Afairlydisciplinesystemrequirementsisnecessarytospecifywhichmicrocontroller,outofscoresofvariants,isrthejob.Thisisdifficultforstudents,astheygenerallylacktheexperienceandintuitionneedetheperseverancetowadethroughmanufacturers’selectionguides.Partoftheproblemisinchoosingmethodsforinterfacingthevariousperipherals(e.g.,whatdisplaydrivershouldbeused?).AstudyofrelevantMotorolaapplicationnotes[2,3,4]provedvhelpfulinunderstandingwhatbasicapproachesareavailable,andwhatmicrocontroller/peripheralcombinationsshouldbeconsidered.TheMC68HC705B16wasfinallychosenonthebasisofitsavailableA/DinputsandPWMoutputsaswellas24digitalI/Olines.Inretrospectthisisprobablyoverkill,asonlyoneA/Dchannel,onchannel,and11I/Opinsareactuallyrequired(seeFigure3).Thedecisionwasmadetoerronthebecauseacompletedevelopmentsystemspecifictothechosenpartwasnecessary,andtheprojectbdidnotpermitasecondsuchsystemtobepurchasedshouldthefirstproveinadequate.MicrocontrollerApplicationDevelopment.Breadboardingoftheperipheralhardware,developmentofmicrocontrollersoftware,andfinaldebuggingandtestingofacustomprinted-circuitboardformicrocontrollerandperipheralsallrequireadevelopmentenvironmentofsomekind.Thechoiceofdevelopmentenvironment,likethatofthemicrocontrolleritself,canbebewilderingandrequiresfacultyexpertise.Motorolamakesthreegradesofdevelopmentenvironmentrangingfromsimpleevaluationboards(ataround$100)tofull-blownreal-timein-circuitemulators(atmorelike$750middleoptionwaschosenforthisproject:theMMEVS,whichconsistsof_aplatformboard(whichsupportsall6805-familyparts),_anemulatormodule(specifictoB-seriesparts),and_acableheadadapter(package-specific).Overall,thesystemcostsabout$900andprovides,withsomelimiin-circuitemulationcapability.ItalsocomeswiththesimplebutsufficientsoftwaredevelopmentenvironmentRAPID[5].Studentsfindlearningtousethistypeofsystemchallenging,buttheexperiencetheygaininreal-worldmicrocontrollerapplicationdevelopmentgreatlyexceedsthetypicalfirst-courseexperiusingsimpleevaluationboards.Printed-CircuitBoard.Thelayoutofasimple(thoughdefinitelynottrivial)printed-circuitboaanotherpracticallearningopportunitypresentedbythisproject.Thefinalboardlayout,withpacoutlines,isshown(at50%ofactualsize)inFigure8.Therelativesimplicityofthecircuitmakplacementandroutingpractical—infact,itlikelygivesbetterresultsthanautomaticinanapplicatithis—andthestudentisthereforeexposedtofundamentalissuesof

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論