Fsm for a simple elevator

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
Hi all... i really need your help please...i have a homework task to build a digital circuit for a two-floor elevator using FSM and then construct the circuit...now my problem is the FSM the rest of the homework is easy BUT I NEED HELP WITH THE FSM PLEASE...

the text is like this :

One elevator serves two floors.On each floor there is a button to call the elevator,and in the car there are two buttons to choose the floor that we want to go.Make an FSM for the task and use SR FlipFlops knowing that:

1.The push of each button is a seperate input signal,and pushing two buttons at the same time is not allowed,but there is a case when none of the buttons is pushed.

2.The states of the FSM represent the elevator on each floor when NOT MOVING...the states must be coded as 01 and 10. PAY ATTENTION ON THE RESET SIGNAL!

-------------------------------------------------------------------------

additionaly what i dont understand is this RESET signal...


thanks in advance...
 

Georacer

Joined Nov 25, 2009
5,182

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
Well i know that i have 4 inputs for all the buttons (one on each floor and two in the car),and two floors that i labeled L0 and L1.

Now if i have 2 states (the floors) then i must use only one SR flip flop,but what confuses me is that the professor wants me to code the states with two bits (01 and 10) which tells me that i have to make 4 states (3 minimum) becouse 2^2=4...if that wasn't mentioned i would have coded the states with one bit (0 and 1).

Now i tried the next logic...i definitely have 4 inputs so i labeled them:
P0 - if i am on the bottom floor (L0) and i want to call the elevator.
PM0 - if i am in the elevator and i want to go on the bottom floor (L0).
P1 - if i am on the first floor (L1) and i want to call the elevator.
PM1 - if i am in the elevator and i want to go on the first floor (L1).

IF I DECIDE TO MAKE CODINGS OF THE STATES WITH ONE BIT then for the transition table i need the excitation table for the SR flip flop (to compute his inputs S and R depending on the Q-present state and Q'-next state for each of the combinations P0,PM0,P1,PM1,Q).So that gives me a transition table with 2^5=32 rows and a K-Map for each S and R with 5 variables. (THIS IS IF I GO WITH THE ONE FLIP FLOP - cause if i decide to go with more flip flops the transition table is HUGE).

My state diagram (FSM) is attached...

So if i make codings like:

L0 is 0
L1 is 1

my coding table and next coded states are also attached...

Now becouse the professor wants me to define a reset signal i define it with the inputs 0,0,0,0 and the L0 state...that is if none of the buttons is pressed (becouse that scenario is allowed) the elevator goes back to the bottom floor as a default.

So now i make the transition table and i get the inputs for S and R,i make K-Maps for S and R and the minimized expressions that i get are:

S=PM0
R=P1+P0*PM0

which i think is something wrong becouse my PM1 input isn't considered and also i don't have the Q and Q' in the expressions...

i don't know where i am wrong and without this solved i can't pass the exam...i just try so hard to understand but the professors show us so little in class and this is my only hope...

I hope you can help me...

Thanks.
 

Attachments

Georacer

Joined Nov 25, 2009
5,182
What is the order of the inputs in your transition diagram and table? I 'd say P0, PM0, P1, PM1, but for example staying in L0 after having PM1=1 isn't reasonable.

And something else: Do you want to take into account the case that more than one button is pressed, say both floors request the elevator at the same time? This decision is very important.
If you assume only one input is active at any time, you can simplify your circuit by encoding your 4 inputs into 2 bits. The drawback is that you can't handle all possible scenarios that can happen.
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
i am very sorry for that the order on the state diagram are P0,PM1,P1,PM0
in the transition table are as they are P0,PM0,P1 and PM1 so i have to fix that...sorry

and for the other question about the buttons...no becouse the professor says that pressing two or more buttons at the same time IS NOT ALLOWED so in my transition table those combinations with more than one logic-1 are 'dont cares'....for example if P0,PM0,P1,PM1,Q is 0,1,0,1,0 in the Q',S and R fields i will put X or b as a 'dont care'...
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
and another thing...i dont need to make an actual circuit from materials...i just need a piece of paper :) just draw the FSM,use SR flip flops to construct the transition table,from there the K-Maps and the expressions for S and R and just draw the circuit....thats it.

the problem is that im confused by the state coding 01 and 10 becouse it scrambles my idea into many question marks and the circuit just dont comes up...how many SR flip flops to use etc.
 

Georacer

Joined Nov 25, 2009
5,182
I agree that you need only one FF. I don't see a reason to insert another one, unless you want to add functionalities like elevator_occupied or elevator_going_up/down. I don't see why your professor wants you to use two FF. If you want, though, we can build a system for two. Your call.

Since you don't have two simultaneous inputs, try the following. Encode your input like so:
Rich (BB code):
P0 PM0 P1 PM1 I1 I2 E
0  0   0   0  0  0  0
0  0   0   1  0  0  1
0  0   1   0  0  1  1
0  1   0   0  1  0  1
1  0   0   0  1  1  1
That way, you convert the 4 inputs into 2 plus 1 that says if any button is pressed. The information content is the same.

Draw your corrected transition diagrams and we'll talk more about it.
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
He does not say that i must use 2 FF... i thought that i need two FF cause of the coding 01 and 10...

I1 and I2 are the floors right? and E is additional signal?
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
ohhh i get it...sorry....so instead of the 4 inputs in the transition table i need to use only these 3 which are basically the same...
 

Georacer

Joined Nov 25, 2009
5,182
I1 and I2, as you probably figured out, are just arbitrary variables that encode which button is pressed. Since we have 5 possible inputs, we need 3 variables (2^2<5<2^3), and E will serve as the third, and additionally as an intuitive way to see if any button is pressed or not.
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
Georacer i am reading something on the internet and i came across ONE-HOT encoding which uses one flip flop for each state...could that be the solution that my professor asks for the two bits that code one state?
 

Georacer

Joined Nov 25, 2009
5,182
One-hot encoding is used in cases that you want to identify your state (or output in general) very quickly and use that one bit of info to do something. As you don't need logic gates to extract which FF is HIGH, the output is obtained without delay (of some nS, but still, a delay).

In you case I bet you don't get for a couple of uS of delay, but you care about keeping things simple. So obviously the 1-FF solution is better suited for your problem.
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
Well i kinda solved it with the 2 FF...im going to work now and im not going to be near a computer...tomorrow i will scan my solution and post it here if that is not a problem so you can see if there is a problem...i will solve it with one FF after that...
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
Hello...this is my solution of the problem with the elevator using 2 SR flip flops becouse of the condition to code the 2 states as 01 and 10...the idea is to indicate that im on the Level_0 when one flip flop is in the set stage and the other is in the reset stage and vice versa for the Level_1.

The attachments are the following:

1.The problem,the FSM,the SR flip flop tables,the coding of the inputs to reduce the K-Map (Thanks to Georacer :) ) ,and the present->next state table.

2.The transition table.

3.KMaps for the SR flip flops.

4.KMaps for the inputs.

5.The realisation of the circuit in Hades.

please notify me if i made a mistake somewhere...

Thanks :)
 

Attachments

Georacer

Joined Nov 25, 2009
5,182
Exemplary work! Well done! I haven't been able to review everything in detail, so I can't say I 'm 100% sure there isn't a typo somewhere, but everything you need is there. I wish everyone who asked for help came up with such work in the end.

For the sake of documentation, can you number your pages to show the thought process?

Also, in your circuit image, the bottom most input is cropped. Could you add that too?

I don't think you had to build the FFs from scratch. Where you specifically told that you mustn't use ready-made FFs in your schematics, or you had trouble finding an SR FF in the software? Admittedly it's not very useful and common.
 

Thread Starter

Meph Floyd

Joined Dec 5, 2011
16
In my assignment on the paper i can use ready-made FF but i wanted to check the circuit in Hades with a few inputs to see if it actualy works...

The pages are:

1.page named IMG.pdf is the FIRST;
2.page named Untitled.jpg with transition table is the SECOND;
3.page named IMG 0002.pdf with KMaps is the THIRD;
4.page named IMG 0003.pdf with KMaps for inputs is the FOURTH;
5.and the picture with the circuit in HADES named HADES.png is the final BUT THE PICTURE IS CROPPED AND YOU CANT SEE THE LAST INPUT SO IN THIS ATTACHMENT YOU HAVE THE WHOLE PICTURE :)

I will be here for further questions or to help out if i can this forum rules :)

Thanks for your help once again...
 

Attachments

Top