Electronic – A binary counter problem

circuit-designcounterdigital-logic

How can I create a digital counter that counts from 000 to 111 and automatically starts reverse counting from 111 to 000. I have tried with simulation it works fine, but with actual ICs I am not getting a proper output.

The following is the hand-made version of the circuit diagram that I simulated on cedar:

enter image description here

original fuzzy image

The top ones are 7 D flip-flops and the bottom ones are three JK flip-flops implementing the up-down counter.

Best Answer

You could do something like this:

forward and reverse bin counter

View the simulation in falstad.com

To build it1, I started with a simple 3-bit "up" counter, similar to the one below - except I used T-flip flops for simplicity, and we only need the first three stages.

up counter from allaboutcircuits.com

image credit: www.allaboutcircuits.com

And a "down" counter:

down counter from allaboutcircuits.com

image credit: www.allaboutcircuits.com

The goal is to have the circuit change from an "up" counter to a "down" counter, and vice versa, when the outputs become binary 111 and 000, respectively.

To do this, I added A1, to detect when the outputs are all high, and A2 to detect when they are all low. The outputs of these two detectors are then sent to Q4 to set and reset the direction flow. So, Q4 can be thought of as a direction controller.

Notice that when Q4 is reset (i.e. has a 0 output) the XOR gates X1 and X2 are simply voltage followers of Q1 and Q2. So, X1 and X2 essentially become transparent.

When Q4 is set (has a 1 output), X1 and X2 invert the outputs of Q1 and Q2, and therefore mimic the \$\bar Q\$ signals. And it is the \$\bar Q\$ signals which are used to create the "down" counter, in the image above.

1I'm using the "I" here because there are likely many different ways to accomplish this. Here, I'm just discussing what I did.