Question

Design a FSM for a Vending Machine In this task, you will design a FSM for...

Design a FSM for a Vending Machine

In this task, you will design a FSM for a simple (albeit strange) vending machine of office supplies. The vending machine sells three possible items, each at a different cost:

Item Cost
Pencil 10 cents
Eraser 20 cents
Pen 30 cents

The vending machines accepts nickels (worth 5 cents), dimes (worth 10 cents), and quarters (worth 25 cents). Physically, it is only possible to insert a single coin at a time. The vending machine features a large button labeled “DONE”, which, when pressed, will dispense the most expensive item which can be purchased with the input money. For example, if a dime and two nickels had been entered (totalling 20 cents), then it would dispense an eraser upon pressing “DONE”. Once an item is dispensed, the vending machine returns to an initial state wherein it shows that no money has been inserted.

To help simplify things, the vending machine does not provide any change. This means that any additional money provided will be lost. For example, if a quarter had been entered and then “DONE” pressed, the vending machine would dispense an eraser (because this is the most expensive item which can be purchased with 25 cents), and then the vending machine would return to the point where it shows that no money has been entered. As another example, if two quarters had been entered, then upon pressing “DONE”, it would dispense a pen (the most expensive item purchasable with 50 cents), and then the vending machine would return to the point where it shows that no money has been entered.

While there are different ways to model these different parameters as inputs, your FSM should deal with the following inputs:

Input Description
K Set to 1 if a nickel has been entered, else 0
D Set to 1 if a dime has been entered, else 0
Q Set to 1 if a quarter has been entered, else 0
E Set to 1 if “DONE” has been pressed, else 0

In addition to the above inputs, you’ll also need to specify what the current state is, which should be indicated with inputs C0 through CN, where N is the position of the greatest possible bit in your state encoding. For example, if you needed eight states in your FSM, then you’d have inputs C0, C1, and C2, as eight states can be uniquely encoded using three bits.

Similarly to the inputs, the output parameters can be modeled in different ways. However, for the sake of consistency across different solutions, your FSM should deal only with the following outputs:

Output Description
DPENCIL Short for “Dispense Pencil”. Set to 1 if we should dispense a pencil, else 0.
DERASER Short for “Dispense Eraser”. Set to 1 if we should dispense an eraser, else 0.
DPEN Short for “Dispense Pen”. Set to 1 if we should dispense a pen, else 0.

In addition to the above outputs, you’ll also need to specify what the next state is, which should be indicated with outputs N0 through NM, where M is the position of the greatest possible bit in your state encoding. For example, if you needed eight states in your FSM, then you’d have inputs N0, N1, and N2, as eight states can be uniquely encoded using three bits.

This overall task is separated into a series of questions.

1. Draw the finite state machine corresponding to this task.

2. How many latches/flip-flops do you need to implement this state machine? (Hint: this corresponds to the number of bits necessary in order to encode all possible states uniquely.)

3. Draw a single truth table representing the behavior of the state machine. Be sure to label your states in binary. Your table should have inputs and outputs corresponding to the inputs and outputs described previously.

To simplify things, you may put don't cares where appoproiate in the inputs. For example, because it is physically impossible to insert more than a single coin at a time, if input K = 1 (indicating a nickel has been inserted), then inputs D and Q can be safely labeled as don't cares, as implicitly they should always be 0 (and in reality we ignore their values entirely in this situation). With this setup, we can cut down on the number of repeated rows; instead of having two rows which differ in only whether or not Q is set, we can have a single row where Q = X.

__________________________________________________________________________________________________________________

The following are a series of hints which may be of use:

---You may assume only one coin is ever entered at a time. For example, this means that if D = 1 (indicating a dime was entered), then it is guaranteed that K = 0 and Q = 0 (indicating a nickel and a quarter were not entered, respectively). Similarly, you don't need to worry about the user inputting multiples of the same coin at once (e.g., two quarters at once), which does not have a possible encoding in this setup. The practical advantage of this assumption is that transitions will only ever depend on one input at a time; you'll never need a transition which corresponds to the user inputting a combination of coins.

---You may assume that “DONE” is pressed only after all coins have been entered. Similar to the previous assumption, this means you don't need to worry about a case where the user inputs a coin while simultaneously pressing “DONE”. For example, if E = 1, then it is guaranteed that K = 0(meaning no nickels were inserted).

---You may assume that when “DONE” is pressed, the user will provide no more input until the vending machine has finished dispensing the most expensive item purchasable with the input money. This means that until the vending machine returns to the original state it started in with no input money, K = 0, D = 0, Q = 0, and E = 0.

---You may assume that the vending machine does not provide any change, and gives no indication to the user when money has simply been eaten. As with the example before, this means that if more money was provided than needed (e.g., providing 25 cents to purchase a 20 cent eraser), then the additional money simply disappears. Similarly, if the user does not provide enough money to purchase anything (e.g., inserting only a nickel and subsequently pressing “DONE”), then no items should be dispensed, but the vending machine will still return to the initial state.

---To help keep your diagrams clean, you need only indicate outputs when the output would be 1. For example, if in one particular state a pencil should be dispensed, then in this particular state DPENCIL should be indicated. In all other states, simply omitting DPENCIL is equivalent to outputting that DPENCIL = 0.

---As for what your states in this vending machine indicate, probably the simplest approach is to have a distinct state for each amount of currency which can be deposited. At the very least, this means having states corresponding to 5 cents deposited, 10 cents deposited, 15 cents deposited, and so on. While your vending machine will likely need more states than this, the bulk of the states work in this fashion.

---Technically, a user can input an arbitrarily large amount of money into the machine. However, you don't need to worry about this too much, as the vending machine only dispenses one item at a time, and provides no change. As such, inputting 30 cents (enough to buy a pen, the most expensive item), is no different than inputting 35 cents or more.

Homework Answers

Answer #1

The following is the mealy FSM of the system

The rectangular boxes represent the various states.

The elipses represent the outputs (since this is a mealy implementation, the outputs depend on the transition and not the state)

Method:

Start with the worst case scenario, that’s a lousy customer who wants to buy a pen in nickels.

So we get 5, 10, 15, 20, 25, 30 cents received as the various states. Any value more than 30 cents is simply equivalent to 30. 10 cents is 10 cents. Doesn’t matter if it’s two nickels or a dime. So these are all the states we need. No more.

Now just see where adding a dime or quarter to any value gets you and add those transitions.

No of flops required: 3 (cuz 7 states) and 2^3=8>7

               

Now that’s a big table!

Draw it taking reference from the diagram

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Design a Sequence Recognizer that will recognize the sequence 101101 by designing a finite state machine...
Design a Sequence Recognizer that will recognize the sequence 101101 by designing a finite state machine (FSM). The input will be (X) and when the pattern is seen the output (Z) will be 1. Example: X = 1 0 1 0 1 1 0 1 1 0 1 1 Z = 0 0 0 0 0 0 0 0 1 0 0 1 a. Make a state diagram for the process using the Moore Machine model b. Make a next...
Design a Sequence Recognizer that will recognize the sequence 101101 by designing a finite state machine...
Design a Sequence Recognizer that will recognize the sequence 101101 by designing a finite state machine (FSM). The input will be (X) and when the pattern is seen the output (Z) will be 1. Example: X = 1 0 1 0 1 1 0 1 1 0 1 1 Z = 0 0 0 0 0 0 0 0 1 0 0 1 a. Make a state diagram for the process using the Moore Machine model b. Make a next...
Design a sequential circuit to control a gumball machine. Gumballs are 15 cents each. The machine...
Design a sequential circuit to control a gumball machine. Gumballs are 15 cents each. The machine accepts nickels (N) or dimes (D), but only one coin at a time. When the appropriate amount of money has been provided, the machine should dispense a gumball (G). it should also give change (C) back to the person at the same time if necessary. Follow the sequential design procedures set out in the course. Implement and test this circuit. Specifically, show what happens...
Design a door code detector (Mealy machine) that has two inputs S and Y where S...
Design a door code detector (Mealy machine) that has two inputs S and Y where S is the start signal (by a push button) and Y gives the code that is a sequence of logic 0’s and 1’s (by a switch). The detector has one output Z (LED). To open the door (i.e., Z=1), you have to press the S button once and after that, input Y with sequence 100*10 where 0* means zero or more (i.e., any number of)...
Design a counter which counts in the sequence that has been assigned to you. Use D...
Design a counter which counts in the sequence that has been assigned to you. Use D flip flops and NAND gates. Simulate your design using SimUaid. Submit the state table, D flip-flop input equations, and transition graph determined in Part 6. The D flip-flop equations can be derived using Karnaugh maps or using LogicAid by entering a state table with zero input variables. Sequence: 000,100,001,110,101,111,(repeat) 000,... Also, please answer the following questions: How can a D flip-flop be set to...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
Create a State machine diagram, class diagram and a sequence diagram A description of the System...
Create a State machine diagram, class diagram and a sequence diagram A description of the System Hjolaleidir.is - Better Biking routes The group “Better biking routes” has got the idea of making the website: hjolaleidir.is for cyclists in the greater Reykjavik area. The group “Better biking routes” want to make the website accessible for a broad spectrum of users. They are catering to users who want information about good routes from a place to a destination and users who wish...
Problem a (PA5a.java) Write a program that deals with inflation, which is essentially the rising cost...
Problem a (PA5a.java) Write a program that deals with inflation, which is essentially the rising cost of general goods over time. That is, the price of goods, such as a packet of peanuts, goes up as time goes by. So, you will write a program to gauge the expected cost of an item in a specified number of years. The program asks for the cost of the item, the number of years, and the rate of inflation. The output is...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT