




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 四层电梯控制器姓名:徐志聪学号:030902529指导老师:赵彦敏电梯控制器的功能模块如图2.1所示,包括主控制器、分控制器、楼层选择器、状态显示器、译码器和楼层显示器。乘客在电梯中选择所要到达的楼层,通过主控制器的处理,电梯开始运行,状态显示器显示电梯的运行状态,电梯所在楼层数通过译码器译码从而在楼层显示器中显示。分控制器把有效的请求传给主控制器进行处理,同时显示电梯的运行状态和电梯所在楼层数。由于分控制器相对简单很多,所以主控制器是核心部分。状态显示器主控制器楼层选择器分控制器译码器楼层显示器 图2.1 电梯控制器原理图第二节 电梯控制器的流程图外部按键请求信号寄存器状态寄存器内部软件执
2、行机构外部硬件执行机构图2.2 总流程图初始化判定电梯运行方向是否有请求?等待电梯运行楼层检测否电梯停止目标层与本层是否同层?是是否目标层?开门延时关门是否停止运行?是否是否是否停止图2.3 电梯控制主流程图第三章 三层电梯控制器的具体设计本设计尝试用硬件描述语言VHDL来实现对三层电梯的控制,源程序经A1tera公司的MAX+plus II软件仿真,保证了设计的正确性。使用VHDL进行电梯控制器的设计,主要就是对电梯软件部分的设计,使用VHDL中的逻辑关系建立电梯的升降模式,开门,关门达到动作,而外部器件的硬件设备基本上保持不变。使用VHDL硬件描述语言设计电梯控制器可以为电梯实现智能控制奠
3、定基础。第一节 三层电梯控制器实现的功能及运行规则电梯一层入口处设有上升请求开关,二层入口处设有上、下请求开关,三层入口处设有下降请求开关,电梯内部设有顾客到达楼层的停站请求开关。每层电梯入口处设有位置指示装置及电梯运行模式 (上升或下降)指示装置。电梯初始状态为一层开门状态。电梯每秒上升(下降)一层楼。电梯到达需要停止的楼层,经过1秒电梯门打开,开门指示灯亮,开门4秒后,电梯门关闭(开门指示灯灭),电梯继续运行,直至执行完最后一个请求信号后停留在当前层。电梯需要寄存器来记忆电梯内外所有请求,并按照电梯运行规则按顺序响应,每个请求信号保留至执行后消除。电梯的运行规则:当电梯处于上升模式时,只响
4、应比电梯所在位置高的上楼请求信号和停站请求信号,由下而上逐个执行,直到最后一个上楼请求执行完毕;如果高层有下楼请求,则直接上升到有下楼请求的最高层,然后进入下降模式。当电梯处于下降模式时则与上升模式相反。第二节 三层电梯控制器的综合设计一、三层电梯控制器的设计思路电梯控制器设计两个进程相互配合,状态机进程作为主要进程,信号灯控制进程作为辅助进程。根据电梯的实际工作情况,可以为状态机设置十个状态,它们分别是“电梯停在一层”“开门”“关门”“开门等待第一秒”“开门等待第二秒”“开门等待第三秒”“开门等待第四秒”“上升”“下降”和“停止”。由于电梯每秒上升或下降一层,则可以用周期为1s的信号来作为电
5、梯状态转换的触发时钟。状态机进程中的很多判断条件是以信号灯控制进程产生的信号灯信号为依据,而信号灯控制进程中信号灯的熄灭又是由状态机进程中传出的信号来控制。三层电梯控制器的设计主要是对实体和结构体的设计,它的VHDL描述模块流程如图3.1所示:元件库的说明定义实体结构体端口状态机进程信号灯控制进程结束按键信号灯图3.1 三层电梯控制器的VHDL描述模块流程二、实体设计实体设计即是对端口名、端口模式及数据类型的说明。首先考虑输入端口,一个异步复位端口“reset”,用于当电梯出现非正常情况时回到初始状态;在电梯外部,一层入口处设有上升请求端,二层入口处设有上升和下降请求端,三层入口处设有下降请求
6、端;在电梯内部,应设有各层停站请求端口;一个电梯时钟输入端口,它提供周期为1s的时钟信号,用作电梯状态转换的触发时钟;还有一个频率很高的按键时钟输入端口。其次考虑输出端口,当有各层上升或下降请求时,各层入口处应该有端口显示请求是否被响应,有请求时端口输出逻辑1,被执行后则恢复成逻辑0;同样的,电梯内部也应有各层停站请求是否被响应的指示端口;一个开关门指示端口,当门开着时,它为逻辑1,门关着时,则为逻辑0;还需要端口来显示电梯所处的位置和模式(上升或下降)。三、结构体设计在结构体中,首先说明了状态机设置的十个状态,分别是:电梯停在1层(stopon1)、开门(dooropen)、关门(doorc
7、lose)、开门等待第1秒(doorwait1)、开门等待第2秒(doorwait2)、开门等待第3秒(doorwait3)、开门等待第4秒(doorwait4)、上升(up)、下降(down)和停止(stop)。在结构体最前端用如下的定义语句,来定义状态机。type lift_state is(stopon1,dooropen,doorclose,doorwait1,doorwait2,doorwait3,doorwait4,up,down,stop);接着描述电梯内部功能实现,在结构体中设计了两个进程,一个状态机进程(ctrlift),它是以reset和liftclk作为敏感信号,控制电梯
8、的状态转移;另外一个是信号灯控制进程(ctrlight),它是以reset和buttonclk作为敏感信号,控制寄存信号的逻辑值。在状态机进程中,电梯关门后根据信号灯的情况,来决定下一个状态是上升、下降还是停止;在信号灯控制进程中,由于使用了专门的频率较高的按键时钟,所以使得按键的灵敏度大,但是时钟频率不能过高,否则容易使按键过于灵敏,而信号灯的熄灭是由状态机进程中传出clearup和cleardn信号来控制。四、VHDL源代码语法的简单说明本程序设计调用了ieee库,ieee库是VHDL设计中最为常用的库,它包含有ieee标准的程序包和其他一些支持工业标准的程序包。本设计采用std-logi
9、c-1164、std-logic-unsigned、std-logic-arith程序包。以关键词entity引导,end entity threelift结尾的部分是程序的实体部分。VHDL的实体描述了电路器件的外部情况,本设计定义了关于三层电梯控制器用到的各类时钟、异步复位按键、信号灯指示端口、电梯的请求端口。它描述了端口模式主要有in、buffer、out,以及各端口信号的数据类型主要有std-logic、std-logic-vector、integer。(3)以关键词architecture引导,end architecture one结尾的语句部分是结构体部分,结构体描述电路器件的内
10、部逻辑功能。五、VHDL源代码library IEEE; -库的说明use IEEE.std_logic_1164.all; -程序包的说明use IEEE.std_logic_unsigned.all;use IEEE.std_logic_arith.all; -(arith)entity fourlift is -实体名称fourlift port(clk1:in std_logic; -按键读取时钟信号 clk2:in std_logic; -led_7数码管显示扫描时钟信号 reset:in std_logic; -异步复位端口close:in std_logic;-关门请求 f1up
11、button:in std_logic; -一层上升请求端口 f2upbutton:in std_logic; -二层上升请求端口 f2dnbutton:in std_logic; -二层下降请求端口 f3dnbutton:in std_logic; -三层下降请求端口 f3upbutton:in std_logic; -三层上升请求端口 f4dnbutton:in std_logic;-四层下降请求端口 stop1button:in std_logic; -一层停站请求端口 stop2button:in std_logic; -二层停站请求端口 stop3button:in std_logi
12、c; -三层停站请求端口 stop4button:in std_logic;-四层停站请求端口 stair:buffer integer range 1 to 4; -电梯位置信号 udsig:buffer std_logic; -电梯运行模式(上升1或下降0 fuplight,fdnlight,stoplight:buffer std_logic_vector(4 downto 1); -上升、下降、停站请求寄存信号doorlight:out std_logic; -开门状态 (1为开门状态) dout:out std_logic_vector(6 downto 0); - 数码管显示楼层段
13、码s:out std_logic_vector(2 downto 0); -数码管显示楼层位码end entity fourlift;architecture chi of fourlift is -结构体type lift_state is -定义十个状态(stop_on_1,door_open,door_close,door_wait1,door_wait2,door_wait3,door_wait4,up,down,stop);signal state:lift_state;signal clr_up:std_logic; -上升和停站请求清除信号signal clr_dn:std_lo
14、gic; -下降和停站请求清除信号signal q:std_logic_vector(3 downto 0); -分频进程中需要的信号signal buttonclk,liftclk:std_logic; -分频后的电梯时钟和按键读取控制时钟beginclklift:process(clk1) -分频产生电梯控制时钟liftclk和按键读取控制时钟buttonclk begin if (clk1'event and clk1='1') then if q="1111" then q<="0000"elseq<=q+1;
15、end if; end if; buttonclk<=q(0); liftclk<=q(3); end process clklift;statelift:process(reset,liftclk) -状态机进程variable position:integer range 4 downto 1;beginif reset='1' then -异步复位,电梯的初始状态为一层开门状态 state<=stop_on_1; clr_up<='0' clr_dn<='0'else if liftclk'event
16、and liftclk='1' then -每个上升沿 case state is when stop_on_1=> doorlight<='1' -开门 stair<=1; position:=1; state<=door_wait1; -电梯等待4s when door_wait1=> clr_up<='0' clr_dn<='0'if(close='1') then state<=door_close;-如果有关门信号,则转至关门状态elsestate<=
17、door_wait2;-等待第二秒end if; when door_wait2=> if(close='1') then state<=door_close; elsestate<=door_wait3;等待第三秒end if; when door_wait3=>if(close='1') then state<=door_close;else state<=door_wait4;等待第四秒end if; when door_wait4=> state<=door_close; when door_close=&
18、gt; -关门,判定电梯下一个运行方式 doorlight<='0' if udsig='1' then -电梯处在上升模式 if stair=4 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then -没有请求信号时,电梯停 在当前层 udsig<='0' state<=door_close;elsif fdnlight(4)='1' or stoplight(4)=
19、'1' then -本层有请求信号时,电梯开门 udsig<='0'- 转为下降 state<=door_open;else -否则下降 udsig<='0' state<=down;end if; elsif stair=3 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='1' state<=door_close;elsif f
20、uplight(3)='1' or stoplight(3)='1' then -本层有上升或停站请求时,电梯开门 udsig<='1' state<=door_open; elsif fuplight="0000" and stoplight="0000" and fdnlight="0100" then -只有3层有下降请求时,电梯开门 udsig<='0' state<=door_open; elsif stoplight(4)='1
21、' or fdnlight(4)='1' then -4层有停站请求或下降请求,则上升 udsig<='1' state<=up; else udsig<='0' state<=down; end if; elsif stair=2 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='1' state<=door_close;
22、elsif fuplight(2)='1' or stoplight(2)='1' then -本层有上升或停站请求时,电梯开门 udsig<='1' state<=door_open; elsif fuplight="0000" and stoplight="0000" and fdnlight="0010" then -只有2层有下降请求时,电梯开门 udsig<='0' state<=door_open; elsif stoplight(4)
23、='1' or fdnlight(4)='1' or stoplight(3)='1' or fdnlight(3)='1' or fuplight(3)='1' then -4层有停站请求或下降请求,则上升 udsig<='1' state<=up; else udsig<='0' state<=down; end if; elsif stair=1 then if fuplight="0000" and fdnlight="0
24、000" and stoplight="0000" then udsig<='1' state<=door_close; elsif stoplight(1)='1' or fuplight(1)='1' then udsig<='1' state<=door_open; else udsig<='1' state<=up; end if; end if; elsif udsig='0' then -电梯处在下降模式 if stair
25、=4 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='0' state<=door_close; elsif fdnlight(4)='1' or stoplight(4)='1' then udsig<='0' state<=door_open; else udsig<='0' state<=down; end
26、if; elsif stair=3 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='0' state<=door_close; elsif fdnlight(3)='1' or stoplight(3)='1' then udsig<='0' state<=door_open; elsif fdnlight="0000"
27、and stoplight="0000" and fuplight="0100" then udsig<='1' state<=door_open; elsif fuplight(1)='1' or stoplight(1)='1' or fuplight(2)='1' or fdnlight(2)='1' or stoplight(2)='1' then -一层有停站请求或上升请求,则下降 udsig<='0' state&
28、lt;=down; else udsig<='1' state<=up; end if; elsif stair=2 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='0' state<=door_close; elsif fdnlight(2)='1' or stoplight(2)='1' then udsig<='0'
29、; state<=door_open; elsif fdnlight="0000" and stoplight="0000" and fuplight="0010" then udsig<='1' state<=door_open; elsif fuplight(1)='1' or stoplight(1)='1' then -一层有停站请求或上升请求,则下降 udsig<='0' state<=down; else udsig<=
30、39;1' state<=up; end if; elsif stair=1 then if fuplight="0000" and fdnlight="0000" and stoplight="0000" then udsig<='1' state<=door_close; elsif stoplight(1)='1' or fuplight(1)='1' then udsig<='1' state<=door_open; else
31、 udsig<='1' state<=up; end if; end if; end if; when up=> -电梯处于上升状态 stair<=stair+1; -电梯楼层数加一 position:=position+1; if position<4 and (stoplight(position)='1' or fuplight(position)='1') then state<=stop; -电梯在1 2 3 层,本层有停站或上升请求时,则停止 elsif position=4 and (stopli
32、ght(position)='1' or fdnlight(position)='1') then state<=stop; -电梯处在4层,并且有4层停站或下降请求,则停止 else state<=door_close; end if; when down=> -电梯处在下降状态 stair<=stair-1; -电梯楼层数减一 position:=position-1; if position>1 and (stoplight(position)='1' and fdnlight(position)='1
33、') then state<=stop; elsif position=1 and (stoplight(position)='1' or fuplight(position)='1') then state<=stop; else state<=door_close; end if; when stop=> state<=door_open; when door_open=> doorlight<='1' if udsig='1' then if stair<4 and (
34、fuplight(position)='1' or stoplight(position)='1') then clr_up<='1' -清除当前层上升和停站请求 else clr_up<='1' clr_dn<='1' end if; elsif udsig='0' then if stair>1 and (fdnlight(position)='1' or stoplight(position)='1') then clr_dn<=&
35、#39;1' -清除当前层下降和停站请求 else clr_up<='1' clr_dn<='1' end if; end if; state<=door_wait1; end case; end if;end if;end process statelift;ctrlight:process(reset,buttonclk) -信号灯控制进程beginif reset='1' then -复位,寄存信号清零 fuplight<="0000" fdnlight<="0000&qu
36、ot; stoplight<="0000"else if buttonclk'event and buttonclk='1' then if f1upbutton='1' then -记忆各层上升请求 fuplight(1)<='1' end if; if f2upbutton='1' then fuplight(2)<='1' end if; if f3upbutton='1' thenfuplight(3)<='1'end if
37、; if clr_up='1' then -上升和停站请求清零 fuplight(stair)<='0' stoplight(stair)<='0' end if; if f2dnbutton='1' then -记忆各层下降请求 fdnlight(2)<='1' end if; if f3dnbutton='1' then fdnlight(3)<='1' end if; if f4dnbutton='1' thenfdnlight(4)&l
38、t;='1' end if; if clr_dn='1' then -下降和停站请求清零 fdnlight(stair)<='0' stoplight(stair)<='0' end if; if stop1button='1' then -记忆各层停站请求 stoplight(1)<='1' end if; if stop2button='1' then stoplight(2)<='1' end if; if stop3button=
39、9;1' then stoplight(3)<='1' end if; if stop4button='1' thenstoplight(4)<='1' end if; end if;end if;end process ctrlight;showlift:process(stair,clk2) -楼层显示进程begins<="000"if stair=1 then dout<="0110000"elsif stair=2 then dout<="110110
40、1"elsif stair=3 then dout<="1111001"elsif stair=4 then dout<="0110011"end if;end process showlift;end architecture chi;第三节 本章小结本设计运用有限状态机的方法,在结构体最前端首先定义了十个状态;然后在结构体中设计了两个进程,状态机进程作为主要进程,信号灯控制进程作辅助进程。在状态机进程中,电梯关门后根据信号灯的情况,来决定下一个状态是上升、下降还是停止;在信号灯控制进程中,而信号灯的熄灭是由状态机进程中传出cle
41、arup和cleardn信号来控制。第四章 三层电梯控制器的调试及仿真第一节 程序的调试在程序编写完成并保存于工程文件夹后,可以把它置顶进行编译,看是否出现错误。在第一次编译时出现了很多问题,主要是由于没有注意到文件名必须与实体名相同,并且后缀是.vhd,还有粗心所造成的端口名书写错误,以及有的if语句结束时忘了写end if。在波形仿真中,发现一个错误,在状态进程中,在当前状态为doorclose,讨论次态的过程中,忽略了对本层请求的考虑,即当电梯停在某层时,当前层入口处有上升或下降请求时,无法响应。经过思考,我添加了本层请求响应语句,最终实现了三层电梯控制器的功能。第一节 波形仿真在波形仿
42、真中,根据实际,我们有必要做一些假设,即是:外部请求上升的乘客,进入电梯后一定是按更高层的停站按钮;外部请求下降的乘客,进入电梯后一定是按更低层的停站按钮;如果有乘客进入电梯,则一定有停站请求;同一时刻有很多人按键的概率很小,所以我们认为请求信号都有一定的先后顺序。设定仿真时间长度为60s,liftclk信号为周期1s的时钟信号,buttonclk信号为周期0.1s的时钟信号。doorlight信号逻辑1表示开门,逻辑0表示关门。udsig信号为逻辑1表示电梯处在上升模式,逻辑0表示处在下降模式。fuplight,fdnlight,stoplight是三位二进制向量,波形图中的1代表“001”
43、,表示一层有请求,2代表“010”,表示二层有请求,4代表“100”,表示三层有请求。图4.1所示的波形是在一层有上升请求的仿真波形,在reset信号产生一个脉冲时,电梯回复初始状态,即stopon1状态,然后等待4s,关门检测没有请求信号,于是电梯此时停在一层。当电梯时钟上升沿检测到一层上升请求信号fuplight(1)为1时,电梯开门,fuplight(1)清零,等待4s,关门检测到二层停站请求,于是电梯上升到二层停止,开门stoplight(2)清零,position信号由1变为2,电梯最终停在二层。 图4.1 有上升请求的仿真波形 图4.2所示的波形是三层有下降请求的波形,当电梯在一层关门后,检测到fdnlight为“100”,则上升到三层,开门等待4s,关门检测到stoplight为1,于是电梯下降到一层,最终停在一层。 图4.2 有下降请求的仿真波形图4.3所示的波形是二层和三层都有下降请求的仿真波形,当电梯在一层关门后,检测到fdnlight为“110”,则直接上升到三层,开门后fdnlight(3)清零,等待4s后,关门下降到二层停止,开门后fdnlight(2)和stoplight(2
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年社区心理服务与管理考试试卷及答案
- 2025年系统集成工程师考试试题及答案解析
- 2025年旅游管理与服务质量提升考试卷及答案
- 信息许可合同范例
- 上班劳动合同范例
- 2025企业与个人借款合同协议
- 2025年信息技术水平考试试题及答案汇聚
- 农村房源出售合同范例
- 公司合同范例填
- 农村机房维护合同范例
- JJF 1343-2022 标准物质的定值及均匀性、稳定性评估
- 水文学习题和答案解析
- 高效课堂新授课评价量化表
- 信和SDS2MS使用说明书
- 维修手册震旦218现场
- 画法几何与阴影透视复习题(DOC)
- 螺旋密封的设计及在流体机械中的应用
- 青岛市失业人员登记表
- 《中国好声音》全国校园海选招商方案(冠名)
- 广西安全文明施工费使用管理细则桂建质新版
- 存货质押贷款业务管理规定
评论
0/150
提交评论