Interactive FSM
In this module, you will learn how to use a Final-State-Machine(FSM) which describes the working of a Soda vending machine:
Problem
Assume, you have a soda vending machine which sells soda cans of cost 15¢ each, and you have only 2 types of coins: 10¢ and 5¢.
In this problem, our goal is to make a state machine which can determine, how much change should be returned, and when a can is dispenced.
Note: In this design, ignore the capacity of the stock, which means, we’ll assume that there will always be can in the vending machine.
Also, you can assume that only one action could be made in every “clock cycle” or state.
Rules
- First, give the change.
- Then dispense the can.
Understanding the possibilities
There are quite some options like:
- entering no money.
- putting 5¢ followed by another 10¢ => getting the can.
- putting 10¢ followed by 10¢ => receiving change => getting a can.
- putting 5¢ followed by 5¢ followed by 10¢=> receiving change => getting a can.
- putting 10¢ followed by 5¢ and getting the can.
- putting 5$ followed by 5¢ followed by 5¢ => getting a can.
FSM diagram
Now translate the options which are listed above into an FSM diagram/flow-chart:
The 'idle' state will be the first state, the machine will be, when its has been 'turned on', and in this the state we also 'Reset' the machine into. Note: The FSM is the Moore machine, because the current state related to the output.
Experiment
Lets try the soda can vending machine and look for the corresponding state changes FSM diagram in each of the above mentioned possibilities.