




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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電商平臺店鋪轉讓合同范本
- 2024年09月浙江醫療衛生招聘臺州市立醫院招聘(中)藥學技術人員2人筆試歷年專業考點(難、易錯點)附帶答案詳解
- 2025年房地產市場交易合同:個人住宅購買協議
- 農村家族公廳公用協議書(2篇)
- 磷肥產業技術標準與國際接軌考核試卷
- 2025年農業設施租賃合同
- 生物質能發電與區域電網的接入考核試卷
- 2024年09月未央區漢城社區衛生服務中心招聘(11人)筆試歷年專業考點(難、易錯點)附帶答案詳解
- 環保技術市場動態與競爭分析考核試卷
- 無機保溫砂漿外墻外保溫系統施工工藝課件
- 產品追溯記錄表
- 高三二輪復習:產業轉移以富士康的企業轉移為例課件
- 政府信息資源管理
- 中小微企業劃型證明
- 西南交大區段站工作組織課程設計2018
- 《監察機關監督執法工作規定》測試題試題含答案
- Q∕GDW 12154-2021 電力安全工器具試驗檢測中心建設規范
- 初中文言文專項訓練十篇(含答案)
- 煤礦頂板事故防治(1)
- 漏電保護器試跳記錄表
評論
0/150
提交評論