Skip to content

Digital Logic

How a Johnson counter works

A Johnson counter, or twisted ring counter, is a shift register whose last output is fed back to its first input inverted: the last flip-flop's Q̄ goes to the first one's D. Starting from all zeros it fills with 1s one at a time, then empties one at a time, and repeats. With n flip-flops it steps through 2n states, and only one bit changes per step.

From a ring to a twisted ring

Wire flip-flops in a ring on one clock: each Q to the next D, the last back to the first. On every tick each bit moves one place along. A plain ring only moves what's already in it, so from 000 it passes 0s round for ever.

Feed the first flip-flop the last one's Q̄ instead. While the last is 0, 1s pour in; once it's 1, 0s pour in. That's the twist.

The sequence

With three flip-flops, first on the left:

TickStateChange
0000
1100first fills
2110second fills
3111full
4011first empties
5001second empties
6000back to the start
states = 2 × number of flip-flops

Six states from three flip-flops; eight from four; ten from five.

Live experiment

Start a stadium wave

Three, four or five fans in a row are flip-flops on one clock, each copying the fan before. The first copies the last one's Q̄ (a twisted ring), its Q (a plain ring), or nothing. From all sitting, the twisted ring fills with 1s and empties again, one fan changing per step: 2n patterns from n fans.

Try it yourself: free lesson

“The twisted ring” is lesson 6 of 6 in Toggle Tides, Digital Logic World 3. Free with an account. Lessons unlock in order, so you’ll do the 19 before it first.

One gate per state

Because the pattern fills and empties in order, any single state can be picked out by looking at just two flip-flops. 110 is the only state with the second flip-flop on and the third off, so FF2 Q AND FF3 Q̄ lights for that state alone. 000 is FF1 Q̄ AND FF3 Q̄; 111 is FF1 Q AND FF3 Q. A binary counter needs a gate watching every bit to do the same. And since only one bit changes per step, like Gray code, a decoding gate never sees a half-changed pattern and never glitches.

Stray states

Three flip-flops can hold eight patterns, but the sequence uses six. The other two, 010 and 101, turn into each other on every tick and never rejoin the sequence. A real design resets everything to 0 at power-up, or adds a small correction gate, so the counter can't start in that loop.

Where Johnson counters are used

The CD4017 chip is a five-stage Johnson counter with ten decoded outputs, the heart of countless LED chasers. A two-stage one steps 00, 10, 11, 01: two square waves a quarter cycle apart, the quadrature signals that radios and stepper-motor drivers use. And because each state is easy to decode, a Johnson counter makes a neat state machine for anything that cycles through a fixed list, from washing-machine programmes to traffic lights.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“The twisted ring” is lesson 6 of 6 in Toggle Tides, Digital Logic World 3. Free with an account. Lessons unlock in order, so you’ll do the 19 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3In a twisted ring, the first flip-flop's D comes from…
    Show the answer

    Answer: The last one's Q̄. That's the twist. From the last Q you'd have a plain ring, which starting from all 0s never changes.

    • Why not “The last one's Q”? That's a plain ring. Starting from all 0s it just passes 0s round and never changes.
    • Why not “Its own Q̄”? That would make the first stage a toggle, a divide-by-2, not part of the ring.
    • Why not “The clock”? The clock times every flip-flop. The first one's data comes from the last stage.
  2. Question 2 of 3Three flip-flops in a twisted ring read 111, first one on the left. On the next tick they read…
    Show the answer

    Answer: 011. The first takes the last one's Q̄, which is 0; the others take the bit before them. 111 becomes 011, and the ring starts to empty.

    • Why not “000”? Only the first flip-flop takes a new value. The others copy their neighbours, which are still 1.
    • Why not “100”? 100 is the first step from 000. From 111 the first stage takes a 0 and the others shift along.
    • Why not “110”? 110 comes before 111 as the ring fills. Next, the first takes the last one's Q̄, a 0, and the ring starts to empty.
  3. Question 3 of 3A plain ring, no twist, powers up at 000. Five ticks later it reads…
    Show the answer

    Answer: 000: there's nothing to pass along. Every flip-flop copies a 0 from the one before. A ring only moves what's already in it.

    • Why not “111”? Nothing ever puts a 1 into a plain ring that starts empty, so it can't fill up.
    • Why not “001”? There's no 1 anywhere in the ring to pass along, so no stage ever changes.
    • Why not “100”? A 1 would need to come from somewhere. Every flip-flop copies a 0 from the one before.
Keep practising: free lesson

“The twisted ring” is lesson 6 of 6 in Toggle Tides, Digital Logic World 3. Free with an account. Lessons unlock in order, so you’ll do the 19 before it first.

Questions people ask

How many states does a Johnson counter have?

Twice the number of flip-flops: 2n. Three flip-flops step through six states, four through eight, five through ten. A binary counter with the same flip-flops would have 2ⁿ states, but needs more logic to decode them.

What is the difference between a ring counter and a Johnson counter?

A ring counter feeds the last Q straight back, so a single 1 circulates and n flip-flops give n states, but it must be loaded with that 1 first. A Johnson counter feeds back the last Q̄, starts happily from all zeros, and gives 2n states.

What happens if a Johnson counter starts in an unused state?

Three flip-flops have eight patterns but use six. The other two, 010 and 101, chase each other in a loop of their own and never rejoin the sequence. Practical designs reset to 000 at power-up, or add a gate that steers a stray state back.

Every topic