C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-07-2008, 05:10 AM   #1
Registered User
 
Join Date: Apr 2008
Posts: 83
Vending Machine Logic?

Dear All,

I am designing code for Vending Machine..could anybody know the logic
or just give me links where i will find the logic??

thanks in Advance
shwetha_siddu is offline   Reply With Quote
Old 05-07-2008, 05:12 AM   #2
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
Other than general knowledge and intuition what is there to know?

You put in $, you select an item, the item is despensed and you get your change back. Have you never used a vending machine in your life?
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline   Reply With Quote
Old 05-07-2008, 06:03 AM   #3
Wheres the lesbians?
 
mike_g's Avatar
 
Join Date: Oct 2006
Location: UK
Posts: 1,219
If its got those curly thing that the food comes out of you want to make sure that they don't rotate too much so that they drop two thin items in one go. You also need to make sure that they drop one item - packets of crisps often get stuck. Maybe you could use lasers to scan how fat the object is and rotate accordingly. That would rule.
mike_g is offline   Reply With Quote
Old 05-07-2008, 07:38 PM   #4
Registered User
 
Join Date: Nov 2007
Posts: 171
It's fairly straightforward. Here's some pseudo code:
Code:
if (someone puts money into the machine)
{
    prompt snack selection
    make sure snack is not dispensed
    if (the person hits the money return button)
        do nothing
}
__________________
I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo
NeonBlack is offline   Reply With Quote
Old 05-07-2008, 10:32 PM   #5
Registered User
 
Join Date: Apr 2006
Location: United States
Posts: 3,201
Quote:
Originally Posted by NeonBlack View Post
It's fairly straightforward. Here's some pseudo code:
Code:
if (someone puts money into the machine)
{
    prompt snack selection
    make sure snack is not dispensed
    if (the person hits the money return button)
        do nothing
}
When exactly do I get the snack?
whiteflags is offline   Reply With Quote
Old 05-07-2008, 10:55 PM   #6
verbose cat
 
Join Date: Jun 2003
Posts: 209
It ate your money, too? You'll just have to fill out one of those little refund cards. Now where are they...?
__________________
abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "
jEssYcAt is offline   Reply With Quote
Old 05-07-2008, 11:12 PM   #7
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,470
A vending machine would have a significant amount of code to deal with the DBA (dollar bill acceptor), the coin acceptor, the button inputs, and the machinery to actually dispense the product.

I would say there is a hefty amount of device code involved.
Bubba is offline   Reply With Quote
Old 05-07-2008, 11:20 PM   #8
& the hat of GPL slaying
 
Thantos's Avatar
 
Join Date: Sep 2001
Posts: 5,730
Quote:
Originally Posted by Bubba View Post
A vending machine would have a significant amount of code to deal with the DBA (dollar bill acceptor), the coin acceptor, the button inputs, and the machinery to actually dispense the product.

I would say there is a hefty amount of device code involved.
Well the coin acceptor was a mechnical action before, not sure if that is still 100% true though. I would image that both the bill and coin devices do the processing on board and use signaling to the vending machine logic.

Buttons mainly just have to be debounced and for dispensing it merely requires turning a motor (for screw based ones) or opening a latch (for drop ones like soda machines).

Vending machines are used as examples a lot when dealing with Finite State Machines and the core logic really isn't that difficult.

It really comes down to keeping track of how much money has been deposited and then when a selection is made seeing if enough money has been deposited.
Thantos is offline   Reply With Quote
Old 05-08-2008, 12:39 AM   #9
Banned
 
master5001's Avatar
 
Join Date: Aug 2001
Location: Visalia, CA, USA
Posts: 3,699
Example:
Code:
switch(user.input)
{
    case A_1:
       eject(PEPSI);
       break;
    case A_2:
       eject(SPRITE);
       break;
    case A_3:
       eject(DR_PEPPER);
       break;

    // etc.
}
Good luck, friend.
master5001 is offline   Reply With Quote
Old 05-08-2008, 12:41 AM   #10
Banned
 
master5001's Avatar
 
Join Date: Aug 2001
Location: Visalia, CA, USA
Posts: 3,699
(I would also like to put my $5 on the fact that this is a homework and this gentleman was not hired to write the logic for someone's machine).
master5001 is offline   Reply With Quote
Old 04-07-2009, 03:33 AM   #11
Registered User
 
Join Date: Apr 2009
Posts: 1
Not really, but i can give you some tips in finding some logic about your programming project well why not to try to search in some open source site about programming i think you can get their some little information about your problem...

_________________
Vending Machine
blue.machine is offline   Reply With Quote
Reply

Tags
crisps, mmmm

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
School Mini-Project on C/C++ (Need Your Help).. EazTerence C++ Programming 4 09-08-2005 01:08 AM
Porting from 32 bit machine to 64 bit machine! anoopks C Programming 10 02-25-2005 08:02 PM
Wanna test vending machine Roaring_Tiger Tech Board 6 08-25-2004 05:51 PM
Vending machine Unregistered C++ Programming 6 06-13-2002 10:21 PM


All times are GMT -6. The time now is 12:27 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22