Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to model an elevator state?

Status
Not open for further replies.

adgjl40112

Newbie level 5
Joined
Mar 26, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,349
Hi guys. I have a question that usually how to do u model elevator state.
There seems to be two kinds of ways for me. Assume it's basic simple one car system. First, cassify according to the "moving" status. For eg. it may have states like up/down/wait for request/door_open/ door_closed/ ... etc
Another one is classified according to its floor such as floor 1, floor 2, floor 3, floor 4, floor 5, ...., floor N/ and still door_open/door_closed/ ...
I just get confused that should I assign different floor different state?

I am now working on some kinds of proejct such as elevator. Need help or any advice to clearify my though. THx
 

Re: Elevator Model

if during "moving" you must perform something, then you should have one more state for moving. If not then just assign each floor one state, door_closed/open will be just signals which would be driven to correct value in each of the state according to the request.
the attached is a code of 3 state FSM which does very simple thing...just assigns a,b according to x,y in different states, just modify this code and rename/add variables which make sense for your purpose.


Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity fsm is
    port (
            clk:    in  std_logic;
            rst:    in  std_logic;
            x:      in  std_logic;
            y:      in  std_logic;
            a:      out  std_logic;
            b:      out  std_logic
         );
end entity;

architecture behavior of fsm is
    type state is (ONE,TWO,THREE);
    signal s_current, s_next: state;

    --internal signals used by state machine
    signal a_sm: std_logic;
    signal b_sm: std_logic;
begin

   fsm_process: process (s_current, x, y)
    begin
    -- state machine default values and output
    s_next <= s_current;
    a_sm <= '0';
    b_sm <= '0';

        case s_current is
----------------------------- STATE ONE -----------------------------
            when ONE =>
            if x = '0' then
                s_next <= ONE;
                else
                    s_next <= TWO;
            end if;

            if y = '1' then
                a_sm <= '1';
            end if;

----------------------------- STATE TWO -----------------------------
            when TWO =>
            if x = '0' then
                s_next <= TWO;
                else
                    s_next <= THREE;
            end if;

            if y = '1' then
                b_sm <= '1';
            end if;


----------------------------- STATE THREE -----------------------------
            when THREE =>
            if x = '0' then
                s_next <= THREE;
                else
                    s_next <= ONE;
            end if;

            if y = '1' then
                a_sm <= '1';
                b_sm <= '1';
            end if;

----------------------------- DEFAULT -----------------------------
            when others =>
            s_next <= ONE;


        end case;
    end process;

    --init state machine register
	fsm_reg: process(clk)
		begin
			if (clk'event and clk = '1') then
				if (rst = '1') then
					s_current	<=	ONE;
					a	        <=	'0';
					b		    <=	'0';

					else
					s_current	<=	s_next;
                    a           <=  a_sm;
                    b           <=  b_sm;
				end if;

			end if;
		end process;
end architecture;
 

Re: Elevator Model

Thx for ur message.
Somehow i still confuse about door_open/door_closed. Shouldn't I model these two as states? Then in this states, it triggers the signal to open or close the door? If these two are not states, it seems that I need to have two states for each floor. One for keeping door closed, one for open? Otherwise, how do me know if we need to open the door at the current floor. Sorry for kind of foolish question.


I am just a beginner of HW language. I know how to write a basic state machine from textbook. My question consists of what should be the input and output should like of my program( BTW, I use the verilog). If I want to provide all the usual function of a car. That is I can press up or down button outside the car. And people the elevator press the button to select which floor he goes to. Still having no idea about it.

I just so confuse about how should the input or output would like. This kind of project seems somewhat "abstract" for me.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top