六層電梯設計_第1頁
六層電梯設計_第2頁
六層電梯設計_第3頁
六層電梯設計_第4頁
六層電梯設計_第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、VHDL數(shù)字系統(tǒng)設計與測試 學 院 通信工程學院 學 號 題 目 六層電梯設計 姓 名 一、設計要求與功能 1.設計要求(1)完成6個樓層多用戶的載客服務控制。 (2)對于載客請求,遵循同向優(yōu)先的原則。   (3)能夠響應提前關電梯門和延時關電梯門的請求。   (4)顯示電梯的運行情況,樓層運行方向。2.設計功能本文涉及了一個六層電梯控制系統(tǒng),基本功能如下:(1)每層電梯入口處設有上下請求開關,電梯內設有顧客到達層次的停站請求開關。(2)設有電梯入口處位置指示裝置及電梯運行模式(上升或下降)指示裝置。(3)電梯每秒

2、升(降)一層樓。(4)電梯到達有停站請求的樓層,經過1秒電梯門打開,開門指示燈亮,開門4秒后,電梯門關閉(開門指示燈滅),電梯繼續(xù)進行,直至執(zhí)行完最后一個請求信號后停留在當前層。(5)能記憶電梯內外所有請求,并按照電梯運行規(guī)則按順序響應,每個請求信號保留至執(zhí)行后消除。(6)電梯運行規(guī)則:當電梯處于上升模式時,只響應比電梯所在位置高的上樓請求信號,由下而上逐個執(zhí)行,直到最后一個上樓請求執(zhí)行完畢;如果高層有下樓請求,則直接升到由下樓請求的最高層,然后進入下降模式。當電梯處于下降模式時則與上升模式相反。(8)人數(shù)超載或超重用一按鈕代替,高電平有效,超載時電梯不能運行,并有相應指示。 (9)

3、事故報警按鈕高電平有效,事故報警不能運行,并有指示燈,信號保留至事故消除(10)電梯初始狀態(tài)為一層開門狀態(tài)。二、總體設計方案控制器的功能模塊如圖1所示,包括主控制器、樓層選擇器、狀態(tài)顯示器、譯碼器和樓層顯示器。乘客在電梯中選擇所要到達的樓層,通過主控制器的處理,電梯開始運行,狀態(tài)顯示器顯示電梯的運行狀態(tài),電梯所在樓層數(shù)通過譯碼器譯碼從而在樓層顯示器中顯示。由于其他模塊相對簡單很多,所以主控制器是核心部分。 圖1 總體設計方案三、設計思路電梯控制器運用狀態(tài)機的設計方法,思路比較清晰。可以將電梯等待的每秒鐘以及開門、關門都看成一個獨立的狀態(tài)。由于電梯又是每秒上升或下降一層,所以就可以通過一個統(tǒng)一的

4、1秒為周期的時鐘來觸發(fā)狀態(tài)機。根據(jù)電梯的實際工作情況,可以把狀態(tài)機設置7個狀態(tài),分別是“電梯停留在第1層”、“開門”、“關門”、“開門等待4秒”、“上升”、“下降”和“停止狀態(tài)”。各個狀態(tài)之間的轉換條件可由上面的設計要求所決定。各狀態(tài)機之間轉換圖如圖2: 圖2狀態(tài)機轉換圖四、原理圖說明電梯控制器為其中的核心部件,控制其電梯的運行情況,而其控制則由按鈕來決定,通過按鈕指示燈判斷電梯的工作狀態(tài)及顯示其運行情況。當按鈕為高電平時,電梯開始工作,并通過按鈕信號燈決定電梯的運行。電梯所處位置顯示通過譯碼器,再通過數(shù)據(jù)選擇器顯示到數(shù)碼管上。udsig和doorlight顯示電梯門和電梯的狀態(tài)。stopli

5、ght6.1 fuplight6.1 fdnlight6.1 顯示按鈕指示。Reset按鈕使電梯恢復到初始位置。樓層position變化相應的數(shù)碼管也跟著變。其頂層原理圖如圖3:圖3頂層原理圖各功能模塊如下:1) 電梯主控制模塊電梯控制器為其中的核心部件,控制其電梯的運行情況,而其控制則由按鈕來決定,通過按鈕指示燈判斷電梯的工作狀態(tài)及顯示其運行情況。 圖4 電梯主控制模塊電梯主控制模塊端口說明:buttonclk 按鈕時鐘信號 liftclk 電梯時鐘信號 reset 復位鍵 f1upbutton 一樓上樓按鈕 f2upbutton 二樓上樓按鈕 f3upbutton 三樓上樓按鈕f4upbu

6、tton 四樓上樓按鈕 f5upbutton 五樓上樓按鈕f2dnbutton 二樓下樓按鈕 f3dnbutton 三樓下樓按鈕f4dnbutton 四樓下樓按鈕 f5dnbutton 五樓下樓按鈕 f6dnbutton 六樓下樓按鈕 stop1button 電梯內部一樓按鈕stop2button 電梯內部二樓按鈕 stop3button 電梯內部三樓按鈕stop4button 電梯內部四樓按鈕 stop5button 電梯內部五樓按鈕stop6button 電梯內部六樓按鈕 fuplight6.1 每樓層上升指示燈fdnlight6.1 每樓層下降指示燈 stoplight6.1 電梯內部樓

7、層指燈 position2.0 樓層位置顯示 doorlight 電梯門狀態(tài)顯示 udsig 電梯上升下降顯示2)分頻器模塊通過分頻器將高頻轉換為低頻,即buttonclk,通過此時鐘信號控制電梯信號燈。當按鈕為高電平時,電梯開始工作,并通過按鈕信號燈決定電梯的運行。 圖5 分頻器模塊模塊端口說明:clk_in 電源輸入端 div_out 分頻后時鐘輸出端3) 譯碼器模塊 圖6譯碼器模塊aaa2.0 樓層位置輸出端 bbb3.0 譯碼輸出端4)數(shù)據(jù)選擇器模塊 圖 7 數(shù)據(jù)選擇器模塊數(shù)據(jù)選擇器將譯碼器輸出顯示到數(shù)碼管上,來表示電梯所處層數(shù)數(shù)據(jù)選擇器模塊端口說明:input3.0 譯碼器輸入端 o

8、utput6.0 數(shù)據(jù)選擇器輸出端五、源代碼電梯程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity sixlift isport( buttonclk:in std_logic; -按鈕時鐘信號 liftclk: in std_logic; -電梯時鐘信號 reset:in std_logic; -復位鍵 f1upbutton:in std_logic; -一樓上升按鈕 f2upbutton:in std_logic; -二

9、樓上升按鈕 f3upbutton:in std_logic; -三樓上升按鈕 f4upbutton:in std_logic; -四樓上升按鈕 f5upbutton:in std_logic; f2dnbutton:in std_logic; -二樓下降按鈕 f3dnbutton:in std_logic; -三樓下降按鈕 f4dnbutton:in std_logic; -四樓下降按鈕 f5dnbutton:in std_logic; -五樓下降按鈕 f6dnbutton:in std_logic; -六樓下降按鈕 fuplight:buffer std_logic_vector(6 dow

10、nto 1); -上升指示燈 fdnlight:buffer std_logic_vector(6 downto 1); -下降指示燈 stop1button,stop2button,stop3button, stop4button, stop5button, stop6button:in std_logic; -電梯內部按鈕 stoplight:buffer std_logic_vector(6 downto 1); -內部停止指示燈 position:buffer integer range 1 to 6; -樓層位置顯示 doorlight:out std_logic; -電梯門指示燈

11、1 開 0關 udsig:buffer std_logic ); -0處于上升模式,1處于下降模式 end sixlift;architecture art of sixlift is type lift_state is (stopon1,dooropen,doorclose,doorwait4,up,down,stop); -電梯所處的7個狀態(tài)signal mylift:lift_state; -內部電梯狀態(tài)信號signal clearup:std_logic; -上升清除信號 signal cleardn:std_logic; -下降清除信號 begincontrollift:proce

12、ss(reset,liftclk) variable pos:integer range 1 to 6; -樓層位置變量 beginif reset='1' then mylift<=stopon1; -起始狀態(tài) clearup<='0' -上樓信號清除 cleardn<='0' -下樓信號清除 pos:=1; -處于一樓 position<=1; -處于一樓else if liftclk'event and liftclk='1' then -四秒后門關 case mylift is when s

13、topon1 => doorlight<='1' -電梯門開 position<=1; -電梯處于一樓 pos:=1; mylift<=doorwait4; when doorwait4 => mylift<=doorclose; when doorclose => doorlight<='0' -電梯門關 if udsig='0' then -電梯處于上升模式 if position=6 then if stoplight="000000" and fuplight="

14、;000000" and fdnlight="000000" then udsig<='1'mylift<=doorclose; else udsig<='1'mylift<=down; end if; elsif position=5 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='0'mylift<=

15、doorclose; elsif stoplight(6)='1' or fdnlight(6)='1' then udsig<='0'mylift<=up; else udsig<='1'mylift<=down; end if; elsif position=4 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='0

16、'mylift<=doorclose; elsif stoplight(5)='1' or stoplight(6)= '1' or fdnlight(6)='1' or fdnlight(5)='1' then udsig<='0'mylift<=up; else udsig<='1'mylift<=down; end if; elsif position=3 then if stoplight="000000" and fuplight=

17、"000000" and fdnlight="000000" then udsig<='0'mylift<=doorclose; elsif stoplight(4)='1' or stoplight(5)='1' or stoplight(6)= '1' or fdnlight(6)='1' or fdnlight(5)='1' or fdnlight(4)='1' then udsig<='0'mylift

18、<=up; else udsig<='1'mylift<=down; end if; elsif position=2 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='0'mylift<=doorclose; elsif stoplight(3)='1' or stoplight(4)='1' or stoplight(5)

19、='1' or stoplight(6)= '1' or fdnlight(6)='1' or fdnlight(5)='1' or fdnlight(4)='1' or fdnlight(3)='1' then udsig<='0'mylift<=up; else udsig<='1'mylift<=down; end if; elsif position=1 then if stoplight="000000" and

20、fuplight="000000" and fdnlight="000000" then udsig<='0'mylift<=doorclose; else udsig<='0'mylift<=up; end if; end if; elsif udsig='1' then if position=1 then if stoplight="000000" and fuplight="000000" and fdnlight="0000

21、00" then udsig<='0'mylift<=doorclose; else udsig<='0' mylift<=up; end if; elsif position=2 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='1'mylift<=doorclose; elsif stoplight(1)='1&#

22、39; or fuplight(1)='1' then udsig<='1'mylift<=down; else udsig<='0' mylift<=up; end if; elsif position=3 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='1'mylift<=doorclose; elsif stop

23、light(1)='1' or stoplight(2)='1' or fuplight(1)='1' or fuplight(2)='1' then udsig<='1'mylift<=down; else udsig<='0' mylift<=up; end if; elsif position=4 then if stoplight="000000" and fuplight="000000" and fdnlight="

24、;000000" then udsig<='1'mylift<=doorclose; elsif stoplight(1)='1' or stoplight(2)='1' or stoplight(3)='1' or fuplight(1)='1' or fuplight(2)='1' or fuplight(3)='1' then udsig<='1'mylift<=down; else udsig<='0'

25、mylift<=up; end if; elsif position=5 then if stoplight="000000" and fuplight="000000" and fdnlight="000000" then udsig<='1'mylift<=doorclose; elsif stoplight(1)='1' or stoplight(2)='1' or stoplight(3)='1' or stoplight(4)='1&#

26、39; or fuplight(1)='1' or fuplight(2)='1' or fuplight(3)='1' or fuplight(4)='1' then udsig<='1'mylift<=down; else udsig<='0' mylift<=up; end if; elsif position=6 then if stoplight="000000" and fuplight="000000" and fdnli

27、ght="000000" then udsig<='1'mylift<=doorclose; else udsig<='1' mylift<=down; end if; end if; end if; when up => position<=position+1;pos:=pos+1; if position <6 and( stoplight(pos)='1' or fuplight(pos)='1') then mylift<=stop; elsif pos

28、=6 and (stoplight(pos)='1' or fdnlight(pos)='1') then mylift<=stop; else mylift<=doorclose; end if; when down => position<=position-1; pos:=pos-1; if position>1 and (stoplight(pos)='1' or fdnlight(pos)='1') then mylift<=stop; elsif pos=1 and (stoplig

29、ht(pos)='1' or fuplight(pos)='1') then mylift<=stop; else mylift<=doorclose;end if; when stop => mylift<=dooropen; when dooropen => doorlight<='1'if udsig='0' thenif position<6 and (stoplight(position)='1' or fuplight(position)='1'

30、) then clearup<='1'else clearup<='1'cleardn<='1'end if; elsif udsig='1' thenif position>1 and (stoplight(position)= '1' or fdnlight(position)='1') then cleardn<='1'else clearup<='1'cleardn<='1' end if;end if

31、;mylift<=doorwait1; end case; end if; end if;end process controllift;controllight:process(reset,buttonclk) begin if reset='1' then stoplight<="000000" fuplight<="000000"fdnlight<="000000" elsif buttonclk'event and buttonclk='1' then if cl

32、earup='1' then stoplight(position)<='0'fuplight(position)<='0' elsif f1upbutton='1' then fuplight(1)<='1' elsif f2upbutton='1' then fuplight(2)<='1' elsif f3upbutton='1' then fuplight(3)<='1' elsif f4upbutton='

33、;1' then fuplight(4)<='1' elsif f5upbutton='1' then fuplight(5)<='1' end if; if cleardn='1' then stoplight(position)<='0' fdnlight(position)<='0' elsif f2dnbutton='1' then fdnlight(2)<='1' elsif f3dnbutton='1'

34、 then fdnlight(3)<='1' elsif f4dnbutton='1' then fdnlight(4)<='1' elsif f5dnbutton='1' then fdnlight(5)<='1' elsif f6dnbutton='1' then fdnlight(6)<='1' end if; if stop1button='1' then stoplight(1)<='1' elsif stop2

35、button='1' then stoplight(2)<='1' elsif stop3button='1' then stoplight(3)<='1' elsif stop4button='1' then stoplight(4)<='1' elsif stop5button='1' then stoplight(5)<='1' elsif stop6button='1' then stoplight(6)<=

36、9;1' end if; end if;end process controllight;end art;分頻器程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div is port( clk_in:in std_logic; div_out:out std_logic);end;architecture a of div is signal fre_N:integer range 0 to 10;signal clk_tmp:std_logic;begin div_o

37、ut<=clk_tmp;process(clk_in)begin if falling_edge(clk_in) then if fre_N>10 then fre_N<=0; clk_tmp<=not clk_tmp; else fre_N<=fre_N+1; end if; end if; end process;end a;譯碼器程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity yima isport( aaa:integer range 1

38、to 6; bbb:out std_logic_vector(3 downto 0);end;architecture a of yima isbeginprocess(aaa)begin if aaa=1 then bbb<="0001" elsif aaa=2 then bbb<="0010" elsif aaa=3 then bbb<="0011" elsif aaa=4 then bbb<="0100" elsif aaa=5 then bbb<="0101"

39、; elsif aaa=6 then bbb<="0110"end if;end process;end a;數(shù)據(jù)選擇器程序:library ieee;use ieee.std_logic_1164.all;entity led is port( input:in std_logic_vector(3 downto 0); output:out std_logic_vector(6 downto 0);end;architecture a of led is begin output<="0110000" when input="0

40、001" else "1101101" when input="0010" else "1111001" when input="0011" else "0110011" when input="0100" else "1011011" when input="0101" else "1011111" when input="0110" else "0000000"e

41、nd a;五、仿真結果與說明1.各模塊仿真分析(1) 電梯控制模塊a. 電梯報警的情形電梯在超載的時候發(fā)出警報信號同時不進行關門動作直至報警解除,同時從波形圖可以看到延時關門和提前關門信號的作用圖8 情況ab.當電梯停在初始狀態(tài)時,高層有上升的請求圖9所示仿真的是在第2層電梯外部有上升請求,也就是f2upbuttton信號的一個脈沖,可以看到電梯從一層上升到五層,position信號由1變到2,doorlight信號1表示開門,0表示關門。當乘客進入電梯以后,在電梯內部要求上升到第三層,也就是stop3button產生一個脈沖,電梯上升到第3層,開門4秒以后關門,停留在第三層,position

42、最后的值為3。在仿真圖中看不到buttonclk,只顯示為一條黑色的線,是因為采用了頻率較大的時鐘。再看fuplight信號燈,當五層有上升請求的時候,它的值由0變到16。(注意fuplight和fdnlight是6位的二進制向量,這里的“010000”,表示五層有請求;“000100”也就是4,表示三層有請求)。當電梯停留到第二層以后,表明該請求被響應,所以它的值變?yōu)?,由于沒有下降請求信號,所以fdnlight信號燈的值一直都為0。當電梯處于第二層時,udsig=0,即此時若沒有其他請求,電梯處于上升模式;當stop6button=1,即電梯內部按了三層請求時,電梯門燈滅電梯開始上升uds

43、ig=0,即處于上升模式10,抵達三層時,udsig=即無論什么請求電梯都開始下降,且doorlight=1,即燈亮,電梯門開。四秒之后燈滅,電梯門關。圖9 情況bc.當電梯停在初始狀態(tài)時,高層有下降的請求圖10是有下降請求的情況,它是圖7的繼續(xù),即當電梯停留在第一層的時候,假設在電梯外第四層有下降請求,這時候fdnlight信號燈由0變?yōu)?,說明第四層有下降請求。電梯下降到第四層,響應了下降請求,所以fdnlight信號燈清0。電梯開始下降,即udsig=1,抵達四樓后電梯門開,doorlight=1, 這時候,在電梯內部有一樓向上請求,接著電梯內部有三樓的請求,所以電梯繼續(xù)下降,到達三層后

44、,電梯門開,四秒后電梯門關,又因為一樓有請求所以最終到達一樓停止響應,position信號的值保持在1,電梯處于上升模式。四秒后電梯門關。 圖10 情況cd. 當電梯處于初始狀態(tài)時,電梯在高層有向下和低層有上升同時的請求圖10所示的仿真,原先電梯停留在第一層,電梯外第四層有下降請求,電梯上升到四層,乘客進入電梯以后要求下降到一層,此時,二層有下降請求,接著又有上升請求,電梯首先在二層停留。然后下降到一層。隨后要響應二層上升請求,上升到二層,乘客進入電梯以后要求上升到三層,所以電梯最后的停留位置在三層。 圖11 情況d(2) 譯碼器模塊本模塊的主要功能是將10進制數(shù)轉換成4位二進數(shù)。當輸入信號aaa=1時,輸出bbb=0001;當輸入信號aaa=2時,輸出bbb=0010;當輸入信號aaa=3時,輸出bbb=0011;當輸入信號aaa=4時,輸出bbb=0100;當輸入信號aaa=5時,輸出bbb=0101;當輸入信號aaa=6時,輸出bbb=0110;其他都為0000;仿真波形如圖12 圖12 譯碼器仿真波形(3) 數(shù)據(jù)選擇模塊此模塊的功能是根據(jù)輸入不同的數(shù)據(jù)輸出不同的數(shù)據(jù),即由輸入定輸出,輸出量通過數(shù)碼管顯示數(shù)據(jù)。當input=0001時, 輸出 0110000, 數(shù)碼管顯示 1;當input=0010時, 輸出 1101101, 數(shù)碼管顯示2;當inpu

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論