Flip Flop counter design

WBahn

Joined Mar 31, 2012
30,088
It sounds like you need to learn basically everything about designing a finite state machine, and that is not a reasonable expectation for a forum such as this. We can help, but you need to do the bulk of it.

So this is what I recommend you do at this point.

Go back to your textbook (or whatever materials you are working from) and study how to design and implement a finite state machine. If you see a discussion of Mealy and Moore machines, you want to focus on a Moore machine.

In general, this is a multistep approach. You first draw a state diagram and, from that, a transition table. Then, for every entry in your transition table you determine the needed values of the FF control inputs. From there, you determine the excitation logic for each input. This is usually followed by minimizing the logic, but that is optional. After that, you just wire it up.

You don't have to get it all. Work as far as you can and, when you get stuck, post what you have done thus far and we can then help you get to the next step. The steps above are a good guide. Draw your state diagram and post that so that we can check it before you attempt to make your transition table -- unless you are confident in your state diagram, in which case keep moving. But when you do get stuck, post everything up to that point. That way we can identify at which point in your work you went astray.
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
It sounds like you need to learn basically everything about designing a finite state machine, and that is not a reasonable expectation for a forum such as this. We can help, but you need to do the bulk of it.

So this is what I recommend you do at this point.

Go back to your textbook (or whatever materials you are working from) and study how to design and implement a finite state machine. If you see a discussion of Mealy and Moore machines, you want to focus on a Moore machine.

In general, this is a multistep approach. You first draw a state diagram and, from that, a transition table. Then, for every entry in your transition table you determine the needed values of the FF control inputs. From there, you determine the excitation logic for each input. This is usually followed by minimizing the logic, but that is optional. After that, you just wire it up.

You don't have to get it all. Work as far as you can and, when you get stuck, post what you have done thus far and we can then help you get to the next step. The steps above are a good guide. Draw your state diagram and post that so that we can check it before you attempt to make your transition table -- unless you are confident in your state diagram, in which case keep moving. But when you do get stuck, post everything up to that point. That way we can identify at which point in your work you went astray.
Can't you solve an example?
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
how do we determine the required entry values for ff?

--------------------NEXT
Q2 Q1 Q0-------Q2 Q1 Q0
0 0 0---------------0 0 0
0 0 1---------------1 1 0
0 1 0---------------1 0 0
0 1 1---------------0 1 0
 
Last edited:

MrChips

Joined Oct 2, 2009
30,824
Designing a synchronous state machine is a methodical step-by-step process.
Have you studied this in class?
Do you know what is a Karnaugh map?
 

MrChips

Joined Oct 2, 2009
30,824
Here is an exercise.

Pick any random sequence of non-repeating states:

3 - 6 - 7 - 1 - 0 - 9 - 4 - repeat...

Design a synchronous state machine that will cycle through the sequence and then repeat.
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
Here is an exercise.

Pick any random sequence of non-repeating states:

3 - 6 - 7 - 1 - 0 - 9 - 4 - repeat...

Design a synchronous state machine that will cycle through the sequence and then repeat.
I don't understand if we can set an example together?
 

WBahn

Joined Mar 31, 2012
30,088
Very good. I haven't gone through it in detail, but it is the right approach. You are VERY close to having the problem solved!

So the circuit as shown should show the sequence 0 -> 2 -> 3 -> 1 on the seven segment display. Does it?

Which FF is Q1 and which is Q2? Annotating your drawing with that information is a very good idea. It's also pretty customary to call the least significant bit Q0 and count up from there. That's because the subscript can then be used as the exponent when determining the state value. But, for reasons that will hopefully become self-evident in another step or two, it actually makes sense to use Q1 and Q2 in the original problem you are working on.

Since the Q' of the left FF goes to the K input of the right FF, it would appear that the left FF is Q1 and the right one is Q2, which would make the left FF your lsb. But the lsb of the 7SEG display is being driven by the right FF. So it appears that your signals to the display are swapped, which would mean that if the machine is sequencing properly it would actually be displaying the sequence

0 -> 1 -> 3 -> 2

Is this what you are seeing?

Once this is resolved, what happens if you instead of grounding the upper two bits and applying Q2 and Q1 to the lower two bits, you instead ground the most and least significant bits and apply Q2 and Q1 to the middle two bits? What is the resulting sequence? What mathematical relationship does it have to the sequence you were seeing before you shifted the signals?
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
Very good. I haven't gone through it in detail, but it is the right approach. You are VERY close to having the problem solved!

So the circuit as shown should show the sequence 0 -> 2 -> 3 -> 1 on the seven segment display. Does it?

Which FF is Q1 and which is Q2? Annotating your drawing with that information is a very good idea. It's also pretty customary to call the least significant bit Q0 and count up from there. That's because the subscript can then be used as the exponent when determining the state value. But, for reasons that will hopefully become self-evident in another step or two, it actually makes sense to use Q1 and Q2 in the original problem you are working on.

Since the Q' of the left FF goes to the K input of the right FF, it would appear that the left FF is Q1 and the right one is Q2, which would make the left FF your lsb. But the lsb of the 7SEG display is being driven by the right FF. So it appears that your signals to the display are swapped, which would mean that if the machine is sequencing properly it would actually be displaying the sequence

0 -> 1 -> 3 -> 2

Is this what you are seeing?

Once this is resolved, what happens if you instead of grounding the upper two bits and applying Q2 and Q1 to the lower two bits, you instead ground the most and least significant bits and apply Q2 and Q1 to the middle two bits? What is the resulting sequence? What mathematical relationship does it have to the sequence you were seeing before you shifted the signals?
right U4:B = Q2
 

WBahn

Joined Mar 31, 2012
30,088
right U4:B = Q2
So the signals to the display are swapped and, if you're solutions is otherwise correct, you should be seeing the sequence

0 -> 1 -> 3 -> 2

Is that what you are seeing. If so, swap the two signals to the display. If not, what is it displaying. No point proceeding until we get it working correctly up to this point.
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
Very good. I haven't gone through it in detail, but it is the right approach. You are VERY close to having the problem solved!

So the circuit as shown should show the sequence 0 -> 2 -> 3 -> 1 on the seven segment display. Does it?

Which FF is Q1 and which is Q2? Annotating your drawing with that information is a very good idea. It's also pretty customary to call the least significant bit Q0 and count up from there. That's because the subscript can then be used as the exponent when determining the state value. But, for reasons that will hopefully become self-evident in another step or two, it actually makes sense to use Q1 and Q2 in the original problem you are working on.

Since the Q' of the left FF goes to the K input of the right FF, it would appear that the left FF is Q1 and the right one is Q2, which would make the left FF your lsb. But the lsb of the 7SEG display is being driven by the right FF. So it appears that your signals to the display are swapped, which would mean that if the machine is sequencing properly it would actually be displaying the sequence

0 -> 1 -> 3 -> 2

Is this what you are seeing?

Once this is resolved, what happens if you instead of grounding the upper two bits and applying Q2 and Q1 to the lower two bits, you instead ground the most and least significant bits and apply Q2 and Q1 to the middle two bits? What is the resulting sequence? What mathematical relationship does it have to the sequence you were seeing before you shifted the signals?
YES 0 -> 1 -> 3 -> 2 runningphoto.JPG
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
So the signals to the display are swapped and, if you're solutions is otherwise correct, you should be seeing the sequence

0 -> 1 -> 3 -> 2

Is that what you are seeing. If so, swap the two signals to the display. If not, what is it displaying. No point proceeding until we get it working correctly up to this point.
yes i see it works.
 

WBahn

Joined Mar 31, 2012
30,088
So swap those two signals and then move them one position to the left (which can be accomplished by moving the Q2 signal from the lsb to the third bit position and grounding the lsb.

What is the sequence you now see?
 

Thread Starter

EYT1

Joined Apr 7, 2020
84
So swap those two signals and then move them one position to the left (which can be accomplished by moving the Q2 signal from the lsb to the third bit position and grounding the lsb.

What is the sequence you now see?
I do not fully understand
 

WBahn

Joined Mar 31, 2012
30,088
I do not fully understand
The circuit in your latest drawing is not the same as the earlier ones. So let's work with your most recent drawing:

FSM.PNG
Assuming I've walked it through correctly, I would expect to see the sequence 0->2->3 displayed.
 
Top