Newbie building 2-bit non-sequential counter using J K Flip Flop and struggling

Thread Starter

shawn_from_melbourne

Joined Mar 17, 2023
14
Project - Overlapping 2 bit counter output

I’m wanting to switch 2 leds on and off in an overlapping pattern. I’m very new to this and been struggling with how to do this for over 7 days. I have tried working the following process using a dual J K Flip Flop and have become stuck. Watched heaps of Youtube clips on the subject and read through many sites covering everything from Karnaugh Maps (Kmaps) to excitation tables etc. See below and now I’m completely lost now when I thought I was getting it. Between completing the KMAP and completing the pinout, one LED lights up and nothing else happens.

Any assistance would be amazing please.

Requirement for 2 LED's to flash, overlapping as below...
2-bit Clock pulse and 2 outputs overlapping.png
Took the following steps....

2-bit Step 1.png


2-bit Step 2.png


2-bit Step 3.png2-bit Step 4.png2-bit Step 5.png


JK Flip Flop circuit - solution 1.png

Neither LED lights up but I can pull-up Q1 by intermittently connecting or disconnecting from J1.

Please can someone tell me where I've gone wrong before I jump off a bridge. :)
 

crutschow

Joined Mar 14, 2008
34,280
It appears that you have Q and /Q of the right FF shorted together, which is not allowed.

Sorry, I don't know where you went wrong in your logic design, but below is the LTspice simulation of the circuit I came up with:
It can also be done with two D-FF's, which requires fewer connections.

I did the design basically by logical thought (I was never much into Karnaugh maps which seem overly complicated for simple logic design).
In this case you look at each state of the two FF's in the transition table, and connect the J and K inputs to get the desired next state from the previous state.

For example the state of U2-Q follows the last transition state of U1-Q at the next clock pulse, while U1-Q follows the last transition state of U2-Q inverted.
From that, and understanding how a JK-FF works, the required connections should be reasonably obvious.

Edit: The operation of the JK-FF may be a little confusing because of the don't-care states but basically, when J is high, Q goes (or stays) high at the next clock pulse, when K is high, Q goes (or stays) low at the next CP, and when both J and K are high, Q alternates its state at each CP.

1679180596448.png
 
Last edited:

WBahn

Joined Mar 31, 2012
29,976
MOD NOTE:

First off, you've posted this in the Microcontrollers forum -- but you don't seem to be involving a microcontroller anywhere. So we need to move it to a proper forum.

Where does the requirement for this come from? Is this a school assignment of some kind?

Your answer to this question will not only help us decide where best to move the thread, but will also help members give you the assistance that will likely help you the most.
 

Attachments

WBahn

Joined Mar 31, 2012
29,976
Project - Overlapping 2 bit counter output

I’m wanting to switch 2 leds on and off in an overlapping pattern. I’m very new to this and been struggling with how to do this for over 7 days. I have tried working the following process using a dual J K Flip Flop and have become stuck. Watched heaps of Youtube clips on the subject and read through many sites covering everything from Karnaugh Maps (Kmaps) to excitation tables etc. See below and now I’m completely lost now when I thought I was getting it. Between completing the KMAP and completing the pinout, one LED lights up and nothing else happens.
View attachment 290128

Notice that the required behavior involves things happening on both the rising and the falling clock edges. This means that one of your FFs needs to have an inverter in the clock signal.


1679210657738.png

As others have noted, you never tie two active outputs together (well, there are SOME situations in which you do this, but this ain't one of them).

There are a few ways to generate two square waves in quadrature, which is what your two outputs are.

Look at each waveform and see if you can spot a very, very simply relationship between what that waveform need to become at each clock edge where it changes and what the value of the other waveform is at that same edge.
 

WBahn

Joined Mar 31, 2012
29,976
Isn't this just a Gray counter you're looking for?
While it is a Gray counter, with the caveat that it advances on each edge of the clock, that's not the specific feature that the TS is looking for and they may or may not know what a Gray counter is. They are just looking for overlapping signals, which a two-bit Gray counter happens to provide.
 

crutschow

Joined Mar 14, 2008
34,280
Do I need to run the Output Q(bar)'s through an inverter ?
No, why would you think that?
You just wire it as shown in my schematic.
What FF are you using?
I've wired up and its toggling but seems logic isn't allowing over-lap.
How are the LEDs being driven?
It's problematic driving them directly from the FF without a transistor buffer.
What are you using for a clock signal?
 
Last edited:

Thread Starter

shawn_from_melbourne

Joined Mar 17, 2023
14
That answers the last question.
How about the rest of them?
I has just running the LED direct via a 480 Ohm resistor to ground.
I'll head to the store and get a couple of transistors and wire-up as advised.
I just tap off the FF2 outputs via a transistor to drive the LED's ?

Thanks so much for your assistance. I'm learning a lot. :)
 

crutschow

Joined Mar 14, 2008
34,280
Should I pass thru the inverter and tap off as below per output ??
Again I ask, why do you want to change the circuit that works as I showed (without an external inversion)?
The needed inversion is already provided by using the /Q output instead of the Q output.

What FF are you using?

I need you to answer all my questions if you want my help.
 
Last edited:

Thread Starter

shawn_from_melbourne

Joined Mar 17, 2023
14
Again I ask, why do you want to change the circuit that works as I showed (without an external inversion)?
The needed inversion is already provided by using the /Q output instead of the Q output.

What FF are you using?

I need you to answer all my questions if you want my help.
I'm using a SN73LS73AN FF.

Sorry I thought I needed external inversion. Now I get it. The Q(bar) is already low.

I'll wire exactly as you showed. I just bought 2 x NPN and 2 x PNP transistors.

I assume from your drawing I tap from the 2 FF2 outputs and light the LED's via a transistor...?

Did this answer all your questions. Sorry I was confused but think I've got it now. I'm incredibly thankful for your help.
 

Thread Starter

shawn_from_melbourne

Joined Mar 17, 2023
14
OK.
For that the reset pins should be tied to V+ for normal operation.
And note that the SN73LS73AN is rated for a maximum V+ supply of 5.5V, not the 9V battery you show (check the data sheet).
The CMOS version I used will operate up to over 15V.

I actually tied the 1 & 2 CLR bar to ground. I'll make the changes now.

And I assume I tap from the FF2 Q(bar) to the base of a PNP transistor and the FF2 output to the base of a NPN transistor...?

Heading back to the shops 10km away to buy a smaller battery pack. I'm getting there. :)
 

sarahMCML

Joined May 11, 2019
363
I actually tied the 1 & 2 CLR bar to ground. I'll make the changes now.

And I assume I tap from the FF2 Q(bar) to the base of a PNP transistor and the FF2 output to the base of a NPN transistor...?

Heading back to the shops 10km away to buy a smaller battery pack. I'm getting there. :)
Just try connecting your LED and series resistor pairs from +5V directly to the Q (or /Q) outputs directly. No transistors needed as long as your LED current isn't too high!
 
Top