Module 3
Module 3
As seen from the FSM, the timer state can be either ‘IDLE’ or
‘READY’ or ‘RUNNING’
State Machine Model
• When the timer is not running, it is said to be in the ‘IDLE’
state that is in normal condition.
• The timer is said to be in the ‘READY’ state when the timer
is loaded with the count corresponding to the required
time delay and it remains in the ‘READY’ state until a ‘Start
Timer’ event occurs.
• The timer changes its state to ‘RUNNING’ from the
‘READY’ state on receiving a ‘Start Timer’ event and
remains in the ‘RUNNING’ state until the timer count
expires or a ‘Stop Timer’ even occurs.
• The timer state changes to ‘IDLE’ from ‘RUNNING’ on
receiving a ‘Stop Timer’ or ‘Timer Expire’ event.
State Machine Model
• Design an automatic tea/coffee vending machine based on
FSM model for the following requirement.
“The tea/coffee vending is initiated by user inserting a 5
rupee coin. After inserting the coin, the user can either
select ‘Coffee’ or ‘Tea’ or press ‘Cancel’ to cancel the order
and take back the coin”.
State Machine Model
• It contains four states namely; ‘Wait for coin’ ‘Wait for
User Input’, ‘Dispense Tea’ and ‘Dispense Coffee’.
• The event ‘Insert Coin’ (5 rupee coin insertion), transitions
the state to ‘Wait for User Input’ and waits until it receives
‘Cancel’, ‘Tea’ or ‘Coffee’ button press.
• If the event triggered in ‘Wait State’ is ‘Cancel’ button
press, the coin is pushed out and the state transitions to
‘Wait for Coin’ else is either ‘Tea’ button press, or ‘Coffee’
button press, the state changes to ‘Dispense Tea’ and
‘Dispense Coffee’ respectively.
• After vending coffee/tea is over, the respective states
transitions back to the ‘Wait for Coin’ state.
State Machine Model