How to set up a circuit that keeps track of strikes in a baseball game using D flip flops in Multisim

flipflopmultisim

What I want is two LED lights and a push button. When the push button is pressed the first time, the first light lights up. When it's pressed a second time, the second light lights up. When it's pressed a third time, both lights turn off.

I set up two D flip flops. The first Q output connects to the second's D input. The push button is hooked to the Clock on both flip flops, the push button which is hooked to a power source. After going through my logic with K-maps, I determined the following:

D1 = Q0'Q1
D0 = Q0'

Q0 is the first flip flop and Q1 is the second flip flops.

So I set up the gates as necessary.

Here is where the problem is. The lights have a strange behavior. Sometimes one turns on, sometimes both turns on. I'm obviously doing something wrong.

Best Answer

While I'm not a Multisim guy, I suggest that you haven't tied D0 to any thing. Try tieing D0 to a logic high.

Furthermore, I suspect that your description means that, the sequence of LEDs should look like

Start Q0 off, Q1 off Push Q0 on, Q1 off Push Q0 off, Q1 on Push Q0 off, Q1 off Push Q0 on, Q1 off Push Q0 off, Q1 on Push Q0 off, Q1 off etc.

If this is so, you need a second input - Start, to force the FFs to the starting position. This may not be true for Multisim, as the program may initialize FFs to 0, but you would need it in real life. Assuming that no Start is needed,

schematic

simulate this circuit – Schematic created using CircuitLab

will do. Obviously, if a batter has one strike and gets a hit or a walk, you can push the button twice more to get back to the starting state.