hdl implementation of vending machine controller

31
Mini Project Report

Upload: pratik-patil

Post on 20-Oct-2015

111 views

Category:

Documents


0 download

DESCRIPTION

To design a Vending Machine which accepts money inputs in any sequence and deliversthe product when required amount is been deposited and gives back the change. It is alsopossible to withdraw the deposited money in between, if consumer wishes by pressing abutton.

TRANSCRIPT

HDL Implementation of Vending Machine Controller

HDL Implementation of Vending Machine Controller2013

Mini Project Report2013HDL Implementation of Vending Machine ControllerUsing Verilog code on Xilinx ISE 9.2i and ModelsimPratik Patil, Belgaum

ABSTRACTA vending machineis amachinewhich dispenses items such as snacks, beverages, lottery tickets, consumer products to customers automatically, after the customer inserts currencyorcreditinto the machine. Nowadays, Vending Machines are well known among Japan, Malaysia and Singapore. The quantity of machines in these countries is on the top worldwide. This is due to the modern lifestyles which require fast food processing with high quality. This paper describes the designing of Vending Machine with Auto-Billing Features. The objective here is to design Vending Machine Controller which accepts money inputs (i and j) in any sequence and delivers the products when the required amount has been deposited and gives back the change. Here an additional facility is provided to the user. It is possible to withdraw the deposited money in between if the customer wishes so by pressing a push button. The Verilog Code for the proposed Vending Machine model is developed and the Simulation results are successfully verified using Xilinx ISE 9.2i tool.

TABLE OF CONTENTS

CHAPTERPAGE NO.

1. INTRODUCTION042. VENDING MACHINE AND ITS HISTORY053. DESIGN METHODOLOGY084. IMPLEMENTATION METHODS115. ADVANTAGES AND DISADVANTAGES136. VERILOG CODE157. SIMULATION AND RESULTS188. CONCLUSION229. REFERENCES23

CHAPTER 1INTRODUCTIONVending Machines are used to dispense various products like Coffee, Snacks, and Cold Drink etc. when money is inserted into it. Vending Machines have been in existence since 1880s. The first commercial coin operated machine was introduced in London and England used for selling post cards. The vending machines are more accessible and practical than the convention purchasing method. Nowadays, these can be found everywhere like at railway stations selling train tickets, in schools and offices vending drinks and snacks , in banks as ATM machine and provides even diamonds and platinum jewelers to customers. Previous CMOS and SED based machines are more time consuming than the FPGA based machines. The FPGA based machine is also more flexible, programmable and can be re-programmed. But in microcontroller based machine, if one wants to enhance the design, he has to change the whole architecture again but in FPGA user can easily increase the number of products.In this paper a new approach is proposed to design a Vending Machine with auto-billing features. The machine also supports a cancel feature means that the person can withdraw the request and the money will be returned back to the user. This machine can be used at various places like Hotels, Restaurants and food streets. This reduces the time and cost.

CHAPTER 2VENDING MACHINE AND ITS HISTORY

Avending machineis amachinewhich dispenses items such as snacks, beverages, alcohol, cigarettes, lottery tickets, cologne, consumer products and even gold and gems to customers automatically, after the customer insertscurrencyorcreditinto the machine.

HistoryThe earliest known reference to a vending machine is in the workofHero of Alexandria, a first-century engineer and mathematician.His machine accepted a coin and then dispensed holy water.Whenthe coin was deposited, it fell upon a pan attached to a lever.The lever opened a valve which let some water flow out. The pancontinued to tilt with the weight of the coin until it fell off, at whichpoint a counterweight snapped the lever up and turned off the valve.

Modern vending machinesThe first modern coin-operated vending machines were introduced in London,Englandin the early 1880s, dispensing post cards. The machine was invented by Percival Everitt in 1883 and soon became a widespread feature at railway stations andpost offices, dispensingenvelopes,postcardsandnotepaper. The Sweetmeat Automatic Delivery Company was founded in 1887 in England as the first company to deal primarily with the installation and maintenance of vending machines. The first vending machine in the U.S. was built in 1888 by theThomas Adams Gum Company, selling gum onNew York Citytrain platforms. The idea of adding games to these machines as a further incentive to buy came in 1897 when the Pulver Manufacturing Company added small figures, which would move around whenever somebody bought some gum from their machines. This idea spawned a whole new type of mechanical device known as the "trade stimulators". The birth ofslot machinesand pinball is ultimately rooted in these early devices.In December 1970, Ussery Industries of Dallas, Texas at its Dallas convention displayed its "talking" vending machine, the Venda Talker. With insertion of a coin, the machine said "thank you" and added a one-liner voiced by comic Henny Youngman.In theWestern world, some vending machines dispense personal products, typically in public toilet facilities. These are often found at toilets used by transient persons in high traffic locations, such as bus stations, shopping centers, airports and service stations.From the 1950s until well into the 1970s, vending machines were used at American airports to sell life insurancepolicies covering death, in the event that the buyer's flight crashed. Such policies were quite profitable, because the risk of a plane crash is low. However, this practice gradually disappeared due to the tendency of American courts to strictly construe such policies against their sellers, such asMutual of Omaha. Starting with 1994, vending machines approached successfully the basic food commerce specialization and began to compete with theFast-Moving Consumer Goodsindustry. Milk dispensers and egg vending machines networks spreading in European towns accelerated after 2000.The basic food vending machines are usually owned byfarmersselling their production directly to consumers, providing fresh food to urban population at low prices, small operational costs and encouraging thedistributism.Another type of vending machine is aChargeboxwhich is used for charging small mobile devices such asmobile phonesandiPods. They are useful for when one runs out of power on such devices in between locations like home and work.From 2000-2010, specialization of vending machines became more common. Vending extended increasingly into non-traditional areas like electronics, or even artwork.Machines of this new category are generally calledAutomated Retailkiosks. The trend of specialization and proliferation of vending machines is perhaps most apparent in Japan where vending machines sell products from toilet paper to hot meals, and there is 1 vending machine per 23 people. Liskom(Russia) andXerox(Global) both have coin-operated or pay-per-copy vending machines.A full-line vending company may set up several types of vending machines that sell a wide range of products. Products may include candy, cookies, chips, fresh fruit, milk, cold food, coffee and other hot drinks, bottles, cans of soda, and even frozen products like ice cream. These products can be sold from machines that include coffee, snack, cold food, 20-oz. bottle machines, and glass-front bottle machines.

CHAPTER 3DESIGN METHODOLOGY OF VENDING MACHINEFINITE STATE MACHINE METHODAfinite-state machine(FSM) orfinite-state automaton(plural:automata), or simply astate machine, is a mathematicalmodel of computationused to design bothcomputer programsandsequential logiccircuits. It is conceived as anabstract machinethat can be in one of a finite number ofstates. The machine is in only one state at a time; the state it is in at any given time is called thecurrent state. It can change from one state to another when initiated by a triggering event or condition; this is called atransition. A particular FSM is defined by a list of its states, and the triggering condition for each transition.The behavior of state machines can be observed in many devices in modern society which perform a predetermined sequence of actions depending on a sequence of events with which they are presented. Simple examples arevending machineswhich dispense products when the proper combination of coins is deposited,elevatorswhich drop riders off at upper floors before going down,traffic lightswhich change sequence when cars are waiting, andcombination lockswhich require the input of combination numbers in the proper order.Finite-state machines can model a large number of problems, among which areelectronic design automation,communication protocol design, languageparsingand other engineering applications. Inbiologyandartificial intelligenceresearch, state machines or hierarchies of state machines have been used to describeneurological systemsand inlinguisticsto describe thegrammarsof naturallanguages.Considered as an abstract model of computation, the finite state machine is weak; it has less computational power than some other models of computation such as theTuring machine.That is, there are tasks which no FSM can do, but some Turing machines can. This is because the FSM has limitedmemory. The memory is limited by the number of states.FSMs are studied in the more general field ofautomata theory.The automata theory is the basis behind the traditional model of computation and is used for many purposes other than controller circuit design, including computer program compiler construction, proofs of algorithm complexity, and the specification and classification of computer programming languages. Because automata are mathematical models that produce values dependent upon internal state and possibly some dependent input values, they are referred to as state machines. A state machine may allow for a finite or an infinite set of possible states and furthermore, they may have nondeterministic or deterministic behavior. A deterministic state machine is one whose outputs are the same for a given internal state and input values. A finite state machine (FSM) is one where all possible state values made a finite set.In a Finite State Machine the circuits output is defined in a different set of states i.e. each output is a state. A State Register to hold the state of the machine and a next state logic to decode the next state. An output register defines the output of the machine. In FSM based machines the hardware gets reduced as in this the whole algorithm can be explained in one process.Two types of State machines are:

MEALY Machine: In this machine model, the output depends on the present state as well as on the input. The MEALY machine model is shown in figure 1.

MOORE Machine: In Moore machine model the output only depends on the present state. The MOORE machine model is shown in figure 2.

CHAPTER 4IMPLEMENTATION METHODS

FPGA BASED DESIGN

Afield-programmable gate array(FPGA) is anintegrated circuitdesigned to be configured by a customer or a designer after manufacturinghence "field-programmable". The FPGA configuration is generally specified using ahardware description language(HDL), similar to that used for anapplication-specific integrated circuit(ASIC) (circuit diagramswere previously used to specify the configuration, as they were for ASICs, but this is increasingly rare).Contemporary FPGAs have large resources oflogic gatesand RAM blocks to implement complex digital computations. As FPGA designs employ very fast I/Os and bidirectional data buses it becomes a challenge to verify correct timing of valid data within setup time and hold time.Floor planningenables resources allocation within FPGA to meet these time constraints. FPGAs can be used to implement any logical function that an ASIC could perform. The ability to update the functionality after shipping,partial re-configuration of a portion of the design and the low non-recurring engineering costs relative to an ASIC design (notwithstanding the generally higher unit cost), offer advantages for many applications.FPGAs containprogrammable logiccomponents called "logic blocks", and a hierarchy of reconfigurable interconnects that allow the blocks to be "wired together"somewhat like many (changeable) logic gates that can be inter-wired in (many) different configurations. Logic blocks can be configured to perform complexcombinational functions, or merely simplelogic gateslikeANDandXOR. In most FPGAs, the logic blocks also include memory elements, which may be simpleflip-flopsor more complete blocks of memory. Some FPGAs have analog features in addition to digital functions. The most common analog feature is programmableslew rateand drive strength on each output pin, allowing the engineer to set slow rates on lightly loaded pins that would otherwiseringunacceptably, and to set stronger, faster rates on heavily loaded pins on high-speed channels that would otherwise run too slowly.Another relatively common analog feature is differential comparators on input pins designed to be connected todifferential signalingchannels. A few "mixed signalFPGAs" have integrated peripheralanalog-to-digital converters (ADCs)anddigital-to-analog converters (DACs)with analog signal conditioning blocks allowing them to operate as asystem-on-a-chip. Such devices blur the line between an FPGA, which carries digital ones and zeros on its internal programmable interconnect fabric, andfield-programmable analog array(FPAA), which carries analog values on its internal programmable interconnect fabric.

CMOS BASED DESIGN

"CMOS" refers to both a particular style of digital circuitry design and the family of processes used to implement that circuitry on integrated circuits (chips). CMOS circuitry dissipatesless powerthan logic families with resistive loads. Since this advantage has increased and grown more important, CMOS processes and variants have come to dominate, thus the vast majority of modern integrated circuit manufacturing is on CMOS processes. As of 2010, CPUs with the bestperformance per watteach year have been CMOSstatic logicsince 1976. CMOS circuits use a combination of p-channel and n-channelmetaloxidesemiconductor field-effect transistors(MOSFETs) to implementlogic gates. Although CMOS logic can be implemented with discrete devices for demonstrations, commercial CMOS products are integrated circuits composed of up to millions of transistors of both types on a rectangular piece of silicon of between 10 and 400mm2

.SINGLE ELECTRON DEVICE (SED) BASED DESIGNSingle Electron Devices (SED) are promising for future ULSI technology because of their ultra low power consumption, higher density of integration and switching speed. Structure of SED is based on the discrete nature of electrons tunneling through thin potential barriers. The ultimate goal of this work is to venture one possible way of using electron-tunneling devices instead of conventional MOS transistors to design and simulate an automatic tea/coffee vending system. The proposed vending machine will establish a good approximation for the limits and challenges that ever-shrinking circuits will meet eventually, when the size of the components become comparable to that of electrons.

CHAPTER 5ADVANTAGES AND DISADVANTAGESAdvantages:1. Vending machines give the clients a free choice to purchase products at any time of the day. One can shop for his or her intended product on a 24 hour, throughout the year.2. Diversity in terms of the products that a vending machine can handle is another advantage that this technology in business has brought. A wide range of products can be sold using the machine as fruits, beverages, drinks, and cigarettes among other products. This concept is also applied to some service provision industries like air drier, play stations and other public utility practices.3. Reduction of overhead costs by not hiring of staff only increases the profit margin for the owner making it a success bound venture.4. The machine can always be moved to other areas if need arises and it will continue delivering the services as usual.Disadvantages:1. The main disadvantage of vending machine is that it can cost you a lot of money.2. Fraud cases are also common in this kind of business by customers who formulate means of hacking into the system of the machine to dispense products.

CHAPTER 6VERILOG CODE OF VENDING MACHINEThe objective here is to design Vending Machine Controller which accepts money inputs(i and j) in any sequence and delivers the products when the required amount has been deposited and gives back the change. Here an additional facility is provided to the user. It is possible to withdraw the deposited money in between if the customer wishes so by pressing a push button.

SPECIFICATIONS:1. Price of the product=Rs.3.2. Possible money inputs=Rs.2 and Re.1.3. Product to be delivered when Rs.3 or Rs.4 is reached.4. A Push button is there (pu) which indicates the cancellation of transaction and thereturn of the amount deposited.

VERILOG CODE:/*Herei=0 indicates no coin has been detected.i=1 and j=0 indicates the detection of Re.1 coin.i=1 and j=1 indicates the detection of Rs.2 coin.pu indicates push button to cancel the transaction.Output p and c indicates the product delivery and coin return respectively.*/module vend(pu,i,j,rst,clk,p,c);input pu,i,j,rst,clk;output p,c;reg [2:0] state,NS;parameterS0=3'b000,S1=3'b001,S2=3'b010,S3=3'b011,S4=3'b100,S5=3'b101,S6=3'b110,S7=3'b111;always@ (posedge clk or negedge rst)if (~rst) state=S0;else state=NS;always@(state or i or j or pu)case(state)S0:NS=pu?S0:(i?(j?S2:S1):S0);S1:NS=pu?S5:(i?(j?S3:S2):S1);S2:NS=pu?S6:(i?(j?S4:S3):S2);S3:NS=S0;S4:NS=S0;S5:NS=S0;S6:NS=S5;S7:NS=S0;endcaseassign{p,c}={(state[0]&state[1]&~state[2])|(~state[0]&~state[1]&state[2]),(state[2]&~state[1])|(state[2]&~state[0])};endmodule

CODE STIMULATION:The above code is stimulated by writing a test bench. A specific case of a test bench isshown below.module testbench();reg pu,i,j,rst,clk;wire p,c;vend test(pu,i,j,rst,clk,p,c);always#5 clk=~clk;initialbegini=1'b0;j=1'b0;clk=1'b0;rst=1'b0;pu=1'b0;#5 rst=1'b1;#5 i=1'b1;#5 pu=1'b1;#100 $finish;endendmodule

CHAPTER 7SIMULATION AND RESULTSThe verilog code is simulated and compiled in Xilinx ISE 9.2i tool. And the following desired results are obtained.

NOTE: Price of the Product is Rs. 3

1. Return of Rs. 2 after the Cancel (pu) button is pressed.

2. Product Delivery and Return of Change after Rs. 4 insertion.

3. Product Delivery after Rs. 3 insertion

RTL SHEMATIC

BLOCKS OF RTL SCHEMATIC

TECHNOLOGY SCHEMATIC

CHAPTER 8CONCLUSIONWhen 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 the balance money. This verilog code has been successfully verified using the Xilinx ISE 9.2i tool and the desired outputs have been achieved. Vending Systems enhances productivity, reduces system development cost, and accelerates time to market. Vending machine give fast response and easy to use by an ordinary person. The designed machine can be used for many applications and we can easily enhance the number of selections. The next stage of this study is to convert this model into hardware and to calculate the total power consumption of the machine. Thus we would conclude saying that we tried our bit to modify the present day complex vending machine into a user friendly and user specific vending machine.

REFERENCES

1. Fauziah Zainuddin, Norlin Mohd Ali, Roslina Mohd Sidek, Awanis Romli, Nooryati Talib & Mohd. Izham Ibrahim (2009) Conceptual Modeling for Simulation: Steaming frozen Food Processing in Vending Machine International Conference on Computer Science and Information Technology, University Malaysia Pahang, pp.145-149.2. Xilinx Inc., Spartan 3 Data sheet: http://ww w.xilinx.com.3. Bhaskar VHDL primer Second Edition.4. Peter Minns & Ian Elliott, FSM-based Digital Design using Verilog HDL, John Wiley & Sons Ltd 2008.5. 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. | 1st Semester M. Tech( VLSI Design & Embedded Systems) 2