+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 2
    Points: 1,959, Level: 10

    Join Date
    Apr 2012
    Location
    US
    Posts
    131
    Helped
    38 / 38
    Points
    1,959
    Level
    10

    How to approach '40cent vending machine that return change' interview question?

    I was asked in an interview, how would you design a vending machine that accepts nickel, dime and quarter, and output a product after the total coin value reaches 40 cent and also return a change if total coin value exceeds 40cent. The change can be in any combination of nickel, dime and quarter.

    I designed this vending machine later and tested it. It works. Basically it had 3 submodule: coin_adder, vending_fsm and coin_change.

    If you were asked the same question, what would be your approach to answer it. Will you show block diagram of different sub blocks first and draw state graph for each sub-blocks and explain the procedural blocks inside, or..?

    It will help other people and myself in how to give the best answer, if asked in interview next time.

    Thanks,
    Last edited by morris_mano; 9th April 2012 at 16:55.

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 5
    Points: 34,805, Level: 45
    Achievements:
    7 years registered Created Blog entry Created Album pictures
    SunnySkyguy's Avatar
    Join Date
    Sep 2007
    Location
    Richmond Hill, ON, Canada
    Posts
    6,702
    Helped
    1672 / 1672
    Points
    34,805
    Level
    45
    Blog Entries
    7

    Re: How to approach '40cent vending machine that return change' interview question?

    In order to start any design, write down all assumptions into a "Spec" so you and others know what you forgot to assume or assumed wrong. Define Scope or boundary of spec, environment limits, inputs , outputs, process behaviours (time delay, verification) , user feedback outputs, , fault tolerance and detection, fault recovery and power initialization in order to define more "States" which you overlooked.



    •   AltAdvertisment

        
       

  3. #3
    Full Member level 2
    Points: 1,959, Level: 10

    Join Date
    Apr 2012
    Location
    US
    Posts
    131
    Helped
    38 / 38
    Points
    1,959
    Level
    10

    Re: How to approach '40cent vending machine that return change' interview question?

    I agree with "Spec" part, but this was an interview question. I am not sure what interviewer was expecting in the answer. It would be helpful to see how people approach the reply to this interview question as if it were during the interview.

    As for the assumption, I assumed there are 3 inputs for each coin, which will be asserted for 1 clock cycle after coin has been inserted. Even though the interviewer asked for a single item, I still think we will need item select switch. Item will not be release if this switch is not pressed even after total value exceeds 40cent . If the user does not want the item and want the money back, simply press the cancel switch. In that case, all the inserted coin will be returned. If the user press the item select switch without having 40 cent in the machine, the error is asserted which can be used to display " not sufficient fund". For change return, it was assumed that to return nickel, dime and quarter, COIN_O[0],COIN_O[1] and COIN_O[2] need to be asserted for 1 clk cycle respectively. The product will be released when VEND_O is asserted for 1 clk cycle. I know there are many more requirements or "spec" for complete design like response delay and fault tolerant but during interview process, to simplify you can reply without those constraints. I have shown my module description below:

    module vending_top(
    input CLK_I,
    input RST_N_I,
    input NICKEL_I,
    input DIME_I,
    input QUARTER_I,
    input SEL_ITEM_I,
    input CANCEL_I,
    output VEND_O,
    output [2:0] COIN_O,
    output ERROR_O);



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 5
    Points: 34,805, Level: 45
    Achievements:
    7 years registered Created Blog entry Created Album pictures
    SunnySkyguy's Avatar
    Join Date
    Sep 2007
    Location
    Richmond Hill, ON, Canada
    Posts
    6,702
    Helped
    1672 / 1672
    Points
    34,805
    Level
    45
    Blog Entries
    7

    Re: How to approach '40cent vending machine that return change' interview question?

    If I asked someone a design question, I would expect a broader solution 1st, because too many people get into implementation specific solutions before knowing what the assumptions are. Such as assumptions and specs. By asking the question at least clarifies what assumptions can be neglected. But design has many levels not just the basic function and depends what interviewer expects.



  5. #5
    Advanced Member level 5
    Points: 34,805, Level: 45
    Achievements:
    7 years registered Created Blog entry Created Album pictures
    SunnySkyguy's Avatar
    Join Date
    Sep 2007
    Location
    Richmond Hill, ON, Canada
    Posts
    6,702
    Helped
    1672 / 1672
    Points
    34,805
    Level
    45
    Blog Entries
    7

    Re: How to approach '40cent vending machine that return change' interview question?

    your solution was good. My suggestion is start with all the inputs and outputs in a block diagram to show functional blocks and then show possible implemenation using purchased modules to satisfy inputs. Also define requirements for acceptance criteria so design can be measured against this unwritten requirement... e.g. reject false coins, accept good coins of all vintage.. test accuracy of OEM modules to verify meet expectations...Define overall agency approval requirements .. packaging, safety,, user interface , appearance, cost issues as undefined design requirements....reliability.. this total solution thinking shows depth and breadth of experience, even if assumption was stated waht was NOT included in the design but requires specs. to ensure suitability of end result... So many millions of dollars in R&D have been wasted I have seen because Managers failed to define proper design specs and the designers end up frustrated when they find surprise requirements change the whole design becuase no one thought about the,.. At the beginning is the best time to do this... not after..... really hundreds of milllions of dollars in R&D at companies I have worked for failed due to poor specs. And the ones that were more successful had the best specs.

    - - - Updated - - -

    I remember fake money getting accepted in vendor machines because it was not designed to include all the latest security counter measures for fake money detection systems. Not just a design flaw but a flaw in the specs and not tested to specs after design.
    A good design question lists your overall requirements™ The best question deserves a better answer. ™
    ... Tony Stewart EE since 1975



--[[ ]]--