FSM Example
Design a vending machine followed by below specifications:-
Soda cost 9000, Water cost 7000.-
The machine accepts 1000, 2000 and 5000 coin.-
Give a change as small as possible.-
If the total coin pushed into machine already equaled or greater than 9000,the
machine has no longer accepts the coins and put it back.-
Coin return button: put all the coins that user pushed into machine out.-
If no buttons pressed, keep the state.-
Output:
+ Coin return out
+ Water out
+ Soda out
+ Changes
Finite State Machine
State Init: all output = 0 ; wait for user push coins into-
State Coin1: user had pushed coins into machine but the money was < 7k-
State Coin2: the money was equal or greater than 7k but smaller than 9k,Water
is ready now-
State Coin3: the money was greater than 9k already, cannot accept any more
coin. Water and Soda is ready-
State Water : output of Water is set, and if money input greater than 7k,change
will gave back to user.-
State Soda : similar state water-
State Return: Return all money when return button was pressed