3层电梯VHDL报告_第1页
3层电梯VHDL报告_第2页
3层电梯VHDL报告_第3页
3层电梯VHDL报告_第4页
3层电梯VHDL报告_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、简易二层电梯控制器模拟真实电梯的运行情况,设计制作一个简易电梯控制器控制二层电梯的运行。 基本要求:1电梯设有一层、二层外部呼叫按钮和内部一层、二层指定按钮(BTN。2、利用数码管显示电梯所在楼层,用 LED显示电梯运行状态如上行、下行、 开门、关门等。提咼要求:1点阵显示楼层;2、用点阵显示楼层的上下滚动移出移入表示电梯的上行或下行运行方向3、增加为三层电梯控制器二. 设计方案及思路设计思路:根据题目要求,我在程序中设计了需要用到的8个外部按钮:f1up,f2up ,f2d n,f3d n,warni ng,stop1,stop2,stop3,reset,另外还有相应的显示信号,程序利用状态

2、机实现总体的控制,状态中用到了7个状态:(stop on 1,doorope n, doorclose,doorwait,up1,dow n1,stop),状态的主要转换如下:设定复位后初始状态是stopon1,然后状态跳转到doorclose,在接收到相应的请求信号时,做出判断,若请求信号的楼层大于当前所在的楼层,则程序跳转到up1状态,小于则跳转到down1状态,如果请求信号的楼层与当前楼层相同 时,则开门进入dooropen状态,然后到开门延迟状态 doorwait,然后再到 doorclose状态,上升和下降的过程中判断电梯是否到达指定的楼层,若到达, 则程序进入stop状态,然后到开

3、门-延时-关门,进而做判断。状态转移图如 下:1各个状态线表示的内容如下:1初始化2初始化后电梯进入工作状态,起始是关门状态3没有任何信号输入时,电梯始终工作在关门状态4电梯接收到信号,且请求信号大于当前楼层5电梯上升后到达指定楼层时停止6电梯停止后便开门7延时等待乘客搭乘电梯或者走出电梯8等待时间结束后电梯关门9电梯接收到信号,且请求信号小于当前楼层10电梯下降到指定楼层后停止11电梯接受的信号与当前楼层相同则开门控制原理图:分块设计:程序中主要分了 3个模块:分频模块,状态控制,状态显示,其中状 态显示分成了信号灯显示部分和点阵显示部分, 因为一开始对点阵的显示比较生 疏,所以点阵显示模块

4、是后来才在总的程序中加入的。 分频模块的作用是将板子 提供的时钟信号分频作为电梯运行状态转换的时钟信号; 状态控制模块是最核心 的一部分,它要分析输入信号并作出相应的状态转换;状态显示的信号灯模块主 要控制对于外部输入做出的反应,而点阵显示部分则主要是利用点阵来显示当前 的楼层信号和运行的电梯上升或下降模式。三. 时序仿真图(1)如图Simulation WaveformsSIiluI也泊塚处 Master Time Bar:IBQ.Ons Jjpoiiner:38B.31 ne Iniervd:208. hb StartEnd从图中可以看出,当复位键reset高电平时,所有信号都不显示,当r

5、eset低电 平,有警报信号时,电梯门打开,并产生警报输出,当警报与复位信号都是低电 平时,一楼有上升请求,显示上升信号,电梯开门后一楼外部请求上升信号熄灭, 内部要求停在2楼和3楼,电梯显示内部请求信号,图中stoplight= ”110”时,表示有2、3层内部停站请求,电梯经过4个电梯时钟信号到达2层,然后开门, 2层上升请求信号清零,然后再关门,上升到 3层,之后开门,关门,此时,没 有然后任何外部信号,就停止在 3层。(2)Simulation WaveformsSliulation. lode : TiilnsA 英Master Tkne Bar:5JO na乳腔USIniervd:

6、Stan:EndNane91. Z1US91.辛US91 翠 US91uE5us92u 01IEU冲us*FJkiroimpUMf2dnnAi212m?1A?f3dni4reset* Eelk liftelkTjnniunrjmunriiniunrMuimiimTiimiinirjnniiiirjnfmiMninTniimiiniimmiiiiwirjifnTiuj皿皿limn皿皿nnuiiwinr uirmmnjLrTLmLrjuuLrTLnjLrjuuLrjuuuuirLnjuiruuinrLTrmruinnjVLrmrjinRTTmjLrTLr nenTarning.Ol.d-ooTll

7、ght1r|L1 1進i stoplight:01 .X LjJXQ0 ididlglitIllOJS fupHrirtq X101 layer13KIZIr1X1310 2?*arninE_n.F丿inJ,4|TJ如图,电梯在3层,接收到2层外部下降请求信号,电梯显示该信号,并从 3 楼下降,同时接收到2层上升请求信号,电梯显示该信号,下降到 2层时,电梯 开门,然后从接受到的1楼停站请求信号,电梯继续下降并在一楼开门,然后电 梯上升到2层开门,然后执行上升任务,到达 3层开门。四. 源程序分析(见附件)五. 功能说明diantlidkftiplight(2.1resetfdnligh(3.

8、2iflupstoplightf3.1f2updoorlightif2dnrow7.0f3dnwl7 0istoplwamingLoutstop 2istop3 warningirist如图,elk接的是开发板的晶振输入信号,作为时 钟信号,reset是复位输入,咼电平有效,复位后状态 转换为stopon1,flup电梯外部1楼上升请求信号, f2up电梯外部2楼请求上升信号,f2dn电梯外部2 楼请求下降信号,电梯外部3楼请求下降信号,stopl 内部一层停站请求端口,stop2内部二层停站请求端 口,stop3内部三层停站请求端口都是高电平有效, 选择相应的端口时会有相应的 LED灯点亮,

9、warning: 内部紧急状况请求,高电平有效,此时电梯门打开, 蜂鸣器鸣叫报警,fuplight外部上升请求显示灯,fdnl ight 外部下降请求显示灯,stoplight 内部请求显示灯,doorlight 开关门 信号灯,用来显示相应的请求信号,row点阵显示行,col点阵显示列,用来显 示楼层信息与上升下降信息的,warning_out紧急状况报警,接到蜂鸣器六. 元器件清单及资源利用实验中用到的是MAXII EPM1270T144C的板子,其中主要用到的是按键开关 和点阵,另外还用到了 2个拨码开关用来表示复位键和警报键, 还用到了蜂鸣器 用来显示警报信号。引脚图如下:Hode N

10、omeDirec&onLucaUcnVO BnkVREF GlWVO StwriardReservedGroupI Cwrei1dkbW13.J-VILWTL (dfef.u16mA (12科7phl li13.3-V LVTTL (iSef.IfirilAQ3aLhJIpLA13.J-V LVTTL (def. .cEi7.a16mA (i4*3MpurI3.3-V LVTTL (讪.5aco(4OutputPTN 14I3.3-V LVTTL (M.CC7.G16niA (1ISoOutputHN 151J.WiLWTLC07.016RiA(i7o2DmpdlP3hl 1613.3-V L

11、VTTL (站lfiffiAO9a哄JLKApU13.J-U ILVTTLdel .lfimA (1g(0urpm_22113.3-V LVTTL (却CD(7bJ010adocrtglTtoutput33.3-V LVirTL 備“16HIA (1iiflupinput201J.J-ViLVTTL16mA (1iz廿12dnIngnutPIhl_9133.3-V LWL (ifef.lfiffiAQ13E*-f2upinputPlN_a&SJ-VlLVTTL (cM.16mA (i丄斗開两Lrt_5l*3.3-V LVTTL (fcf.l&mA (1ISaOutpul33.3-V LVirT

12、L 隔“16mA (116output0Q33.W LWTL (rtef.lfimAji17o坤即口OUlpUlPIN_7733.3.-V LVTTL站,.叩1肋丄匕LlfifflAQ19aftjp 幼“OtitpulPB531.3.-U ILVFTLfufAght(2.9jlfimA (119r?Wt哪吐F1N_123713LVTTL (妊 &mA (120rflwf7)outpu?HN 1L3.3-V LVTTL (X “r(jw7PI0i16H1A (1oIW初outpuiP1N 213.1V LWTL (tfef.ufOW7t.Q16mA (1商afwtsDuqxiiPhi 313.3

13、-V LWTL (tffff.row7.0i|16mA (123arow4DuipuPIhl13.3-V lVTTL (甘iraw7-.fi,JlfimA (i24rflw3OtApUlF1N_513.3-V LVTTL (韓f.”.injiv7_.QimA (125ruw(2OutpulHW 5L3.3-V LVTTL 阳“r(jw70i16mA (136ompmpm?13.3VLWTL 甘“fOW7t.Q16mA (127ofw0JDmpdiPh B13.2-V LVTTTL (dM.rOw7.0lfimAOsEnplhputPIhl=12222.3.-U LVFTLlfimA (129U

14、*-曲p?EqpirtFW_12323J-V LVTTL (删1(130知阿HW 12423.3-V LVTTL (X “16H1A fi31ostopilghil3loutpm743S.WiLVTTL (dfef.5tpliglt(3.1并a加pHgHt巧CkApUlRN_7533J-V LVTTL (昵!仁.曲plig帼九1lfimAjiasEd plight 1|OuipdlPIhl7ii33.3-V ilVTTL (ifef.jbipligherS-.ilfimA (i弭warningDifiirtFIN_134i3.J-V LVTTL (def. .“mA (iwamina outO

15、utpulFN 50-43.3-V LVirTL 昭“16niA(.36附件:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity dia nti isport(clk:in std_logic;-时钟信号reset:in std_logic;-异步复位端口 1-复位flup:in std_logic;-外部一层上升请求端口1-有请求0-无请求以下类似f2up :instdogic;-外部二层上升请求端口f2dn :instdogic;-外部二层下降请求端口f3dn :instd_

16、logic;-外部三层下降请求端口stop1 :in std_logic;-内部一层停站请求端口stop2 :in std_logic;-内部二层停站请求端口stop3 :in std_logic;-内部三层停站请求端口warni ng:in std_logic; -内部紧急状况请求端口fuplight:buffer stdo gic_vector(2 dow nto 1);-外部上升请求显示灯0-灭灯1-亮灯以下类似fdn light:buffer stdo gic_vector(3 dow nto 2);-外部下降请求显示灯stoplight:buffer stdo gic_vector(

17、3 dow nto 1);-内部请求显示灯doorlight:out stdogic;-开关门信号灯Iayer:out std_logic_vector(1 dow nto 0); row:out std_logic_vector(7 dow nto 0);col:out std_logic_vector(7 dow nto 0);warnin g_out:outstd_logic);end en tity dia nti;当前楼层信息在开发板上应用的时候显示在点阵上,不需要此信号点阵显示行点阵显示列紧急状况报警,接到蜂鸣器architecture behave of dia nti is-结

18、构体type state is-定义14个状态(stop on 1,doorope n, doorclose,doorwait,up1,dow n1,stop);sig nal lift_state:state;sig nal clearup:std_logic;-sig nal cleard n: std_logic;-sig nal up_dow n: std_logic;sig nal run_ model:stdo gic_vector(2 dow nto 0);-sig nal pos:i nteger range 1 to 3;-sig nal i:i nteger range 0

19、 to 7;sig nal nu m:i nteger range 0 to 99999;sig nal liftclk:stdo gic;-上升和停站请求清除信号下降和停站请求清除信号电梯模式(上升或下降)信号 电梯位置信号电梯时钟信号begin 分频模块-功能:对时钟信号分频,产生电梯运行的时钟信号fenpin:process(clk,reset) variable coun t:i nteger range 0 to 1;beginif reset=1 the nliftclk=0;elseif clkeve nt and clk=1 the nif coun t=1 the ncoun

20、 t:=0; liftclk=1;elsecoun t:=co un t+1; liftclk=0;end if;end if;end if;end process fenpin;在开发板上应用的时候需要将分频倍数改大一些1变成24999;状态机进程异步复位,电梯的初始状态为一层开门状态有警报时开门状态转换楼停止,初始状态关门状态电梯处于关门停止模式 状态转换-功能:电梯的主要控制模块 ctrlift:process(reset,liftclk,war ning) variable cn t: in teger range 0 to 4; beginif reset=1 the n-lift_

21、state=stop on1; clearup=0:cleard n=0:elseif liftclkeve nt and liftclk=1 then if warnin g=1 the n run_model=000; doorlight=1; -elsedoorlight-1doorlight=0; run_model=000; pos=1;up_dow n=1: lift_state doorlight=0; run_model=000;if up_dow n=1 the nif pos=3 then -电梯在 3 层if fuplight=00 and fdn light=OO an

22、d stoplight=000 the n-没有任何请求信号,电梯停在当前层up_dow n=0:lift_state=doorclose;elsif fdn light(3)=1 or stoplight(3)=1 the n -3层有请求信号时,电梯开门up_dow n=0;lift_state=doorope n;else-否则其它层有信号时,下降up_dow n=0; lift_state=dow n1;end if;elsif pos=2 then -电梯在 2 层if fuplight=OO and fdn light=OO and stoplight=000 the n-无信号,

23、电梯停在当前层up_dow n=1: lift_state=doorclose;elsif fuplight(2)=1 or stoplight(2)=1 the n-2有上升或停站请求时时,电梯开门up_dow n=1:lift_state=doorope n;elsif fuplight=00 and stoplight=000 and fdn light=O1then -2层有下降请求时,电梯开门up_dow n=0: lift_state=doorope n;elsif stoplight(3)=1 or fdnl ight(3)=1 the n-3层有停站请求或下降请求,则上升up_

24、dow n=1:lift_state=up1;elseup_dow *=0;-一层有请求信号时,下降lift_state=dow n1;end if;elsif pos=1 the n -电梯在一层if fuplight=00 and fdnl ight=OO and stoplight=000 then -无信号,电梯停在当前层up_dow n=1: lift_state=doorclose;elsif stoplight(1)=1 or fuplight(1)=1 the n-一楼有停站请求或者上升请求时,开门up_dow n=1:lift_state=doorope n;其他楼层有请el

25、se-求信号时,到上升状态up_dow n=1;lift_state=up1;end if;end if;电梯处在下降模式电梯在3层elsif up_dow n= O the n if pos=3 the nif fuplight=00 and fdnl ight=00 and stoplight=000 then up_dow n=0:lift_state=doorclose;-无信号时关门elsif fdn light(3)=1 or stoplight(3)=1 the nup_dow n=0:lift_state=doorope n; -3层有停站请求和下降信号时,开门elseup_d

26、ow n=0:lift_state=dow n1;-其他情况,下降end if;elsif pos=2 then-电梯在 2 层if fuplight=00 and fdn light=OO and stoplight=000 the nup_dow n=0:lift_state=doorclose; -无信号,关门elsif fdn light(2)=1 or stoplight(2)=1 the nup_dow n=0:lift_state=doorope n;-2层有停战和下降请求,开门elsiffdn light=OO and stoplight=000 and fuplight=10

27、 thenup_dow n=1:lift_state=dooropen;-只有2层上升请求时,开门elsif fuplight(1)=1 or stoplight(1)=1 the n -层有停-站请求或上升请求,则下降up_dow n=0:lift_state=dow n1;elseup_dow n=1:lift_state=up1;-其他情况,上升end if;elsif pos=1 the n-电梯在一层if fuplight=00 and fdn light=OO and stoplight=000 the nup_dow n=1;lift_state=doorclose;elsif

28、stoplight(1)=1 or fuplight(1)=1 the nup_dow n=1;lift_state=doorope n;elseup_dow n=1;lift_stateif ent =0 the nrun_model=001;- lift_state=up1;en t:=e nt+1;elsif en t=1 or en t=2 or en t=3 the n run_model=010;- lift_state=up1;en t:=e nt+1;elsif en t=4 the nrun_model=100;en t:=0;pos=pos+1; -加速上升模式平稳上升模式

29、减速上升模式电梯楼层数加一if pos3 and (stoplight(pos)=1 or fuplight(pos)=1)lift_state=stop;elsif-电梯在一层或二层,本层有停站或上升请求时,则停止pos=3 and (stoplight(pos)=1 or fdnlight(pos)=1)lift_state=stop;电梯处在三层,并且有三 层停站或下降请求,则停止elselift_stateif ent = 0 the n run_model=110;- lift_state=dow n1;en t:=e nt+1;elsif en t=1 or en t=2 or e

30、n t=3 the n加速下降模式run_model=101; lift_state=dow n1; en t:=c nt+1;elsif en t=4 the nrun_model=011; en t:=0;pos1 and (stoplight(pos)=1 and fdn light(pos)=1)the nlift_state=stop;elsif pos=1 and (stoplight(pos)=1 or fuplight(pos)=1)the nlift_state=stop;elselift_statelift_statedoorlight=1;run_model=111;-电

31、梯处于开门停止模式if up_dow n=1 the nif pos3 and (fuplight(pos)=1 or stoplight(pos)=1) the nclearup=1:-电梯在3层以下时,清除当前层上升和停站请求elseclearup=1;cleard n1 and (fdn light(pos)=1 or stoplight(pos)=1) the ncleard n=1;-电梯在1层以上时清除当前层下降和停站请求elseclearup=1;cleard n=1:end if;end if;lift_stateif cn t=0 the ndoorlight=1;run_m

32、odel=111;cn t:=c nt+1;lift_state=doorwait;elsif cn t=1 the ndoorlight=1;clearup=0;cleard n=0;run_model=111;cn t:=c nt+1;lift_state=doorwait;elsif cn t=2 the n doorlight=1: run_model=111; cn t:=c nt+1; lift_state=doorwait;elsif cn t=3 or cn t=4 the n doorlight=0; run_model=000; cnt:=0; lift_state=doo

33、rclose;end if;end case;end if;end if;end if;if pos=1 the n layer=01; elsif pos=2 the n layer =10; elsif pos =3 the n layer=11; end if;end process ctrlift;light:process(reset, clk) - beginif reset=1 the n - fuplight=00;fdnl ight=OO;stoplight=000;elseif clkeve nt and clk=1 the n if warnin g=1 the n wa

34、rnin g_out=1;elsewarni ng_out=0;信号灯控制进程复位,寄存信号清零if clearup=1 the nfuplight(pos)=0; stoplight(pos)=0; elseif f1up =1 the n fuplight(1)=1;上升和停站请求清零记忆各层上升请求elsif f2up =1the n fuplight(2)=1: end if;end if;if cleard n=1 the n fdn light(pos)=0: stoplight(pos)=0: elseif f2dn =1 the n fdn light(2)=1: elsif

35、f3dn =1 the n fdn light(3)=1;end if;end if;if stop1 =1 then stoplight(1)=1;elsif stop2 =1 the n stoplight(2)=1;elsif stop3 =1 the n stoplight(3)=1;end if;end if;end if;end if;end process light;下降和停站请求清零记忆各层下降请求记忆各层停站请求dia nzhe n: process(clk,reset,pos,r un _model)beginif reset=1 the ncol=00000000; r

36、ow=00000000;elseif clkeve nt and clk=1 the nif i=7 the ni=0;elsei=i+1;end if;if num=99999 the n num=0; else num col = 00000000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00000000;row col = 00111100;ro

37、w col = 00100000;row col = 00100000;row col = 00111100;row col = 00000100;row col = 00000100;row col = 00111100;row col = 00000000;row col = 00111100;row col = 00100000;row col = 00100000;row col = 00111100;row col = 00100000;row col = 00100000;row col = 00111100;row = 11111110; end case;elsif (pos=1 and (run_model=001 or run_model=010 )the n-1 upif num col = 00000000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row col = 00011000;row

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论