# help designing a binary counter using JK flip flops

Discussion in 'Homework Help' started by inkosi, Nov 5, 2014.

1. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
Hi. I have to design a binary counter with an arbitrary sequence (1, 5, 3, 8, etc.) using JK flip-flops. So first I made the state diagram, the excitation table and I got this:

Now I have problems designing the K-map... I know the kmaps I have drawn there are wrong but where exactly does each value of for example J2 correspond to? I thought they corresponded to the value of the present state... do they actually correspond from numbers from 0 onwards (like the first value of J2 is 000, next value is 001, then 010?) And also, what about the blank squares? Do I replace those with don't cares or are they supposed to be left blank?

Any help to clear my doubts would be appreciated

Oct 2, 2009
12,212
3,276
3. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
The sequence I was given was actually 1, 4, 3, 5, 7, 6, 2, 1... sorry for not being clearer

4. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Ok.

Since 0-state is not used, this becomes a don't-care. Put an X in that box.

I am not sure how you arrive at X's in the other boxes. These should be 0 or 1.

Edit: I understand your X's now. You have already solved for J-K flipflops.
I haven't gone through your work completely but it appears to be correct.

Last edited: Nov 5, 2014

Dec 10, 2013
35
0
6. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Not sure what you mean.
You go to the present state, for example 000, and put an x in that box.
Go to the present state, for example 001, the required values of J2 = 1, K2 = x. Put this in the 001 box.

You have drawn the K-map correctly.

It is preferable to draw the truth table in sequential ascending order showing all states, 0-1-2-3-4-5-6-7.

inkosi likes this.
7. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
Yeah I thought my kmaps would be like that... I was just confused by another student who told me something else. And yeah I definitely agree. When I did that question in rough it was a headache placing all values on the kmaps.

8. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Your next step is to reduce the K-maps into combinational logic.
Show me how you would do one of the flip-flops.

9. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
I actually did those before as well.... but because I didn't put an X in the 000 state some of my expressions are wrong. I will re-do them with the X there:

the actual design ended up being a disaster... I assume this is a result of the expressions being wrong:

10. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Omitting to put X in the 000 state will not give you the wrong answer.
Putting the X in the 000 state could allow you to arrive at a reduced solution.

I am not sure how you are labeling the K-maps with Q0Q1 and Q2=0 Q2=1.

Are you sure this shouldn't be reversed to Q2Q1 and Q0=0 Q0=1 ?

11. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
Oh wow. I didn't even realise that. I'll do this all over again and post what I get.

12. ### inkosi Thread Starter Member

Dec 10, 2013
35
0

I think these are right .. however designing the final flip-flop diagram is proving to be a pain. It looks really messy especially because of the Jo and Ko expressions..

13. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Looks good. As for J0 and K0, if that's what it takes then you just have to live with it.
Note that K0 is a negated XOR function. That would simplify the wiring using an XOR gate.
J0 can also be reduced to a NAND gate

14. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
Oh good call. I made this:

It looks a bit messy, but is it fine?

15. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
Don't know. Are you going to simulate it or build it to check the results?

16. ### inkosi Thread Starter Member

Dec 10, 2013
35
0
Simulate using MultiSIM. I think it IS right, but I will definitely double check it.

17. ### WBahn Moderator

Mar 31, 2012
17,441
4,696
It doesn't matter how he organizes it, as long as there is a 1:1 mapping between variable states and boxes and as long as they are in Gray code order.

18. ### MrChips Moderator

Oct 2, 2009
12,212
3,276
He did incorrectly reverse the order of the labeling of the bits on the K-maps and that would make a difference, i.e. Q2 was switched with Q0.

19. ### WBahn Moderator

Mar 31, 2012
17,441
4,696
You aren't fully exploiting the groupings. In J0 you can have two groups of four and you can have groups of four in both K1 and K2, which reduce them to single wires. While not readily apparent, you can use an XOR in K0 and J0.

20. ### WBahn Moderator

Mar 31, 2012
17,441
4,696
Okay, I didn't look at it in that close of detail.

21. ### WBahn Moderator

Mar 31, 2012
17,441
4,696
It's very close, but K0 is not (Q2 XOR Q1), it is (Q2 XOR Q1)'. However, you can invert the output of an XOR by inverting any combination of an odd number of inputs and outputs. So that means that you have K0 = (Q2' XOR Q1) or you have K0 = (Q2 XOR Q1').

Also, while not critical, it is interesting to note that there is a certain symmetry here if you use J0 = (Q2 XOR Q1), namely K2 = J2', K1 = J1', and K0 = J0'.

inkosi likes this.