International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                               (NCDATES- 09th & 10th January 2015)
 RESEARCH ARTICLE                                                                           OPEN ACCESS
       Implementation of FPGA Based Smart Vending Machine
                                 B Jyothi 1, I. Sarah 2, A. Srinivas 3
          1
            CMR College of Engineering & Technology , Assoc. Prof, E.C.E Dept., Hyderabad, India
                                          Email: jyothiboorla404@gmail.com
         2
           CMR College of Engineering & Technology, Asst. Prof, E.C.E Dept., Narsapur,Medak, India
                                         Email: isarahpaul@gmail.com
         3
           CMR College of Engineering & Technology, Asst. Prof, E.C.E Dept., Narsapur,Medak, India
                                         Email: asrinivas011@gmail.com
Abstract:
A vending machine is a machine which dispenses items such as snacks, beverages, lottery tickets, consumer
products and even gold and gems to customers automatically, after the customer inserts currency or card into the
machine. Vending machines are very common in the countries like Japan, Germany, and U.S. etc. The
requirements of the vending machines are increasing day by day due to the modern and fast life style. The
FPGA based vending machines are more flexible and faster than the CMOS based machines. The FPGA based
vending machine is also programmable and can be reprogrammed whereas in the Embedded based machines we
have to change the whole architecture of the machine if we want to change or enhance the design of the
machine.
     In this paper implemention of vending machine using Finite State Machine (FSM) Model is proposed using
VHDL.FSM modelling is the most important part in developing proposed vending machine model as this
reduces the required hardware. In this project MEALY Machine Model is used to model the process for state i.e.
user selection, waiting for money insertion, product delivery and servicing.
Keywords- FSM, VHDL, Vending Machine, FPGA.
              I. INTRODUCTION
     Vending Machines are used to dispense various         machine can be used at various places like Hotels,
products like Coffee, Snacks, and Cold Drink etc.          Restaurants and food streets. This reduces the time
when money is inserted into it. Vending Machines           and cost.
have been in existence since 1880s. The first                   The      machines     usually      work,    when
commercial coin operated machine was introduced            some money (usually coins or paper money) is put in
in London and England used for selling post cards.         a slot. Then a button needs to be pushed, or a lever
The vending machines are more accessible and               pulled. If there is enough money in the machine, the
practical than the convention purchasing method.           selected item will be dropped to a tray, where it can
Nowadays, these can be found everywhere like at            be taken out by the person making the purchase.
railway stations selling train tickets, in schools and     Older vending machines were mechanical, but most
offices vending drinks and snacks , in banks as ATM        new ones are electronic. Many modern vending
machine and provides even diamonds and platinum            machines can accept debit or credit cards in addition
jewelers to customers. Previous CMOS and SED               to cash.
based machines are more time consuming than the                 Some products need to be prepared to become
FPGA based machines. The FPGA based machine is             available. For example, tickets are printed or
also more flexible, programmable and can be re-            magnetized on the spot, and coffee is freshly
programmed. But in microcontroller based machine,          concocted. One of the most common form of
if one wants to enhance the design, he has to change       vending machine, the snack machine, often uses a
the whole architecture again but in FPGA user can          metal coil which when ordered rotates to release the
easily increase the number of products.                    product.
     In this paper a novel approach is proposed to              In the Western world, some vending machines
design a Vending Machine with auto-billing                 dispense personal products, typically in public toilet
features. The machine also supports a cancel feature       facilities. The machines in ladies' restrooms typically
means that the person can withdraw the request and         sell pads or tampons. The machines in men's rooms,
the money will be returned back to the user. This          when they are present, are most commonly for the
                                                           sale of condoms, though in some locations they may
  CMR Engineering College                                                                         43|P a g e
        International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
        NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                                  (NCDATES- 09th & 10th January 2015)
be found dispensing cologne, medicine, small
candies, or even pornography. These are often found
at toilets used by transient persons in high traffic
locations, such as bus stations, shopping centers,
airports and service stations.
                                                                   Figure 2: MOORE Machine Model
1.1 Operation of Vending Machine
                                                           The paper is organized as: section 2 describes the
   I.     When the user puts in money, money               related work. Section 3 relates the implementation of
          counter tells the control unit, the amount       Vending Machine and section 4 gives the design
          of money inserted in the Vending                 methodology with description of states. Section 5
          Machine.                                         and section 6 shows simulation results and
                                                           conclusion respectively.
  II.     When the user presses the button to
          purchase the item that he wants, the                         II. RELATED WORK
          control unit turns on the motor and                   Various researches have been carried out in
          dispenses the product if correct amount is       order to design the Vending Machines. A few of
          inserted.                                        them are discussed here as: Fauziah Zainuddin [1]
                                                           proposes a vending machine for steaming frozen
 III.     If there is any change, machine will return      food using conceptual modelling. In which the
          it to the user.                                  process of three main states (user selection state,
                                                           freezer state and steaming state) has been modelled
IV.       The machine will demand for servicing            using process approach, which emphasized on the
          when the products are not available inside       process flow or control logic to construct the model
                                                           for steamed buns vending machine application.
          the machine.
                                                           Conceptual modelling is described in [6]. In [4] the
1.2 FSM (Finite State Machine) [2] [3]                     concept of automatic mobile payment is discussed.
                                                           This concept is based on the short message payment
In a Finite State Machine the circuit’s output is          with the main control module M68HC11 and GPRS
defined in a different set of states i.e. each output is   module MC35. Thee various methods of designing
a state. A State Register to hold the state of the         VHDL based machines are discussed in [2], [3]
machine and a next state logic to decode the next          and [9]. Also in [5] the passenger’s requirements
state. An output register defines the output of the        for ticketing system are given. In [7] a coffee
machine. In FSM based machines the hardware gets           vending machine is designed using single electron
reduced as in this the whole algorithm can be
                                                           encoded logic (SEEL). The designed circuit is
explained in one process.
                                                           tested and its power and switching time is
                                                           compared with the CMOS technology.
Two types of State machines are:
MEALY Machine: In this machine model, the                    III. IMPLEMENTATION OF VENDING
output depends on the present state as well as on                       MACHINE
the input. The MEALY machine model is shown                    In this paper a state diagram is constructed for
in figure 1.                                               the proposed machine which can vend four
                                                           products that is coffee, cold drink, candies and
                                                           snacks. Four select (select1, select2, select3,
                                                           select4) inputs are taken for selection of products.
                                                           Select1 is used for the selection of snacks.
                                                           Similarly select2, select3, select4 are used for
                                                           coffee, cold drink and candies respectively. Rs_10
          Figure 1: MEALY Machine Model                    and rs_20 inputs represents rupees 10/- and 20/-
                                                           notes respectively. A cancel input is also used
MOORE Machine: In Moore machine model                      when the user wants to withdraw his request and
the output only depends on the present state.              also the money will be returned through the return
The MOORE machine model is shown in figure                 output. Return, product and change are the
2.                                                         outputs. Return and change vectors are seven bits
   CMR Engineering College                                                                       44|P a g e
          International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
          NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                                    (NCDATES- 09th & 10th January 2015)
  wide. Money is an in/out signal which can be               product to be dispensed. This state can be one of the
  updated with the total money of all products               select1, select2, select3 and select 4. The machine
  delivered at a time. Money signal is seven bits            can accept only two types of notes i.e. rupees 10/-
  wide. Money_count is an internal signal which              and 20/-. Let us suppose that the user selects sel1
  can be updated at every transition. This signal is         input. The machine will firstly check that whether
  also seven bits wide. If the inserted money is             the products are available in the machine or not.
  more than the total money of products then the             After this the control unit will move to the waiting
  change will be returned through the change output          state, where it will wait for the money to be inserted.
                                                             Then if rupees 10/- note is inserted then the machine
  signal. The products with their prices are shown
                                                             will go to state_1 and wait until the desired money is
  by table 1. There are also two input signal clk and
                                                             inserted. And if rupees 20/- note is inserted the
  reset. The machine will work on the positive edge
                                                             machine will move to state_2 and then wait until
  of clock and will return to its initial state when         30/- rupees are inserted to the machine. When the
  reset button is pressed. The proposed vending              desired amount is inserted the machine will go to the
  machine is designed using FSM modelling and is             snacks state and snacks will be delivered at the
  coded in VHDL language. The detail of the entire           product output. If products are not available in the
  signal with their direction and description is             machine then the control unit will demand for
  shown in table 2.                                          servicing and after service the machine will get
                                                             reset. This methodology is explained using a flow
  Table 1: Products with their prices                        diagram shown in figure 3.
      S.No.            Products         Price
        1.              Snacks          30/-
          2.            Coffee           40/-
          3.           Cold drink        40/-
          4.            Candies          30/-
  Table 2: Inputs/Outputs with Remarks
 Name          Width       Direction     Description
  clk           1            input          Clock
 Reset          1            Input        Syn reset
 Sel1           1            input         Snacks
 Sel2           1            input         Coffee
 Sel3           1            input       Cold drink
 Sel4           1            input         Candies
Cancel          1            input         Cancel
Money           7            inout      Total money
Rs_10           1            input       Rupees 10/-
Rs_20           1            input       Rupees 20/-
Product         1           output       Product out
Change          7           output      Extra change
Return          7           output      Return money
           IV. DESIGN METHODOLOGY
       The state diagram mainly consists of four states      Figure 3: Flow Chart for Proposed Vending
  (User Selection, Waiting for the money insertion,          Machine
  product       deliveryand         servicing      (when
  product_not_available=’1’)). Initially when the reset
                                                             There is also an additional feature of withdrawing
  button is pressed, the machine will be ready for the
  users to select the product. This state is the initial
                                                             the request if the user doesn’t want to take the
  state of the design. After this the user will select the   product. When cancel button is pressed then the
     CMR Engineering College                                                                        45|P a g e
        International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
        NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                                  (NCDATES- 09th & 10th January 2015)
money inserted will be returned to the user                        When state_2=> 
through the return output. A money_count signal             
is used for calculating the total money inserted in                     Rs_10=0 & rs_20=1; 
the machine. And if the money inserted is more
than the money of the product then the extra                            Change=0;            Product=1;
change will be returned to the user. The total
amount of the product taken at a time is shown by                       Money_count=money_count+20;
the money signal. Similarly the user can select
and get the other products following the above
procedure.                                                         When snacks=>
                                                                    Money_count>=30;
                                                                    Product=1;
Description of states                                               Change=money_count-30;
The selection of products and all the states are                    Snack_count=snack_count-1;
shown below in figure 4.                                         When service=>
         When initialize=>                                         snack_count=
                  money_count=0;
                                                                    4 product<=0;
                  Change=0;
                                                                    next_state<=resett;
                  Product=0;
                                                                 When cancel1=>
         When select1=>
                  Sel1&!sel2&!sel3&!sel4
                                                                    cancel=1;
                  When                                              return<=money_count;
                  product_available=1=>nx_st1<=w            Similarly we can select other products (coffee,
                  aiting1;                                  Cold drink and candies).
                  When
                  product_available=0=>nx_st1<=se                    V. SIMULATION RESULTS
                  rvice1;                                       The state diagram shown in figure 4 is
         When waiting1=>                                   simulated using Xilinx ISE Simulator. Simulation
                  When                                      Waveforms for the selection of four products like
          rs_10&!rs_20=>nx_st1<=state_1;                    snacks is shown in figure 5 and 6 respectively
                  When ! rs_10&                             with servicing feature when products are not
          rs_20=>nx_st1<=state_2;                           available in the machine and change return
                  Change =0; Product=0;                     features when the money inserted is more than the
                  When money_count>=30                      money of the product.
          nx_st1<=snacks;                                       Let us take an example that the user wants to
         When state_1=>                                    take Snacks. When one selects sel1 button, the
          Rs_10=1&rs_20=0;
                                                            machine will check that whether the products are
          Change =0; Product=0;
                                                            available or not, if available then it will go to the
           money_count=money_count+10;
                                                            waiting state and wait for total money insertion. If
                                                            rs_10 note is inserted it will go to state_1 and if
                                                            rs_20 note is inserted it will so to state_2 and
                                                            check whether money_count>=30 or not. If the
                                                            money_count >- 30 then machine will go to state
                                                            snacks and vend the product.
                                                            1. Price of the Product is Rs. 3
                                                            Return of Rs. 2 after the Cancel (pu) button is
                                                            pressed.
Figure 4: Finite State Machine Diagram of Vending Machine
  CMR Engineering College                                                                         46|P a g e
        International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
        NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                                  (NCDATES- 09th & 10th January 2015)
                                                     RTL Schematic:
                       Fig 5.1 Return Money
2.     Product Delivery and Return of Change after
       Rs. 4 insertion.
                                                          Fig 5.5 RTL schematic of Vending Machine
                                                          Logic utilization          Used Available            Utilization
                                                      Number of Slices              228         3584              6%
     Fig 5.2 Product delivery and Return of change    Number of Slice flip flops    98          7168              1%
                                                      Number of 4 input LUT’s       432         7168              6%
3.   Product Delivery after Rs. 3 insertion
                                                      Number of bonded IOB’s         31         173              17%
                                                      Number of GCLK’s                1           8              12%
                                                       Table 3: Device Utilization Summary
                                                      The comparison of VHDL based machine with
                                                      the CMOS technology based machine on the
                                                      basis of switching speed is shown in table 4.
                                                     Table 4: Comparison of Switching Speed
                     Fig 5.3 Product deliver                                                Using
                                                      Parameter using FPGA Single Electron CMOS
                                                                            Device (SED) technology
                                                      Switching Speed 9.3 ns         12.53 ns          300ns
                                                                    VI. CONCLUSION
                                                          When we realized that we have at last made a
                                                     code that could actually work as a user friendly
                                                     vending machine. This code can actually provide a
                                                     variety of options to the user and also return him/her
                 Fig 5.4 Product delivery
                                                     the balance money. This verilog code has been
                                                     successfully verified using the Xilinx ISE 9.2i tool
     CMR Engineering College                                                                47|P a g e
        International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622
        NATIONAL CONFERENCE on Developments, Advances & Trends in Engineering Sciences
                                  (NCDATES- 09th & 10th January 2015)
and the desired outputs have been achieved. Vending     [6]  C. J Clement Singh, K Senthil Kumar,
Systems enhances productivity, reduces system                Jayanto Gope, Suman Basu & Subir Kumar
development cost, and accelerates time to market.            Sarkar (2007) “ Single Electron Device
Vending machine gives fast response and is easy to           based Automatic Tea Vending Machine”
use by an ordinary person. The designed machine              proceedings of International Conference on
can be used for many applications and we can easily          Information       and       Communication
enhance the number of selections. The next stage of          Technology in Electrical Sciences (ICTES
this study is to convert this model into hardware and        2007) , pp 891-896.
to calculate the total power consumption of the         [7] P. Smith (1997) “Automatic Hot-food
machine. Thus we would conclude saying that we               Vending Machine,” Trends in Food Science
tried our bit to modify the present day complex              & Technology October 1997, Vol. 81, and
vending machine into a user friendly and user                pp. 349.
specific vending machine.                               [8] M. Zhou, Y. J. Son, & Z. Chen, (2004),
                                                             “Knowledge Representation for Conceptual
                   Future Work:                              Simulation Modeling” Proceedings of the
     Vending Machines designed in this way can be            2004 Winter Simulation Conference, pp. 450
used to dispense single products, cancel request and         – 458.
auto billing features are added by FPGA                 [9] Muhammad Ali Qureshi, Abdul Aziz &
implementation which are not provided by                     Hafiz     Faiz   Rasool     “Design    and
embedded systems design in future we can use other           Implementation of Automatic Ticket System
methods for dispensing multiple products at the              using Verilog HDL” proceedings of
same time, which will be more comfortable to the             tnternational conference on Information
user.                                                        Technology, pp- 707-712.
                                                        [10] Steve Kilts,” Advanced FPGA Design:
                  REFERENCES                                 Architecture,      Implementation,     and
  [1]    Fauziah Zainuddin, Norlin Mohd Ali,                 optimization”, Wiley-IEEE press, 2007.
         Roslina Mohd Sidek, Awanis Romli,              [11] Seyed Bahram Zahir Azami & Mohammad
         Nooryati Talib & Mohd. Izham Ibrahim                Tanabian “Automatic Mobile Payment on a
         (2009)      “Conceptual    Modeling      for        non-     Connected    Vending     Machine”
         Simulation:     Steaming     frozen    Food         proceedings of Canadian Conference on
         Processing     in     Vending      Machine”         Electrical and Computer Engineering, 2004,
         International Conference on Computer                pp- 731-734.
         Science and Information Technology,
         University Malaysia Pahang, pp.145-149.
  [2]    Zhang Wen & Zhang Xin Long (2010)
         “Design and Implementation of automatic
         vending machine Based on the short
         massage payment” International Conference
         on Information and          Communication
         technology in Electrical Sciences, Neijiang,
         Sichuan, China.pp.978-981.
  [3]    B. Caulfield & M.O Mahony (2005)
         “Passenger Requirements of a Public
         Transport Ticketing System” Proceedings of
         the 8th International IEEE Conference on
         Intelligent Transportation Systems Vienna,
         Austria, pp-32-37.
  [4]    M. Zhou, Q. Zhang & Z. Chen (2006),
         “What Can Be Done to Automate
         Conceptual      Simulation      Modelling?”
         Proceedings of the 2006 Winter Simulation
         Conference, pp. 809 – 814.
  [5]    Biplab Roy & Biswarup Mukherjee (2010)
         “Design of Coffee Vending Machine using
         Single Electron Devices” Proceedings of
         2010 International Symposium on Electronic
         System Design. Pp 38-43.
  CMR Engineering College                                                                48|P a g e