Create Mod Counter Using Flip Flops: 5 to 2 Cycle

  • Thread starter Thread starter surfy14
  • Start date Start date
  • Tags Tags
    Counter Flip flop
AI Thread Summary
The discussion focuses on designing a mod counter using JK flip-flops that counts down from 5 to 2, while skipping states 7 and 6. The user successfully counts from 7 to 2 but struggles with skipping unwanted states. Suggestions include manipulating the J and K inputs to create a more flexible design and using K-maps to derive the next state equations. The conversation emphasizes the importance of understanding clocked state machines and proper implementation of the JK flip-flop equations. Ultimately, the user is guided towards refining their approach to achieve the desired counting sequence.
surfy14
Messages
5
Reaction score
0

Homework Statement



To create a mod counter using flip flops that counts from 5 down to 2 and repeats this cycle...example 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2...

The Attempt at a Solution



I currently can get it to count from 7 down to 2 no problems...the issue is...I don't know how to skip states 7 and 6 right now. Using 3 jk flip flops...allows 2^3 states...or 0-7. Once the state reaches 1...I use an and gate to clear all the flip flops so that it jumps back to 7. Here is my schematic so far...but I'm assuming I have to somehow manipulate the j and k inputs to skip states 7 and 6; basically not hardwire a 1 to j and k. Any help would be appreciated...thanks.

http://www.freeimagehosting.net/newuploads/j92t9.jpg
 
Physics news on Phys.org
Remove the inverter on the output hexD(1)
 
ivanis said:
Remove the inverter on the output hexD(1)

that does start the counter at 5, but the order is 5, 4, 7, 6, 1, 0...it is not 5, 4, 3, 2
 
You're right.
But I have another quick idea - you have to check it, sure.
What I was thinking that you are resetting with event "1", it means in fact that you will have this value on the output for a short time, right?

So I don't know if it's critical for you, but I'd rather reset on event "2" with a proper delay. This method has an advantage you can use to get your 5,4,3,2. because as you have "2" at the output it means "101" directly at the triggers. Now if you drop the first and the third trigger outputs with reset - the second will turn high on the negative slope of the first. it means after the reset you get "010", inverted into "101" at the output (dear value 5).

If you need a scheme, I can add a sketch of how it looks in my imagination.
Manipulating JK makes the scheme more flexible, but also much more complicated, let's try to avoid that.
 
Why don't you do it properly? Implement the next state equations with appropriate JK inputs instead of setting them all 1. Using appropriate "don't cares" for the disallowed states results in very simple JK equations requiring no additional logic gates at all.
 
LCKurtz said:
Why don't you do it properly? Implement the next state equations with appropriate JK inputs instead of setting them all 1. Using appropriate "don't cares" for the disallowed states results in very simple JK equations requiring no additional logic gates at all.

is there a way you can provide an example, but not give the answer...say in a 2 bit jk circuit counting from 2 to 1...skipping 3 and 0...or something similar.
 
surfy14 said:
is there a way you can provide an example, but not give the answer...say in a 2 bit jk circuit counting from 2 to 1...skipping 3 and 0...or something similar.

Haven't you studied clocked state machines in your class? You have the general equation for the next state of a JK flip-flop$$
Q^+ = J\bar Q +\bar K Q$$so you can calculate ##J## by picking the 1's off the ##\bar Q## portion of the K-map and ##K## by picking the 0's off the ##Q## portion of the K-map of your next state equation for each bit. If you don't know what I'm talking about, you probably need more help than I can give you here.
 
LCKurtz said:
Haven't you studied clocked state machines in your class? You have the general equation for the next state of a JK flip-flop$$
Q^+ = J\bar Q +\bar K Q$$so you can calculate ##J## by picking the 1's off the ##\bar Q## portion of the K-map and ##K## by picking the 0's off the ##Q## portion of the K-map of your next state equation for each bit. If you don't know what I'm talking about, you probably need more help than I can give you here.

What you suggest requires an explicit control of J and K inputs (and in general case it is a proper way) meaning that you need a complex logic in the front part. What surfy14 does is just using the time strobe. I think his task can be solved but can not be generalized to any output sequences. If you control J and K it is easy to obtain any sequence of numbers at the output with quite simple reorganization of the input control logic.
 
LCKurtz said:
Haven't you studied clocked state machines in your class? You have the general equation for the next state of a JK flip-flop$$
Q^+ = J\bar Q +\bar K Q$$so you can calculate ##J## by picking the 1's off the ##\bar Q## portion of the K-map and ##K## by picking the 0's off the ##Q## portion of the K-map of your next state equation for each bit. If you don't know what I'm talking about, you probably need more help than I can give you here.

I made my transition table, k-maps, and equations, but not sure if they are right.

Here are my final next state equations derived from my k-maps

Q0 next state = Q0 NOT
Q1 next state = Q0
Q2 next state = Q1 NOT * Q0 + Q1 * Q0 NOT

Using Q+ = J QNOT + KNOT Q

J2 = Q1 NOT
K2 = Q1

I don't now how to calculate j0/k0/j1/k1 since their equations are not in the format of Q+ = J QNOT + KNOT Q. It is probably something easy that I'm not seeing...this is the first time I've attempted something like this so bear with me.
 
Last edited:
  • #10
surfy14 said:
I made my transition table, k-maps, and equations, but not sure if they are right.

Here are my final next state equations derived from my k-maps

Q0 next state = Q0 NOT
Q1 next state = Q0
Q2 next state = Q1 NOT * Q0 + Q1 * Q0 NOT

Using Q+ = J QNOT + KNOT Q

J2 = Q1 NOT
K2 = Q1

I don't now how to calculate j0/k0/j1/k1 since their equations are not in the format of Q+ = J QNOT + KNOT Q. It is probably something easy that I'm not seeing...this is the first time I've attempted something like this so bear with me.

OK, that's good progress. I agree that ##Q_0^+=\bar Q_0##. One way to figure out J and K is to notice from the next state equation for a JK flip flop ##Q^+=J\bar Q+\bar K Q## that ##J = Q^+|_{Q=0}## and ##\bar K = Q^+|_{Q=1}##. So in this case, where ##Q_0^+=\bar Q_0##, when ##Q_0=0## you get ##J_0=1## and when ##Q_0=1## you get ##\bar K_0 = 0##, so ##K_0 = 1##. That makes sense because, if you think about it, if you want a JK flip flop to toggle on every clock pulse, you want J and K to be 1.

Now, turning to ##Q_2##, the most significant bit, I agree again that ##Q_2^+=Q_0\bar Q_1+\bar Q_0Q_1##. You could do the same thing here, but it is better to go to the K-map, because you can use the don't cares. What you want to do to get ##J_2## is just look at the ##Q_2=0## part of the K-map and pick the 1's plus any good don't cares. To get ##K_2##, pick the 0's from the ##Q_2=1## part of the K-map, again using any useful don't cares. See what you get.

Finally, for ##Q_1##, check your tables and see if you don't get ##Q_1^+=\bar Q_0\bar Q_1+Q_0Q_1##. Then do either of the above techniques to get ##J_1## and ##K_1##.
 
Last edited:
  • #11
LCKurtz said:
OK, that's good progress. I agree that ##Q_0^+=\bar Q_0##. One way to figure out J and K is to notice from the next state equation for a JK flip flop ##Q^+=J\bar Q+\bar K Q## that ##J = Q^+|_{Q=0}## and ##\bar K = Q^+|_{Q=1}##. So in this case, where ##Q_0^+=\bar Q_0##, when ##Q_0=0## you get ##J_0=1## and when ##Q_0=1## you get ##\bar K_0 = 0##, so ##K_0 = 1##. That makes sense because, if you think about it, if you want a JK flip flop to toggle on every clock pulse, you want J and K to be 1.

Now, turning to ##Q_2##, the most significant bit, I agree again that ##Q_2^+=Q_0\bar Q_1+\bar Q_0Q_1##. You could do the same thing here, but it is better to go to the K-map, because you can use the don't cares. What you want to do to get ##J_2## is just look at the ##Q_2=0## part of the K-map and pick the 1's plus any good don't cares. To get ##K_2##, pick the 0's from the ##Q_2=1## part of the K-map, again using any useful don't cares. See what you get.

Finally, for ##Q_1##, check your tables and see if you don't get ##Q_1^+=\bar Q_0\bar Q_1+Q_0Q_1##. Then do either of the above techniques to get ##J_1## and ##K_1##.

thx for your help. close this thread.
 
Back
Top