《毕业设计基于单片机的十字路口交通灯设计.doc》由会员分享,可在线阅读,更多相关《毕业设计基于单片机的十字路口交通灯设计.doc(22页珍藏版)》请在三一办公上搜索。
1、摘 要交通灯是交管部分管理城市交通的重要工具。现在交通灯一般设在十字路口,在醒目位置用红、绿、黄三种颜色的指示灯,加上一个倒计时的显示计时器来控制行车,对于一般情况下的安全行车、车辆分流发挥着作用。交通信号灯控制方式很多。本系统采用MCS-51系列单片机AT89C52为中心器件来设计交通灯控制器,实现了红绿灯循环点亮,同时数码管显示倒计时时间,倒计时剩5秒时黄灯闪烁警示;本系统还设置了一个紧急模式,按下紧急模式按钮,各个方向都为红灯,所有车辆禁止通行。本系统设计周期短、可靠性高、实用性强、操作简单、维护方便、扩展功能强。 关键词:单片机;交通灯 第一章 绪论1.1 单片机概述单片机(单片微型计
2、算机)是一种集成在电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计时器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的计算机系统。随着微电子技术,自动控制技术,微机应用技术的发展,使单片微型计算机也得到迅速的发展,单片微型计算机是微型计算机的一个重要分支,单片机微型计算机简称单片机,特别适用于控制领域,故又称为微控制器。单片机的应用已经渗透到国民经济的各个部门和领域,它起到了越来越重要的作用。它已成为工业控制领域,智能仪器仪表,尖端
3、武器,日常生活中最广泛使用的控制器。1.2 交通灯发展现状最早的交通灯出现于一八六八年英国伦敦。那时的交通灯只有红、绿两色,经改良后,再增加一盏黄色的灯,红灯表示停止,黄灯表示准备,绿灯则表示通行。颜色也有各自要表达的含意,要表达热或剧烈的话,最强是红色,其次是黄色。绿色则有较冷及平静的含意。因此,人们常以红色代表危险,黄色代表警觉,绿色代表安全。由于红光的穿透力最强,其他颜色的光很容易被散射,在雾天里就不容易看见,而红光最不容易被散射,即使空气能见度比较低,也容易被看见,不会发生事故。所以我们用红色表示禁止。中国最早的马路红绿灯,是于1928年出现在上海的英租界。 从最早的手牵皮带到20世纪
4、50年代的电气控制,从采用计算机控制到现代化的电子定时监控,交通信号灯在科学化、自动化上不断地更新、发展和完善。目前,交通灯已是交管部分管理城市交通的重要工具。现在交通灯一般设在十字路口,在醒目位置用红、绿、黄三种颜色的指示灯,加上一个倒计时的显示计时器来控制行车,对于一般情况下的安全行车、车辆分流发挥着作用。目前绝大部分交通灯其时间都是设定好的,采用的是单段式定时控制或多段式定时控制。面向21世纪的智能化汽车的交通运输系统应使车、路高度智能化,使人、车、路三者合一,逐步实现汽车在公路上自动安全地运行。为解决交通堵塞,交通事故的国际难题而发展起来的智能交通系统,是将先进的信息技术,数据通讯和传
5、输技术、电子自动控制技术及计算机处理技术等有效地用于整个地面运输管理体系,全方位发挥作用的实时、准确、高效的公路综合管理系统。第二章 系统方案2.1 系统要求指标及其功能本系统要实现:1.正常模式第一阶段:东西方向绿灯亮,南北方向红灯亮,倒计时60秒。此时东西方向车辆通行,南北方向禁止。第二阶段:当计时到最后5秒,东西方向绿灯灭,黄灯每秒闪烁一次。第三阶段:当计时到零后,东西方向红灯亮,南北方向绿灯亮,再次倒计时60秒。此时东西方向车辆禁止,南北方向车辆通行。第四阶段:当计时到最后5秒,南北方向绿灯灭,黄灯每秒闪烁一次。2.紧急模式:按下紧急按钮,各个方向都强制变为红灯。所有方向禁止通行。2.
6、2 各种方案选择比较2.2.1 实现方式的选择方案一:采用纯数字门电路。通过各种逻辑门电路的组合连接,实现系统功能。此方案设计复杂,电路复杂,功能单一,且需要门电路较多,成本较高,也不美观。维护调试都比较麻烦。方案二:采用单片机为主控制器。此方案电路简单,设计工作主要是软件设计,设计较为灵活,功能都是通过软件实现,硬件花费少;应用KEIL 软件,C语言编程,软件设计也较为方便。系统易于调试维护。应用单片机使得系统更具有智能化的特色,是当今的主流。故采用本方案。2.2.3 显示模块的选择方案一:采用大屏幕点阵显示屏。此方案显示效果较好,但设计复杂,成本较高,性价比低。方案二:采用数码管显示。此器
7、件价格较低廉,能显示数字,亮度较高,且规格较多,满足系统显示要求。本系统可选用大尺寸、高亮度的LED数码管。故选用此方案。2.2.4 时钟电路的选择方案一:采用555集成电路组成振荡电路,输出信号作为单片机时钟输入。但此方案输出频率较低,且计时不准确,成本也较高。方案二:采用晶振组成时钟电路。此方案硬件花费少,计时准确,成本较低,系统工作频率快。2.3 系统的描述图2.3.1 交通灯的系统框图本系统以AT89C52单片机为控制核心,结合LED发光二极管,数码管电路等外围电路,通过单片机I/O口实现对发光二极管亮灭的控制,数码管显示的控制。程序设计方面,东西,南北两个方向转换时间均为60秒,其中
8、绿灯55秒,紧接着黄灯5秒,每秒闪烁一次,期间数码管显示倒计时时间,60秒计时结束,转换到另一方向,依次循环。紧急按钮的作用是紧急状态下,所有方向均为红灯,禁止一切车辆通行。第三章 电路设计3.1 系统总体设计本设计的主要电路有:单片机STC89C52最小系统、数码管显示驱动模块、按键输入模块,LED发光二极管电路,交通灯仿真模拟模块。外围电路都与单片机引脚I/O口相连,以实现单片机对外围电路的控制,实现相应功能。3.2 单元电路设计3.2.1 单片机最小系统图3.2.1 单片机最小系统如图3.2.1 单片机最小系统包括单片机、时钟电路、复位电路。其他引脚I/O相应的扩充功能。3.2.2 电源
9、电路图3.2.2 电源电路本电源电路如上图所示,应用7805三端稳压电源模块构成。输出稳压5V电压,为单片机、LED灯和数码管提供工作电压。电容为滤波作用,使输出电源更平滑稳定。3.2.3 数码管与发光二极管电路如右图,数码管为共阳极数码管,发光二极管为共阳极,有红、绿、蓝三种颜色,代表红绿灯。数码管和发光二极管安放在东、西、南、北4个方向。3.2.3 交通灯模拟仿真模块通过PROTUES 软件仿真的方式搭建仿真模块如图。图3.2.3 交通灯仿真模块第四章 程序设计4.1程序总体流程图图4.1.1 系统总体流程图程序设计实现功能为东西,南北两个方向转换时间均为60秒,其中绿灯55秒,紧接着黄灯
10、5秒,每秒闪烁一次,期间数码管显示倒计时时间,60秒计时结束,转换到另一方向,依次循环。紧急按钮的作用是紧急状态下,所有方向均为红灯,禁止一切车辆通行。第五章 测试与仿真5.1测试方法测试仿真工具:Protues软件仿真5.2测试效果图5.2.1 Protues仿真总体效果图 以上为各个状态下交通灯的显示状态。满足设计要求。第五章 总结本系统以STC89C52单片机为控制核心,结合周边电路。经过测试,各项功能指标均达到设计要求,且电路设计简洁,程序设计也较为简单,界面效果简洁美观,操作简单实用。通过此次毕业课题的设计,让我学到很多东西,一方面,它是3年大学所学知识的一个综合应用,考察了我大学所
11、学的知识,是一次彻底的知识巩固和提高。另一方面,通过综合的应用设计,锻炼了我应用知识的能力和动手能力。同时,在设计的过程中,也锻炼了我解决问题的能力,遇到问题坚持不懈的毅力和细心程度。让我在以后求职就业中更好的学习和提高自己。第六章参考文献1 李全利. 单片机原理及接口技术.高等教育出版社2 公茂法. 单片机原理与实践.北京航空航天出版社3 全国大学生电子设计竞赛组委会. 第九届全国大学生电子设计竞赛获奖作品选编.北京理工大学出版社4 及力. Protel 99原理图与PCB设计教程. 电子工业出版社第七章附录/*=程序清单=*/#includetypedef unsigned char uc
12、har;typedef unsigned int uint;#define DATA P0#define ON 0#define OFF 1sbit WE1=P20;sbit WE2=P21;sbit NS1=P22;sbit NS2=P23;sbit WE_R=P10; sbit WE_Y=P11;sbit WE_G=P12;sbit NS_R=P13;sbit NS_Y=P14;sbit NS_G=P15;bit flag,alarm_flag;uchar sec;uchar code lab=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,/数码管编码 0x07,0
13、x7f,0x6f;/*=自定义子程序=*/void delays(uchar s,uchar init);void init_T1();void delay500ms();void delay20ms();void init_INT0();/*=主程序=*/void main()uchar i;init_T1();init_INT0();while(1)while(!alarm_flag)WE_G=ON;WE_Y=OFF;WE_R=OFF;NS_G=OFF;NS_Y=OFF;NS_R=ON; delays(55,59);WE_G=OFF;WE_Y=ON;WE_R=OFF;NS_G=OFF;NS
14、_Y=OFF;NS_R=ON;for(i=5;i0;i-)WE_Y=ON;delay500ms();WE_Y=OFF;delay500ms();sec-; WE_G=OFF;WE_Y=OFF;WE_R=ON;NS_G=ON;NS_Y=OFF;NS_R=OFF;delays(55,59);WE_G=OFF;WE_Y=OFF;WE_R=ON;NS_G=OFF;NS_Y=ON;NS_R=OFF;for(i=5;i0;i-)NS_Y=ON;delay500ms();NS_Y=OFF;delay500ms();sec-;sec=0;WE_G=OFF;WE_Y=OFF;WE_R=ON;NS_G=OFF;N
15、S_Y=OFF;NS_R=ON;void delay500ms()uchar i;for(i=10;i0;i-)TMOD=TMOD|0X10;TH0=15536/256;TL0=15536%256;TR0=1;while(!TF0)if(alarm_flag) return;TF0=0;void delays(uchar s,uchar init)uchar i;if(init) sec=init;while(s-)for(i=20;i0;i-)TMOD=TMOD|0X10;TH0=15536/256;TL0=15536%256;TR0=1;while(!TF0)if(alarm_flag)
16、return;TF0=0;sec-;void delay20ms()uchar i,j;for(i=40;i0;i-)for(j=250;j0;j-);void init_T1()TMOD=0X11;TH1=60536/256;TL1=60536%256;ET1=1;TR1=1;EA=1;void init_INT0()待添加的隐藏文字内容2EA=1;EX0=1;IT0=1;void INT0_SIR() interrupt 0EX0=0;delay20ms();if(INT0)return;alarm_flag=alarm_flag;EX0=1;void T1_SIR()interrupt
17、3TH1=60536/256;TL1=60536%256;if(flag)WE1=0;WE2=0;NS1=0;NS2=0;DATA=labsec/10;WE1=1;NS1=1;flag=0;else WE1=0;WE2=0;NS1=0;NS2=0;DATA=labsec%10;WE2=1;NS2=1;flag=1;Employment tribunals sort out disagreements between employers and employees.You may need to make a claim to an employment tribunal if: you don
18、t 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 haventappealeda
19、gainst 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 t
20、he 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
21、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 strai
22、ght 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, yo
23、ur 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 Cit
24、izens 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 taskf
25、orce, 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
26、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 the
27、y 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 b
28、ack 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.一字开头的年龄已经到了尾声。或许是愧疚
29、于自己似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。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
30、 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 imp
31、ortant; 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 basketbal
32、l hoops, suddenly found himself has already cant remember his appearance.童年时,觉得压岁钱和新衣服是过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。Orig
33、inally, 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
34、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.一个人的时候,自己的
35、想法总是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。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 var
36、ious 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.此刻,天空是阴暗的,空气里有着刚下过雨之后的清新因子。突然想到那件蓝格子衬衫;那些被折成各种各样形状的信纸;那段从街角深巷伊始的友谊;还有那场还没有开始就宣告了
37、终结的邂逅计划那些年那些天的非做不可,终于和青春一样,都将在我们的人生中谢幕。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
38、 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
39、 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 so
40、mething 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
41、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 stop
42、 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 order
43、 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 there