交通灯信号控制器的设计.docx
- 文档编号:23934971
- 上传时间:2023-05-22
- 格式:DOCX
- 页数:26
- 大小:142.53KB
交通灯信号控制器的设计.docx
《交通灯信号控制器的设计.docx》由会员分享,可在线阅读,更多相关《交通灯信号控制器的设计.docx(26页珍藏版)》请在冰豆网上搜索。
交通灯信号控制器的设计
黑龙江科技学院
课程设计任务书
一、设计题目:
二、设计的主要内容:
指导教师:
日期:
教师评语:
评阅成绩:
评阅人:
日期:
摘要
交通灯信号控制器通常要实现自动控制和手动控制其红绿灯的变化,基于FPGA设计的交通灯信号控制器电路简单、可靠性好。
本设计可控制2个路口的红、黄、绿三盏灯.让其按特定的规律进行变化。
利用QuartusⅡ对设计结果进行仿真,发现系统工作性能良好。
据此设计而成的硬件电路,也实现了控制要求。
关键词:
交通灯自动控制手动控制
第1章交通灯信号控制器概述
1.1选题背景及意义
当今时代是一个自动化时代,交通灯控制等很多行业的设备都与计算机密切相关。
因此,一个好的交通灯信号控制器,将给道路拥挤、违章控制等方面给予技术革新。
交通灯系统多采用FPGA以及各种门电路控制,甚至还需要人工控制交通灯,这些控制装置成本较低,设计灵活。
本设计采用VHDL语言进行交通灯信号控制器的设计,VHDL类似于其它流行语言,但其功能完全不同,适应于硬件的一般结构,性能总比常规CPU的程序设计语言在性能上要高几个数量级,为电子自动化的普及和推广奠定了坚实的基础。
1.2主要实现功能
1.南北和东西方向各有一组绿,转弯,红,黄灯,各自的持续时间分别为10s,10s,25s,5s,当绿灯和另一红灯同时亮时,允许左拐。
2.当有紧急情况(如救护车通过)时,按下紧急状态按键KEY,两个方向均为红灯亮,计时停止,当特殊情况结束后,控制器恢复原来状态,正常工作。
3.两组数码管以倒计时方式显示两个方向允许通行或禁止通行的时间。
第2章交通灯信号控制器设计思想
2.1总体设计
交通灯信号控制器原理图如图2-1所示,输入管脚两个,用于接收外部信号,信号经过内部各子模块处理,送到输出端输出,而输出管脚则有七个,即输出端,分别接收由各底层模块处理好的输出信号,实现相应的功能。
图2-1总体原理图
2.2输入输出设置
Clk时钟频率输入,可由仿真软件直接提供,为准确确定时间长度,选择1Mhz高平信号。
紧急状态按键KEY,当按一下键,表示紧急情况发生,两个方向均为红灯亮,计时器停止计时并且不断闪烁,蜂鸣器发出蜂鸣声,当再次按下键时,信号灯和计时器恢复原来状态,正常工作。
东西方向和南北方向个使用四个LED显示。
东西方向和南北方向计时均为2位数,使用四个LED七段数码管显示,输出一个catn信号控制选择数码管显示,num_out信号输出显示的内容。
一个voice输出,控制紧急状态下的蜂鸣器。
第3章顶层模块
在VHDL设计中,采用自顶向下的设计思路。
顶层模块通过元件例化,将各子模块调用到一起,实现模块间信号的输入输出,如图3-1所示,在顶层模块中,根据硬件设计以及总体设计图,设置如下端口:
1)外部时钟信号:
Clk
2)紧急状态按键:
Key
3)东西方向状态灯:
r1,y1,g1,t1
4)南北方向状态灯:
r2,y2,g2,t2
5)蜂鸣器控制:
voice
6)数码管显示信号:
num_out
7)数码管共阴极控制:
catn
图3-1总体结构框图
第4章底层模块
4.1Emergency模块
在底层文件中,把不同功能分模块设计。
Emergency模块,紧急情况控制信号是采用按键的输入方式,当按键按下的时候,由Emergency模块接收按键信息并输出信号给其它模块。
输入端口:
bin_in接收按键信息
输出端口:
bin_out输出紧急信号
4.2Deboucen模块
由于紧急控制采用BTN按键,其产生时刻和持续时间的长短是随机不定的,且存在因开关簧片反弹引起的电平抖动现象,因此必须安排一个消抖和同步化电路模块,以保证系统能捕捉到输入脉冲。
输入端口:
key按键信息,clk时钟信号
输出端口:
key_out消抖后信号
4.3Frequency1模块
由于外部时钟信号clk的频率为1MHz,而实际需要的内部计时时钟频率为1Hz,需要一个分频电路。
输入端口:
clk外部时钟信号
输出端口:
clk_out分频后信号
4.4StatusSelect模块
由于共需要显示4个数字,需要循环点亮7位数码管,该模块通过输入的时钟信号,循环输出4个选择信号。
当紧急状态信号到来,改变显示状态,通过计数部分,实现闪烁,并输出蜂鸣信号。
输入端口:
clk时钟信号,show紧急显示
输出端口:
sel选择信号,voice蜂鸣信号
4.5TimeSelect模块
接收状态选择信号以及交通灯剩余时间信号,根据状态选择信号,选择剩余时间的位数输出给译码模块,并选择阴极控制显示位置。
输入接口:
sel状态选择信号,timeh1,timel1,timeh2,timel2剩余时间
输出接口:
catn共阴极控制,time_out数字输出
4.6Display模块
接收数字信号,进行7位数码管显示译码输出。
为了使七段数码管能够显示出所要表示的数值,通常需要使用数字显示译码器将所要表示的数值译成数码管所需要的驱动信号。
输入接口:
num_in输入信号
输出接口:
num_out译码输出
4.7信号灯控制模块
信号灯控制模块,东西方向ControlA,南北方向ControlB。
自定义一个Type类型,包括green,yellow,red,turn状态,接收到分频后的信号,通过case语句,进行状态选择,在每个状态下分别计时,当计时结束后,选择下一个状态,循环显示。
当紧急状态下,停止循环,计数停止。
输入接口:
clk时钟信号,show紧急状态控制
输出接口:
timehtimel计时数字输出,r,g,y,t信号灯输出
第5章仿真分析
本设计的程序使用QuartusⅡ进行仿真,波形仿真时,为方便观察,将分频器改为10分频。
通过观察图5-1,r1,y1,g1,t1,r2,y2,g2,t2可看出为循环显示,一方向为红灯时,另一方向显示绿灯、转弯灯、黄灯。
图5-1
通过观察图5-2,放大后可看到倒计时显示的变化,以及共阴极控制的选择。
图5-2
通过观察图5-3,当按下KEY键,key信号产生脉冲,进入紧急状态,只有两盏红灯亮,同时蜂鸣器产生蜂鸣信号,当再次按下KEY键,紧急状态解除
图5-3
参考文献
[l]庄新敏《QuartusⅡ用户指南及仿真实现》国防工业出版社2001年
[2]张亦华《数字电路EDA入门-VHDL程序实例集》北京邮电大学出版社2003年
[3]马临超《基于VHDL语言的交通灯控制器设计》河南机电高等专科学校学报2008年
[4]侯伯亨《VHDL硬件描述语言与数字逻辑电路设计》西安电子科技大学出版社1999年
[5]任勇峰《VHDL与硬件实现速成》国防工业出版社2005年
源程序
Emergency模块
libraryieee;
useieee.std_logic_1164.all;
entityEmergencyis
port(
BTN_in:
instd_logic;
BTN_out:
outstd_logic
);
endEmergency;
architectureEmergency_arcof
Emergencyis
begin
process(BTN_in)
variabletemp:
std_logic;
begin
ifBTN_in'eventandBTN_in='1'then
temp:
=nottemp;
endif;
BTN_out<=temp;
endprocess;
end;
Frequency1模块
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityFrequency1is
port(
clk:
instd_logic;
clk_out:
outstd_logic
);
endFrequency1;
architectureFrequency1_arcofFrequency1is
begin
process(clk)
variabletemp:
integerrange0to999999;
begin
if(clk'eventandclk='1')then
if(temp=999999)thentemp:
=0;
clk_out<='0';
else
temp:
=temp+1;
clk_out<='1';
endif;
endif;
endprocess;
end;
StatusSelect模块
libraryieee;
useieee.std_logic_1164.all;
entityStatusSelectis
port(
clk,show:
instd_logic;
sel:
outstd_logic_vector(2downto0);
voice:
outstd_logic);
endStatusSelect;
architectureStatusSelect_arcofStatusSelectis
signaltemp:
std_logic_vector(2downto0);
begin
process(clk,show)
variablet:
integerrange0to499999;
variablea:
std_logic;
begin
if(clk'eventandclk='1')then
caseshowis
when'0'=>
voice<='0';
casetempis
when"000"=>temp<="001";
when"001"=>temp<="010";
when"010"=>temp<="011";
when"011"=>temp<="000";
whenothers=>temp<="000";
endcase;
whenothers=>
voice<=a;
if(t=499999)then
t:
=0;
a:
=nota;
else
t:
=t+1;
endif;
if(a='1')then
casetempis
when"000"=>temp<="001";
when"001"=>temp<="010";
when"010"=>temp<="011";
when"011"=>temp<="000";
whenothers=>temp<="000";
endcase;
else
temp<="111";
endif;
endcase;
endif;
sel<=temp;
endprocess;
end;
TimeSelect模块
libraryieee;
useieee.std_logic_1164.all;
entityTimeSelectis
port(
sel:
instd_logic_vector(2downto0);timeh1,timeh2,timel1,timel2:
instd_logic_vector(3downto0);
catn:
outstd_logic_vector(5downto0);
time_out:
outstd_logic_vector(3downto0));
endTimeSelect;
architectureTimeSelect_arcofTimeSelectis
begin
process(sel)
begin
caseselis
when"000"=>time_out<=timeh1;
catn<="111110";
when"001"=>time_out<=timel1;
catn<="111101";
when"010"=>time_out<=timeh2;
catn<="101111";
when"011"=>time_out<=timel2;
catn<="011111";
whenothers=>time_out<="0000";
catn<="111111";
endcase;
endprocess;
end;
Display模块
libraryieee;
useieee.std_logic_1164.all;
entityDisplayis
port(
num_in:
instd_logic_vector(3downto0);
num_out:
outstd_logic_vector(6downto0)
);
endDisplay;
architectureDisplay_arcofDisplayis
begin
process(num_in)
begin
casenum_inis
when"0000"=>num_out<="0111111";
when"0001"=>num_out<="0000110";
when"0010"=>num_out<="1011011";
when"0011"=>num_out<="1001111";
when"0100"=>num_out<="1100110";
when"0101"=>num_out<="1101101";
when"0110"=>num_out<="1111101";
when"0111"=>num_out<="0100111";
when"1000"=>num_out<="1111111";
when"1001"=>num_out<="1101111";
whenothers=>num_out<="0000000";
endcase;
endprocess;
end;
信号灯控制模块
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityControlAis
port(
clk:
instd_logic;
show:
instd_logic:
='1';
timeh,timel:
outstd_logic_vector(3downto0);
r,g,y,t:
outstd_logic);
endControlA;
architectureControlA_arcofControlAis
typecoloris(green,yellow,red,turn);
begin
process(clk,show)
variablereset:
std_logic:
='0';
variabletempr,tempg,tempy,tempt:
std_logic;
variabletemp_h,temp_l:
std_logic_vector(3downto0);
variabletemp_color:
color:
=green;
begin
if(clk'eventandclk='1')then
caseshowis
when'0'=>
casetemp_coloris
whenyellow=>
tempr:
='0';
tempg:
='0';
tempy:
='1';
tempt:
='0';
caseresetis
when'0'=>
temp_h:
="0000";
temp_l:
="0100";
reset:
='1';
whenothers=>
casetemp_lis
when"0000"=>
temp_l:
="1001";
temp_h:
=temp_h-1;
when"0001"=>
casetemp_his
when"0000"=>
temp_h:
="0000";
temp_l:
="0000";
reset:
='0';
temp_color:
=red;
whenothers=>
temp_l:
="0000";
endcase;
whenothers=>
temp_l:
=temp_l-1;
endcase;
endcase;
whengreen=>
tempr:
='0';
tempg:
='1';
tempy:
='0';
tempt:
='0';
caseresetis
when'0'=>
temp_h:
="0000";
temp_l:
="1001";
reset:
='1';
whenothers=>
casetemp_lis
when"0000"=>
temp_l:
="1001";
temp_h:
=temp_h-1;
when"0001"=>
casetemp_his
when"0000"=>
temp_h:
="0000";
temp_l:
="0000";
reset:
='0';
temp_color:
=turn;
whenothers=>
temp_l:
="0000";
endcase;
whenothers=>
temp_l:
=temp_l-1;
endcase;
endcase;
whenred=>
tempr:
='1';
tempg:
='0';
tempy:
='0';
tempt:
='0';
caseresetis
when'0'=>
temp_h:
="0010";
temp_l:
="0100";
reset:
='1';
casetemp_lis
when"0000"=>
temp_l:
="1001";
temp_h:
=temp_h-1;
when"0001"=>
casetemp_his
when"0000"=>
temp_h:
="0000";
temp_l:
="0000";
reset:
='0';
temp_color:
=green;
whenothers=>
temp_l:
="0000";
endcase;
whenothers=>
temp_l:
=temp_l-1;
endcase;
endcase;
whenturn=>
tempr:
='0';
tempg:
='1';
tempy:
='0';
tempt:
='1';
caseresetis
when'0'=>
temp_h:
="0000";
temp_l:
="1001";
reset:
='1';
whenothers=>
casetemp_lis
when"0000"=>
temp_l:
="1001";
temp_h:
=temp_h-1;
when"0001"=>
casetemp_his
when"0000"=>
temp_h:
="0000";
temp_l:
="0000";
reset:
='0';
temp_color:
=yellow;
whenothers=>
temp_l:
="0000";
endcase;
whenothers=>
temp_l:
=temp_l-1;
endcase;
endcase;
endcase;
whenothers=>
tempr:
='1';
tempg:
='0';
tempy:
='0';
tempt:
='0';
endcase;
endif;
timeh<=temp_h;
timel<=temp_l;
r<=tempr;
g<=tempg;
y<=tempy;
t<=tempt;
endprocess;
end;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 交通灯 信号 控制器 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)