Vending Machine Logic?

This is a discussion on Vending Machine Logic? within the C Programming forums, part of the General Programming Boards category; Dear All, I am designing code for Vending Machine..could anybody know the logic or just give me links where i ...

  1. #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

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    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?

  3. #3
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    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.

  4. #4
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    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

  5. #5
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,658
    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?

  6. #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 "

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  8. #8
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    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.

  9. #9
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    (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).

  11. #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

Popular pages Recent additions subscribe to a feed

Similar Threads

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

Tags for this Thread


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