毕业设计基于AT89C51单片机的秒表设计

上传人:仙*** 文档编号:35464484 上传时间:2021-10-27 格式:DOC 页数:18 大小:687.50KB
收藏 版权申诉 举报 下载
毕业设计基于AT89C51单片机的秒表设计_第1页
第1页 / 共18页
毕业设计基于AT89C51单片机的秒表设计_第2页
第2页 / 共18页
毕业设计基于AT89C51单片机的秒表设计_第3页
第3页 / 共18页
资源描述:

《毕业设计基于AT89C51单片机的秒表设计》由会员分享,可在线阅读,更多相关《毕业设计基于AT89C51单片机的秒表设计(18页珍藏版)》请在装配图网上搜索。

1、目 录一、设计的内容、要求及目的1二、系统总体方案选择与说明1三、系统方框图与工作原理2四、各部分方案选定、功能及计算24.1 按键部分24.2 显示部分3五、器件说明4六、调试说明、使用说明4心得体会5参考文献5附录6附录A 系统原理图6附录B 程序清单7一、 设计的内容、要求及目的设计内容我设计的是以51单片机为核心的秒表,显示“00.00”,第1次按下1按钮后就开始计时;第2次按1按钮后,计时停止;然后按2按钮可以记录;最后按3按钮,计时归零。通过液晶显示器显示秒十位、个位、小数点后一位和两位,最小单位为0.01秒,在设计过程中用一个存储单元作为秒计数单元,当一秒钟到来时,就让秒计数单元

2、加1,当秒计数达到59.59时,就自动返回到00.00,重新开始秒计数。设计要求1. 设计方案要合理、正确;2. 系统硬件设计;3. 完成必要元器件选择;4. 系统软件设计及调试;5. 写出设计报告。设计目的本次设计的是秒表,为了更好的完成课程设计,采用的是硬件定时,即用单片机内部的定时器T0。先将时钟初始化,赋入初值50ms定时,循环20次来进行1秒定时。采用的是AT89C51单片机,有按键部分和显示部分。二、 系统总体方案选择与说明此次课程设计题目是秒表,由于此次课程设计要求是秒表,则在定时时要求比较精确,所以采用硬件的定时器定时时比较准确的;由于秒表的定时程序是很小的,在利用软件定时占用

3、的CPU并不是很多,不能显现出来,但真正大程序时会很占用资源的,所以在用定时中断过程中是非常节省资源的由课程设计的要求和任务,我采用的C语言编程,设计秒表要求一秒定时,采用了定时器,即用单片机内部的定时器T0。先将时钟初始化,赋入初值50ms定时,循环20次来进行1秒定时。然后由定义的变量second来进行加一运算,然后将其值通过P2口在数码管上进行显示。其中数码管的显示时,我在程序中首先定义了一个关于数码管显示的字形码定义,以便在显示时调用即可。本次采用的是AT89C51单片机:AT89C51是一种带4K字节FLASH存储器(FPEROMFlash Programmable and Eras

4、able Read Only Memory)的低电压、高性能CMOS 8位微处理器,俗称单片机。AT89C2051是一种带2K字节闪存可编程可擦除只读存储器的单片机。单片机的可擦除只读存储器可以反复擦除1000次。该器件采用ATMEL高密度非易失存储器制造技术制造,与工业标准的MCS-51指令集和输出管脚相兼容。由于将多功能8位CPU和闪烁存储器组合在单个芯片中,ATMEL的AT89C51是一种高效微控制器,AT89C2051是它的一种精简版本。AT89C单片机为很多嵌入式控制系统提供了一种灵活性高且价廉的方案。引脚排列如图所示主要特性:与MCS-51 兼容 4K字节可编程FLASH存储器 寿

5、命:1000写/擦循环 数据保留时间:10年 全静态工作:0Hz-24MHz 三级程序存储器锁定 1288位内部RAM 32可编程I/O线 两个16位定时器/计数器 5个中断源 可编程串行通道 低功耗的闲置和掉电模式片内振荡器和时钟电路三、 系统方框图与工作原理秒表采用的是AT89C51单片机,单片机的P1口连接着按键,实现按键功能;P0、P2、P3口连接着显示器,实现显示功能。如图3.1所示:按键显示器AT89C51 P0P1 P2 P3 图3.1秒表总体系统方框图四、 各部分方案选定、功能及计算4.1 按键部分K1和单片机的P1.0口相连,实现启动/停止功能,按下K1键,开启计时功能,再按

6、一下,即停止计时;K2和单片机的P1.1相连,实现记录功能,按下K2键,开启记录功能,共有3个可以记录;K3和单片机的P1.2相连,实现重置功能按下K3,即清零重置。如图4.1所示:图4.1按键部分4.2 显示部分单片机的P2.0到P2,7分别和显示器的D0到D7相对应连接;单片机的P0.0到P0.3分别和显示器的CS1、CS2、RW和RS相对应连接;单片机的P3.4和显示器的E相对应连接。以上是实现显示功能,如图4.2所示:图4.2显示部分五、 器件说明(1) MCS-51单片机实验操作台1台;(2) PC机及单片机调试软件;(3) 单片机应用系统板1套;(4) 制作工具1套;(5) 系统设

7、计所需的元器件。六、调试说明、使用说明编好的程序在Keil中有许多错误,这些错误在平时的实验中也碰到过很多。例如,字母开头忘了加0,零和字母搞错了,有些标号用了几次,CJNE写成了CJNZ等等,幸好这些错误在平时实验中遇到很多次了,所以改正很快的。除了常见错误,还有些错误在平时没遇到过的。如:AJMP指令跳转不回指定的地位,是由于跳转的长度大于AJMP跳转的长度,最后只有用LJMP跳转后跳到指定的位置。在几天的调试和修改程序中,我的知识也得到了巩固,使我对单片机的知识更加的渴望。在Proteus编辑窗口中单击开始仿真按钮,开始仿真,按启动按钮,开始读秒,按记录按钮记录数据,可以记录3个数据,最

8、后按重置按钮,重置数据。如图6.1所示:图6.1心得体会通过这次课程设计秒表计时器,使我又重新开始学习C语言,因为C语言是大一学的,至从学完就再也没用过,所以开始很陌生,我又找了有关资料来了解,才有了一点眉目。刚开始以为可以用汇编很容易就写出来,以为学的很明白了,但是用汇编时才发现原来都不怎么熟练,编了一会程序发现只有一种感觉举步维艰啊!还是放弃汇编选择C语言吧!对于单片机,我们课本学习的是80C51,但是这次做课程设计用的是89C51,这样不仅使我们掌握了80C51,而且对89C51也有了一定的了解了,在课堂上学习的都理论的,跟实际永远有一定的差距,不实践就不会发现问题。而且我还更加熟练的应

9、用了proteus和keil两个软件。通过这次课程设计使我把课堂上学习的东西都用到了实践中,例如:定时/计数器的应用与中断。学习的时候不怎么理解,但是在实践中应用了以后就自然了解了。这次课程设计使我受益匪浅,而且都是实际的东西。最后,还要感谢本次课程设计的老师,也是我们单片机的老师,感谢在老师悉心的指导下,完成了本次课程设计。参考文献1、 单片机原理与应用 王迎旭等编 机械工业出版社2、 51系列单片机设计实例 楼然苗等编 北京航空航天大学出版社3、 计算机硬件技术基础实验教程 黄勤等编 重庆大学出版社4、微型计算机接口技术及应用 刘乐善主编 华中科技大学出版社5、单片微型计算机原理及接口技术

10、陈光东等 华中科技大学出版社附录附录A 系统原理图附录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)f_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;else retur

19、n 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;g an employment tribunal claiEmployment tribunals sort out disagreements between employers and employees.You may need to make a claim to an employment tribunal if: you do

20、nt 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 employment tribunal, even if you haventappealed

21、against 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 employment tribunal within three months of

22、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 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

23、 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 employment tribunal, you should get help stra

24、ight 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 adamages-based agreement. In England and Wales, y

25、our 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 an experienced adviser, for example, at a Ci

26、tizens 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-based Webb, the head of Fifas anti-racism task

27、force, 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 how he felt and I would like to speak to him

28、 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 investigation into the referees actions.CSKA said th

29、ey 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 became the appearance of the same day; May be

30、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, suddenly feel something, do it.一字开头的年龄已经到了尾声。或许是愧

31、疚于自己似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。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, bu

32、t 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 that isnt really grow up, it seems is not so im

33、portant; 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 sweat profusely, looked at his thrown a basketba

34、ll hoops, suddenly found himself has already cant remember his appearance.童年时,觉得压岁钱和新衣服是过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。Ori

35、ginally, 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 shake his. Also once seemed to be determined

36、 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 injection, or is a self-righteous spiritual.一个人的时候,自己

37、的想法总是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。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 va

38、rious 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 limited cloud cover. The balloon, with capsul

40、e 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) an

41、d 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 feet ( Then, I would assume, he will slowly step out onto s

42、omething resembling an Olympic diving platform.Below, the Earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. Still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into

43、 the shallow end. Skydiver preps for the big jumpWhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to sto

44、p him completely.If he goes too fast or spins out of control, he has a stabilization parachute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In orde

45、r to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work higher than 25,000 feet (7,620 meters).cause there17

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!