




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、莄蚁袃芇蒆袆蝿芆蚈虿膈芅莈薂肄芄蒀螇羀芃薂薀袆芃节螆螂节莄薈肀莁蒇螄羆莀蕿薇袂荿艿螂袈莈蒁蚅膇莈薃袀肃莇蚆蚃罿莆莅衿袅羂蒈蚂螁肁薀袇聿肁芀蚀羅肀莂袅羁聿薄螈袇肈蚆薁膆肇莆螆肂肆蒈蕿羈肅薁螅袄膅芀薈螀膄莃螃聿膃薅薆肅膂蚇袁羁膁莇蚄袇膀葿袀螃腿薂蚂肁腿芁袈羇芈莄蚁袃芇蒆袆蝿芆蚈虿膈芅莈薂肄芄蒀螇羀芃薂薀袆芃节螆螂节莄薈肀莁蒇螄羆莀蕿薇袂荿艿螂袈莈蒁蚅膇莈薃袀肃莇蚆蚃罿莆莅衿袅羂蒈蚂螁肁薀袇聿肁芀蚀羅肀莂袅羁聿薄螈袇肈蚆薁膆肇莆螆肂肆蒈蕿羈肅薁螅袄膅芀薈螀膄莃螃聿膃薅薆肅膂蚇袁羁膁莇蚄袇膀葿袀螃腿薂蚂肁腿芁袈羇芈莄蚁袃芇蒆袆蝿芆蚈虿膈芅莈薂肄芄蒀螇羀芃薂薀袆芃节螆螂节莄薈肀莁蒇螄羆莀蕿薇袂荿艿螂袈莈
2、蒁蚅膇莈薃袀肃莇蚆蚃罿莆莅衿袅羂蒈蚂螁肁薀袇聿肁芀蚀羅肀莂袅羁聿薄螈袇肈蚆薁膆肇莆螆肂肆蒈蕿羈肅薁螅袄膅芀薈螀膄莃螃聿膃薅薆肅膂蚇袁羁膁莇蚄袇膀葿袀螃腿薂蚂肁腿芁袈羇芈莄蚁袃芇蒆袆蝿芆蚈虿膈芅莈薂肄芄蒀螇羀芃薂薀袆芃节螆螂节莄薈肀莁蒇螄羆 一个vhdl电梯控制器的程序1、 每层电梯的入口处设有上下请求开关,电梯内设有乘客到达层次的停站请求开关。2、 设有电梯所处位置指示装置及电梯运行模式(上升或下降)指示装置。3、 电梯每秒升降一层。4、 电梯到达有停站请求的楼层后,经过1s电梯打开,开门只是灯亮,开门4s后,电梯门关闭(关门指示灯灭),电梯继续运行,直至执行完请求信号后停在当前楼层。5、 能
3、记忆电梯内外的所以请求信号,并按照电梯运行规则依次响应,每个请求信号保留至执行后消除。6、 电梯运行规则:当电梯处于上升模式时,只响应比电梯所在位置高的上楼信号,由下至上依次执行,直到最后一个上楼请求执行完毕,如更高层有下楼请求时,则直接升到有下降请求的最高楼接客,然后进入下降模式,但电梯处于下降模式时,则与上升模式相反。7、 电梯初始状态为一层门开。library ieee; use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity led1 isport(ledin:in std_logic_vector(3 do
4、wnto 0);ledout:out std_logic_vector(6 downto 0);end led1;architecture a_led of led1 isbeginprocess(ledin)begin case ledin is -the sequence is g f e d c b awhen 0000 = ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout ledout=xxxxxxx; -必须有,
5、here it is x,single quoteend case;end process ;end a_led;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity lift1 isport (clk: in std_logic; -2hz信号upin: in std_logic; -上升请求键downin: in std_logic; -下降请求键st_ch: in std_logic; -楼层选择键close: in std_
6、logic; -提前关门键delay: in std_logic; -延时关门键run_stop: in std_logic; -电梯运行开关lamp: out std_logic; -运行或停止灯run_waitdis: out std_logic_vector (6 downto 0); -运行或等待时间st_outdis: out std_logic_vector (6 downto 0); -电梯所在楼层指示directdis: out std_logic_vector (6 downto 0) -楼层选择指示);end lift1;architecture lift1_arch of
7、 lift1 iscomponent led1port(ledin:in std_logic_vector(3 downto 0);ledout:out std_logic_vector(6 downto 0);end component;signal ur,dr:std_logic_vector (6 downto 1);signal dir,liftor:integer range 0 to 5;signal wai_t:std_logic_vector (2 downto 0);signal divide,hand,clkin:std_logic;signal ladd:std_logi
8、c_vector (1 downto 0);signal closex,delayx:std_logic;signal run_wait: std_logic_vector (3 downto 0);signal st_out: std_logic_vector (3 downto 0);signal direct: std_logic_vector (3 downto 0);begindirect=0&conv_std_logic_vector(dir,3)+1;st_out=0&conv_std_logic_vector(liftor,3)+1;run_wait=0&wai_t;lamp=
9、ladd(1);hand=wai_t(2) and (not wai_t(1) and wai_t(0);closex=close and (not ladd(1);delayx=delay and (not ladd(1);urun_wait:led1 port map(run_wait,run_waitdis);ust_out:led1 port map(st_out,st_outdis);udirect:led1 port map(direct,directdis);p0:process(clk)beginif (clkevent and clk=1) thenclkin=not clk
10、in;end if;end process p0;p1:process(clkin)beginif (clkinevent and clkin=1) thendivide=not divide;if (dir=5) thendir=0;elsedirnum) and (st_ch=1) or (upin=1) thencase t iswhen 1 = ur(1) ur(2) ur(3) ur(4) ur(5) ur(6)null;end case;elsif (hand=1) then case num iswhen 1 = ur(1) ur(2) ur(3) ur(4) ur(5) ur(
11、6)null;end case;end if;if (t dr(1) dr(2) dr(3) dr(4) dr(5) dr(6)null;end case;elsif (hand=1) thencase num iswhen 1 = dr(1) dr(2) dr(3) dr(4) dr(5) dr(6)null;end case;end if;elseur=000000;dr=000000;end if;end process p2;p3:process(ur,dr,liftor,ladd,wai_t,run_stop)beginif (run_stop=1) thenif (wai_t=11
12、0) thenif (ur or dr)=000000) thenladd(1)if (ur(1) or dr(1)0) thenladd(1)=0;elseladdif (ur(2) or dr(2)0) thenladd(1)0000) or(ur(1) or dr(1)=0) thenladd=11;elseladdif (ur(3) or dr(3)0) thenladd(1)000) or(ur(2 downto 1) or dr(2 downto 1)=00) thenladd=11;elseladdif (ur(4) or dr(4)0) thenladd(1)00) or(ur
13、(3 downto 1) or dr(3 downto 1)=000) thenladd=11;elseladdif (ur(5) or dr(5)0) thenladd(1)0) or(ur(4 downto 1) or dr(4 downto 1)=0000) thenladd=11;elseladdif (ur(6) or dr(6)0) thenladd(1)=0; elseladdnull;end case;end if;end if;elseladd=00;end if;end process p3;p4:process(divide,wai_t,ladd,closex,delay
14、x)beginif (divideevent and divide=1) thenif (wai_t=000 or closex=1) thenwai_t=110;elseif (delayx=0) thenwai_t=wai_t-1;elsewai_t=010;end if;if (wai_t=001) thenif (ladd=11) then liftor=liftor+1;elsif (ladd=10) thenliftor=liftor-1;end if;end if;end if;end if;end process p4;end lift1_arch;library ieee;u
15、se ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity lifter isport (clk: in std_logic; -4mhz信号upin: in std_logic; -上升请求键downin: in std_logic; -下降请求键st_ch: in std_logic; -楼层选择键close: in std_logic; -提前关门键delay: in std_logic; -延时关门键run_stop: in std_logic; -电梯运行
16、开关lamp: out std_logic; -运行或停止灯selout:out std_logic_vector (2 downto 0);segout: out std_logic_vector (6 downto 0) );end lifter;architecture lift1_arch of lifter iscomponent led1port(ledin:in std_logic_vector(3 downto 0);ledout:out std_logic_vector(6 downto 0);end component;signal ur,dr:std_logic_vect
17、or (6 downto 1);signal dir,liftor:integer range 0 to 5;signal wai_t:std_logic_vector (2 downto 0);signal div,cp,hand,clkin:std_logic;signal ladd,s:std_logic_vector (1 downto 0);signal closex,delayx:std_logic;signal run_wait: std_logic_vector (3 downto 0);signal st_out: std_logic_vector (3 downto 0);
18、signal direct: std_logic_vector (3 downto 0);signal dout: std_logic_vector (3 downto 0);signal q:std_logic_vector (21 downto 0);begindirect=0&conv_std_logic_vector(dir,3)+1;st_out=0&conv_std_logic_vector(liftor,3)+1;run_wait=0&wai_t;lamp=ladd(1);hand=wai_t(2) and (not wai_t(1) and wai_t(0);closex=(n
19、ot close) and (not ladd(1);delayx=(not delay) and (not ladd(1);selout=001 when s=0 else010 when s=1 else100 when s=2 else000;dout=direct when s=0 elserun_wait when s=1 elsest_out when s=2 else0000000;u:led1 port map(dout,segout);p0:process(clk)beginif (clkevent and clk=1) thenq=q+1;end if;end proces
20、s p0;cp=q(20);s=q(14 downto 13);p1:process(cp)beginif (cpevent and cp=1) thendiv=not div;if (dir=5) thendir=0;elsedirnum) and (st_ch=0) or (upin=0) thencase t iswhen 1 = ur(1) ur(2) ur(3) ur(4) ur(5) ur(6)null;end case;elsif (hand=1) then case num iswhen 1 = ur(1) ur(2) ur(3) ur(4) ur(5) ur(6)null;e
21、nd case;end if;if (t dr(1) dr(2) dr(3) dr(4) dr(5) dr(6)null;end case;elsif (hand=1) thencase num iswhen 1 = dr(1) dr(2) dr(3) dr(4) dr(5) dr(6)null;end case;end if;elseur=000000;dr=000000;end if;end process p2;p3:process(ur,dr,liftor,ladd,wai_t,run_stop)beginif (run_stop=1) thenif (wai_t=110) theni
22、f (ur or dr)=000000) thenladd(1)if (ur(1) or dr(1)0) thenladd(1)=0;elseladdif (ur(2) or dr(2)0) thenladd(1)0000) or(ur(1) or dr(1)=0) thenladd=11;elseladdif (ur(3) or dr(3)0) thenladd(1)000) or(ur(2 downto 1) or dr(2 downto 1)=00) thenladd=11;elseladdif (ur(4) or dr(4)0) thenladd(1)00) or(ur(3 downt
23、o 1) or dr(3 downto 1)=000) thenladd=11;elseladdif (ur(5) or dr(5)0) thenladd(1)0) or(ur(4 downto 1) or dr(4 downto 1)=0000) thenladd=11;elseladdif (ur(6) or dr(6)0) thenladd(1)=0; elseladdnull;end case;end if;end if;elseladd=00;end if;end process p3;p4:process(div,wai_t,ladd,closex,delayx)beginif (
24、divevent and div=1) thenif (wai_t=000 or closex=1) thenwai_t=110;elseif (delayx=0) thenwai_t=wai_t-1;elsewai_t=010;end if;if (wai_t=001) thenif (ladd=11) then liftor=liftor+1;elsif (ladd=10) thenliftor=liftor-1;end if;end if;end if;end if;end process p4;end lift1_arch;摘要:介绍了基于vhdl语言设计的电梯控制器,并进行了电路综合
25、和仿真。该控制器遵循方向优先的原则,提供16个楼层多用户的载客服务并指示电梯的运行情况。 关键词:vhdl;控制器;eda;电梯现代硬件设计运用eda(electronic designautomation)技术采用并行工程和“自顶向下”的设计方法,从系统设计入手,在顶层进行层次划分和结构设计,在功能模块一级进行仿真、纠错,并用vhdl,veriloghdl等硬件描述语言对高层次的系统行为进行描述,在系统一级进行验证,最后用逻辑综合优化工具生成门级逻辑电路的网表,其对应的物理实现可以是印刷电路板或专用集成电路。vhdl(very high speed integrated circuithar
26、dware description language)即超高速集成电路硬件描述语言,主要用于描述数字系统的行为、结构、功能和接口。本文采用vhdl语言来设计实用电梯控制器,其代码具有良好的可读性和易理解性,源程序经xilinx公司的foundation软件仿真,目标器件选用fpga器件。1电梯控制器的功能本电梯控制器分为主控制器和分控制器。主控制器是电梯内部的控制器,每个楼层有一个分控制器。主控制器的功能:1)完成16个楼层多用户的载客服务控制。2)电梯运行时显示电梯的运行方向和所在的楼层。3)当电梯到达选择的楼层时,电梯自动开门。4)具有提前关电梯门和延时关电梯门的功能。5)响应分控制器的有
27、效请求,如果到达有请求的楼层,电梯自动开门。分控制器的功能:1)显示电梯的运行状态和所在的楼层。2)显示乘客的上升和下降请求。分控制器的有效请求原则:1)电梯处于等待状态时,上升和下降请求都响应。2)电梯处于上升状态时,有上升请求的分控制器所在楼层数大于电梯所在的楼层数。3)电梯处于下降状态时,有下降请求的分控制器所在楼层数小于电梯所在的楼层数。2控制器的设计控制器的功能模块如图1所示,包括主控制器、分控制器、楼层选择器、状态显示器、译码器和楼层显示器。乘客在电梯中选择所要到达的楼层,通过主控制器的处理,电梯开始运行,状态显示器显示电梯的运行状态,电梯所在的楼层数通过译码器译码从而在楼层显示器
28、中显示。分控制器把有效的请求传给主控的楼层数。由于分控制器相对简单很多,所以主控制器是核心部分。主控制器系统由vhdl语言实现,其输入输出端口定义如下:结构体分为3个进程,分别完成寄存器的置位复位、电梯运行状态判断、时序电路及电梯运行楼层变化和响应提前延时请求。程序中定义了以下几个信号:urr(16 b上升寄存器),drr(16 b的下降寄存器),ur(上升寄存器各位相或),dr(下降寄存器各位相或),let(判断状态的使能信号),输出端口qout,lamp的内部信号lift,ladd,时序内部信号time。楼层请求寄存器的复位和置位如果乘客进入电梯后所选的楼层大于所在的楼层,而且电梯处于上升
29、或者是ladd为“01”的等待状态,则给上升请求寄存器urr相应的位置位。当电梯运行到所在的楼层,在time等于“110”时给该位复位。如果有多个请求则urr相应的位都置位。下降请求寄存器drr原理相似。寄存器urr和drr的各位相或后得到的ur和dr信号作为状态变化的条件信号。电梯运行状态的判断分为3个状态:waitt,upper,down。状态图如图2所示。当电梯开关switch为“0”时,为等待状态,状态指示信号ladd为“00”,switch为“1”时,time为“101”而且使能信号let有效时,进行状态确定。没有上升下降请求时也为等待状态,状态信号ladd为 “01”;上升状态时状态信号ladd为“11”;下降状态时状态信号为“10”。时序电路及电梯运行时楼层变化和提前延时关门功能:根据ladd状态对所到达的楼层数信号lift做相应的增减。电梯在time信号跳变到“110”时关门,此时设置使能信号let为“1”,当time信号跳变到“010”时,如果电
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年纺织品市场动态分析试题及答案
- 国际美术设计师考试知识点回顾试题及答案
- 2024年助理广告师考试知识图谱试题及答案
- 社工比赛面试题及答案
- 2024年纺织品检验员复习计划试题及答案
- 2024年纺织品设计师证书备考中的经验借鉴试题及答案
- 潍坊化学初中试题及答案
- 2024年纺织品设计师的工作愿景考题及答案
- 精雕细琢2024国际商业美术设计师试题及答案
- 体能教练测试题及答案
- 脑血管病介入诊疗并发症及其处理课件
- 家校共育一年级家长会ppt
- 《微电子学概论》第八章-光电子器件课件
- 化学分析送样单2
- 化工原理教案:6 吸收
- 花篮拉杆悬挑脚手架专项施工方案
- 【高考真题】2022年新高考浙江语文高考真题试卷(Word版含答案)
- 铝镁料仓等施工方案精品
- 目前最准确的通达信缠论分笔公式
- 《丑小鸭》教学设计
- 绿化种植施工合同
评论
0/150
提交评论