TOA Practical Examples of Finite State Machines
TOA Practical Examples of Finite State Machines
The system starts with the green light turned on as output. Once a light is turned on, it should
stay that way for a certain minimum time, say 10 seconds, and then only change when a car
comes up or time expires. Green will be changed to Yellow to Red when timer expires. And
Red will change to Orange to Green if timer expires or there is a car at the front.
An ATM is a machine that allows you to withdraw money, deposit cash or checks, view your
balance or transfer money between accounts.
An ATM is a machine that lets you do banking tasks on your own without needing to go inside a
bank. It works like a computerized kiosk. Users insert their debit or credit card, enter their PIN,
and then select from a menu of available services. These services can include withdrawing cash,
depositing money, transferring funds, paying bills, checking balances, and more. The ATM
executes the selected transaction, dispenses cash or accepts deposits, and provides a printed
receipt for record-keeping.
-----------------------------------------------------------------------------------------------------
3. Explain the working of any Vending Machine along with its DFA with output.
a) The vending machine I used, is one where you need 75 cents to dispense the object from
the machine. The machine only takes a quarter (25 cents) or a dollar (100 cents). In case
a person puts a dollar in the machine, along with the object being dispensed there is also
25 cents/ 1 quarter returned as change. On the other hand, if the person puts 3 quarters,
there will be no change and only the object will be dispensed.
c) Based on the state diagram, and the working of the vending machine we get the
following state diagram:
4. Explain the working of 2-bit and 3-bit shift registers along with their DFAs. Also
mention their use in computer electronics.
The shift register is capable of shifting its binary contents in one or both directions. It
shifts its contents a bit each clock plus. It uses a cascade of flip flops where the output of
the flip flop is the input of the next flip flop.
An n-bit shift register is formed from n flip-flops, where each flip-flop stores one bit
The following is the state diagram for the 2-bit shift register
output 0 1
00 00 01
01 10 11
10 00 01
11 10 11
The following is the state diagram for the 3-bit shift register:
output 0 1
000 000 100
001 000 100
010 001 101
011 001 101
100 010 110
101 010 110
110 011 111
111 011 111
Use in CS:
Since shift registers are used for data movement or data storage their use in computer science
is inside calculators. To store two numbers before they are added or to convert data from
serial to parallel and from parallel to serial.
----------------------------------------------------------------------------------------------------------------
Q={ ready,
wash,
rinse ,
spin
}
∑={ insert coin,
Timer complete,
Press start,
cancel
}
q° = { idle }
F = { idle}
δ = { idle -> insert coin = ready,
ready -> cancel = idle,
ready -> press start = wash,
wash -> timer complete = rinse,
rinse -> timer complete = spin,
spin -> cancel ,complete = idle,
wash -> cancel = idle,
rinse -> cancel = idle }
-----------------------------------------------------------------------------------------------------------------
6. Design a Transducer (Mealy/Moore) to represent the following bar code
case study.
A bar code represents bits as alternating light and dark bands. The light bands are of uniform width,
while the dark bands have width either equal to, or double, the width of the light bands. Below is an
example of a code-word using the bar code. The tick marks on top show the single widths.
Assume that a bar-code reader translates the bands into symbols, L for light, D for dark, one symbol
per single width. Thus the symbol sequence for the code-word above would be
LDLDDLDDLDLDDLDL
A bar pattern represents a binary sequence as follows: a 0 is encoded as LD, while a 1 is encoded as
LDD. A finite-state transducer M can translate such a code into binary. The output alphabet for the
transducer is {0, 1, _, end}. When started in its initial state, the transducer will "idle" as long as it
receives only L's. When it receives its first D, it knows that the code has started. The transducer will
give output 0 or 1 as soon it has determined the next bit from the bar pattern. If the bit is not known
yet, it will give output _. Thus for the input sequence above, M will produce
__0_1__1__0_1__0
LDLDDLDDLDLDDLDL
where we have repeated the input below the output for convenience. The transducer will output the
symbol end when it subsequently encounters two L's in a row, at which point it will return to its
initial state.
1. Give the state diagram for transducer M, assuming that only sequences of the indicated form can
occur as input.
2. Certain input sequences should not occur, e.g. L D D D. Give a state-transition diagram for an
acceptor A that accepts only the sequences corresponding to a valid bar code.
------------------------------------- THE END --------------------------------------------------------------