# Flip flop mod counter

1. Apr 14, 2012

### surfy14

1. The problem statement, all variables and given/known data

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....

3. The attempt at a solution

I currently can get it to count from 7 down to 2 no problems...the issue is...I dont 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.

2. Apr 15, 2012

### ivanis

Remove the inverter on the output hexD(1)

3. Apr 15, 2012

### surfy14

that does start the counter at 5, but the order is 5, 4, 7, 6, 1, 0....it is not 5, 4, 3, 2

4. Apr 16, 2012

### ivanis

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.

5. Apr 16, 2012

### LCKurtz

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.

6. Apr 16, 2012

### surfy14

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.

7. Apr 16, 2012

### LCKurtz

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.

8. Apr 17, 2012

### ivanis

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.

9. Apr 17, 2012

### surfy14

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 dont 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: Apr 17, 2012
10. Apr 17, 2012

### LCKurtz

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: Apr 17, 2012
11. Apr 17, 2012