課程設(shè)計單片機串口與紅外雙機通信設(shè)計_第1頁
課程設(shè)計單片機串口與紅外雙機通信設(shè)計_第2頁
課程設(shè)計單片機串口與紅外雙機通信設(shè)計_第3頁
課程設(shè)計單片機串口與紅外雙機通信設(shè)計_第4頁
課程設(shè)計單片機串口與紅外雙機通信設(shè)計_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、中國礦業(yè)大學(xué)單片機系統(tǒng)綜合設(shè)計姓 名: * 學(xué) 號: * 專 業(yè): * 題 目: 單片機串口與紅外雙機通信 專 題: 單片機技術(shù)綜合設(shè)計 設(shè)計地點: * 設(shè)計日期: * 成 績: 指導(dǎo)教師: 年 月 單片機系統(tǒng)設(shè)計任務(wù)書學(xué)生姓名:* 專業(yè)年級:* 學(xué)號:* 設(shè)計日期: *設(shè)計專題: 單片機技術(shù)綜合設(shè)計設(shè)計題目:單片機串口與紅外雙機通信設(shè)計內(nèi)容和要求:1. 主要內(nèi)容: 實現(xiàn)51學(xué)習(xí)板的按鍵掃描及顯示按鍵的功能 實現(xiàn)51學(xué)習(xí)板的串口通信及顯示的功能 實現(xiàn)51學(xué)習(xí)板的紅外通信及顯示的功能 2. 整體電路原理圖 按鍵掃描、串口通信、紅外通信及顯示電路圖3. 設(shè)計原理圖 用altium designer

2、 9設(shè)計原理圖 指導(dǎo)教師簽字: 年 月 日摘 要利用所學(xué)的模電,數(shù)電,51單片機的知識,用c語言實現(xiàn)兩塊單片機板子的通信,通過部分模塊集成如:最小系統(tǒng),鍵盤設(shè)計,顯示設(shè)計,串口設(shè)計,紅外設(shè)計,軟件設(shè)計,延時子程序設(shè)計,鍵盤設(shè)計,顯示軟件設(shè)計,串口軟件設(shè)計,紅外軟件設(shè)計,實現(xiàn)串口和紅外的通信。關(guān)鍵詞:鍵盤顯示;串口通信;紅外通信目 錄1設(shè)計原理概述11.1設(shè)計背景11.2設(shè)計原理框圖12硬件的設(shè)計22.1最小系統(tǒng)的設(shè)計22.1.1最小系統(tǒng)的電路設(shè)計22.1.2單片機at89s51介紹22.2鍵盤的設(shè)計42.2.1鍵盤的電路設(shè)計42.2.2芯片mc74hc245an的介紹42.3顯示的設(shè)計52.3

3、.1顯示的電路設(shè)計52.3.2芯片mc74hc273n的介紹52.3.3 lc5011-11 led/7段及顯示介紹62.4紅外的設(shè)計62.4.1芯片mc74hc273n的介紹及參數(shù)63軟件的設(shè)計83.1程序的流程圖83.3.1單片機按鍵掃描及顯示程序概述和流程83.3.2單片機串口數(shù)據(jù)通信及顯示程序概述和流程93.3.3單片機紅外數(shù)據(jù)通信及顯示程序概述和流程93.2掃描及顯示的程序設(shè)計94小結(jié)165參考文獻(xiàn)176附錄181設(shè)計原理概述1.1設(shè)計背景在許多基于單片機的應(yīng)用系統(tǒng)中,系統(tǒng)需要實現(xiàn)遙控功能,而紅外通信則是被采用較多的一種方法。紅外通信具有控制簡單、實施方便、傳輸可靠性高的特點,是一種

4、較為常用的通信方式。 在許多基于單片機的應(yīng)用系統(tǒng)中,系統(tǒng)需要實現(xiàn)遙控功能,而紅外通信則是被采用較多的一種方法。紅外通信具有控制簡單、實施方便、傳輸可靠性高的特點,是一種較為常用的通信方式。紅外線通信是一種廉價、近距離、無線、低功耗、保密性強的通訊方案,主要應(yīng)用于近距離的無線數(shù)據(jù)傳輸,也有用于近距離無線網(wǎng)絡(luò)接入。從早期的irda規(guī)范(115200bps)到askir(1.152mbps),再到最新的fastir(4mbps),紅外線接口的速度不斷提高,使用紅外線接口和電腦通信的信息設(shè)備也越來越多。紅外線接口是使用有方向性的紅外線進(jìn)行通訊,由于它的波長較短,對障礙物的衍射能力差,所以只適合于短距離

5、無線通訊的場合,進(jìn)行點對點的直線數(shù)據(jù)傳輸,因此在小型的移動設(shè)備中獲得了廣泛的應(yīng)用。1.2設(shè)計原理框圖 原理設(shè)計圖 2硬件的設(shè)計2.1最小系統(tǒng)的設(shè)計2.1.1最小系統(tǒng)的電路設(shè)計2.1.2單片機at89s51介紹at89s51是一個低功耗,高性能cmos 8位單片機,片內(nèi)含4k bytes isp的可反復(fù)擦寫1000次的flash只讀程序存儲器,器件采用atmel公司的高密度、非易失性存儲技術(shù)制造,兼容標(biāo)準(zhǔn)mcs-51指令系統(tǒng)及80c51引腳結(jié)構(gòu),芯片內(nèi)集成了通用8位中央處理器和isp flash存儲單元,at89s51在眾多嵌入式控制應(yīng)用系統(tǒng)中得到廣泛應(yīng)用。ats8951的管腳圖及主要性能參數(shù):

6、at89s51提供以下標(biāo)準(zhǔn)功能:4k字節(jié)閃速存儲器,128字節(jié)內(nèi)部ram,32個i/o口線,看門狗(wdt),兩個數(shù)據(jù)指針,兩個16位定時/計數(shù)器,一個5向量兩級中斷結(jié)構(gòu),一個全雙工串行通信口,片內(nèi)振蕩器及時鐘電路。同時,at89s51可降至0hz的靜態(tài)邏輯操作,并支持兩種軟件可選的節(jié)電工作模式??臻e方式停止cpu的工作,但允許ram,定時/計數(shù)器,串行通信口及中斷系統(tǒng)繼續(xù)工作。掉電方式保存ram中到內(nèi)容,但振蕩器停止工作并禁止其它所有工作部件直到下一個硬件復(fù)位。與mcs-51產(chǎn)品指令系統(tǒng)完全兼容,4k字節(jié)在系統(tǒng)編程(isp)flash 閃速存儲器,1000次擦寫周期,4.0-5.5v的工作電

7、壓范圍,全靜態(tài)工作模式:0hz-33mhz,三級程序加密鎖,128*8字節(jié)內(nèi)部ram、32個可編程i/o口線、2個16位定時/計數(shù)器、6個中斷源,全雙工串行uart通道,低功耗空閑和掉電模式,中斷可從空閑模式喚醒系統(tǒng),看門狗(wdt)及雙數(shù)據(jù)指針,掉電標(biāo)示和快速編程特性,靈活的在系統(tǒng)編程(isp-字節(jié)或頁寫模式)。2.2鍵盤的設(shè)計2.2.1鍵盤的電路設(shè)計2.2.2芯片mc74hc245an的介紹 總線驅(qū)動器,典型的ttl型三態(tài)緩沖門電路。 由于單片機等cpu的數(shù)據(jù)地址控制總線端口都有一定的負(fù)載能力,如果負(fù)載超過其負(fù)載能力,一般應(yīng)加驅(qū)動器。 另外,也可以使用74hc244等其他電路,74hc24

8、4比74hc245多了鎖存器。芯片mc74hc245的管腳圖及功能:2.3顯示的設(shè)計2.3.1顯示的電路設(shè)計2.3.2芯片mc74hc273n的介紹mc74hc273是一款高速cmos器件,74hc273引腳兼容低功耗肖特ttl(lsttl)系列。mc74hc273具有八路邊沿觸發(fā),d型觸發(fā)器,帶獨立的d輸入和q輸出,mc74hc273的公共時鐘(pc)和復(fù)位(mr)端可以同時讀取和復(fù)位(清零)所有觸發(fā)器。每一個d輸入的狀態(tài)將在時鐘脈沖上升沿之前的一段就緒時間內(nèi)被傳輸?shù)接|發(fā)器對應(yīng)的輸出(qn)上。一旦mr輸入電平為低,則所有輸出將被強制置為低,而不依賴于時鐘或者數(shù)據(jù)輸入。mc74hc273適用

9、于要求原碼輸出或者所有儲存元件共用時鐘和主復(fù)位的應(yīng)用。芯片mc74hc273的管腳圖及功能:2.3.3 lc5011-11 led/7段及顯示介紹(1) 數(shù)碼管內(nèi)部已將3端、8端連接在一起,所以使用時,3端接地,8端懸空。(2)限流電阻計算:數(shù)碼管的工作電壓為u(手冊數(shù)據(jù)),工作電流為i(手冊數(shù)據(jù)),譯碼器輸出的高電平uag,則限流電阻上的電壓應(yīng)該為uu,限流電阻阻值: r(uagu)i(3)高電平點亮數(shù)碼管,顯示數(shù)字0 9。2.4紅外的設(shè)計2.4.1芯片mc74hc273n的介紹及參數(shù)3軟件的設(shè)計3.1程序的流程圖3.3.1單片機按鍵掃描及顯示程序概述和流程3.3.2單片機串口數(shù)據(jù)通信及顯示

10、程序概述和流程3.3.3單片機紅外數(shù)據(jù)通信及顯示程序概述和流程3.2掃描及顯示的程序設(shè)計void delay(uchar x)uchar i;while(x-)for(i=0;i100;i+);void get_key(void) uchar temp; font_code=0x00; reg_code=0xfe;temp = key_addr & 0x0f; /僅需要低四位if(temp=0x0e)key_n=1;if(temp=0x0d)key_n=5;if(temp=0x0b)key_n=9;if(temp=0x07)key_n=13; font_code=0x00; reg_code=

11、0xfd;temp = key_addr & 0x0f; /僅需要低四位 if(temp=0x0e)key_n=2;if(temp=0x0d)key_n=6;if(temp=0x0b)key_n=10;if(temp=0x07)key_n=14; font_code=0x00; reg_code=0xfb;temp = key_addr & 0x0f; /僅需要低四位 if(temp=0x0e)key_n=3;if(temp=0x0d)key_n=7;if(temp=0x0b)key_n=11;if(temp=0x07)key_n=15; font_code=0x00; reg_code=0x

12、f7;temp = key_addr & 0x0f; /僅需要低四位 if(temp=0x0e)key_n=4;if(temp=0x0d)key_n=8;if(temp=0x0b)key_n=12;if(temp=0x07)key_n=16; void desplay() font_code=doflykey_n; reg_code=0x80; 3.3串口及顯示的程序設(shè)計3.3.1發(fā)送串口程序#include unsigned char code tab =0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5

13、e,0x79,0x71;/0-f表格,用于查表是數(shù)碼管顯示0fsbit p32=p32;/p32位端口p3.2void send(unsigned char dat) sbuf=dat; while(ti=0) ; ti=0; void delay(void) unsigned char m,n; for(m=0;m200;m+) for(n=0;n250;n+) ; /延時程序void main(void) unsigned char i; tmod=0x20; scon=0x40;/串口模式1,接受禁止 pcon=0x00; /pcon=0000 0000b,波特率9600 th1=0xf

14、d; /515us定時 tl1=0xfd; tr1=1; while(1) if(p32=0) delay();if(p32=0) delay();delay();delay();send(tabi); delay(); delay();i+;if(i=16)i=0; 3.3.2接收程序#include /包含單片機寄存器的頭文件#include#define font_code xbyte0xefff /數(shù)碼管顯示字符碼寫地址#define reg_code xbyte0xdfff /字位碼寫地址 unsigned char receive(void) unsigned char dat;

15、while(ri=0) ; ri=0; dat=sbuf; /dat中數(shù)據(jù)為接收(發(fā)送)寄存器(sbuf)中數(shù)據(jù) return dat;void main(void) tmod=0x20;/定時器1工作方式二(為串口提供波特率發(fā)生器),8位工作方式 scon=0x50; /可尋址的專用寄存器用于串行數(shù)據(jù)的通信控制,工作方式一,波特率9600bit/s,允許接收ti=1 pcon=0x00; /pcon=0000 0000b,波特率9600 th1=0xfd; tl1=0xfd; /515us tr1=1; / 定時器控制寄存器tcon中t1運行控制位置1 ren=1; /scon中的允許接受位

16、,置1允許接收 while(1) font_code=receive(); reg_code=0x80; 3.4紅外的軟件設(shè)計3.4.1紅外發(fā)送程序#include unsigned char code tab =0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5e,0x79,0x71;/0-f表格,用于查表是數(shù)碼管顯示0fsbit p32=p32;/p32位端口p3.2void send(unsigned char dat) sbuf=dat; while(ti=0) ; ti=0;/*/ / / /示波

17、器顯示周期為28us,頻率為35.7khz /無法達(dá)到所需要的38khz的載波頻率。 /*/#include sbit p11=p17; void carry(void) tmod=0x01; th0=0xff; tl0=0xfb; tr0=1; tf0=0;p11=0xff; while(1) while(tf0=0) ; tf0=0; p11=p11; th0=0xff; tl0=0xfb; void delay(void) unsigned char m,n; for(m=0;m200;m+) for(n=0;n250;n+) ; /延時程序void main(void) unsigne

18、d char i; tmod=0x20; scon=0x40;/串口模式1,接受禁止 pcon=0x00; /pcon=0000 0000b,波特率9600 th1=0xfd; /515us定時 tl1=0xfd; tr1=1; while(1) if(p32=0) delay();if(p32=0) delay();delay();delay();send(tabi); delay(); delay();i+;if(i=16)i=0; 4小結(jié)這次課程試驗,總體下來感覺不錯。在郭老師的幫助下,我成功地實現(xiàn)了串口通信、紅外通信以及鍵盤掃描、顯示。本次實驗中,我發(fā)現(xiàn)了在我們對于51單片機開發(fā)板的熟

19、悉前提下,目標(biāo)功能程序是關(guān)鍵。只有熟悉編程,才能成功實現(xiàn)功能。最后,感謝老師給予我的指導(dǎo),感謝學(xué)校實驗室給予我的學(xué)習(xí)環(huán)境,謝謝!5參考文獻(xiàn)1雷道仲. 單片機典型系統(tǒng)設(shè)計實例精講.北京. 電子工業(yè)出版社,20062 常喜茂. c51基礎(chǔ)與應(yīng)用實例.北京.電子工業(yè)出版社,20093 曹國清. 數(shù)字電路與邏輯設(shè)計. 徐州:中國礦業(yè)大學(xué),19984 康華光. 電子技術(shù)基礎(chǔ). 武漢:高等教育出版社,20066附錄employment tribunals sort out disagreements between employers and employees.you may need to make

20、a claim to an employment tribunal if: you dont agree with the 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 emp

21、loyment tribunal, even if you haventappealedagainst the disciplinary 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

22、 employment tribunal within three months of the date when the event you are complaining about happened. if your application is received after this time limit, the tribunal will not usually accept it.if you are worried about how the time limits apply to you, take advice from one of the organisations

23、listed underfurther help.employment tribunals are less formal than 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

24、employment tribunal, you should get help straight away from one 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 adam

25、ages-based agreement. in england and wales, your solicitor cant 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

26、 an experienced adviser, for example, at a citizens advice bureau. 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-b

27、ased webb, the head of fifas anti-racism taskforce, is in london 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

28、 how he felt and i would like to speak to him first to find out 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 investi

29、gation into the referees actions.cska said they were surprised 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 b

30、ecame the appearance of the same day; may be back in the past, 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, sudd

31、enly feel something, do it.一字開頭的年齡已經(jīng)到了尾聲?;蛟S是愧疚于自己似乎把轉(zhuǎn)瞬即逝的很多個不同的日子過成了同一天的樣子;或許是追溯過去,對自己那些近乎偏執(zhí)的怪異信念的醒悟,這些天以來,思緒一直很凌亂,在腦海中不斷糾纏??傆X得自己自己似乎應(yīng)該去做點什么,或者寫點什么。二十年的人生軌跡深深淺淺,突然就感覺到有些事情,非做不可了。the end of our life, and can meet many things really do?而窮盡我們的一生,又能遇到多少事情是真正地非做不可?during my childhood, think lucky money a

32、nd new clothes are necessary for new year, but as the advance of 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 th

33、at isnt really grow up, it seems is not so important; then in high 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 swe

34、at profusely, looked at his thrown a basketball hoops, suddenly found himself has already cant remember his appearance.童年時,覺得壓歲錢和新衣服是過年必備,但是隨著年齡的推進(jìn),會越來越發(fā)現(xiàn),那些東西根本就可有可無;初中時,以為要有一場暗戀才意味著真正的成長,但三年過去后,自己心平氣和的寫同學(xué)錄的時候,突然就發(fā)現(xiàn)是不是真正的成長了,好像并沒有那么重要了;然后到了高中,覺得非要吐露出自己的心聲才能為高中生涯里的懵懂情愫劃上一個句點,但畢業(yè)晚會的時候最終還是被梗塞在了咽喉,后來再次

35、站在他曾經(jīng)揮汗如雨的球場,看著他投過籃球的球框時,突然間發(fā)現(xiàn)自己已經(jīng)想不起他的容顏。originally, this world, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.原來,這個世界上,對某個事件能產(chǎn)生化學(xué)反應(yīng)的,除了非做不可的堅決,還有,時間。a persons time, your ideas are always special to clear. want, want, line is clear, as if nothing could

36、 shake his. also once seemed to be determined to do something, 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 injectio

37、n, or is a self-righteous spiritual.一個人的時候,自己的想法總是特別地清晰。想要的,不想要的,界限明確,好像沒有什么可以撼動自己。也曾經(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 o

38、f blue plaid shirt; those were broken into various shapes of stationery; 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.此刻,天空是陰暗的,空氣里有著剛下過雨之后的清新因子。突然想到那件藍(lán)

39、格子襯衫;那些被折成各種各樣形狀的信紙;那段從街角深巷伊始的友誼;還有那場還沒有開始就宣告了終結(jié)的邂逅計劃那些年那些天的非做不可,終于和青春一樣,都將在我們的人生中謝幕。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

40、limited cloud cover. the balloon, with capsule attached, will move 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,0

溫馨提示

  • 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

提交評論