版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、difficult, not hating; blueprints, not rhetoric; words and simple, but full of love, truth, passion, entrepreneurial passion. Take this opportunity, my inspirational quotes Li Dazhaos classic iron specialise in uplifting blend with the article gave everyone, with a view on how to do well under the n
2、ew situation of township and village leaders inspire and help, and also share with you. A good play to create iron shoulders strong arms, to assume the burden be passed; only specific qualities, will it be possible in specific areas to create a world. In my view, village chiefs in the new situation,
3、 we must first have five basic quality. One ambition is to pioneer. Who is handsome. People only high-minded can stimulate the flow of momentum to become brave and persistent, become quiet and powerful. Township and village party leaders, within their respective jurisdictions, political stability an
4、d economic and social development issues, decisions and orientation depends to a large extent because of your. Everybody in village chiefs and the positions, both the trust of the masses, the Organizations trust, more ability to you, fully affirmed the moral and other qualities. Therefore, we must a
5、lways maintain the historical mission and social responsibility, and our ideal tree rooted in the hard work of the soil, with indomitable spirit, indomitable courage to open up a new situation of villages and towns. To have a feeling of closeness to the second. The people and country. Our business f
6、oundation in the peoples blood in the people power people. Advanced decisions of the party cadres to the feelings of the people is an eternal theme. Fan Zhong-yan, called first, and enjoy comfort about others, Zheng Banqiaos also wrote a Ya Chai lay listening to the rustling of bamboo, the suspect i
7、s suffering. Cao County officials, little my, a total turn off. Old of feudal official even has so feelings, alone we is to serving for purposes of people servant does? we more should always hold with on people of deep feelings, heart Department masses of leading visited tea, care masses of emotions
8、 thoughts complained, always insisted put masses of interests put in first, consciously from itself do up, from small do up, from masses most care, and most directly, and most reality of interests problem grabbed, real do love for people by Department, and right for people by with, and Lee for peopl
9、e by conspiracy to. Three with the fame of mind. Non-indifferent not insist your dream, without serenity not go far. Ascension to fame is morality, is the sublimation of the soul. As Township and village, be sure to maintain a normal state of mind, establish a correct viewpoint on power, position an
10、d values and Outlook, as fame is light like water, depending . 50 km, also red and like hundreds of thousands of the KMT military combat, but he went on to collect a variety of newspapers and magazines, and then race against time to pore over. As long as the study of mind, it is not necessary to com
11、e to the library, workshops, into the villages, people learned farming techniques, problem-solving methods, participation in計(jì)算機(jī)控制技術(shù)課程設(shè)計(jì) 題目 電加熱爐溫度測控系統(tǒng)設(shè)計(jì) 學(xué)院 機(jī)械電子工程學(xué)院 專業(yè) 機(jī)械設(shè)計(jì)制造及其自動(dòng)化 學(xué)生姓名 吳崇燈(21) 陳治祥(27) 謝立杰(26)冷態(tài)啟動(dòng)為脫硝氨區(qū)系統(tǒng)的初次啟動(dòng)或脫硝氨區(qū)系統(tǒng)檢修后的重新啟動(dòng)。在冷態(tài)啟動(dòng)前,脫硝氨區(qū)系統(tǒng)內(nèi)的全部機(jī)械設(shè)備處于停運(yùn)狀態(tài)conferences, learned superiors pol
12、icies; reports, you can learn to deal with problems, art, just wanted to learn, to learn at any time. To continuously expand the scope of the study. The complexity and comprehensiveness of our work, decided to not only do we want to be professionals, or if generalists, to dabble in different areas o
13、f knowledge. Mastery of knowledge not only to have knowledge to rational analysis. This on requirements we, not only to learning national of route, and approach, and policy, also to learning national of legal, and regulations; not only to with political theory armed mind, also to with economic theor
14、y guide work; not only to read history, also to read history; not only to absorption SM of mirror, also to gets is of road; not only to from local learn, also to to outside learn; not only to to books learn, also to field study learn. Therefore, I would encourage you, and more to the outside world w
15、hen I have time to take a look at, take a stroll, outside developments, learn other peoples development approach, and then come back to guide our work. Second, we must think. Learning without thought to overshadow, thinking without learning is perilous. We want to foster the character of advancing w
16、ith the times, forge ahead, often reflect themselves in adapting to the new situation on whether there are delays, have anything to fear in the reform and innovation, whether in terms of accelerating the development of a relaxation, keep promising State of mind. In order to do investigations, invest
17、igations is the road to heaven, God disposes of the base. To wants to real heard truth, and justice to truth, and get truth, received effectiveness, on must in-depth actual, and outreach, and in-depth masses, worship masses for Division, and masses heart, with masses with discussion everyone care of
18、 problem, listening they of calls, understand they of mood, feel they of suffering, summary they of experience, concentrated they of wisdom, especially on masses most hope, and most urgent, and most worries, and most complained of hot, and difficulties and focus problem, more to active research, cau
19、ght not put. Dare to innovate, in our work, often remain the old way doesnt work, the new approach would not situation, the reason, the key is that many people know that copying other peoples ideas, mechanically, using someone elses old ways. To change this predicament, requires us to break the shac
20、kles of traditional concepts to overcome conservative, conformist, good at finding new problems and to accept new things, summarize new experience, new ideas, developing new programmes and Maverick, a new approach to solve problems, speed up development. Especially in implement superior policy spiri
21、t of process in the, both implementation, and cannot mechanically, to to extraordinary of courage and develop enterprising of spirit, put flexibility and principle combined up, put superior of spirit and local reality combined up, Yong conspiracy to breakthrough of policy, and exercise innovation of
22、 lift, developed out development works of, and grass-roots welcomes of27目錄1 意義與要求11.1 實(shí)際意義11.2 技術(shù)要求12 設(shè)計(jì)內(nèi)容及步驟12.1 方案設(shè)計(jì)12.2 詳細(xì)設(shè)計(jì)22.2.1 主要硬件介紹22.2.2 電路設(shè)計(jì)方法32.2.3 繪制流程圖62.2.4 程序設(shè)計(jì)72.3 調(diào)試和仿真73 結(jié)果分析84 課程設(shè)計(jì)心得體會(huì)9參考文獻(xiàn)10附錄11電加熱爐溫度控制系統(tǒng)設(shè)計(jì)1 意義與要求1.1 實(shí)際意義在現(xiàn)實(shí)生活當(dāng)中,很多場合需要對溫度進(jìn)行智能控制,日常生活中最常見的要算空調(diào)和冰箱了,他們都能根據(jù)環(huán)境實(shí)時(shí)情況,結(jié)合人
23、為的設(shè)定,對溫度進(jìn)行智能控制。工業(yè)生產(chǎn)中的電加熱爐溫度監(jiān)控系統(tǒng)和培養(yǎng)基的溫度監(jiān)控系統(tǒng)都是計(jì)算機(jī)控制系統(tǒng)的典型應(yīng)用。通過這次課程設(shè)計(jì),我們將自己動(dòng)手設(shè)計(jì)一個(gè)小型的計(jì)算機(jī)控制系統(tǒng),目的在于將理論結(jié)合實(shí)踐以加深我們對課本知識(shí)的理解。1.2 技術(shù)要求要求利用所學(xué)過的知識(shí)設(shè)計(jì)一個(gè)溫度控制系統(tǒng),并用軟件仿真。功能要求如下:(1)能夠利用溫度傳感器檢測環(huán)境中的實(shí)時(shí)溫度;(2)能對所要求的溫度進(jìn)行設(shè)定;(3)將傳感器檢測到得實(shí)時(shí)溫度與設(shè)定值相比較,當(dāng)環(huán)境中的溫度高于或低于所設(shè)定的溫度時(shí),系統(tǒng)會(huì)自動(dòng)做出相應(yīng)的動(dòng)作來改變這一狀況,使系統(tǒng)溫度始終保持在設(shè)定的溫度值。2 設(shè)計(jì)內(nèi)容及步驟2.1 方案設(shè)計(jì)要想達(dá)到技術(shù)要求
24、的內(nèi)容,少不了以下幾種器件:單片機(jī)、溫度傳感器、LCD顯示屏、直流電動(dòng)機(jī)等。其中單片機(jī)用作主控制器,控制其他器件的工作和處理數(shù)據(jù);溫度傳感器用來檢測環(huán)境中的實(shí)時(shí)溫度,并將檢測值送到單片機(jī)中進(jìn)行數(shù)值對比;LCD顯示屏用來顯示溫度、時(shí)間的數(shù)字值;直流電動(dòng)機(jī)用來表示電加熱爐的工作情況,轉(zhuǎn)動(dòng)表示電加熱爐通電加熱,停止轉(zhuǎn)動(dòng)表示電加熱爐斷電停止加熱。整體思路是這樣的:首先我們通過按鍵設(shè)定所需要的溫度值,然后利用溫度傳感器檢測電加熱爐的實(shí)時(shí)加熱溫度,并送至單片機(jī)與設(shè)定值進(jìn)行比較。若檢測值小于設(shè)定值,則無任何動(dòng)作,電加熱爐繼續(xù)導(dǎo)通加熱;若檢測值大于設(shè)定值,則單片機(jī)控制光電耦合器導(dǎo)通,繼電器動(dòng)作,電加熱爐斷電停
25、止加熱。一旦爐溫低于設(shè)定值,單片機(jī)又控制光電耦合器斷開,繼電器開關(guān)分離,電加熱爐開始導(dǎo)通加熱。這個(gè)過程中所設(shè)定的溫度值和傳感器檢測到得溫度值都要在LCD顯示屏上顯示出來,以方便操作人員觀察。另外,還可以加上時(shí)鐘模塊,以方便計(jì)時(shí)。這個(gè)設(shè)計(jì)思路相對比較簡單,利用所學(xué)過的知識(shí)容易實(shí)現(xiàn),加上光電耦合器用于隔離強(qiáng)電和弱電,比較安全,正好符合我們自動(dòng)化專業(yè)用弱電控制強(qiáng)電的目的,正所謂學(xué)以致用。2.2 詳細(xì)設(shè)計(jì)2.2.1 主要硬件介紹1單片機(jī)這里選用AT89C51單片機(jī)作為控制系統(tǒng)的處理器。AT89C51是一種帶4K字節(jié)閃存可編程可擦除只讀存儲(chǔ)器的低電壓、高性能CMOS 8位微處理器。2溫度傳感器溫度傳感器
26、有很多種型號(hào),這里我選用DS18B20溫度傳感器。數(shù)字溫度傳感器DS18B20具有獨(dú)特的單總線接口方式,支持多節(jié)點(diǎn),使分布式溫度傳感器設(shè)計(jì)大為簡化。測溫時(shí)無需任何外圍原件,可以通過數(shù)據(jù)線直接供電,具有超低功耗工作方式。測溫范圍為-55到+125攝氏度,可直接將溫度轉(zhuǎn)換值以16位二進(jìn)制數(shù)字碼的方式串行輸出,因此特別適合單線多點(diǎn)溫度測量系統(tǒng)。由于傳輸?shù)氖谴袛?shù)據(jù),可以不需要放大器和A/D轉(zhuǎn)換器,因而這種測溫方式大大提高了各種溫度測控系統(tǒng)的可靠性,降低了成本,縮小了體積。3開關(guān)器件由于單片機(jī)與電動(dòng)機(jī)之間需要用開關(guān)器件連接,并且前者用弱電控制,后者由強(qiáng)電控制,這就尤其需要注意安全問題。于是我想到了在課
27、本中學(xué)過的高性能安全開關(guān)器件光電耦合器。光電耦合器是由一個(gè)發(fā)光器件和和一個(gè)光電轉(zhuǎn)換器件組成,這里所用的光電耦合器OPTOCOUPLER-NPN是由一個(gè)發(fā)光二極管和一個(gè)光敏晶體管所組成。當(dāng)發(fā)光二極管發(fā)光,就會(huì)使得光敏晶體管導(dǎo)通,繼電器通電動(dòng)作,將開關(guān)吸合,電動(dòng)機(jī)回路斷開。2.2.2 電路設(shè)計(jì)方法1顯示部分電路顯示電路截圖如下圖所示。圖2.1 顯示部分電路圖這里我選用LCDLM016L液晶顯示屏作為系統(tǒng)的顯示器件,如圖所示,LCDLM016L采用標(biāo)準(zhǔn)的16腳接口,仿真時(shí)隱藏了背光正極和背光負(fù)極兩個(gè)引腳。它通過D0-D78位數(shù)據(jù)端來與單片機(jī)進(jìn)行數(shù)據(jù)和指令傳輸,這里我們將它與單片機(jī)的P0口連接。在顯示
28、屏上顯示的內(nèi)容包括設(shè)定的溫度值SET、傳感器檢測到的環(huán)境溫度SA以及時(shí)鐘,這個(gè)時(shí)鐘是可以調(diào)整的,這樣方便工作人員在對系統(tǒng)進(jìn)行操作時(shí)有一個(gè)時(shí)間概念。2溫度檢測電路溫度傳感器與單片機(jī)的連接情況如下圖所示。圖2.2 溫度檢測電路圖溫度傳感器18B20將檢測到的環(huán)境實(shí)時(shí)溫度進(jìn)行A/D轉(zhuǎn)換和放大,然后串行送入單片機(jī)P1.7口,便于單片機(jī)將此數(shù)值與設(shè)定的溫度值進(jìn)行比較,然后先做出相應(yīng)反應(yīng)。在仿真時(shí),我們只能通過按18B20上的加減按鈕來調(diào)節(jié)實(shí)時(shí)溫度,是一個(gè)模擬的過程。3鍵盤電路鍵盤電路如下圖所示。圖2.3 鍵盤電路圖這里減排設(shè)計(jì)得比較簡單,“MS”鍵是切換調(diào)整對象的,調(diào)整對象包括時(shí)、分、溫度設(shè)定值三項(xiàng),“
29、+”鍵是向上加調(diào)整對象的值,“”鍵是向下減調(diào)整對象的值,“ON/OFF”鍵是打開和關(guān)閉系統(tǒng)自動(dòng)調(diào)節(jié)功能的開關(guān)鍵。4電氣開關(guān)及工作電路電器開關(guān)及工作電路如下圖所示。圖2.4 電氣開關(guān)及工作電路圖如圖所示,光電耦合器1腳接電源,2腳接單片機(jī)P3.7腳。工作過程用以下三個(gè)階段來描述:(1)單片機(jī)將溫度傳感器送入的值與設(shè)定值進(jìn)行比較,若送入值小于設(shè)定值,則P3.7腳保持高電平,這樣發(fā)光二極管不發(fā)光,光敏晶體管保持高阻態(tài),繼電器也不會(huì)工作,電動(dòng)機(jī)和燈泡維持導(dǎo)通,相當(dāng)于電爐繼續(xù)加熱,指示燈亮;(2)一旦送入值比設(shè)定值大,單片機(jī)將會(huì)控制P3.7腳變?yōu)榈碗娖?,發(fā)光二極管導(dǎo)通發(fā)光,光敏晶體管受光照影響導(dǎo)通,繼而
30、繼電器工作,電磁鐵將單刀雙擲開關(guān)吸向左端,使電動(dòng)機(jī)和燈泡同時(shí)停止工作,這就相當(dāng)于電爐斷電,停止加熱;(3)電爐短路一段時(shí)間后,必然導(dǎo)致爐溫降低,而溫度傳感器DS18B20在不間斷地檢測爐溫,當(dāng)檢測值低于設(shè)定值后,單片機(jī)又控制P3.7腳恢復(fù)高電平,光電耦合器恢復(fù)高阻態(tài),繼電器斷電,單刀雙擲開關(guān)被彈回右端,電動(dòng)機(jī)和燈泡又開始工作,這相當(dāng)于電爐從新開始加熱。 2.2.3 繪制流程圖NNYY將P3.7口置1設(shè)定值=采集值?送入單片機(jī)進(jìn)行溫度值比較按鍵掃描、溫度采集時(shí)鐘定時(shí)器0初始化,DS18B20初始化延時(shí)500ms啟動(dòng)初始化P1口,初始化24C02LCD初始化讀出24C02保存的數(shù)據(jù)賦于K開始2.2
31、.4 程序設(shè)計(jì)由于整個(gè)程序工程量比較大,我采用模塊化設(shè)計(jì)方法來設(shè)計(jì)這個(gè)程序。首先定義在后面將會(huì)用到的變量,不可能一次定義準(zhǔn)確,所以邊定義邊補(bǔ)充。然后編寫子函數(shù),包括LCM初始化子函數(shù)、顯示指定坐標(biāo)的一個(gè)字符子函數(shù)、ds18b20初始化函數(shù)、ds18b20延遲子函數(shù)、讀取ds18b20當(dāng)前溫度子函數(shù)、液晶顯示子函數(shù)、鍵盤掃描子函數(shù)、設(shè)定工作模式子函數(shù)、按鍵加法子函數(shù)、按鍵減法子函數(shù)、24C02讀寫驅(qū)動(dòng)程序、定時(shí)器t0中斷子函數(shù)等子程序,最后是主函數(shù)。2.3 調(diào)試和仿真在Keil軟件中編寫完程序后,編譯生成.Hex文件,單片機(jī)可以執(zhí)行.Hex文件。在Protues軟件中,給單片機(jī)加載所生成的.He
32、x文件,按下運(yùn)行按鈕,系統(tǒng)開始仿真。系統(tǒng)仿真截圖如下圖所示。圖2.5系統(tǒng)仿真圖(一)上一張是當(dāng)溫度采樣值小于設(shè)定值,電熱爐處于工作狀態(tài)時(shí)的仿真截圖。以下這張是當(dāng)溫度采樣值高于設(shè)定值后,系統(tǒng)自動(dòng)做出反應(yīng),使電熱爐斷電停止工作的仿真截圖。圖2.6系統(tǒng)仿真圖(二)3 結(jié)果分析由以上仿真結(jié)果可以知道,此次的設(shè)計(jì)基本成功。當(dāng)采樣溫度低于設(shè)定值的時(shí)候,系統(tǒng)不會(huì)對電熱爐做出相應(yīng)動(dòng)作,電熱爐保持加熱。一旦采樣溫度高于設(shè)定值,系統(tǒng)就會(huì)做出反應(yīng),使電加熱爐斷電停止加熱。當(dāng)溫度降下來后,系統(tǒng)又會(huì)自動(dòng)控制電加熱爐重新開始加熱。系統(tǒng)的反應(yīng)速度也是十分精確的,會(huì)在很短的時(shí)間內(nèi)作出相應(yīng)動(dòng)作。另外,由于在電路中加入了EPRO
33、M24C02,使得該系統(tǒng)具有掉電保護(hù)功能,來電后自動(dòng)恢復(fù)正常工作。除此之外,該系統(tǒng)還有一個(gè)比較實(shí)用的小功能電子鐘,這樣的話工作人員可以利用它準(zhǔn)確掌握系統(tǒng)已經(jīng)工作的時(shí)間,也就是說可以把它當(dāng)做一個(gè)定時(shí)器來用。在安全保護(hù)方面,該系統(tǒng)也有相當(dāng)不錯(cuò)的表現(xiàn),由于使用了光電耦合器和就電磁繼電器,將強(qiáng)電部分和弱電部分充分隔離,十分安全。綜合以上分析,該系統(tǒng)的設(shè)計(jì)十分成功。4 課程設(shè)計(jì)心得體會(huì)本次課程設(shè)計(jì),我們的題目是電加熱爐溫度控制系統(tǒng)設(shè)計(jì)。說到電加熱爐,我們都比較熟悉,在日常生活中我們經(jīng)常用到,特別是冬天用它來煮火鍋。我們也會(huì)發(fā)現(xiàn)這樣一個(gè)問題,一般的電加熱爐是沒有溫度自動(dòng)控制的,當(dāng)溫度上升到我們需要的程度時(shí)
34、,它仍然繼續(xù)加熱,這不僅會(huì)影響到加熱效果,還會(huì)造成電能的浪費(fèi)。那么就有必要設(shè)計(jì)一種能自動(dòng)調(diào)節(jié)爐溫的系統(tǒng),把它應(yīng)用到日常生活中,將會(huì)給人們帶來極大的方便。在設(shè)計(jì)的過程中,也遇到一些麻煩,比如說怎樣來實(shí)現(xiàn)電動(dòng)機(jī)回路的自動(dòng)通斷調(diào)節(jié)、怎樣來實(shí)現(xiàn)時(shí)鐘的調(diào)整等等,這些問題都令我們十分棘手。通過去圖書館查閱相關(guān)資料和上網(wǎng)搜索各硬件的原理以及應(yīng)用,我們最終都一一解決了這些問題。由于我們是三個(gè)同學(xué)做同一個(gè)題目,在設(shè)計(jì)過程中,我們遇到困難的時(shí)候也經(jīng)常相互討論,相互請教,最終一起完成任務(wù)。 參考文獻(xiàn)1 于海生微型計(jì)算機(jī)控制技術(shù)清華大學(xué)出版社,20042 譚浩強(qiáng)C程序設(shè)計(jì)(第三版). 清華大學(xué)出版社,20063 戴焯
35、. 傳感與檢測技術(shù). 武漢理工大學(xué)出版社,20064 張毅剛. 單片機(jī)原理及應(yīng)用. 高等教育出版社,20035 柯節(jié)成. 簡明電子元件器件手冊. 高等教育出版社,2005附錄系統(tǒng)的完整程序如下:/*電加熱爐溫度控制系統(tǒng)問題描述:當(dāng)溫控開關(guān)打開時(shí),若測得環(huán)境溫度大于設(shè)定溫度,則繼電器吸合,電加熱爐停止工作;若測得環(huán)境溫度小于設(shè)定溫度,則繼電器釋放,電加熱爐繼續(xù)工作。*/#include#include#include #define uchar unsigned char#define uint unsigned int#define BUSY 0x80 /lcd忙檢測標(biāo)志 #define DA
36、TAPORT P0 /定義P0口為LCD通訊端口 #define PLAYE_ADDR XBYTE0XBFFF /語音報(bào)警地址 sbit RED_ALARM=P10; /紅色指示燈sbit WRITE_ALARM=P11; /白色指示燈sbit GREEN_ALARM=P12; /綠色指示燈sbit BLUE_ALARM=P13;sbit P1_4=P14; /時(shí)鐘調(diào)整sbit P1_5=P15; /時(shí)鐘加sbit P1_6=P16; /時(shí)鐘減sbit DQ = P17; /定義ds18b20通信端口 sbit LCM_RS=P20; /數(shù)據(jù)/命令端sbit LCM_RW=P21; /讀/寫選
37、擇端sbit LCM_EN=P22;sbit sda=P23; /IO口定義sbit scl=P24; /LCD使能信號(hào)sbit ad_busy=P32; /adc中斷方式接口sbit RECLED_EOC=P35; /ISD1420放音結(jié)束查詢標(biāo)志sbit OUT=P37;uchar ad_data; /ad采樣值存儲(chǔ)uchar seconde; /定義并初始化時(shí)鐘變量uchar minite;uchar hour;uchar mstcnt=0;uchar temp1,temp2,temp; /溫度顯示變量uchar t,set;uchar K;bit ON_OFF=0;bit outfla
38、g;bit write=0;uchar code str0=- : : - ;uchar code str1=SET: C SA: . C;void delay_LCM(uint); /LCD延時(shí)子程序void initLCM( void); /LCD初始化子程序void lcd_wait(void); /LCD檢測忙子程序void WriteCommandLCM(uchar WCLCM,uchar BusyC); /寫指令到ICM子函數(shù)void WriteDataLCM(uchar WDLCM); /寫數(shù)據(jù)到LCM子函數(shù)void DisplayOneChar(uchar X,uchar Y,
39、uchar DData) /顯示指定坐標(biāo)的一個(gè)字符子函數(shù)void DisplayListChar(uchar X,uchar Y,uchar code *DData);/顯示指定坐標(biāo)的一串字符子函數(shù)void init_timer0(void); /定時(shí)器初始化void displayfun1(void);void displayfun2(void);void displayfun3(void);void displayfun4(void);void keyscan(void ); /鍵盤掃描子程序void set_adj(void);void inc_key(void);void dec_ke
40、y(void);void delay_18B20(unsigned int i);void Init_DS18B20(void) ;uchar ReadOneChar(void);void WriteOneChar(unsigned char dat);void ReadTemperature(void);void ad0809(void);void playalarm(void); /*延時(shí)K*1ms,12.000mhz*/void delay_LCM(uint k) uint i,j; for(i=0;ik;i+) for(j=0;j60;j+) ; /*寫指令到LCM子函數(shù)*/void
41、WriteCommandLCM(uchar WCLCM,uchar BusyC) if(BusyC)lcd_wait();DATAPORT=WCLCM; LCM_RS=0; / 選中指令寄存器 LCM_RW=0; / 寫模式 LCM_EN=1; _nop_(); _nop_();_nop_(); LCM_EN=0; /*寫數(shù)據(jù)到LCM子函數(shù)*/void WriteDataLCM(uchar WDLCM) lcd_wait( ); /檢測忙信號(hào) DATAPORT=WDLCM; LCM_RS=1; / 選中數(shù)據(jù)寄存器 LCM_RW=0; / 寫模式 LCM_EN=1; _nop_();_nop_(
42、);_nop_(); LCM_EN=0;/*lcm內(nèi)部等待函數(shù)*/void lcd_wait(void) DATAPORT=0xff; LCM_EN=1; LCM_RS=0; LCM_RW=1; _nop_(); while(DATAPORT&BUSY) LCM_EN=0; _nop_(); _nop_(); LCM_EN=1; _nop_(); _nop_(); LCM_EN=0;/*LCM初始化子函數(shù)*/void initLCM( ) DATAPORT=0;delay_LCM(15);WriteCommandLCM(0x38,0); /三次顯示模式設(shè)置,不檢測忙信號(hào) delay_LCM(5
43、); WriteCommandLCM(0x38,0); delay_LCM(5); WriteCommandLCM(0x38,0); delay_LCM(5); WriteCommandLCM(0x38,1);/8bit數(shù)據(jù)傳送,2行顯示,5*7字型,檢測忙信號(hào) WriteCommandLCM(0x08,1); /關(guān)閉顯示,檢測忙信號(hào) WriteCommandLCM(0x01,1); /清屏,檢測忙信號(hào) WriteCommandLCM(0x06,1); /顯示光標(biāo)右移設(shè)置,檢測忙信號(hào) WriteCommandLCM(0x0c,1); /顯示屏打開,光標(biāo)不顯示,不閃爍,檢測忙信號(hào)/*顯示指定坐標(biāo)
44、的一個(gè)字符子函數(shù)*/void DisplayOneChar(uchar X,uchar Y,uchar DData) Y&=1; X&=15; if(Y)X|=0x40; /若y為1(顯示第二行),地址碼+0X40 X|=0x80; /指令碼為地址碼+0X80 WriteCommandLCM(X,0); WriteDataLCM(DData);/*顯示指定坐標(biāo)的一串字符子函數(shù)*/void DisplayListChar(uchar X,uchar Y,uchar code *DData) uchar ListLength=0; Y&=0x01; X&=0x0f; while(X0;i-) DQ
45、 = 0; / 給脈沖信號(hào) dat=1; DQ = 1; / 給脈沖信號(hào) if(DQ) dat|=0x80; delay_18B20(4); return(dat);/*ds18b20寫一個(gè)字節(jié)*/ void WriteOneChar(uchar dat) unsigned char i=0; for (i=8; i0; i-) DQ = 0; DQ = dat&0x01; delay_18B20(5); DQ = 1; dat=1; /*讀取ds18b20當(dāng)前溫度*/void ReadTemperature(void)unsigned char a=0;unsigned char b=0;u
46、nsigned char t=0;Init_DS18B20();WriteOneChar(0xCC); / 跳過讀序號(hào)列號(hào)的操作WriteOneChar(0x44); / 啟動(dòng)溫度轉(zhuǎn)換delay_18B20(100); / this message is wery importantInit_DS18B20();WriteOneChar(0xCC); /跳過讀序號(hào)列號(hào)的操作WriteOneChar(0xBE); /讀取溫度寄存器等(共可讀9個(gè)寄存器) 前兩個(gè)就是溫度delay_18B20(100);a=ReadOneChar(); /讀取溫度值低位b=ReadOneChar(); /讀取溫度值
47、高位temp1=b4;temp2=a&0x0f;temp=(b*256+a)4); /當(dāng)前采集溫度值除16得實(shí)際溫度值/*液晶顯示子函數(shù)1正常顯示*/void displayfun1(void)WriteCommandLCM(0x0c,1); /顯示屏打開,光標(biāo)不顯示,不閃爍,檢測忙信號(hào)DisplayListChar(0,0,str0);DisplayListChar(0,1,str1); DisplayOneChar(3,0,hour/10+0x30); /液晶上顯示小時(shí)DisplayOneChar(4,0,hour%10+0x30);DisplayOneChar(6,0,minite/10
48、+0x30);/液晶上顯示分DisplayOneChar(7,0,minite%10+0x30);DisplayOneChar(9,0,seconde/10+0x30); /液晶上顯示秒DisplayOneChar(10,0,seconde%10+0x30);DisplayOneChar(4,1,K/10+0x30); /液晶上顯示設(shè)定的溫度DisplayOneChar(5,1,K%10+0x30); DisplayOneChar(11,1,temp1/10+0x30); /液晶上顯示測得的溫度 DisplayOneChar(12,1,temp1%10+0x30);DisplayOneChar
49、(14,1,temp2/10+0x30);if(ON_OFF=0) /若溫控標(biāo)志為0DisplayOneChar(14,0,0x4f); / 液晶上顯示不控溫的標(biāo)志DisplayOneChar(15,0,0x46);elseDisplayOneChar(14,0,0x4f); / 液晶上顯示控溫的標(biāo)志DisplayOneChar(15,0,0x4e);if(outflag=1) DisplayOneChar(0,0,0x7c); elseDisplayOneChar(0,0,0xef);/*液晶顯示子函數(shù)2*/void displayfun2(void)WriteCommandLCM(0x0c,1); /顯
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023九年級(jí)語文上冊 第一單元 1 沁園春 雪說課稿 新人教版
- 怎樣成為一個(gè)行業(yè)的專家
- 西京學(xué)院《社群傳播研究》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《機(jī)器人控制技術(shù)》2022-2023學(xué)年期末試卷
- 西京學(xué)院《安裝工程計(jì)量與計(jì)價(jià)》2023-2024學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《模擬電子技術(shù)》2021-2022學(xué)年期末試卷
- 西華師范大學(xué)《小學(xué)心理健康課程與教學(xué)》2022-2023學(xué)年第一學(xué)期期末試卷
- 西華師范大學(xué)《災(zāi)害地理學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 通信原理 課件
- 西華師范大學(xué)《教育研究方法》2021-2022學(xué)年第一學(xué)期期末試卷
- 項(xiàng)目進(jìn)度管理培訓(xùn)(-)課件
- 醫(yī)院合同管理辦法
- 2023年度小區(qū)業(yè)主大會(huì)會(huì)議召開工作方案
- 第10課《唐雎不辱使命》課件-部編版語文九年級(jí)下冊
- 高考語文 如何讀懂詩歌 課件(32張PPT)
- 中壓交聯(lián)電纜電纜正、負(fù)和零序計(jì)算
- 3C戰(zhàn)略三角模型
- 高標(biāo)準(zhǔn)農(nóng)田建設(shè)示范工程質(zhì)量管理體系與措施
- 學(xué)生頂崗實(shí)習(xí)安全教育課件
- 公司組織架構(gòu)圖模板課件
- 遼寧省葫蘆島市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會(huì)明細(xì)
評論
0/150
提交評論