用VHDL语言设计电梯控制器.docx
- 文档编号:9798987
- 上传时间:2023-02-06
- 格式:DOCX
- 页数:12
- 大小:95.13KB
用VHDL语言设计电梯控制器.docx
《用VHDL语言设计电梯控制器.docx》由会员分享,可在线阅读,更多相关《用VHDL语言设计电梯控制器.docx(12页珍藏版)》请在冰豆网上搜索。
用VHDL语言设计电梯控制器
石家庄经济学院
数字逻辑课程设计报告
题目电梯控制器的设计
姓名menghao
学号
班号3班
指导老师
成绩
2011年6月
1.课程设计目的
2.设计任务
3.开发工具选择
3.设计方案
4.模块描述
5.VHDL实现
6.调试仿真
7.课程设计回顾总结
参考文献
1. 课程设计目的
1)使学生更好地巩固和加深对基础知识的理解,学会设计中小型数字系统的方法,独立完成调试过程,增强学生理论联系实际的能力,提高学生电路设计和分析的能力。
2)通过实践教学引导学生在理论指导下有所创新,为后继专业课的学习和日后工程实践奠定基础。
2、设计要求
1)综合应用课程中学到的理论知识,独立完成一个设计任务。
2)根据所要完成的设计任务,采用硬件描述语言 VHDL进行描述,依靠计算机,借助EDA开发工具,实现系统功能。
3)整理设计报告及相关的文档(包括总体设计思想,设计说明,程序源代码,仿真结果图、设计总结等)。
3.设计任务
任务和要求:
可使用拨键开关输入欲到达的楼层。
要求有数码管显示当前楼层,目标楼层,并且可以输入三个目标楼层,按输入的顺序达到,达到时有开门指示灯。
在电梯移动时,有相应的指示灯显示其方向。
注意:
电梯经过一个楼层和在楼层停留应各自设定一个固定时间。
4.开发工具选择
quartersⅡ5.1
5.设计方案
实验要求设计一个3层的电梯的梯控制器,采用状态机来实现,这样思路清晰,便于理解。
可以分为10个状态,为“一楼”、“等待状态1”、“等待状态2”、“等待状态3”、“等待状态4”、“开门”、“关门”、“上升”、“下降”、“停止”。
各状态之间按需要转换。
由状态机进程和信号指示灯进程一起控制。
输入由电梯外部的请求,电梯内部的请求,时钟信号组成。
输出由指示灯和电梯位置组成。
6.模块描述
分为4各部分
人员输入模块为按键模块
电梯控制模块为电梯条件判断状态模块
信号灯指示模块为指示灯显示模块
电梯终端模块为电梯服务模块
7.VHDL实现
代码分为实体,结构体两大块;
结构体中又分为电梯进程和指示灯进程;
电梯进程为10个状态机之间转换的代码;
指示灯进程为内外部请求指示灯的代码。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitysandiantiis
port(anclk:
instd_logic;--按键时钟信号
ticlk:
instd_logic;--电梯时钟信号
reset:
instd_logic;--复位
fiup:
instd_logic;--1楼外部上升请求
seup:
instd_logic;--2楼外部上升请求
sedn:
instd_logic;--2楼外部下降请求
thdn:
instd_logic;--3楼外部下降请求
uplight:
bufferstd_logic_vector(3downto1);---上升请求指示灯
dnlight:
bufferstd_logic_vector(3downto1);---下降请求指示灯
yilou,erlou,sanlou:
instd_logic;----停站请求
splight:
bufferstd_logic_vector(3downto1);--停站请求指示灯
weizhi:
bufferintegerrange1to3;---位置指示
door:
outstd_logic;---门状态指示
updown:
bufferstd_logic);--上升下降状态指示
endsandianti;
architecturemenghaoofsandiantiis
typelift_stateis----状态机
(lift1,dooropen,doorclose,wait1,wait2,wait3,wait4,up,down,stop);
signalmeng:
lift_state;
signalclearup:
std_logic;----清除上升状态
signalcleardn:
std_logic;----清除下降状态
begin
ctrlift:
process(reset,ticlk)------电梯控制进程
variablehao:
integerrange3downto1;----显示楼层同weizh作用一样,但显示方便
begin
ifreset='1'then
meng<=lift1;
clearup<='0';
cleardn<='0';
else
ifticlk'eventandticlk='1'then
casemengis
whenlift1=>
door<='1';
weizhi<=1;hao:
=1;
meng<=wait1;
whenwait1=>
meng<=wait2;
whenwait2=>
clearup<='0';
cleardn<='0';
meng<=wait3;
whenwait3=>
meng<=wait4;
whenwait4=>
meng<=doorclose;
whendoorclose=>
door<='0';
ifupdown='0'then
ifweizhi=3then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='1';
meng<=doorclose;
elseupdown<='1';meng<=down;
endif;
elsifweizhi=2then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='0';
meng<=doorclose;
elsifsplight(3)='1'or(splight(3)='0'anddnlight(3)='1')then
updown<='0';
meng<=up;
elseupdown<='1';meng<=down;
endif;
elsifweizhi=1then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='0';
meng<=doorclose;
elseupdown<='0';meng<=up;
endif;
endif;
elsifupdown='1'then
ifweizhi=1then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='0';
meng<=doorclose;
elseupdown<='0';meng<=up;
endif;
elsifweizhi=2then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='1';
meng<=doorclose;
elsifsplight
(1)='1'or(splight
(1)='0'anduplight
(1)='1')then
updown<='1';
meng<=down;
elseupdown<='0';meng<=up;
endif;
elsifweizhi=3then
ifsplight="000"anduplight="000"anddnlight="000"then
updown<='1';
meng<=doorclose;
elseupdown<='1';meng<=down;
endif;
endif;
endif;
whenup=>
weizhi<=weizhi+1;
hao:
=hao+1;
ifhao<3and(splight(hao)='1'oruplight(hao)='1')then
meng<=stop;
elsifhao=3and(splight(hao)='1'ordnlight(hao)='1')then
meng<=stop;
elsemeng<=doorclose;
endif;
whendown=>
weizhi<=weizhi-1;
hao:
=hao-1;
ifhao>1and(splight(hao)='1'ordnlight(hao)='1')
thenmeng<=stop;
elsifhao=1and(splight(hao)='1'oruplight(hao)='1')
thenmeng<=stop;
elsemeng<=doorclose;
endif;
whenstop=>
meng<=dooropen;
whendooropen=>
door<='1';
ifupdown='0'then
ifweizhi<=2and(splight(weizhi)='1'oruplight(weizhi)='1')then
clearup<='1';
elseclearup<='1';cleardn<='1';
endif;
elsifupdown='1'then
ifweizhi>=2and(splight(weizhi)='1'ordnlight(weizhi)='1')then
cleardn<='1';
elseclearup<='1';cleardn<='1';
endif;
endif;
meng<=wait1;
endcase;
endif;
endif;
endprocessctrlift;
ctrlight:
process(reset,anclk)-----指示灯进程
begin
ifreset='1'then
splight<="000";uplight<="000";dnlight<="000";
else
ifanclk'eventandanclk='1'then
ifclearup='1'then
splight(weizhi)<='0';uplight(weizhi)<='0';
else
iffiup='1'thenuplight
(1)<='1';
elsifseup='1'thenuplight
(2)<='1';
endif;
endif;
ifcleardn='1'then
splight(weizhi)<='0';dnlight(weizhi)<='0';
else
ifsedn='1'thendnlight
(2)<='1';
elsifthdn='1'thendnlight(3)<='1';
endif;
endif;
ifyilou='1'thensplight
(1)<='1';
elsiferlou='1'thensplight
(2)<='1';
elsifsanlou='1'thensplight(3)<='1';
endif;
endif;
endif;
endprocessctrlight;
endarchitecturemenghao;
8.调试仿真
1.电梯在2楼外部有上升请求,电梯从1楼升到2楼,开门,在电梯内部有3楼停站,电梯到达3楼,之后内外没有请求,电梯停在3楼。
2.电梯在3楼外部有下降请求,电梯从1楼升到3楼,开门,在电梯内部有1楼停站,电梯到达1楼,之后内外没有请求,电梯停在1楼。
3.电梯在2楼外部有上升请求,电梯从1楼升到2楼,开门,在电梯内部有3楼停站,电梯到达3楼,开门,之后电梯在2楼外部有下降请求,电梯从3楼下到2楼,开门,在电梯内部有1楼停站,电梯到达1楼,开门,之后内外没有请求,电梯停在1楼。
4.电梯在1楼外部有上升请求,进入电梯,内部有3楼停站请求,在电梯上升过程中,在2楼外部有下降请求,不理会,电梯到达3楼,之后相应2楼外部下降请求,在2楼停止开门,之后内部有1楼停站请求,下降到1楼,之后内外没有请求,电梯停在1楼。
9.课程设计回顾总结
在编程的过程中,由于考虑的情况不够全面,也出现了不少问题,例如代码出错了,所以当仿真的时候仿真波形和实际不符,经过改正之后可以了实现了。
由于第一次写这种比较复杂的,情况这么多的代码,开始的初期有很大的障碍,之后经过查阅相关资料,还是实现了设计要求的功能,这个代码,功能还是有些不太全,有些缺陷,并不能和实际情况完全一样,还有很多的情况没有考虑进去,但是时间有限,只能这样了。
通过这次的课程设计,把理论和实际结合了起来,让我更加理解了VHDL语言在日常生活中的应用。
参考文献
《数字逻辑与数字系统》 --张兴忠等编著
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VHDL 语言 设计 电梯 控制器