【文章內容簡介】
時注意處理這方面的錯誤。常見的錯誤分為三種:(1) 語法錯誤。這種錯誤在編譯時有提示,通常是變量定義錯誤,或語法結構錯誤。(2) 運行時錯誤。這部分錯誤是因為用戶違法操作造成的,比如輸入油罐編號超過設計值,將無法在界面內顯示。(3)邏輯錯誤。這種錯誤是最復雜的,在編程過程中也最容易犯。 調試結果1. 下位機調試(1) 溫度測試 提高溫度傳感器的溫度,觀察數(shù)碼管溫度顯示的變化; 溫度調試用手指接觸溫度傳感器,溫度上升(2) 壓力傳感器測試旋轉電位器(此電位器用來模擬壓力傳感器),觀察壓力值和液位值的變化,: 壓力調試(3) 串口數(shù)據(jù)測試將本系統(tǒng)的串口連接到計算機,用串口調試工具觀察串口數(shù)據(jù),: 串口調試結果2. 上位機調試(1) 啟動測試查看軟件能否正常啟動;通過多次檢測,軟件在32位linux系統(tǒng)平臺下運行正常,沒有出現(xiàn)異常情況。(2) 后臺數(shù)據(jù)測試在linux終端模式下,以文本形查看各項數(shù)據(jù)是否符合需求,: 后臺數(shù)據(jù)調試(3) 圖形界面測試在軟件圖像界面下查看各項數(shù)據(jù)是否與下位機數(shù)據(jù)一致,: 軟件界面數(shù)據(jù)調試(5) 錯誤處理測試設置儲油罐編號超過軟件測試范圍(1到4),觀察現(xiàn)象。當油罐編號超過4,界面中無數(shù)值顯示,符合要求。 錯誤數(shù)據(jù)調試結果6 總結分析經(jīng)過兩個多月的奮斗,畢業(yè)設計終于順利完成了,但是仍有許多不足之處,需要在以后的學習和實踐過程中改進,比如說:(1) 由于本人水平有限,加之時間較倉促,多次嘗試在系統(tǒng)中添加數(shù)據(jù)庫,添加統(tǒng)計功能,遺憾的是均未能成功,但是面向對象的Qt圖形編輯軟件完全支持這些功能,在以后的學習過程中可以添加進去。(2) 51單片機的算數(shù)計算能力有限,計算較大數(shù)值的乘除法會產(chǎn)生較大的誤差。需要用其他辦法(算法)解決此問題。(3) 本系統(tǒng)中采用的數(shù)學模型不適合計算球狀等不規(guī)則形狀的儲油罐。(4) 在初期程序設計系統(tǒng)中,沒有統(tǒng)一變量名稱,給后期調試造成了許多不必要的麻煩,這是一個經(jīng)驗教訓。(5) 由于對基礎知識的掌握不夠牢固,在設計過程中走了不少彎路,做了不少無用功。總的來說,這次課程設計還是比較成功的,雖然在設計中遇到了很多問題,但是在老師和同學的幫助下,逐步解決了,有點小小的成就感,終于覺得平時所學的知識有了實用的價值,達到了理論與實際相結合的目的,在設計過程中還學到了不少新的知識,而且鍛煉了自己的能力,使自己對以后的路有了更加清楚的認識,同時,對未來有了更多的信心。參考文獻[1] .北京:高等教育出版社,[2] 馮博琴、吳寧,微型計算機原理與接口技術,清華大學出版社,[3] :清華大學出版社,[4] 劉篤仁、:機械工業(yè)出版社, [5] 成潔 .Linux窗口程序設計::清華大學出版社,[6] 黃維通 .Visual C++面向對象與可視化程序設計(第3版).北京:清華大學出版社, [7] 劉篤仁、韓保君,傳感器原理及應用技術,北京:機械工業(yè)出版社, [8] 童詩白,模擬電子技術基礎,北京:高等教育出版社, [9] 周航慈,單片機應用程序設計,北京:北京航空航天大學出版社, 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附錄下位機源代碼: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)。 //儲油罐編號, COM_Out(wd)。 COM_Out(pdow())。//向串口發(fā)送端底壓力值 COM_Out(pup())。 //向串口發(fā)送上端壓力值 } }} define uint unsigned intdefine uchar unsigned charuint ADmain()。//儲油量函數(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。//儲油罐編號2顯示模塊函數(shù)代碼 /*數(shù)碼管動態(tài)掃描顯示函數(shù),片選信號接38譯碼器,段選信號接鎖存器,*/include includedefine uchar unsigned chardefine uint unsigned intsbit duan = P3^7。//P3^7連接74HC573鎖存器的鎖存信號端uchar code weitable[9] = {0,0,1,2,3,4,5,6,7}。 /* 本應該為: wei [8] = {0,1,2,3,4,5,6,7} 但是這樣 的話,wei[1]對應的是第二個元素, wei[0]才對應 的是第一個元素 為了直觀方便起見,使wei[1]對應到選通第一個數(shù)碼管 的代碼0x00(也即是數(shù)組中的0)就在數(shù)組前面加了一個 空元素(可以為任意值),數(shù)組大小隨之增大一位。 */ uchar code duantable[10] = {0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f}。 /* 以上table中的10個元素顯示到數(shù)碼管上 時分別為{0,1,2,3,4,5,6,7,8,9} table[0]對應數(shù)組中的第一個元素,顯示到數(shù) 碼管上是:0 以此類推table[9]對應數(shù)組中 的第十個元素,顯示到數(shù)碼管上是:10 */void display (uchar d,uchar w){ duan = 0。 P0=0xff。 duan = 1。 // 打開鎖存器的鎖存端 P0 = duantable[d]。 //將段選信號放進鎖存器 duan = 0。// 關閉鎖存器的鎖存端 P2 amp。= 0xf8。/*給P2口賦位選值前,先將p2與(1111 1000)邏輯與, // 將P2^0,P2^1,P2^2清零,從而不影響其他位原來的電平*/ P2 |= weitable[w]。/*將位選信號放進P2口的低三位, // 只改變P2口低三位的值,不影響其他位*/ delay_display (8)。}void delay_display (uint i){ uchar x,j。 for(j=0。ji。j++) for(x=0。x=110。x++)。}/*顯示一個數(shù)字的時候,調用display()即可,格式:display(段 ,位)。 */ void display (unsigned char ,unsigned char )。void delay_display (unsigned int i)。3串口發(fā)送模塊代碼 /********************************************************************* 文件名 : * 描述 : 該文件實現(xiàn)通過串口把數(shù)據(jù)從單片機發(fā)送到電腦。***********************************************************************/includeincludeincludedefine uchar unsigned chardefine uint unsigned int /********************************************************************* 名稱 : Com_Init()* 功能 : 初始化串口程序,, 波特率9600* 輸入 : 無* 輸出 : 無***********************************************************************/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。 //把傳進來的數(shù)據(jù)放入SBUF while(!TI) //如果發(fā)送完畢,硬件會置位TI {