三层电梯控制电路设计.设计要求每层电梯入口处设有上下请求开关, 电梯内设有顾客到达层次的停站请设有电梯入口处位置指示装置及电梯运行模式 (上升或下降)指示装置。
电梯每秒升(降)一层楼。
电梯到达有停站请求的楼层,经过1秒电梯门打开,开门指示灯亮,开 门4秒后,电梯门关闭(开门指示灯灭),电梯继续进行,直至执行完最后一个请 求信号后停留在当前层。
5. 能记忆电梯内外所有请求,并按照电梯运行规则按顺序响应,每个请 求信号保留至执行后消除。
6. 电梯运行规则一当电梯处于上升模式时, 楼请求信号,由下而上逐个执行,直到最后一个上楼请求执行完毕; 下楼请求,则相反。
7. 电梯初始状态为一层开门状态。
二. 设计目的电梯控制器是控制电梯按顾客要求自动上下的装置。
本文采用 来设计实用三层电梯控制器,其代码具有良好的可读性和易理解性 电梯控制器的设计,可以发现本设计有一定的扩展性,而且可以作为更多层电梯 控制器实现的基础。
三. 控制器的设计方案.控制器的功能模块如图1所示,包括主控制器、分控制器、楼层选择器、状 态显示器、译码器和楼层显示器。
乘客在电梯中选择所要到达的楼层, 通过主控 制器的处理,电梯开始运行,状态显示器显示电梯的运行状态, 电梯所在楼层数 通过译码器译码从而在楼层显示器中显示。
分控制器把有效的请求传给主控制器 进行处理,同时显示电梯的运行状态和电梯所在楼层数。
由于分控制器相对简单 很多,所以主控制器是核心部分。
1.求开关。
2. 3. 4. 只响应比电梯所在位置高的上如果咼层有 VHDL 语言,通过对三层 图1.电梯控制器原理图四. 三层电梯控制器的结构体设计首先说明一下状态。
状态机设置了 lO 个状态,分别是电梯停留在 l 层(stoponI)、开门(dooropen)、关门(doorclose)、开门等待第 1 秒(doorwaitl)、开门等 待第2秒(doorwait2)、开门等待第3秒(doorwait3)、开门等待第4秒(doorwait4)、 上升(up)、下降(down)和停止(stop)。
在实体说明定义完端口之后,在结构体 architecture 和begin 之间需要有如下的定义语句,来定义状态机。
在结构体中, 设计了俩个进程互相配合, 一个是状态机进程作为主要进程, 另外一个是信号灯控制进程作为辅助进程。
状态机进程中的很多判断条件是以信 号灯进程产生的信号灯信号为依据的, 而信号灯进程中信号灯的熄灭又是由状态 机进程中传出的clearup 和cleardn 信号来控制。
在状态机进程中, 在电梯的上升状态中, 通过对信号灯的判断, 决定下一个 状态是继续上升还是停止; 在电梯下降状态中, 也是通过对信号灯的判断, 决定 下一个状态是继续下降还是停止; 在电梯停止状态中, 判断是最复杂的, 通过对 信号的判断,决定电梯是上升、下降还是停止。
本设计需要完成的任务是编写 VHDL 弋码来模拟现实中的三层电梯工作。
在 点阵上显示电梯所在的楼层, 当其它楼层有上或下的请求信号时, 表示该楼层上 或下的绿色或黄色指示灯亮, 电梯开始上或下运行, 当到达该楼层时, 表示该楼 层上或下的绿色或黄色指示灯灭, 表示到达该楼层的红色指示灯亮, 层数,红色指示灯灭 。
五 . vhdl 源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;architecture behave of elevator is signal state1,state3 : std_logic; 点阵显示楼entity elevator isport( clkSignal k1,k2u,k2d,k3buttond1,d2u,d2d,d3 everyfloordoor1,door2,door3 ledr0,r1,r2,r3,r4,r5,r6,r7 segment driversa,sb,sc--Display Select endelevator; : in std_logic; --Clock : in std_logic; : out std_logic; : buffer std_logic; out --Push --Led of --door std_logic; out --7 std_logic);state2u,state2d : std_logic; doorflag : std_logic; udflag,runflag : std_logic; --up and down flag,run flag: std_logic_vector(2 downto 0); --display end if;if(k3='0' and door3='0') then state3<='1'; d3<='1';signal signal signal signalcounter dcount signal display signal locationsignal wcountcountersignal counter : std_logic_vector(7 downto 0);: std_logic_vector(1 downto 0);: std_logic_vector(10 downto 0); --wait doorcount : std_logic_vector(9 downto 0); --doorsignal col1,col2,col3,col4,col5,col6 : std_logic_vector(7 downto 0);beginprocess(clk) -- judge the key is or is not been pushed beginif(clk'event and clk='1') then if(k1='0' and door1='0') thenstate1<='1'; d1<='1';elsif(location=0 and wcount=0) then d1<='0';if(doorcount=1020) then state1<='0';end if;end if; if(k2u='0' and door2='0') then state2u<='1'; d2u<='1';elsif(location=1 and udflag='1' and wcount=0) then d2u<='0';if(doorcount=1020) then state2u<='0';end if;end if; if(k2d='0' and door2='0') then state2d<='1'; d2d<='1';elsif(location=1 and udflag='0' and wcount=0) then d2d<='0';if(doorcount=1020) then state2d<='0';end if;elsif(location=2 and wcount=0) then d3<='0';if(doorcount=1020) then state3<='0';end if;end if;end if;end process;process(clk)beginif(clk'event and clk='1') then if(location=0) then --display 1 col1<="00000001";col2<="00100001"; col3<="01111111"; col4<="11111111"; col5<="00000001";col6<="00000001";elsif(location=1) then --display 2 col1<="01100011"; col2<="11100111";col3<="10001101"; col4<="10011001"; col5<="11110011"; col6<="01100111";elsif(location=2) then --display 3 col1<="01000010"; col2<="11011011";col3<="10011001"; col4<="10011001"; col5<="11111111"; col6<="01100110";end if;end if;end process;process(clk) --accumulate dcount beginif(clk'event and clk='1') then dcount<=dcount+1;end if; end p rocess;p rocess(clk)beginif(clk'eve nt and clk='1') the nsa<=dco un t(0);sb<=dco un t(1);sc<=dco un t(2);case dco unt iswhe n "111"=>dis pl ay<="00000000";whe n others=>dis pl ayv="OOOOOOOO"; end case;end if;end p rocess;p rocess(clk) --I nbeginif(clk'eve nt and clk='1') the nrO<=dis play(7);r7<=dis play (O );end if;end p rocess; end behave; 注释:1. 本程序设计调用了 IEEE 库,IEEE 库是VHDL 设计中最为常用的库,它 包含有IEEE标准的程序包和其他一些支持工业标准的程序包。