Electronic – How to design a LIFT simulator using FSM(Finite State Machine)

designstate-machines

I want to design a LIFT with the help of Finite state machine.

There are four floors. So I took them as 0, 1,2,3 and correspondingly the states.
The 0,1,2,3 buttons are present inside the lift. If some one presses them accordingly it changes from one state(floor) to another.

But they are also UP, DOWN arrows present outside the lift on each floor.
No DOWN arrow in 0th floor and no UP arrow in 3rd floor

I am not getting how to incorporate them into the design.
With only four states 0,1,2,3 and say a person pressed the button 3 inside the lift from 1st floor, we are sending it state 3 directly. Now if in 2nd floor someone presses the UP arrow, the the lift should stop at the 2nd floor before going directly to 3rd floor, which I am missing.

May be taking UP, DOWN signals as asynchronous may help. But they are 6 such signals. So it is posing me into trouble.

Can some one help me. A state diagram helps me further.

Best Answer

You're confusing the floor destinations with the states. They are not the same.

For a lift, states would be:

  • Idle
  • Moving up
  • Moving down

The states would be changed by events such as:

  • Call button pressed
  • Floor button pressed
  • Arrived at target floor

The FSM doesn't care about what floor is what, only which floor it wants to get to when in a moving state.

Read more abut FSMs here: http://hacking.majenko.co.uk/finite-state-machine