Mechatronics Portfolio - Nick Greco
Lab 0x01: Virtual Vending Machine

Summary

Finite-state machine design, with th eurpose of returning minimum change, was used to create a virtual vending machine. The vending machine simulates drink selection & payment via keyboard entries.

Source Code can be found here: https://bitbucket.org/nicho755/me-305-labs/src/master/ME405_Lab0x01_Vendotron/ME405_Lab0x01.py

Engineering Requirements

The vending machine has four input buttons representing four different beverages that users can select from with corresponding prices: 1) Cuke = $1.00 2) Popsi = $1.20 3) Spryte = $0.85 4) Dr. Pupper = $1.10

In addition, the machine take in user input in the form of money being inserted through the "Insert Coin" slot and requesting for the current balance to be returned via the eject button. The machine will output strings on the LCD screen and display current balance, insufficient funds, drink output confirmation, and amount of change returned.

To ensure the machine runs like a finite state machine, the script cannot include any blocking, or input, commands, the program must account for the following behavior:

  • On startup: Vendotron displays an initialization message on the LCD screen.
  • At any time a coin may be inserted: When a coin is inserted, the balance displayed on the screen must reflect so.
  • At any time, a drink may be selected:
    1. If the current balance is sufficient, Vendotron vends the desired beverage through the flap at the bottom of the machine and then correct change is provided through the coin return.
    2. If the current balance is insufficient then the machine displays an Insufficient Funds message and then displays the price for the selected item.
  • At any time the Eject button may be pressed: When the eject button is pressed, the machine returns the full balance through the coin return. The balance should contain change in the least number of denominations.
  • The vending machine must prompt the user to select a second beverage if there is remaining balance.

Vending Machine Finite State Machine Diagram

Below is the finite state machine diagram for the vending machine. (Adapted from my HW 0x00 submission)

Figure 1. Vendotron Finite-State Machine

User Interaction

Users are able to input the following valid commands via keyboard
Payment Input
'0' - insert 1 cent
'1' - insert 5 cents
'2' - insert 10 cents
'3' - insert 25 cents
'4' - insert 1 dollar
'5' - insert 5 dollars
'6' - insert 10 dollars
'7' - insert 20 dollars
Selecting Drink:
'C' or 'c' - select Cuke
'P' or 'p' - select Popsi
'S' or 's' - select Spryte
'D' or 'd' - select Dr. Pupper
Return Balance
'E' or 'e' - eject change