课程设计单片机串口与红外双机通信设计_第1页
课程设计单片机串口与红外双机通信设计_第2页
课程设计单片机串口与红外双机通信设计_第3页
课程设计单片机串口与红外双机通信设计_第4页
课程设计单片机串口与红外双机通信设计_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、中国矿业大学单片机系统综合设计姓 名: * 学 号: * 专 业: * 题 目: 单片机串口与红外双机通信 专 题: 单片机技术综合设计 设计地点: * 设计日期: * 成 绩: 指导教师: 年 月 单片机系统设计任务书学生姓名:* 专业年级:* 学号:* 设计日期: *设计专题: 单片机技术综合设计设计题目:单片机串口与红外双机通信设计内容和要求:1. 主要内容: 实现51学习板的按键扫描及显示按键的功能 实现51学习板的串口通信及显示的功能 实现51学习板的红外通信及显示的功能 2. 整体电路原理图 按键扫描、串口通信、红外通信及显示电路图3. 设计原理图 用altium designer

2、 9设计原理图 指导教师签字: 年 月 日摘 要利用所学的模电,数电,51单片机的知识,用c语言实现两块单片机板子的通信,通过部分模块集成如:最小系统,键盘设计,显示设计,串口设计,红外设计,软件设计,延时子程序设计,键盘设计,显示软件设计,串口软件设计,红外软件设计,实现串口和红外的通信。关键词:键盘显示;串口通信;红外通信目 录1设计原理概述11.1设计背景11.2设计原理框图12硬件的设计22.1最小系统的设计22.1.1最小系统的电路设计22.1.2单片机at89s51介绍22.2键盘的设计42.2.1键盘的电路设计42.2.2芯片mc74hc245an的介绍42.3显示的设计52.3

3、.1显示的电路设计52.3.2芯片mc74hc273n的介绍52.3.3 lc5011-11 led/7段及显示介绍62.4红外的设计62.4.1芯片mc74hc273n的介绍及参数63软件的设计83.1程序的流程图83.3.1单片机按键扫描及显示程序概述和流程83.3.2单片机串口数据通信及显示程序概述和流程93.3.3单片机红外数据通信及显示程序概述和流程93.2扫描及显示的程序设计94小结165参考文献176附录181设计原理概述1.1设计背景在许多基于单片机的应用系统中,系统需要实现遥控功能,而红外通信则是被采用较多的一种方法。红外通信具有控制简单、实施方便、传输可靠性高的特点,是一种

4、较为常用的通信方式。 在许多基于单片机的应用系统中,系统需要实现遥控功能,而红外通信则是被采用较多的一种方法。红外通信具有控制简单、实施方便、传输可靠性高的特点,是一种较为常用的通信方式。红外线通信是一种廉价、近距离、无线、低功耗、保密性强的通讯方案,主要应用于近距离的无线数据传输,也有用于近距离无线网络接入。从早期的irda规范(115200bps)到askir(1.152mbps),再到最新的fastir(4mbps),红外线接口的速度不断提高,使用红外线接口和电脑通信的信息设备也越来越多。红外线接口是使用有方向性的红外线进行通讯,由于它的波长较短,对障碍物的衍射能力差,所以只适合于短距离

5、无线通讯的场合,进行点对点的直线数据传输,因此在小型的移动设备中获得了广泛的应用。1.2设计原理框图 原理设计图 2硬件的设计2.1最小系统的设计2.1.1最小系统的电路设计2.1.2单片机at89s51介绍at89s51是一个低功耗,高性能cmos 8位单片机,片内含4k bytes isp的可反复擦写1000次的flash只读程序存储器,器件采用atmel公司的高密度、非易失性存储技术制造,兼容标准mcs-51指令系统及80c51引脚结构,芯片内集成了通用8位中央处理器和isp flash存储单元,at89s51在众多嵌入式控制应用系统中得到广泛应用。ats8951的管脚图及主要性能参数:

6、at89s51提供以下标准功能:4k字节闪速存储器,128字节内部ram,32个i/o口线,看门狗(wdt),两个数据指针,两个16位定时/计数器,一个5向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟电路。同时,at89s51可降至0hz的静态逻辑操作,并支持两种软件可选的节电工作模式。空闲方式停止cpu的工作,但允许ram,定时/计数器,串行通信口及中断系统继续工作。掉电方式保存ram中到内容,但振荡器停止工作并禁止其它所有工作部件直到下一个硬件复位。与mcs-51产品指令系统完全兼容,4k字节在系统编程(isp)flash 闪速存储器,1000次擦写周期,4.0-5.5v的工作电

7、压范围,全静态工作模式:0hz-33mhz,三级程序加密锁,128*8字节内部ram、32个可编程i/o口线、2个16位定时/计数器、6个中断源,全双工串行uart通道,低功耗空闲和掉电模式,中断可从空闲模式唤醒系统,看门狗(wdt)及双数据指针,掉电标示和快速编程特性,灵活的在系统编程(isp-字节或页写模式)。2.2键盘的设计2.2.1键盘的电路设计2.2.2芯片mc74hc245an的介绍 总线驱动器,典型的ttl型三态缓冲门电路。 由于单片机等cpu的数据地址控制总线端口都有一定的负载能力,如果负载超过其负载能力,一般应加驱动器。 另外,也可以使用74hc244等其他电路,74hc24

8、4比74hc245多了锁存器。芯片mc74hc245的管脚图及功能:2.3显示的设计2.3.1显示的电路设计2.3.2芯片mc74hc273n的介绍mc74hc273是一款高速cmos器件,74hc273引脚兼容低功耗肖特ttl(lsttl)系列。mc74hc273具有八路边沿触发,d型触发器,带独立的d输入和q输出,mc74hc273的公共时钟(pc)和复位(mr)端可以同时读取和复位(清零)所有触发器。每一个d输入的状态将在时钟脉冲上升沿之前的一段就绪时间内被传输到触发器对应的输出(qn)上。一旦mr输入电平为低,则所有输出将被强制置为低,而不依赖于时钟或者数据输入。mc74hc273适用

9、于要求原码输出或者所有储存元件共用时钟和主复位的应用。芯片mc74hc273的管脚图及功能:2.3.3 lc5011-11 led/7段及显示介绍(1) 数码管内部已将3端、8端连接在一起,所以使用时,3端接地,8端悬空。(2)限流电阻计算:数码管的工作电压为u(手册数据),工作电流为i(手册数据),译码器输出的高电平uag,则限流电阻上的电压应该为uu,限流电阻阻值: r(uagu)i(3)高电平点亮数码管,显示数字0 9。2.4红外的设计2.4.1芯片mc74hc273n的介绍及参数3软件的设计3.1程序的流程图3.3.1单片机按键扫描及显示程序概述和流程3.3.2单片机串口数据通信及显示

10、程序概述和流程3.3.3单片机红外数据通信及显示程序概述和流程3.2扫描及显示的程序设计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串口及显示的程序设计3.3.1发送串口程序#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表格,用于查表是数码管显示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 /数码管显示字符码写地址#define reg_code xbyte0xdfff /字位码写地址 unsigned char receive(void) unsigned char dat;

15、while(ri=0) ; ri=0; dat=sbuf; /dat中数据为接收(发送)寄存器(sbuf)中数据 return dat;void main(void) tmod=0x20;/定时器1工作方式二(为串口提供波特率发生器),8位工作方式 scon=0x50; /可寻址的专用寄存器用于串行数据的通信控制,工作方式一,波特率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红外的软件设计3.4.1红外发送程序#include unsigned char code tab =0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5e,0x79,0x71;/0-f表格,用于查表是数码管显示0fsbit p32=p32;/p32位端口p3.2void send(unsigned char dat) sbuf=dat; while(ti=0) ; ti=0;/*/ / / /示波

17、器显示周期为28us,频率为35.7khz /无法达到所需要的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小结这次课程试验,总体下来感觉不错。在郭老师的帮助下,我成功地实现了串口通信、红外通信以及键盘扫描、显示。本次实验中,我发现了在我们对于51单片机开发板的熟

19、悉前提下,目标功能程序是关键。只有熟悉编程,才能成功实现功能。最后,感谢老师给予我的指导,感谢学校实验室给予我的学习环境,谢谢!5参考文献1雷道仲. 单片机典型系统设计实例精讲.北京. 电子工业出版社,20062 常喜茂. c51基础与应用实例.北京.电子工业出版社,20093 曹国清. 数字电路与逻辑设计. 徐州:中国矿业大学,19984 康华光. 电子技术基础. 武汉:高等教育出版社,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.一字开头的年龄已经到了尾声。或许是愧疚于自己似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。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.童年时,觉得压岁钱和新衣服是过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次

35、站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。originally, this world, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.原来,这个世界上,对某个事件能产生化学反应的,除了非做不可的坚决,还有,时间。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.一个人的时候,自己的想法总是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。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.此刻,天空是阴暗的,空气里有着刚下过雨之后的清新因子。突然想到那件蓝

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

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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论