Question: Design a vending machine controller for a vending machine that sells an item for 25 cents. The types of coins the vending machine accepts are
Design a vending machine controller for a vending machine that sells an item for 25 cents. The types of coins the vending machine accepts are nickels, dimes, and quarters. The vending machine does not give change (that is, the customer will lose their money if more than 25 cents is inserted before the item is vended). You will design and implement a Finite State Machine (FSM) to control your vending machine. The FSM will keep track of the state of the system, that is how much money has been inserted, and once enough money has been inserted it will turn on the motor to vend the item. As coins are inserted your vending machine controller should also keep track of remaining amount due in order to display how much money is due to purchase the item. Your controller will have six parts: 1. Your FSM which will be implemented as an array of states. Each state is represented by a struct in C where the fields of the struct are the outputs of the controller (the vend motor control signal and the amount due) and the array of pointers to next states. 2. A main function which declares a state pointer, initializes the state pointer to a start state, and then continuously loops. In the infinite loop the following actions will take place: The output will be displayed for the current (present) state (part 4) The input will be read (part 6) The controller will transition to the next state based on the input value by updating the state pointer . 3. A function to generate the control signals for a 7-segment controller based on the digit to be displayed. It should take as input the value of the digit and a period flag. The value of the digit can be 0 to 9The value of the period flag should be 0 for no period and 1 for a period. The function should return the control signals expressed as hexadecimal numbers To the right is a picture of a seven segment display with each segment assigned a letter. You can control the display by writing a 1 to the pin that controls the LED (light emitting diode) for that segment. Assume that the segments can be controlled with a byte (8-bit) control signal where segment a is the most significant bit (msb) bit 7, segment b is bit 6, segment c is bit 5, etc. Bit O controls the period (P) So, to display a "0 the function input would be O for the digit and 0 for the period flag and it should return the following 8-bit value: 11111100 (which is OxFC in hex). To display a "O." the function input would be a 0 for the digit and a 1 for the period flag and it should return the following 8-bit value: 11111101 (which is OxFD). To display a 2" the function input would be 2 for the digit and 0 for the period flag and it should return the following 8-bit value: 11011010 (which is 0xDA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
