AND-gate with flip-flop to turn on lamp

Thread Starter

TsAmE

Joined Apr 19, 2010
72
3 pushbutton units A, B and C each produce a logic '1' while pressed. Design a circuit in which briefly pressing C permanently turns off an indicator lamp L. To turn L on again, button A must be pressed first, then button B. Pressing them in the reverse order has no effect.

In the diagram attachment (which is the correct answer), I dont get how pressing B then A would have no effect as:

*If B is pressed first, a '1' will correspond to one of the inputs of the AND-gate, the R of the flip-flop will be triggered resetting the other input of the AND-gate to 0 (first input=0, second input=1). But now when A is pressed, the first input will change to '1', and thus both inputs = '1', which means the lamp turns on, but it shouldnt:confused:
 

Attachments

hgmjr

Joined Jan 28, 2005
9,027
Actually it would be better if the attached diagram had more details than it does. There are several inputs to a flip/flip and there are several flavors of flip/flop.

hgmjr
 

Georacer

Joined Nov 25, 2009
5,182
Let's notice that you use JK flip flops, as you ommited to label them in your schematic.

Let's examine things from the beginning:

  • At first, all flip flops are set to 0 state and all inputs are 0. The lamp is off
  • We press A. FF1 gets 1/0 as input and is set to 1
  • We release A. FF1 gets 0/0 as input and is on hold at 1
  • We press B. AND Gate gets 1/1 and ouputs 1. FF2 gets 1/0 as input and is set to 1. The lamp is lit.
  • We release B. And Gate gets 1/0 and outputs 0. FF2 gets 0/0 as input and is on hold at 1. The lamp is lit.
Now, to close the lamp:

  • We press C. FF2 gets 0/1 as inputs and goes to reset (state 0). The lamp is off. Also FF1 gets 0/1 and goes to reset (state 0).
If we press B,A when system is off:

  • We press B. FF1 is in 0. AND Gate gets 0/1 and outputs 0. FF2 gets 0/0 and stays in 0.
  • We press A. FF1 gets 1/0 and goes to set (state 1). AND Gate gets 1/0 and outputs 0. FF2 gets 0/0 and remains on hold at state 0.
If we press A at this point (after B is pressed), the lamp is lit. I hope this makes obvious how this sytem works. Please ask further is something remains obscure.
 

Thread Starter

TsAmE

Joined Apr 19, 2010
72
Let's notice that you use JK flip flops, as you ommited to label them in your schematic.

Let's examine things from the beginning:

  • At first, all flip flops are set to 0 state and all inputs are 0. The lamp is off
  • We press A. FF1 gets 1/0 as input and is set to 1
  • We release A. FF1 gets 0/0 as input and is on hold at 1
  • We press B. AND Gate gets 1/1 and ouputs 1. FF2 gets 1/0 as input and is set to 1. The lamp is lit.
  • We release B. And Gate gets 1/0 and outputs 0. FF2 gets 0/0 as input and is on hold at 1. The lamp is lit.
Now, to close the lamp:

  • We press C. FF2 gets 0/1 as inputs and goes to reset (state 0). The lamp is off. Also FF1 gets 0/1 and goes to reset (state 0).
If we press B,A when system is off:

  • We press B. FF1 is in 0. AND Gate gets 0/1 and outputs 0. FF2 gets 0/0 and stays in 0.
  • We press A. FF1 gets 1/0 and goes to set (state 1). AND Gate gets 1/0 and outputs 0. FF2 gets 0/0 and remains on hold at state 0.
If we press A at this point (after B is pressed), the lamp is lit. I hope this makes obvious how this sytem works. Please ask further is something remains obscure.
Sorry I forgot to be more specific but it contains a RS flip-flop (refer to attachment). Does this change what you said above?
 

Attachments

Georacer

Joined Nov 25, 2009
5,182
As long as you don't excite both inputs of the FF (wich isn't our case) RS and JK are identical. So, no, the analysis is the same.
 

retched

Joined Dec 5, 2009
5,207
Who is to say both wont be excited at the same time?

Using both buttons, in a required order, requires logic. If the inputs are the same, there will be no differentiation between button orders.
 

Georacer

Joined Nov 25, 2009
5,182
Who is to say both wont be excited at the same time?
That would be the data of the exercice.
It states that the sequences would be A then B, or B then A. And C will be pressed when the lamp is lit (after pressing A and then B).
I agree that RS is a bad choice for a robust system, but when solving a theoretical exercise you have to make simplifications and assumptions in order to come to a clean solution. Let alone the fact that the tutor won't get "use JK FF" as an answer, if he asked for RS.

To TsAmE: I should specify that I made my analysis assuming that the J pin is on the top and K pin is on the bottom of the FF. Alternatively, the S pin is on top and the R on the bottom for an RS FF.
 

retched

Joined Dec 5, 2009
5,207
button A must be pressed first, then button B. Pressing them in the reverse order has no effect.
What I was getting at, is the data of the exercise calls for no effect if B then A is pressed.

So, using a logic system to dump low if A is not pressed first.

So if latching A, then A=1

so when B is pressed, if A=1 then let B=1

therefore the AND is happy and triggers.

If B is pressed and A=0, 'A' has NOT been pressed yet, then B=0.

I think the main point it using the logic with latching flip-flops to get the button press order logic together.
 

Thread Starter

TsAmE

Joined Apr 19, 2010
72
I have only learnt about the RS flip-flop so far in my course, thats why this question is based on it. I understand most of this diagram, but I just dont understand the part when if B is pressed first then A, the lamp will not light as:

*Pressing B would make the 2nd input of the AND-gate = 1
*Then pressing A would set the 1st input of the AND-gate = 1
*Thus 1 and 1 makes the lamp turn on which isnt right.
*I dont get if the reset line coming out of the bottom-left of the first flip-flop is joined to B? Which I havent taken into consideration.
 

beenthere

Joined Apr 20, 2004
15,819
The link in post #5 gives you the truth table for an R-S flip flop. Try assigning A & B for R & S so A = R and B = S, or the other way around to see how the flip flop works. Then it should be easy to see how to AND the B signal to get the function. Using C to reset is the next step.
 

Georacer

Joined Nov 25, 2009
5,182
*Pressing B would make the 2nd input of the AND-gate = 1
*Then pressing A would set the 1st input of the AND-gate = 1
*Thus 1 and 1 makes the lamp turn on which isnt right.
You have a logic gap in your thoughts. As your switches are pussbuttons, they do not latch on one position, but return to 0 when you don't press the anymore. Consequently, ressing B will make the 2nd input of AND 1, but you will then let B go to 0, before you press A. As a result, the AND gate will never have 1 on both its inputs at one time, and won't give 1 to the S pin of the second RS FF.
Is that clear?
 

hgmjr

Joined Jan 28, 2005
9,027
I have only learnt about the RS flip-flop so far in my course, thats why this question is based on it. I understand most of this diagram, but I just dont understand the part when if B is pressed first then A, the lamp will not light as:

*Pressing B would make the 2nd input of the AND-gate = 1
*Then pressing A would set the 1st input of the AND-gate = 1
*Thus 1 and 1 makes the lamp turn on which isnt right.
*I dont get if the reset line coming out of the bottom-left of the first flip-flop is joined to B? Which I havent taken into consideration.
I tend to agree with georacer that you must be thinking that you hold the pushbutton B down and then press pushbutton A. My interpretation of the sequence is that you press A (then release A) and then press B (then release B). A and B are momentary switches and therefore they return to the open state when released. If after pressing C and releasing C, you press B (then release B) and then press A (then release A), then the light should not light.

hgmjr
 

Thread Starter

TsAmE

Joined Apr 19, 2010
72
You have a logic gap in your thoughts. As your switches are pussbuttons, they do not latch on one position, but return to 0 when you don't press the anymore. Consequently, ressing B will make the 2nd input of AND 1, but you will then let B go to 0, before you press A. As a result, the AND gate will never have 1 on both its inputs at one time, and won't give 1 to the S pin of the second RS FF.
Is that clear?
Ah of course that makes sense now, thanks a lot:) The other thing which confused me was that the reset line of the first flip-flop intersects the B line (either it is joined, or the line overlaps?). In a logic diagram how would you tell that the lines which intersect on the diagram, arent actually joined together like in this one?
 

Georacer

Joined Nov 25, 2009
5,182
B and C lines do not intersect. The most commonly used symbol for non intersecting lines is this:
Circuit Bridge.png

However, in simple designs as this one, when it is obvious that the lines are separate, we don't express it visually.
On the other hand, when two lines DO intersect, we draw a dot over the intersection, like this:
Circuit Intersection.png
 
Top