Implementing Memory Function using flip-flop ICs

Discussion in 'Homework Help' started by wind_blast942, Oct 7, 2010.

  1. wind_blast942

    Thread Starter New Member

    Sep 7, 2010
    22
    0
    Hi all

    I have this project (to be implemented with IC chips on breadboard) where basically i have to:

    1) Check the difference of 2 inputs (I0, I1), and if it is equal to a fixed value (for e.g 7)

    2) If so light up a green LED.

    3) If not (failed tries = 1), reset the circuit and allow user to input in the correct value again.

    4) If the value is still incorrect (failed tries = 2), lock the circuit.

    The problem i am having now is how to implement the memory portion of "failed tries".

    I initally thought that since for step 1, i used a combination of AND and NOT gates to force the output to be 1 only if the fixed value 7 is met. So this would imply that the output is 0 when the value is not met.

    As such i would use the 0 from the output as indication that the user has inputted in a wrong value and feed it into a flip-flop (e.g D flip flop), saving it into its output as 1 to indicate failed tries = 1.

    However the problem occurs when the user inputs the wrong value again
    (failed tries = 2).
    I tried to tie the first flip flop output (with failed tries = 1) to the 2nd flip flop (which is supposed to store failed tries = 2).

    I thought this might work but upon simulation, i noticed that since the output of my check difference of inputs (in step 1) is also 0 when the user fails (the AND and NOT gate combination could not discriminate between 1st and 2nd try), tying the 1st flip flop o/p (try1) to the 2nd flip flop o/p (try2) will result in an immediate change in try2 (try1 = 1, try2 = 1), indicating that 2 tries are up, which is not what happened.

    Sorry for the confusing post, hope that the attached diagram helps. The V1 to V4 represent the result of part 1 (i.e. the difference between the 2 inputs (which are not shown)).[​IMG]

    Any advice on how to go about this memory problem is greatly appreciated :)

    Thanks.
     
    Last edited: Oct 7, 2010
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    You need to make a finite state machine by using flip flops. The textbook Logic Circuit Design by M. Mano is a huge help if you have it. Search the net for a quick theory crash course. I found this pdf to be simple and explanatory: http://www.cs.princeton.edu/courses/archive/spr06/cos116/FSM_Tutorial.pdf

    Some suggestions:
    You first need to identify the states of operation of your circuit. As I read it, you have 3. First Input, Second Input, Lock. 3 states need 2 bits to be represented and therefore you went right about choosing to use 2 flip flops.
    The state of the flip flop will indicate the total state you are on, ie if FF1 is 0 and FF2 is 1 then you are on state 01 or in decimal 1. Keep that in mind when drawing the truth table.

    Do some reading and then come back with your questions.

    However, just for this particular application, you could wire the result of the comparison to the clock of a T-FF and Input a 1. Then wire the Q of the first FF to the clock of another T-FF and feed it a 1. When the first 1 from a false comparison arrives it will trigger the first FF which will change its output to 1. A second 1 from the comparison, will turn the first FF to 0, completing a pulse and driving the second FF to high too.
    I would use the 74LS74.
     
  3. wind_blast942

    Thread Starter New Member

    Sep 7, 2010
    22
    0
    Thanks for the help. However there is one part i am not quite sure.

    How would the system know if the 1 from the output of the comparision is from the first comparision state and not from the second comparision state (and vice-versa); since it is possible that the output remains as 1 throughout the whole time, and if you draw the waveform out, it will just be a straight line at logic level 1 at all times?
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    I guess you will have an enter button that will activate the gates. You will want to have time to set the switches without the led flashing on and off. That "enter" button can be liked to the clock of the first FF. That would be a good practice.
     
Loading...