交通灯.docx

上传人:b****4 文档编号:4673282 上传时间:2023-05-07 格式:DOCX 页数:12 大小:1.78MB
下载 相关 举报
交通灯.docx_第1页
第1页 / 共12页
交通灯.docx_第2页
第2页 / 共12页
交通灯.docx_第3页
第3页 / 共12页
交通灯.docx_第4页
第4页 / 共12页
交通灯.docx_第5页
第5页 / 共12页
交通灯.docx_第6页
第6页 / 共12页
交通灯.docx_第7页
第7页 / 共12页
交通灯.docx_第8页
第8页 / 共12页
交通灯.docx_第9页
第9页 / 共12页
交通灯.docx_第10页
第10页 / 共12页
交通灯.docx_第11页
第11页 / 共12页
交通灯.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

交通灯.docx

《交通灯.docx》由会员分享,可在线阅读,更多相关《交通灯.docx(12页珍藏版)》请在冰点文库上搜索。

交通灯.docx

交通灯

 

项目设计报告

 

课题名称:

交通灯控制器

班级:

13电子

(2)班

学号:

姓名:

指导教师:

龚兰芳

简要说明

在十字路口,每条道路各有一组红、黄、绿灯和倒计时显示器,用以指挥车辆和行人有序地通过。

其中,红灯(R)亮,表示该条道路禁止通行;黄灯(Y)亮,表示停车;绿灯(G)亮,表示可以通行。

倒计时显示器是用来显示允许通行和禁止通行的时间。

交通灯控制器就是用来自动控制十字路口的交通灯和计时器,指挥各种车辆和行人安全通行。

1、设计目的

利用VHDL设计数字系统的能力,结合生活实际例子,模拟实际环境,编写出程序控制彩灯的亮灭,以及数码管的计数,实现十字路口交通灯的现象。

2、任务要求

1)在十字路口的两个方向上各设一组红、黄、绿灯,显示顺序为其中一方向(东西方向)是绿灯、黄灯、红灯;另一方向(南北方向)是红灯、绿灯、黄灯。

2)设置两组数码管,以倒计时的方式显示允许通行或禁止通行的时间,其中绿灯、黄灯、红灯的持续时间分别为:

20S、5S和25S。

3)当各条路上任意一条上出现特殊情况时,如当消防车、救护车或其他需要优先放行的车辆通过时,各方均是亮红灯,倒计时停止,且显示数字闪烁。

当特殊运行状态结束后,控制器恢复原来状态,继续正常运行。

 

3、任务分析

1)整理思路,从要求中可以发现交通灯的亮灭的规律。

计数器的计数值与交通灯亮灭的关系如图所示:

分析:

显然本课题的核心是一个计数范围为0~49(共50S)的计数器和一个根据计数值做出规定反应的控制器。

另外,所用实验板配备的晶振为20Hz,因此还需要一个分频电路。

最后,要驱动七段数码管,显然还需要一个译码电路。

4、硬件要求

含有芯片EPM2400T100C5的开发板和下载线与电源线。

交通灯控制器主要用到了两个拨码开关和四组红绿黄LED灯。

拨码开关分别是rst是复位开关,hold是紧急开关。

四组LED灯地东西和南北两个方向的交通指示灯。

5、源程序(*.vhd)

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityjiaotongdengis

port(

clk,hold,rst:

instd_logic;

x:

outstd_logic_vector(0to6);

row:

outstd_logic_vector(0to3);

fm:

outstd_logic;

en:

outstd_logic_vector(0to5);

r,g,y:

outstd_logic

);

endjiaotongdeng;

architecturejtdofjiaotongdengis

signalclk1,clk2:

std_logic;

signalpinlv:

std_logic;

signaljishu:

integerrange1to36;

signalw1:

integerrange0to3;

signalw2:

integerrange0to1;

signala,b,c,d:

integerrange0to9;

signale,f:

integerrange0to3;

signalcountnum:

integerrange0to49;

signalflash:

std_logic;-------数码管的闪烁,紧急时

signalnuma,numb:

integerrange0to25;

begin

process(clk)--------用于倒数计数1hz

variablecnt1:

integerrange0to2000;

variablecnt2:

integerrange0to12500;

begin

ifrising_edge(clk)then

ifcnt1=2000then

cnt1:

=0;

ifcnt2=12500then

cnt2:

=0;

clk1<=notclk1;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

process(clk)---用于数码管的位选1000hz和交通灯的组选

variablecnt1:

integerrange0to100;

variablecnt2:

integerrange0to250;

begin

ifrising_edge(clk)then

ifcnt1=100then

cnt1:

=0;

ifcnt2=250then

cnt2:

=0;

clk2<=notclk2;

else

cnt2:

=cnt2+1;

endif;

else

cnt1:

=cnt1+1;

endif;

endif;

endprocess;

process(rst,clk1)--循环计数50s

variabledd:

std_logic_vector(3downto0);

begin

ifrst='1'then

countnum<=0;

elsifrising_edge(clk1)then

ifhold='1'then

countnum<=countnum;

elsifcountnum=49then

countnum<=0;

else

countnum<=countnum+1;

endif;

endif;

endprocess;

process(clk1,clk2,flash)--数码管的位选

variablenum:

integerrange0to9;

begin

ifflash=clk1then

en<="111111";

endif;

ifflash='0'then

ifrising_edge(clk2)then

ifw1=3then

w1<=0;

else

w1<=w1+1;

endif;

endif;

casew1is

when0=>en<="111110";num:

=a;

when1=>en<="111101";num:

=b;

when2=>en<="101111";num:

=c;

when3=>en<="011111";num:

=d;

endcase;

casenumis----数字对应的数码管的亮灭

when0=>x<="0111111";

when1=>x<="0000110";

when2=>x<="1011011";

when3=>x<="1001111";

when4=>x<="1100110";

when5=>x<="1101101";

when6=>x<="1111101";

when7=>x<="0000111";

when8=>x<="1111111";

when9=>x<="1101111";

endcase;

endif;

endprocess;

process(clk2)---交通灯的红,绿,黄灯的组选

variablede:

integerrange0to3;

begin

ifrising_edge(clk2)then

ifw2=1then

w2<=0;

else

w2<=w2+1;

endif;

casew2is

when0=>row<="0101";de:

=e;----两个方向

when1=>row<="1010";de:

=f;

endcase;

casedeis----灯的三种亮灭情况:

红亮,黄亮,绿亮

when0=>r<='1';y<='0';g<='0';

when1=>r<='0';y<=clk1;g<='0';

when2=>r<='0';y<='0';g<='1';

when3=>r<=clk1;y<='0';g<='0';

endcase;

endif;

endprocess;

process(clk1)---在不同的时间显示不同的灯

begin

ifhold='1'then----紧急情况的时候

e<=3;

f<=3;

fm<=clk1;---蜂鸣器的鸣叫

flash<=clk1;

else

fm<='0';

flash<='0';

ifcountnum<=19then--东西方向绿灯亮

numa<=19-countnum;

e<=2;

elsifcountnum<=24then--东西方向黄灯亮

numa<=24-countnum;

e<=1;

else

numa<=49-countnum;--东西方向红灯亮

e<=0;

endif;

ifcountnum<=24then--南北方向红灯亮

numb<=24-countnum;

f<=0;

elsifcountnum<=44then--南北方向绿灯亮

numb<=44-countnum;

f<=2;

else

numb<=49-countnum;--南北方向黄灯亮

f<=1;

endif;

endif;

endprocess;

process(numa,numb)--分位模块

begin

ifnuma>=20then

b<=2;

a<=numa-20;

elsifnuma>=10then

b<=1;

a<=numa-10;

else

b<=0;

a<=numa;

endif;

ifnumb>=20then

d<=2;

c<=numb-20;

elsifnumb>=10then

d<=1;

c<=numb-10;

else

d<=0;

c<=numb;

endif;

endprocess;

end;

 

6、接线图

7、总结

通过这次课程设计,我进一步加深了对可编程逻辑器件的了解。

并进一步熟练了对QuartusII软件的操作。

在编写程序的过程中,遇到了很多问题,使我发现自己以前学习上存在的不足。

通过与同学探讨和请教老师,终于把问题都解决了,并加深了对交通灯原理和设计思路的了解。

同时,在交通灯控制器的程序上加了一点自己的设计,使效果达到了目的,也有了创新的花样。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2