




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、单片机at89c51电子抢答器设计 1.系统说明:给主持人设置一个开关,用来控制系统的清零(编号显示数码管灭灯)和抢答器的开始。抢答器具有数据锁存和显示的功能。抢答开始后,若有选手按动抢答器按钮,编号立即锁存,并在led数码上显示选手的编号,同时扬声器给出音响提示。此外,要封锁输入电路,禁止其他选手抢答。2.硬件电路设计:总体设计图3-1 总体设计如图p3.0为开始抢答,p3.2为停止,p1.0-p1.7为八路抢答输入,数码管段选p0口,位选p2口低3位,蜂鸣器(用绿灯代替)输出为p3.6口。p3.2为时间加1调整,p3.3为时间减1调整。p3.0为开始抢答,p3.1为停止,p1.0-p1.7
2、为八路抢答输入,数码管段选p0口,位选p2的低三位口。(1)外部振荡电路:一般选用石英晶体振荡器。此电路在加电大约延迟10ms后振荡器起振,在xtal2引脚产生幅度为3v左右的正弦波时钟信号,其振荡频率主要由石英晶振的频率确定。电路中两个电容 c1,c2的作用有两个:一是帮助振荡器起振;二是对振荡器的频率进行微调。c1,c2的典型值为30pf。(2)复位电路的设计:单片机的第9脚rst为硬件复位端,只要将该端持续4个机器周期的高电平即可实现复位,复位后单片机的各状态都恢复到初始化状态,其电路图所示:在方案中使用到了硬件复位和软件复位两种功能,由上面的硬件复位可使寄存器及存储器的值都恢复到初始值
3、,而前面的功能提到了倒计时间需要有记忆功能,该功能实现的前提条件就是不能对单片机进行硬件复位,所以设定了软复位功能。软复位实际上就是当程序执行完毕之后,将程序指针通过一条跳转指令让它跳转到程序执行的起始地址。(3)按钮输入电路的设计:抢答器的输入按钮使用常开开关,这些常开开关组成了抢答按键,硬件电路简单,在程序设计上也不复杂,只要在程序中消除在按键过程中产生的“毛刺” 现象就可以了。这里采用最常用的方法即延时法,其的原理为:因为“毛刺”脉冲一般持续时间短,约为几ms,而按键的时间一般远远大于这个时间,所以当单片机检测到有按键动静后再延时一段时间(这里取10ms)后再判断此电平是否保持原状态,如
4、果是则为有效按键,否则无效。(4)发声:这里能利用程序来控制单片机p3.6口线反复输出高电平或低电平,即在该口线上产生一定频率的矩形波,接上扬声器就能发出一定频率的声音,再利用延时程序控制“高”“低”电平的持续时间,就能改变输出频率,从而改变音调,使扬声器发出不同的声音。3.软件部分:(1)程序系统结构图:硬件电路确定后,软件的编程要与硬件相匹配,软硬件才能结合完成所要实现的功能。由功能分析得到以下的软件结构图:系统初始化模块按键模块正确抢答模块非法抢答模块调整时间模块显示模块程序流程图整个程序主要由定时器t0、定时器t1、外部中断0和主程序构成。定时器t0用于使扬声器发声,当需要响铃时,把响
5、铃标志位置一,每次中断都对p3.7取反,扬声器发声,改变定时器初值,可改变扬声器频率。定时器程流程图如下:p3.7取反定时器重新赋值返回主函数响铃标志为1?ny定时器t1用于倒计时,每次中断为50ms,当计数标志为20时即为一秒,显示数字减1。其流程图如下:返回主函数计时标志加一计数器重新赋值外部中断0用于调整倒计时时间,流程图如下:显示时间r1r1减1返回主函数r1置0r1增1r1置99加1键按下?减1键按下?r1到0?r1到99?返回键按下?ynyyynnnny 主程序协调三个中断一起工作,实现抢答功能,其流程图如下:按键发声显示抢答号,剩余时间停止键按下?抢答键按下?停止键按下?开始键按
6、下?程序初始化倒计时显示倒计时开始按键发声准备状态,显示fff倒计时大于5s?显示法规号码按键发声非法抢答?停止键按下?提醒发声倒计时结束?ynnynnnnnyyyyy(2)程序代码: org 0000h ajmp main org 0003h ajmp int0sub org 000bh ajmp t0int org 001bh ajmp t1intok equ 20h ; 抢答开始标志位ring equ 22h ; 响铃标志位 org 0040hmain: mov r1,#0fh; 初设抢答时间为15s mov r2,#0ah; 初设答题时间为10s mov tmod,#11h; 设置未定
7、时器/模式1 mov th0,#0f0h mov tl0,#0ffh; 越高发声频率越高,越尖 mov th1,#3ch mov tl1,#0b0h; 50ms为一次溢出中断 setb ea setb et0 setb et1 setb ex0 setb ex1; 允许四个中断,t0/t1/int0/int1 clr ok clr ring setb tr1 setb tr0; 一开始就运行定时器,以开始显示fff.如果想重新计数,重置th1/tl1就可以了查询程序:start: mov r5,#0bh mov r4,#0bh mov r3,#0bh acall display; 未开始抢答时
8、候显示fff jb p3.0,next acall delay jb p3.0,next;去抖动,如果开始键按下就向下执行,否者跳到非法抢答查询 acall bark;按键发声 mov a,r1 mov r6,a; 送r1-r6,因为r1中保存了抢答时间 setb ok; 抢答标志位,用于count只程序中判断是否查询抢答 mov r3,#0ah; 抢答只显示计时,灭号数 ajmp count;进入倒计时程序,查询有效抢答的程序在count里面next: jnb p1.0,false1 jnb p1.1,false2 jnb p1.2,false3 jnb p1.3,false4 jnb p1
9、.4,false5 jnb p1.5,false6 jnb p1.6,false7jnb p1.7,false8 ajmp start非法抢答处理程序:false1: acall bark; 按键发声 mov r3,#01h ajmp errorfalse2: acall bark mov r3,#02h ajmp errorfalse3: acall bark mov r3,#03h ajmp errorfalse4: acall bark mov r3,#04h ajmp errorfalse5: acall bark mov r3,#05h ajmp errorfalse6: acall
10、 bark mov r3,#06h ajmp errorfalse7: acall bark mov r3,#07h ajmp errorfalse8: acall bark mov r3,#08h ajmp error倒计时程序(包括有效抢答程序): count: mov r0,#00h; 重置定时器中断次数 mov th1,#3ch mov tl1,#0b0h; 重置定时器recount: mov a,r6; r6保存了倒计时的时间 mov b,#0ah div ab; 除十分出个位/十位 mov 30h,a; 十位存于(30h) mov 31h,b; 个位存于(31h) mov r5,3
11、0h ; 取十位 mov r4,31h ; 取个位 mov a,r6 clr c subb a,#07h jnc larger ;大于5s跳到larger,小于等于5s会提醒 mov a,r0 cjne a,#0ah,full;1s中0.5s向下运行 clr ring ajmp checkfull: cjne a,#14h,check ; 1s时,响并显示号数并清r0,重新计时 setb ring mov a,r6 jz quit ; 计时完毕 mov r0,#00h dec r6 ; 一秒标志减1 ajmp checklarger: mov a,r0 cjne a,#14h,check ;
12、如果1s向下运行,否者跳到查停/显示 dec r6; 计时一秒r6自动减1 mov r0,#00hcheck: jnb p3.1,quit; 如按下停止键退出 acall display jnb p1.0,true1 jnb p1.1,true2 jnb p1.2,true3 jnb p1.3,true4 jnb p1.4,true5 jnb p1.5,true6 jnb p1.6,true7 jnb p1.7,true8 ajmp recountquit: clr ok ; 如果按下了停止键重新回到开始 clr ring acall bark ajmp start正常抢答处理程序:true1
13、: acall bark; 按键发声 mov a,r2 mov r6,a; 抢答时间r2送r6 mov r3,#01h clr ok; ajmp loop2true2:acall bark; mov a,r2 mov r6,a mov r3,#02h clr ok ajmp loop2true3:acall bark; mov a,r2 mov r6,a mov r3,#03h clr ok ajmp loop2true4:acall bark; mov a,r2 mov r6,a mov r3,#04h clr ok ajmp loop2true5: acall bark; mov a,r2
14、 mov r6,a mov r3,#05h clr ok ajmp loop2true6: acall bark; mov a,r2 mov r6,a mov r3,#06h clr ok ajmp loop2true7: acall bark; mov a,r2 mov r6,a mov r3,#07h clr ok ajmp loop2true8: acall bark; mov a,r2 mov r6,a mov r3,#08h clr okloop2: ajmp display ;抢答后停止计时,等待返回setb ring jnb p3.1 quit ajmp loop2犯规抢答程序:
15、error: setb ring ;犯规响铃 mov r5,#0bh mov r4,#0bh; 显示ff和犯规号数loop3: acall display jnb p3.1 quit1; 等待“停止”键按下 ajmp loop3 quit1: clr ring clr ok ajmp start显示程序:display:mov dptr,#dat1; 查表显示程序,利用p0口做段选码口输出/p2低三位做位选码输出 mov a,r5 movc a,a+dptr mov p2,#01h mov p0,a acall delay mov dptr,#dat2 mov a,r4 movc a,a+dp
16、tr mov p2,#02h mov p0,a acall delay mov a,r3 movc a,a+dptr mov p2,#04h mov p0,a acall delay retdat1:db 00h,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00h,71h;灭,1,2,3,4,5,6,7,8,9,灭,fdat2:db 3fh, 06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00h,71hdelay1: mov 35h,#08hloop0: acall display djnz 35h,loop0 ret延时(显示和去抖动用到
17、):delay: mov 32h,#12hloop: mov 33h,#0afhloop1: djnz 33h,loop1 djnz 32h,loop ret发声程序:bark: setb ring acall delay1 acall delay1 clr ring; 按键发声 retint0(抢答时间r1调整程序): int0sub:mov a,r1 mov b,#0ah div ab mov r5,a mov r4,b mov r3,#0ah acall display;先在两个时间led上显示r1 jnb p3.2,inc0; p3.2为+1s键,如按下跳到inco jnb p3.3,
18、dec0; p3.3为-1s键,如按下跳到deco jnb p3.4,back0; p3.4为确定键,如按下跳到backo ajmp int0subinc0: mov a,r1 cjne a,#63h,add0; 如果不是99,r2加1,如果加到99了,r1就置0,重新加起 mov r1,#00h acall delay1 ajmp int0subadd0: inc r1 acall delay1 ajmp int0subdec0: mov a,r1 jz setr1;如果r1为0, r1就置99, dec r1 acall delay1 ajmp int0subsetr1: mov r1,#
19、63h acall delay1 ajmp int0subback0: retito溢出中断(响铃程序):t0int:mov th0,#0ech mov tl0,#0ffh jnb ring,out cpl p3.6 ; ring标志位为1时候p3.6口不短取反使喇叭发出一定频率的声音out: retit1溢出中断(计时程序):t1int: mov th1,#3ch mov tl1,#0b0h inc r0 reti end4.调试与运行:1.调试:把编写好的程序放入仿真软件中,结合硬件电路进行调试与运行。(1)在仿真软件中按下开始按钮,从而达到仿真的目的; (2)led显示器显示当前0030
20、初始化;(3)按照本次实际任务要求,逐个调试功能是否能实现。正常抢答过程调试:当主持人按下“开始”键后,允许选手抢答,进入正常抢答流程。若在倒计时时间内有选手抢答,则显示管显示抢答成功的选手编号和答题时间倒计时。若无选手在抢答倒计时时间内抢答,则自动跳回系统开始部分。在选手正常抢答后,如果选手回答成功。则有主持人按下“结束”键,结束本次抢答,系统跳回开始部分。如果选手在答题倒计时内,未能成功回答,则系统自动跳回开始部分。违规抢答过程调试 :在主持人未按下“开始”键时有选手进行抢答则会进入违规抢答流程。显示管闪烁显示违规选手编号并伴有蜂鸣器报警声。当主持人按下“结束”键后系统跳回开始部分。时间控
21、制功能调试:在系统开始工作后按下“抢答(回答)时间控制”键后即可通过“加一“或”减一“键进行时间控制如图5.10所示抢答时间由20s被修改为22s。2.结果:在运行过程中,设计能够满足抢答时间正确显示,违规抢答显示。倒计时显示的功能,程序功能运行良好。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 dont a
22、gree 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 haventappealedagai
23、nst 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 the
24、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 are
25、 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 straight
26、 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, your
27、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 citize
28、ns 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 taskforc
29、e, 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 fir
30、st 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 they w
31、ere 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 back
32、 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.一字开头的年龄已经到了尾声。或许是愧疚于自己
33、似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。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
34、 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 import
35、ant; 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 basketball h
36、oops, suddenly found himself has already cant remember his appearance.童年时,觉得压岁钱和新衣服是过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。origina
37、lly, 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 to
38、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.一个人的时候,自己的想法总
39、是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。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 variou
40、s 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.此刻,天空是阴暗的,空气里有着刚下过雨之后的清新因子。突然想到那件蓝格子衬衫;那些被折成各种各样形状的信纸;那段从街角深巷伊始的友谊;还有那场还没有开始就宣告了终结的
41、邂逅计划那些年那些天的非做不可,终于和青春一样,都将在我们的人生中谢幕。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 at
42、tached, 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 ballo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 银行与管委会合作协议
- 民宿营销活动方案
- 机场航线资源共享协议
- 交易合同保密协议
- 草皮采购施工合同
- 店铺商铺房屋租赁合同
- 产品推广策略与技术方案介绍手册
- 工程合同付款方式范本5篇
- 租金链上支付智能合约协议
- Unit 9 Can you come to my party Section A 2a - 2d 教学设计 2024-2025学年人教版英语八年级上册
- 2025年度电视产品进出口贸易合同4篇
- 2025年“开学第一课”观后感心得体会(3篇)
- 外科护理5分钟小讲课
- 2025年天津市宁河区事业单位招聘12人高频重点提升(共500题)附带答案详解
- 2024年福建省莆田市数学三上期末质量检测模拟试题含解析
- 2025年山东菏泽投资发展集团限公司招聘61人管理单位笔试遴选500模拟题附带答案详解
- 幕墙工程项目管理手册
- 地理中图版2025新版七年级下册 中图版七年级下地理教学计划
- 北京某中学2024-2025学年九年级上学期期中数学试题
- 2025-2025年七年级英语下册教学计划
- 酒店客房管理手册
评论
0/150
提交评论