# How to create a up/down circuits using Flipflops

Discussion in 'Homework Help' started by mrmap, Apr 29, 2012.

1. ### mrmap Thread Starter New Member

Apr 29, 2012
2
0
Hi all,
My homework is design a counting number circuits down from 362 to 0, and up from 0 to 362, later.
we just only use Flipflop.
What should I do? Anyone could help me
Thank you so much

Jan 3, 2012
26
4
3. ### PNeil New Member

Oct 27, 2010
11
1
Since you will be using FFs, you will need to figure out how much FFs you need. Here is a formula you can use.

NumberOfFlipFlops = log(MaxCount) / log(2)

Where MaxCount is the highest number you want to count to.

For example, if you want to count to a maximum of 16, you need 4 Flip Flops.

NumberOfFlipFlops = log(16) / log(2)

On the other hand, if you want to know how much a group of filps will count to, you can use this formula.

MaxCount = 2^NumberOfFlipFlops

This formula works because exponent is the opposite (complement) of log.

For example, if you have 4 FFs,

2^4 = 16

In your case, the need to count to 362.

log(362) / log(2) = 8.499845887

Since you must use a whole FF, you need to round that number off to 9 flip flops, since 8 flips will only count to 256. (use the formula) 9 will however cout to 512 (way more than you need, but you have no choice here)

Next you need to determine what type of FFs you will use (JK, D, etc.)

D FFs are easier to use, while JK are more universal and give more versatility.

Determine if Counter will be Synchronous or Asynchronous.

I am gonna assume you know how to connect them.

You need away to set the FFs to the top number (362) and then put the FFs in a mode to count down. With further detection or a switch, instruct the FFs to count up.

While this circuit is not hard to do, it is a rather large circuit. Especially if you use JKs. Logic gates are also needed for detection. It would be a lot easier if you use counter ICs

spark8217 likes this.
4. ### mrmap Thread Starter New Member

Apr 29, 2012
2
0
Thank you for supporting me. But I just have one problem.
The problem is the way to set first value of FF. For example, I want to set the first value equals 2. And then the Counter will countdown 2 - 1 - 0 - 9 -8 7 -6 -5 4 -3 -2 -1 -0.

5. ### WBahn Moderator

Mar 31, 2012
17,788
4,808
First, focus on getting a single bit to do the things that you need it to do. But, of course, first you have to figure out what you need it to do.

Let's first consider a three bit counter to keep things really simple. Call the bits A, B, and C with A being the right-most bit and C being the left-most. So the value that it represents is CBA in binary where each letter is replaced with the current value of that bit.

Now, let's say that you want to load a particular value into the counter. Well, you need a LOAD signal that actually says to load the value. For a given bit, you also need a signal that says what value to load it with. So each bit will have it's own VALUE signal, but the LOAD signal will be common to all of them.

So, with just this, can you write a truth table that, give the values of LOAD and VALUE for a given bit (FF) tell you what the next state of the bit should be? Only worry about the case when LOAD is HI right now, because we haven't talked about what we want it to do when it is running (LOAD is LO).

When it's not being loaded, we want it to either count up or count down, except when we are at either end of the count cycle (362 going up and 0 going down). So, let's say that we have a value of 001 and are counting up, what do we want the next value for the bits to be? Look at this in general and figure out, given an arbitrary binary value (say 010110111) how you determine what happens to which bits. Do the same thing for counting down.

Once you have that figured out, ask how you would us an UP signal to control whether you use the counting up logic or the counting down logic.

The only remaining thing is to produce a signal that is HI when you are at the end of the count cycle and use it to toggle the UP signal.

Each one of these tasks is pretty straightforward by itself, so work on figuring them out separately. Then worry about combining them into a coherent whole.