單片機硬件實習(xí)報告——模擬電梯設(shè)計_第1頁
單片機硬件實習(xí)報告——模擬電梯設(shè)計_第2頁
單片機硬件實習(xí)報告——模擬電梯設(shè)計_第3頁
單片機硬件實習(xí)報告——模擬電梯設(shè)計_第4頁
單片機硬件實習(xí)報告——模擬電梯設(shè)計_第5頁
已閱讀5頁,還剩7頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、 單片機硬件實習(xí)報告題 目 : 模 擬 電 梯 設(shè) 計 學(xué)生姓名: 學(xué)號: 學(xué)院(系: 專業(yè)班級: 指導(dǎo)教師: 實習(xí)時間: 2011 年 2 月 21 日 2010 年 3 月 4 日目 錄1.前言11.1設(shè)計背景11.2設(shè)計內(nèi)容11.3硬件實習(xí)的目的12.硬件電路描述及設(shè)計12.1 電路連線及概述12.2 8255掃描鍵盤及與led接口電路圖23.軟件電路描述及設(shè)計33.1軟件設(shè)計流程圖34.源程序代碼45.設(shè)計心得10參考文獻10常州大學(xué)硬件實習(xí)報告1.前言1.1設(shè)計背景電梯作為現(xiàn)代高層建筑最常用的垂直運輸工具,廣泛應(yīng)用于社會活動的各個角落,如何保證每臺電梯都能夠可靠運行,已成為提高物業(yè)管

2、理水平和電梯技術(shù)進步的關(guān)鍵所在。電梯運行質(zhì)量直接由控制系統(tǒng)的功能決定,而控制系統(tǒng)軟件又直接決定著控制系統(tǒng)運行的好壞。上位機監(jiān)控對電梯安全運行和故障維修具有重要意義,在減少維修管理人員的同時,可及時發(fā)現(xiàn)故障,縮短故障候梯時間,實現(xiàn)管理的自動化。面向?qū)ο蟮某绦蛟O(shè)計更適合對現(xiàn)實生活中的描述,更加體現(xiàn)了軟件的工業(yè)化的精神。1.2設(shè)計內(nèi)容本文根據(jù)實驗室提供的單片機實驗箱,利用鍵盤、開關(guān)、數(shù)碼管和 led模擬實現(xiàn)八層電梯的控制。并且設(shè)計急停開關(guān)和斷電維修開關(guān)以模擬實物電梯的更多的運行功能。軟件利用c語言,通過檢測用戶請求的按鍵信息,根據(jù)電梯運行到相應(yīng)樓層送到單片機計數(shù)來確定樓層數(shù),并送到數(shù)碼管進行顯示。硬

3、件設(shè)計簡單可靠,結(jié)合軟件,基本實現(xiàn)了八層電梯運行的模擬。1.3硬件實習(xí)的目的(1)利用所學(xué)過的知識,初步分析單片機原理及接口技術(shù)的能力;(2)進一步掌握硬件電路和軟件功能的設(shè)計方法;(3)了解8255可編程并行接口芯片的工作原理,掌握8255的各種模式編程方法;(4)實驗結(jié)果調(diào)試分析、總結(jié)及撰寫技術(shù)報告的能力。2.硬件電路設(shè)計及描述2.1 電路連線及概述p1.0-p1.7接l0-l7八個發(fā)光二極管2.2 8255掃描鍵盤與led接口電路圖3.軟件設(shè)計流程及描述 3.1軟件設(shè)計流程圖4.源程序代碼#include#include/*the address of 8255*/#define c82

4、55 xbyte0xf22b /8255command#define p8255a xbyte0xf228#define p8255b xbyte0xf229#define p8255c xbyte0xf22a#define p8255 xbyte0xf22a/* three tables */unsigned char code table= /segment value for led0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f;unsigned char code table1=/0x7f-light p10 .0x7f,0xbf,0xdf,0xef,0

5、xf7,0xfb,0xfd,0xfe;unsigned char code table2= /p1=table1elevator.currentlevel|table2elevator.currentlevel0x80,0x40,0x20,0x10, /-extinguish the led on current floor0x08,0x04,0x02,0x01;void init();void keyscan();void currentshow(unsigned char); void delay();/2svoid delayms();/20msunsigned int move;uns

6、igned int currentfloor;unsigned int direction;unsigned int destination9;char times=0; unsigned int repairs; /0-do not repair; 1-repairing/* */ void main()unsigned char i,j;init(); /*init the elevator*/currentshow(currentfloor);while(1)while(repairs=250) / repairs=250 need to repairrepairs=p33;move=p

7、31;keyscan();while(move=254&destination0!=0) /moving key was pressed while(repairs=250) / repairs0;j-) /weather there are destinations downstairsif(destinationj=0x1)break; if(jbit orbreak;case 1: /risingif(currentfloor=8) /weather there are destinations upstairsmove=0;direction=2;else for(j=currentf

8、loor+1;j8)direction=2;elseif(destinationcurrentfloor+1!=0)/ move=0;destination0-;direction=0;destinationcurrentfloor+1=0;p1|=table2currentfloor;/extinguish the corresponding led/ |-bit orcurrentshow(currentfloor);currentfloor+;break;default: /stationaryfor(i=1;i9;i+) /decide up or downif(destination

9、i!=0)break; if(icurrentfloor)/should updirection=1;elsemove=0;destination0-;direction=0;destinationcurrentfloor=0;/the destination is current level, /do nothing but extiguish the ledp1|=table2currentfloor-1;delay(); /2s/levelvoid init() /timer,elevator unsigned char i;/*timer and external interrupt

10、init*/tmod=0x01;th0=(65536-45872)/256;/50mstl0=(65536-45872)%256;ea=1;et0=1;ex0=1;ex1=1;it1=1;/*elevator init*/move=0;/*0-the elevator now will not move,commands comes from p30*/for(i=0;ilight the corresponding ledcase 0xfd:key=1;p1&=table1key;break;case 0xfb:key=2;p1&=table1key;break;case 0xf7:key=

11、3;p1&=table1key;break;case 0xef:key=4;p1&=table1key;break;case 0xdf:key=5;p1&=table1key;break;case 0xbf:key=6;p1&=table1key;break;case 0x7f:key=7;p1&=table1key;break;destinationkey+1=1; /set the corresponding level destination0+; /total number of destination temp=p8255b; while(temp!=0xff) temp=p8255

12、b;void currentshow(unsigned char num)p8255c=0x0; /wei xuanp8255a=tablenum;void delayms()unsigned int i,j;/delay for 20msfor(i=20;i0;i-)for(j=110;j0;j-);void delay()tr0=1;while(times!=40)times=0;tr0=0;void t0_timer() interrupt 1th0=(65536-45872)/256;/50mstl0=(65536-45872)%256;times+;void extern0() in

13、terrupt 0 /wait to repairex1=0;if(repairs=0)repairs=1;elserepairs=0;ex1=1;void extern1() interrupt 3 /emergencydirection=0; /stop the elevatormove=0;5.設(shè)計心得本次實習(xí)我們選擇了模擬日常生活中常見的電梯運行過程。這次實習(xí)讓我對程序的設(shè)計、調(diào)試有了更深刻的認(rèn)識。尤其是寫單片機這類的與硬件相關(guān)的程序。在調(diào)試的時候會有不少意想不到的結(jié)果。這要求除了對程序充分了解,還要對硬件的特性,電路的連接也深刻認(rèn)識。關(guān)于程序,總結(jié)如下:必須養(yǎng)成在寫之前仔細(xì)分析需求、要求,畫出流程圖,先明確各個模塊的作用。最后分塊細(xì)化,從底向上設(shè)計的習(xí)慣。否則很容易出現(xiàn)程序?qū)懥艘话氚l(fā)現(xiàn)理解出錯,功能達不到的情況。還有程序注釋必須及時,不能等到寫完了再注釋,否則可能之后連自己也看不懂程序。及時的修改記錄也是必要的。對于硬件、電路:要熟練掌握如何用c、匯編語言操作芯片。要掌握常用芯片的用法、特性,至少要熟悉其datasheet,需要使用時通過查閱手冊,能快速、熟練的使用該芯片。參考文獻1.王玉芳

溫馨提示

  • 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)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論