# Design a Counter With an Arbitrary Sequence

I'm trying to design an asynchronous counter with JK flip- flops, with an arbitrary sequence.

The sequence is: 0,1,10,11,0,5,14,15.

I know how to solve this kind of problems, but in this case the sequence repeats one number, 0.

I want to solve this like this guy: https://www.youtube.com/watch?v=Zce6NlHuvfs

But I don't how to manage the problem of the repetition of one number in the sequence.

Any idea?

• Keeping track of the preceding value is a potential solution. Dec 18, 2016 at 14:01

If you write down the mapping of count states 0-7 to outputs

count             oputput
C2 C1 C0          O3 O2 O1 O0
0  0  0           0  0  0  0    =  0
0  0  1           0  0  0  1    =  1
0  1  0           1  0  1  0    = 10
0  1  1           1  0  1  1    = 11
1  0  0           0  0  0  0    =  0
1  0  1           0  1  0  1    =  5
1  1  0           1  1  1  0    = 14
1  1  1           1  1  1  1    = 15


You see that
O0 = C0
O1 = O3 = C1
O2 = (C0 OR C1) AND C2

So you can accomplish that simply with a 3 bit counter one OR and one AND gate:

simulate this circuit – Schematic created using CircuitLab

Note: there is, however, a so-called hazard between count state 5 and 6, i.e. there might be multiple edges before the signal settles to the new state. That won't be a problem if you don't care about output edges, only about levels.

• This is good. +1! Dec 18, 2016 at 14:32
• Which software do you use to make that schematic? Dec 18, 2016 at 18:41
• @Josedearimatea He's using the schematic editor built into site. See the pencil, diode, capacitor and resistor symbol at top of the Editor or type Ctrl-M while in Editor. Dec 18, 2016 at 20:12

Instead of making a counter that counts in a strange sequence, let the counter count normally, then map the result thru a lookup table. It seems your numbers are limited to the 0-15 range, so 4 bits. That means you only need a 4-bit memory with 4-bit addresses, for a total of 64 bits.

Even easier is to do this all in firmware in a microcontroller. Generate the count by incrementing, then use the low 4 bits to index into a table.