【文章內(nèi)容簡(jiǎn)介】
時(shí)注意處理這方面的錯(cuò)誤。常見(jiàn)的錯(cuò)誤分為三種:(1) 語(yǔ)法錯(cuò)誤。這種錯(cuò)誤在編譯時(shí)有提示,通常是變量定義錯(cuò)誤,或語(yǔ)法結(jié)構(gòu)錯(cuò)誤。(2) 運(yùn)行時(shí)錯(cuò)誤。這部分錯(cuò)誤是因?yàn)橛脩暨`法操作造成的,比如輸入油罐編號(hào)超過(guò)設(shè)計(jì)值,將無(wú)法在界面內(nèi)顯示。(3)邏輯錯(cuò)誤。這種錯(cuò)誤是最復(fù)雜的,在編程過(guò)程中也最容易犯。 調(diào)試結(jié)果1. 下位機(jī)調(diào)試(1) 溫度測(cè)試 提高溫度傳感器的溫度,觀察數(shù)碼管溫度顯示的變化; 溫度調(diào)試用手指接觸溫度傳感器,溫度上升(2) 壓力傳感器測(cè)試旋轉(zhuǎn)電位器(此電位器用來(lái)模擬壓力傳感器),觀察壓力值和液位值的變化,: 壓力調(diào)試(3) 串口數(shù)據(jù)測(cè)試將本系統(tǒng)的串口連接到計(jì)算機(jī),用串口調(diào)試工具觀察串口數(shù)據(jù),: 串口調(diào)試結(jié)果2. 上位機(jī)調(diào)試(1) 啟動(dòng)測(cè)試查看軟件能否正常啟動(dòng);通過(guò)多次檢測(cè),軟件在32位linux系統(tǒng)平臺(tái)下運(yùn)行正常,沒(méi)有出現(xiàn)異常情況。(2) 后臺(tái)數(shù)據(jù)測(cè)試在linux終端模式下,以文本形查看各項(xiàng)數(shù)據(jù)是否符合需求,: 后臺(tái)數(shù)據(jù)調(diào)試(3) 圖形界面測(cè)試在軟件圖像界面下查看各項(xiàng)數(shù)據(jù)是否與下位機(jī)數(shù)據(jù)一致,: 軟件界面數(shù)據(jù)調(diào)試(5) 錯(cuò)誤處理測(cè)試設(shè)置儲(chǔ)油罐編號(hào)超過(guò)軟件測(cè)試范圍(1到4),觀察現(xiàn)象。當(dāng)油罐編號(hào)超過(guò)4,界面中無(wú)數(shù)值顯示,符合要求。 錯(cuò)誤數(shù)據(jù)調(diào)試結(jié)果6 總結(jié)分析經(jīng)過(guò)兩個(gè)多月的奮斗,畢業(yè)設(shè)計(jì)終于順利完成了,但是仍有許多不足之處,需要在以后的學(xué)習(xí)和實(shí)踐過(guò)程中改進(jìn),比如說(shuō):(1) 由于本人水平有限,加之時(shí)間較倉(cāng)促,多次嘗試在系統(tǒng)中添加數(shù)據(jù)庫(kù),添加統(tǒng)計(jì)功能,遺憾的是均未能成功,但是面向?qū)ο蟮腝t圖形編輯軟件完全支持這些功能,在以后的學(xué)習(xí)過(guò)程中可以添加進(jìn)去。(2) 51單片機(jī)的算數(shù)計(jì)算能力有限,計(jì)算較大數(shù)值的乘除法會(huì)產(chǎn)生較大的誤差。需要用其他辦法(算法)解決此問(wèn)題。(3) 本系統(tǒng)中采用的數(shù)學(xué)模型不適合計(jì)算球狀等不規(guī)則形狀的儲(chǔ)油罐。(4) 在初期程序設(shè)計(jì)系統(tǒng)中,沒(méi)有統(tǒng)一變量名稱,給后期調(diào)試造成了許多不必要的麻煩,這是一個(gè)經(jīng)驗(yàn)教訓(xùn)。(5) 由于對(duì)基礎(chǔ)知識(shí)的掌握不夠牢固,在設(shè)計(jì)過(guò)程中走了不少?gòu)澛?,做了不少無(wú)用功。總的來(lái)說(shuō),這次課程設(shè)計(jì)還是比較成功的,雖然在設(shè)計(jì)中遇到了很多問(wèn)題,但是在老師和同學(xué)的幫助下,逐步解決了,有點(diǎn)小小的成就感,終于覺(jué)得平時(shí)所學(xué)的知識(shí)有了實(shí)用的價(jià)值,達(dá)到了理論與實(shí)際相結(jié)合的目的,在設(shè)計(jì)過(guò)程中還學(xué)到了不少新的知識(shí),而且鍛煉了自己的能力,使自己對(duì)以后的路有了更加清楚的認(rèn)識(shí),同時(shí),對(duì)未來(lái)有了更多的信心。參考文獻(xiàn)[1] .北京:高等教育出版社,[2] 馮博琴、吳寧,微型計(jì)算機(jī)原理與接口技術(shù),清華大學(xué)出版社,[3] :清華大學(xué)出版社,[4] 劉篤仁、:機(jī)械工業(yè)出版社, [5] 成潔 .Linux窗口程序設(shè)計(jì)::清華大學(xué)出版社,[6] 黃維通 .Visual C++面向?qū)ο笈c可視化程序設(shè)計(jì)(第3版).北京:清華大學(xué)出版社, [7] 劉篤仁、韓保君,傳感器原理及應(yīng)用技術(shù),北京:機(jī)械工業(yè)出版社, [8] 童詩(shī)白,模擬電子技術(shù)基礎(chǔ),北京:高等教育出版社, [9] 周航慈,單片機(jī)應(yīng)用程序設(shè)計(jì),北京:北京航空航天大學(xué)出版社, The Realtime Monitoring System of Oil Storage Tank Name:Zhang Guoyan Instructor: Zhang Zhenhong Zhang Yi Abstract: As China has a rich oil resource, so there are many oil refining enterprises in China, naturally, the oil storage tank has been important equipment to storage oil. At the same time, the liquid level of oil storage tank great affect the inventory management and economic operation of factories. However, the liquid level measurement of many responses cans, large oil tank, and gas stations is still using artificial examining and the methods of analysis and assay, and the measurement of other parameters is also has not an execute realtime dynamic measurement. This situation makes accidents happen easily, and can’t provide a accurate basis for the productive operation and management decision of factories. This system in terms of the problems above uses the monolithic technology and sensor technology to measure the temperature and pressure of oil, and makes it shows the oil capacity and temperature value. It also uses the serial port to sent data to PC, so that there is a more concise calculation and statistics. Thus, the system can provide a technical support for the safety of industrial production.Key Words: Tanks, liquid level, a monitoring system附錄下位機(jī)源代碼:1主函數(shù)代碼 include include void main(){ uchar p,bai,shi,ge。 uchar x。 uchar wd,wdshi,wdge。 while (1) { p = ADmain()。 wd = wendu()。 for(x=0。x=110。x++) { bai = p/100。 shi = (p%100)/10。 ge = p%10。 display (bai,1)。 display (shi,2)。 display (ge,3)。 wdshi = wd/10。 wdge = wd%10。 display (wdshi, 7)。 display (wdge, 8)。 COM_Out(0x00)。 COM_Out(0xfe)。 COM_Out(num)。 //儲(chǔ)油罐編號(hào), COM_Out(wd)。 COM_Out(pdow())。//向串口發(fā)送端底壓力值 COM_Out(pup())。 //向串口發(fā)送上端壓力值 } }} define uint unsigned intdefine uchar unsigned charuint ADmain()。//儲(chǔ)油量函數(shù)void display (uchar ,uchar )。//顯示函數(shù)void COM_Out(uchar i)。//串口發(fā)送函數(shù)uchar wendu()。//溫度讀取函數(shù)unsigned char pup()。 //上端壓力返回函數(shù)unsigned char pdow()。 //底端壓力返回函數(shù)unsigned char num = 1。//儲(chǔ)油罐編號(hào)2顯示模塊函數(shù)代碼 /*數(shù)碼管動(dòng)態(tài)掃描顯示函數(shù),片選信號(hào)接38譯碼器,段選信號(hào)接鎖存器,*/include includedefine uchar unsigned chardefine uint unsigned intsbit duan = P3^7。//P3^7連接74HC573鎖存器的鎖存信號(hào)端uchar code weitable[9] = {0,0,1,2,3,4,5,6,7}。 /* 本應(yīng)該為: wei [8] = {0,1,2,3,4,5,6,7} 但是這樣 的話,wei[1]對(duì)應(yīng)的是第二個(gè)元素, wei[0]才對(duì)應(yīng) 的是第一個(gè)元素 為了直觀方便起見(jiàn),使wei[1]對(duì)應(yīng)到選通第一個(gè)數(shù)碼管 的代碼0x00(也即是數(shù)組中的0)就在數(shù)組前面加了一個(gè) 空元素(可以為任意值),數(shù)組大小隨之增大一位。 */ uchar code duantable[10] = {0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f}。 /* 以上table中的10個(gè)元素顯示到數(shù)碼管上 時(shí)分別為{0,1,2,3,4,5,6,7,8,9} table[0]對(duì)應(yīng)數(shù)組中的第一個(gè)元素,顯示到數(shù) 碼管上是:0 以此類(lèi)推table[9]對(duì)應(yīng)數(shù)組中 的第十個(gè)元素,顯示到數(shù)碼管上是:10 */void display (uchar d,uchar w){ duan = 0。 P0=0xff。 duan = 1。 // 打開(kāi)鎖存器的鎖存端 P0 = duantable[d]。 //將段選信號(hào)放進(jìn)鎖存器 duan = 0。// 關(guān)閉鎖存器的鎖存端 P2 amp。= 0xf8。/*給P2口賦位選值前,先將p2與(1111 1000)邏輯與, // 將P2^0,P2^1,P2^2清零,從而不影響其他位原來(lái)的電平*/ P2 |= weitable[w]。/*將位選信號(hào)放進(jìn)P2口的低三位, // 只改變P2口低三位的值,不影響其他位*/ delay_display (8)。}void delay_display (uint i){ uchar x,j。 for(j=0。ji。j++) for(x=0。x=110。x++)。}/*顯示一個(gè)數(shù)字的時(shí)候,調(diào)用display()即可,格式:display(段 ,位)。 */ void display (unsigned char ,unsigned char )。void delay_display (unsigned int i)。3串口發(fā)送模塊代碼 /********************************************************************* 文件名 : * 描述 : 該文件實(shí)現(xiàn)通過(guò)串口把數(shù)據(jù)從單片機(jī)發(fā)送到電腦。***********************************************************************/includeincludeincludedefine uchar unsigned chardefine uint unsigned int /********************************************************************* 名稱 : Com_Init()* 功能 : 初始化串口程序,, 波特率9600* 輸入 : 無(wú)* 輸出 : 無(wú)***********************************************************************/void Com_Init(void){ TMOD = 0x20。 PCON = 0x00。 SCON = 0x50。 TH1 = 0xFd。 TL1 = 0xFd。 TR1 = 1。 }/********************************************************************* 名稱 :COM_Out()* 功能 : 發(fā)送數(shù)據(jù)***********************************************************************/void COM_Out(uchar i){ Com_Init()。 //初始化串口 SBUF = i。 //把傳進(jìn)來(lái)的數(shù)據(jù)放入SBUF while(!TI) //如果發(fā)送完畢,硬件會(huì)置位TI {