Register to reply

Flip flop mod counter

by surfy14
Tags: counter, flip, flop
Share this thread:
surfy14
#1
Apr14-12, 07:52 PM
P: 5
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.

Phys.Org News Partner Science news on Phys.org
Security CTO to detail Android Fake ID flaw at Black Hat
Huge waves measured for first time in Arctic Ocean
Mysterious molecules in space
ivanis
#2
Apr15-12, 02:33 AM
P: 7
Remove the inverter on the output hexD(1)
surfy14
#3
Apr15-12, 05:31 PM
P: 5
Quote Quote by ivanis View Post
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

ivanis
#4
Apr16-12, 04:21 AM
P: 7
Flip flop mod counter

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.
LCKurtz
#5
Apr16-12, 02:14 PM
HW Helper
Thanks
PF Gold
LCKurtz's Avatar
P: 7,583
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.
surfy14
#6
Apr16-12, 09:59 PM
P: 5
Quote Quote by LCKurtz View Post
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.
LCKurtz
#7
Apr16-12, 10:38 PM
HW Helper
Thanks
PF Gold
LCKurtz's Avatar
P: 7,583
Quote Quote by surfy14 View Post
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.
ivanis
#8
Apr17-12, 01:51 AM
P: 7
Quote Quote by LCKurtz View Post
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.
surfy14
#9
Apr17-12, 12:36 PM
P: 5
Quote Quote by LCKurtz View Post
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 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.
LCKurtz
#10
Apr17-12, 01:36 PM
HW Helper
Thanks
PF Gold
LCKurtz's Avatar
P: 7,583
Quote Quote by surfy14 View Post
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.
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##.
surfy14
#11
Apr17-12, 02:01 PM
P: 5
Quote Quote by LCKurtz View Post
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.


Register to reply

Related Discussions
Counter Flip Flop Help Please! Engineering, Comp Sci, & Technology Homework 7
T flip-flop counter using VHDL Electrical Engineering 1
Drawing D flip flop using T flip flop Engineering, Comp Sci, & Technology Homework 2
Lab Memo: Flip-Flop Analysis - 4 bit counter Engineering, Comp Sci, & Technology Homework 2