畢業(yè)設(shè)計基于AT89C51單片機的秒表設(shè)計_第1頁
畢業(yè)設(shè)計基于AT89C51單片機的秒表設(shè)計_第2頁
畢業(yè)設(shè)計基于AT89C51單片機的秒表設(shè)計_第3頁
畢業(yè)設(shè)計基于AT89C51單片機的秒表設(shè)計_第4頁
畢業(yè)設(shè)計基于AT89C51單片機的秒表設(shè)計_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、目 錄一、設(shè)計的內(nèi)容、要求及目的1二、系統(tǒng)總體方案選擇與說明1三、系統(tǒng)方框圖與工作原理2四、各部分方案選定、功能及計算24.1 按鍵部分24.2 顯示部分3五、器件說明4六、調(diào)試說明、使用說明4心得體會5參考文獻5附錄6附錄a 系統(tǒng)原理圖6附錄b 程序清單7一、 設(shè)計的內(nèi)容、要求及目的設(shè)計內(nèi)容我設(shè)計的是以51單片機為核心的秒表,顯示“00.00”,第1次按下1按鈕后就開始計時;第2次按1按鈕后,計時停止;然后按2按鈕可以記錄;最后按3按鈕,計時歸零。通過液晶顯示器顯示秒十位、個位、小數(shù)點后一位和兩位,最小單位為0.01秒,在設(shè)計過程中用一個存儲單元作為秒計數(shù)單元,當一秒鐘到來時,就讓秒計數(shù)單元

2、加1,當秒計數(shù)達到59.59時,就自動返回到00.00,重新開始秒計數(shù)。設(shè)計要求1. 設(shè)計方案要合理、正確;2. 系統(tǒng)硬件設(shè)計;3. 完成必要元器件選擇;4. 系統(tǒng)軟件設(shè)計及調(diào)試;5. 寫出設(shè)計報告。設(shè)計目的本次設(shè)計的是秒表,為了更好的完成課程設(shè)計,采用的是硬件定時,即用單片機內(nèi)部的定時器t0。先將時鐘初始化,賦入初值50ms定時,循環(huán)20次來進行1秒定時。采用的是at89c51單片機,有按鍵部分和顯示部分。二、 系統(tǒng)總體方案選擇與說明此次課程設(shè)計題目是秒表,由于此次課程設(shè)計要求是秒表,則在定時時要求比較精確,所以采用硬件的定時器定時時比較準確的;由于秒表的定時程序是很小的,在利用軟件定時占用

3、的cpu并不是很多,不能顯現(xiàn)出來,但真正大程序時會很占用資源的,所以在用定時中斷過程中是非常節(jié)省資源的由課程設(shè)計的要求和任務(wù),我采用的c語言編程,設(shè)計秒表要求一秒定時,采用了定時器,即用單片機內(nèi)部的定時器t0。先將時鐘初始化,賦入初值50ms定時,循環(huán)20次來進行1秒定時。然后由定義的變量second來進行加一運算,然后將其值通過p2口在數(shù)碼管上進行顯示。其中數(shù)碼管的顯示時,我在程序中首先定義了一個關(guān)于數(shù)碼管顯示的字形碼定義,以便在顯示時調(diào)用即可。本次采用的是at89c51單片機:at89c51是一種帶4k字節(jié)flash存儲器(fperomflash programmable and eras

4、able read only memory)的低電壓、高性能cmos 8位微處理器,俗稱單片機。at89c2051是一種帶2k字節(jié)閃存可編程可擦除只讀存儲器的單片機。單片機的可擦除只讀存儲器可以反復擦除1000次。該器件采用atmel高密度非易失存儲器制造技術(shù)制造,與工業(yè)標準的mcs-51指令集和輸出管腳相兼容。由于將多功能8位cpu和閃爍存儲器組合在單個芯片中,atmel的at89c51是一種高效微控制器,at89c2051是它的一種精簡版本。at89c單片機為很多嵌入式控制系統(tǒng)提供了一種靈活性高且價廉的方案。引腳排列如圖所示主要特性:與mcs-51 兼容 4k字節(jié)可編程flash存儲器 壽

5、命:1000寫/擦循環(huán) 數(shù)據(jù)保留時間:10年 全靜態(tài)工作:0hz-24mhz 三級程序存儲器鎖定 1288位內(nèi)部ram 32可編程i/o線 兩個16位定時器/計數(shù)器 5個中斷源 可編程串行通道 低功耗的閑置和掉電模式片內(nèi)振蕩器和時鐘電路三、 系統(tǒng)方框圖與工作原理秒表采用的是at89c51單片機,單片機的p1口連接著按鍵,實現(xiàn)按鍵功能;p0、p2、p3口連接著顯示器,實現(xiàn)顯示功能。如圖3.1所示:按鍵顯示器at89c51 p0p1 p2 p3 圖3.1秒表總體系統(tǒng)方框圖四、 各部分方案選定、功能及計算4.1 按鍵部分k1和單片機的p1.0口相連,實現(xiàn)啟動/停止功能,按下k1鍵,開啟計時功能,再按

6、一下,即停止計時;k2和單片機的p1.1相連,實現(xiàn)記錄功能,按下k2鍵,開啟記錄功能,共有3個可以記錄;k3和單片機的p1.2相連,實現(xiàn)重置功能按下k3,即清零重置。如圖4.1所示:圖4.1按鍵部分4.2 顯示部分單片機的p2.0到p2,7分別和顯示器的d0到d7相對應(yīng)連接;單片機的p0.0到p0.3分別和顯示器的cs1、cs2、rw和rs相對應(yīng)連接;單片機的p3.4和顯示器的e相對應(yīng)連接。以上是實現(xiàn)顯示功能,如圖4.2所示:圖4.2顯示部分五、 器件說明(1) mcs-51單片機實驗操作臺1臺;(2) pc機及單片機調(diào)試軟件;(3) 單片機應(yīng)用系統(tǒng)板1套;(4) 制作工具1套;(5) 系統(tǒng)設(shè)

7、計所需的元器件。六、調(diào)試說明、使用說明編好的程序在keil中有許多錯誤,這些錯誤在平時的實驗中也碰到過很多。例如,字母開頭忘了加0,零和字母搞錯了,有些標號用了幾次,cjne寫成了cjnz等等,幸好這些錯誤在平時實驗中遇到很多次了,所以改正很快的。除了常見錯誤,還有些錯誤在平時沒遇到過的。如:ajmp指令跳轉(zhuǎn)不回指定的地位,是由于跳轉(zhuǎn)的長度大于ajmp跳轉(zhuǎn)的長度,最后只有用ljmp跳轉(zhuǎn)后跳到指定的位置。在幾天的調(diào)試和修改程序中,我的知識也得到了鞏固,使我對單片機的知識更加的渴望。在proteus編輯窗口中單擊開始仿真按鈕,開始仿真,按啟動按鈕,開始讀秒,按記錄按鈕記錄數(shù)據(jù),可以記錄3個數(shù)據(jù),最

8、后按重置按鈕,重置數(shù)據(jù)。如圖6.1所示:圖6.1心得體會通過這次課程設(shè)計秒表計時器,使我又重新開始學習c語言,因為c語言是大一學的,至從學完就再也沒用過,所以開始很陌生,我又找了有關(guān)資料來了解,才有了一點眉目。剛開始以為可以用匯編很容易就寫出來,以為學的很明白了,但是用匯編時才發(fā)現(xiàn)原來都不怎么熟練,編了一會程序發(fā)現(xiàn)只有一種感覺舉步維艱??!還是放棄匯編選擇c語言吧!對于單片機,我們課本學習的是80c51,但是這次做課程設(shè)計用的是89c51,這樣不僅使我們掌握了80c51,而且對89c51也有了一定的了解了,在課堂上學習的都理論的,跟實際永遠有一定的差距,不實踐就不會發(fā)現(xiàn)問題。而且我還更加熟練的應(yīng)

9、用了proteus和keil兩個軟件。通過這次課程設(shè)計使我把課堂上學習的東西都用到了實踐中,例如:定時/計數(shù)器的應(yīng)用與中斷。學習的時候不怎么理解,但是在實踐中應(yīng)用了以后就自然了解了。這次課程設(shè)計使我受益匪淺,而且都是實際的東西。最后,還要感謝本次課程設(shè)計的老師,也是我們單片機的老師,感謝在老師悉心的指導下,完成了本次課程設(shè)計。參考文獻1、 單片機原理與應(yīng)用 王迎旭等編 機械工業(yè)出版社2、 51系列單片機設(shè)計實例 樓然苗等編 北京航空航天大學出版社3、 計算機硬件技術(shù)基礎(chǔ)實驗教程 黃勤等編 重慶大學出版社4、微型計算機接口技術(shù)及應(yīng)用 劉樂善主編 華中科技大學出版社5、單片微型計算機原理及接口技術(shù)

10、陳光東等 華中科技大學出版社附錄附錄a 系統(tǒng)原理圖附錄b 程序清單#include#includechar status=0,c=0,c_r=1;char save1_m,save1_s,save2_m,save2_s,save3_m,save3_s,save4_m,save4_s;sbit led1=p34;sbit led2=p35;sbit led3=p36;sbit led=p30;bit flag=0;bit reset=0;ui dj,zj,lc;uc m=0,s=0;extern scan_key1();extern scan_key2();extern scan_key3();

11、extern scan_key4();extern scan_key5();void delay(uc a)uc i;while(a-)for(i=100;i0;i-);void initshow() /0xb80xbf表示第07頁(64行); 0x01_表示行(0x400x3f) display_hz(0xb8,0x40,hz0); /單 display_hz(0xb8,0x50,hz1); /價 display_fh(0xb8,0x60,fh0); /:/* display_hz(0xb8,0xb0,hz8); /元 */ display_hz(0xba,0x40,hz2); /里:一個漢

12、字占2行 行+2 display_hz(0xba,0x50,hz3); /程 display_fh(0xba,0x60,fh0); /:/* / display_fivenum(0xba,0xa8,lc); /display_fh(0xba,0xb0,fh2); /k display_fh(0xba,0xb4,fh3); /m display_hz(0xbc,0x40,hz4); /總 display_hz(0xbc,0x50,hz1); /價 display_fh(0xbc,0x60,fh0); /: / display_fivenum(0xbc,0xa8,zj); display_hz(0

13、xbc,0xb0,hz8); /元 void ad_time(void) s+; if(s=60)s=0; m+; if(m=60)m=0;void save_second(char i)if(i=1) save1_m=m;save1_s=s; else if(i=2) save2_m=m;save2_s=s; else if(i=3) save3_m=m;save3_s=s; void recover_second(char i) if(i=1) m=save1_m;s=save1_s; else if(i=2) m=save2_m;s=save2_s; else if(i=3) m=sav

14、e3_m;s=save3_s; else if(i=4) m=save4_m;s=save4_s; void init(void) tmod=0x01; th0=(65536-16600)/256; tl0=(65536-16600)%256; ea=1; et0=1; tr0=0; void main(void) ui t=1000; init(); inilcd(); clearscreen(2); initshow(); display_fivenum(0xb8,0x80,m,s); while(1) /鍵盤掃描程序 led=led; if(scan_key1()=1) tr0=tr0;

15、 else if(scan_key2()=1&tr0=1) led1=led1; flag=1; c+; save_second(c); if(c=4)c=50; else if(scan_key3()=1) tr0=0; clearscreen(2); initshow(); display_fivenum(0xb8,0x80,0,0); m=0;s=0;c=0; void timer0(void) interrupt 1 th0=(65536-16600)/256; tl0=(65536-16600)%256; ad_time(); if(flag=1) flag=0; tr0=0; if

16、(c=1)display_fivenum(0xba,0x80,save1_m,save1_s); else if(c=2)display_fivenum(0xbc,0x80,save2_m,save2_s); else if(c=3)display_fivenum(0xbe,0x80,save3_m,save3_s); tr0=1; display_fivenum(0xb8,0x80,m,s);按鍵#include#define uchar unsigned charsbit key1=p10;bit f_k1=1;sbit key2=p11;bit f_k2=1;sbit key3=p12;

17、bit f_k3=1;sbit key4=p13;bit f_k4=1;sbit key5=p14;bit f_k5=1;void delay(char i)while(i-);char scan_key1(void) if(key1=0) delay(100); if(key1=0) f_k1=0; return 0; else return 0; else if(f_k1=0) f_k1=1; return 1; else return 0; char scan_key2(void)if(key2=0)delay(100);if(key2=0)f_k2=0;return 0;else re

18、turn 0;else if(f_k2=0)f_k2=1;return 1;else return 0;char scan_key3(void)if(key3=0)delay(100);if(key3=0)待添加的隱藏文字內(nèi)容3f_k3=0;return 0;else return 0;else if(f_k3=0)f_k3=1;return 1;else return 0;char scan_key4(void)if(key4=0)delay(100);if(key4=0)f_k4=0;return 0;else return 0;else if(f_k4=0)f_k4=1;return 1

19、;else return 0;char scan_key5(void)if(key5=0)delay(100);if(key5=0)f_k5=0;return 0;else return 0;else if(f_k5=0)f_k5=1;return 1;else return 0;employment tribunals sort out disagreements between employers and employees.you may need to make a claim to an employment tribunal if: you dont agree with the

20、disciplinary action your employer has taken against you your employer dismisses you and you think that you have been dismissed unfairly.for more information about dismissal and unfair dismissal, seedismissal.you can make a claim to an employment tribunal, even if you haventappealedagainst the discip

21、linary action your employer has taken against you. however, if you win your case, the tribunal may reduce any compensation awarded to you as a result of your failure to appeal.remember that in most cases you must make an application to an employment tribunal within three months of the date when the

22、event you are complaining about happened. if your application is received after this time limit, the tribunal will not usually accept i.if you are worried about how the time limits apply to you, take advice from one of the organisations listed underfurther help.employment tribunals are less formal t

23、han some other courts, but it is still a legal process and you will need to give evidence under an oath or affirmation.most people find making a claim to an employment tribunal challenging. if you are thinking about making a claim to an employment tribunal, you should get help straight away from one

24、 of the organisations listed underfurther help.if you are being represented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you win the case. this is known as adamages-based agreement. in england and wales, your solicitor cant

25、 charge you more than 35% of your compensation if you win the case.if you are thinking about signing up for a damages-based agreement, you should make sure youre clear about the terms of the agreement. it might be best to get advice from an experienced adviser, for example, at a citizens advice bure

26、au. to find your nearest cab, including those that give advice by e-mail, click onnearest cab.for more information about making a claim to an employment tribunal, seeemployment tribunals.the (lack of) air up there watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in londo

27、n for the football associations 150th anniversary celebrations and will attend citys premier league match at chelsea on sunday.i am going to be at the match tomorrow and i have asked to meet yaya toure, he told bbc sport.for me its about how he felt and i would like to speak to him first to find out

28、 what his experience was.uefa hasopened disciplinary proceedings against cskafor the racist behaviour of their fans duringcitys 2-1 win.michel platini, president of european footballs governing body, has also ordered an immediate investigation into the referees actions.cska said they were surprised

29、and disappointed by toures complaint. in a statement the russian side added: we found no racist insults from fans of cska.age has reached the end of the beginning of a word. may be guilty in his seems to passing a lot of different life became the appearance of the same day; may be back in the past,

30、to oneself the paranoid weird belief disillusionment, these days, my mind has been very messy, in my mind constantly. always feel oneself should go to do something, or write something. twenty years of life trajectory deeply shallow, suddenly feel something, do it.一字開頭的年齡已經(jīng)到了尾聲。或許是愧疚于自己似乎把轉(zhuǎn)瞬即逝的很多個不同的

31、日子過成了同一天的樣子;或許是追溯過去,對自己那些近乎偏執(zhí)的怪異信念的醒悟,這些天以來,思緒一直很凌亂,在腦海中不斷糾纏。總覺得自己自己似乎應(yīng)該去做點什么,或者寫點什么。二十年的人生軌跡深深淺淺,突然就感覺到有些事情,非做不可了。the end of our life, and can meet many things really do?而窮盡我們的一生,又能遇到多少事情是真正地非做不可?during my childhood, think lucky money and new clothes are necessary for new year, but as the advance o

32、f the age, will be more and more found that those things are optional; junior high school, thought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni in peace, suddenly found that isnt really grow up, it seems is not so important; then in h

33、igh school, think dont want to give vent to out your inner voice can be in the high school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly

34、 found himself has already cant remember his appearance.童年時,覺得壓歲錢和新衣服是過年必備,但是隨著年齡的推進,會越來越發(fā)現(xiàn),那些東西根本就可有可無;初中時,以為要有一場暗戀才意味著真正的成長,但三年過去后,自己心平氣和的寫同學錄的時候,突然就發(fā)現(xiàn)是不是真正的成長了,好像并沒有那么重要了;然后到了高中,覺得非要吐露出自己的心聲才能為高中生涯里的懵懂情愫劃上一個句點,但畢業(yè)晚會的時候最終還是被梗塞在了咽喉,后來再次站在他曾經(jīng)揮汗如雨的球場,看著他投過籃球的球框時,突然間發(fā)現(xiàn)自己已經(jīng)想不起他的容顏。originally, this worl

35、d, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.原來,這個世界上,對某個事件能產(chǎn)生化學反應(yīng)的,除了非做不可的堅決,還有,時間。a persons time, your ideas are always special to clear. want, want, line is clear, as if nothing could shake his. also once seemed to be determined to do something,

36、but more often is he backed out at last. dislike his cowardice, finally found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. those who do, just green years oneself give oneself an arm injection, or is a self-righteous spiritual.一個人的時候,自己的想法總是特別地清晰。想要的,不想要

37、的,界限明確,好像沒有什么可以撼動自己。也曾經(jīng)好像已經(jīng)下定了決心去做某件事,但更多的時候是最后又打起了退堂鼓。嫌惡過自己的怯懦,最終卻發(fā)現(xiàn)有很多緣分,有很多錯過,好像冥冥之中真的已經(jīng)注定。那些曾經(jīng)所謂的非做不可,只是青蔥年華里自己給自己注射的一支強心劑,或者說,是自以為是的精神寄托罷了。at the moment, the sky is dark, the air is fresh factor after just rained. suddenly thought of blue plaid shirt; those were broken into various shapes of st

38、ationery; from the corner at the beginning of deep friendship; have declared the end of the encounter that havent start planning. those years, those days of do, finally, like youth, will end in our life.此刻,天空是陰暗的,空氣里有著剛下過雨之后的清新因子。突然想到那件藍格子襯衫;那些被折成各種各樣形狀的信紙;那段從街角深巷伊始的友誼;還有那場還沒有開始就宣告了終結(jié)的邂逅計劃那些年那些天的非做不

39、可,終于和青春一樣,都將在我們的人生中謝幕。baumgartner the disappointing news: mission aborted. r plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. the balloon, with capsule attached, will m

40、ove through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. as he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.the supersonic descent could happen as early as sunda.the weathethe balloon will slowly drift to the edge of space at 120,000 fee

溫馨提示

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

評論

0/150

提交評論