Table of Contents
ToggleOne inverted feedback wire turns a plain shift register into a counter with twice the states and almost free decoding. We build a 4 bit version from D flip flops, read its truth table and timing, and fix the lock out problem.
The twisted ring design feeds the inverted last output back to the first D flip flop, so N stages count through 2N states with one bit changing per clock. Below you will find the truth table, timing, decoding gates, lock out states and a working calculator.

What is a Johnson counter and how does it work?
Johnson counter is a shift register counter in which the inverted output of the last D flip flop drives the input of the first, so N flip flops give 2N states. A 4 bit version steps 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001 and repeats. With an 8 kHz clock, each flip flop output becomes a 1 kHz square wave at 50% duty.
What Is a Johnson Counter?
A johnson counter is a synchronous shift register counter whose last flip flop feeds its inverted output back to the first flip flop. Because of this twist, N flip flops step through 2N unique states, so 4 flip flops count to 8 and 5 flip flops count to 10.
- Other names: twisted ring counter, switch tail ring counter, walking ring counter.
- Count: 2N for N flip flops (MOD 2N), against N for a plain ring counter.
- Only one flip flop changes per clock, like a Gray code.
- Any single state decodes with one 2 input AND gate.
- Unused patterns: 2^N minus 2N, which can form a lock out loop.
You will meet it in decade counters, LED chasers, stepper motor drivers and clock dividers. If you are new to counters, first read our guide to ripple and synchronous counters, because this design sits in the synchronous family.
A 5 stage version with 10 decoded outputs is what sits inside the popular CD4017 decade counter IC. The chip also adds anti lock gating so it cannot get trapped in an unused state.
How Does a Johnson Counter Work?
It shifts data one stage to the right on every clock edge while the first stage loads the complement of the last stage. Starting from all zeros, ones fill the register from the left and then zeros fill it again, giving 2N states before the pattern repeats.
Take four D flip flops named A, B, C and D, the edge triggered type from our article on flip flop types. Q of A drives D of B, Q of B drives D of C and Q of C drives D of D, exactly like a serial in shift register.
The only change is the feedback wire. A plain ring counter sends Q of D back to the input of A, while here we take the inverted output Q’ of D, and that single inversion is what doubles the count.

Use edge triggered D flip flops, never level sensitive latches. A transparent latch lets data race through several stages in one clock, as our note on latches shows.
Johnson Counter Truth Table for 4 Bit
The 4 bit truth table has 8 rows, one per clock pulse, and every row differs from the previous one in exactly one bit. The last column lists the 2 input AND gate that decodes each state.
| Clock | QA | QB | QC | QD | State | Decode gate |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | S0 | QA’ . QD’ |
| 1 | 1 | 0 | 0 | 0 | S1 | QA . QB’ |
| 2 | 1 | 1 | 0 | 0 | S2 | QB . QC’ |
| 3 | 1 | 1 | 1 | 0 | S3 | QC . QD’ |
| 4 | 1 | 1 | 1 | 1 | S4 | QA . QD |
| 5 | 0 | 1 | 1 | 1 | S5 | QA’ . QB |
| 6 | 0 | 0 | 1 | 1 | S6 | QB’ . QC |
| 7 | 0 | 0 | 0 | 1 | S7 | QC’ . QD |
| 8 | 0 | 0 | 0 | 0 | S0 | repeats |
Read it column by column and you see that QB is QA delayed by one clock, QC is QB delayed by one clock, and so on. Because only one bit moves at a time, the code is a kind of Gray code, which is why decoding is glitch free.
How Many States Does a Johnson Counter Have?
With N flip flops you get 2N valid states, while the register can hold 2^N patterns, so 2^N minus 2N patterns stay unused. For 4 flip flops that means 8 used and 8 unused.
Count unused = 2^N minus 2N
Stage output = f clk / 2N
Decoded pulse = 1 / f clk
A binary counter uses all 2^N patterns, but each output then needs a wider decoding gate, as in our 7 segment display decoder. The twisted ring needs more flip flops for the same count, but every state decodes with a 2 input gate.

Each output rises one clock after the stage before it and stays high for 4 clocks, a square wave with 50% duty. With an 8 kHz clock every waveform repeats at 1000 Hz.
How to Decode the States With 2 Input AND Gates
You decode any state of a johnson counter with one 2 input AND gate placed on the boundary between ones and zeros in the pattern. Every valid state has exactly one such boundary, so the rule works for any length.
A 4 bit design needs 8 such gates, one per state, as listed in the truth table. A binary counter of the same count needs 3 input gates and can glitch when two bits change together, which our encoder and decoder guide covers.
With only NAND or NOR gates on the board, Boolean algebra lets you rewrite each AND term. A small Karnaugh map that treats unused patterns as do not care confirms each equation.
Sum the four outputs of a 4 bit version through suitably chosen resistors into one node and you get a stepped sine wave. Its frequency follows the clock, so changing the clock tunes the sine.
What Are Lock Out States in a Johnson Counter?
Lock out states are unused patterns in which the counter can start after power up or a noise spike and then keep circulating without ever reaching the valid sequence. In the 4 bit design all 8 unused patterns form one closed loop.
| Step | QA QB QC QD | Step | QA QB QC QD |
|---|---|---|---|
| 1 | 0 1 0 0 | 5 | 1 0 1 1 |
| 2 | 1 0 1 0 | 6 | 0 1 0 1 |
| 3 | 1 1 0 1 | 7 | 0 0 1 0 |
| 4 | 0 1 1 0 | 8 | 1 0 0 1 |
After step 8 the register returns to 0100 and the loop repeats forever. You fix it with a power on reset that clears every flip flop, a self correcting gate on one D input, or both.
Self correcting: DC = QB . (QA + QC)
Recovery within 5 clocks
In every valid state the new expression equals QB, so the normal count is untouched. We simulated all 16 starting patterns, and each unused one reaches the valid loop within 5 clocks.
Johnson Counter Calculator: States and Output Frequency
Enter the number of flip flops and the clock frequency, and the calculator gives the MOD number, unused patterns, stage output frequency and decoded pulse timing.
Johnson Counter Solved Example
A 4 bit johnson counter on an 8 kHz clock gives a 1000 Hz square wave at every stage output, and each decoded state stays high for 125 microseconds. The working uses the calculator default numbers.
States = 2 x 4 = 8 (MOD 8)
Unused = 16 minus 8 = 8
f out = 8000 / 8 = 1000 Hz
Decoded pulse = 1 / 8000 s = 125 µs
Decoded period = 8 x 125 µs = 1000 µs
So each decoded output is high 12.5 % of the time, one clock in eight. The clock often comes from a 555 timer or a crystal oscillator, so check the datasheet maximum clock rate at your supply voltage.
Difference Between Ring Counter and Johnson Counter
A ring counter returns Q of the last stage to the first and gives N states, while a johnson counter returns the inverted output and gives 2N states. So the same flip flops count twice as far.
| Feature | Ring counter | Johnson counter |
|---|---|---|
| Feedback | Q of last stage | Inverted Q of last stage |
| States with N flip flops | N | 2N |
| Decoding | None, outputs are one hot | One 2 input AND gate per state |
| Start up | Must preset a single 1 | Starts from 0000 after reset |
| Unused patterns (N = 4) | 12 | 8 |
- Twice the states of a ring counter
- Glitch free decoding with 2 input gates
- Exact 50% duty at every stage
- Fully synchronous, no ripple delay
- Uses only 2N of 2^N patterns
- Can lock out without reset or correction
- Many flip flops for long counts
- Needs decode gates, unlike a ring counter
Johnson Counter Troubleshooting Tips
Most faults come from a dirty clock, a missing reset or a lock out state, so check them in that order. The flowchart shows the sequence we follow on the bench.

- Probe the clock at every flip flop pin and look for clean, single edges.
- Confirm reset clears all stages to 0000 at power up.
- Step the clock slowly and check that only one bit changes per pulse.
- Tie unused CMOS inputs such as clock enable to a valid level.
- Fit a 100 nF decoupling capacitor close to each logic IC supply pin.
A slow or noisy clock edge can double clock a CMOS stage and make the count jump. Use a Schmitt trigger buffer and a short clock trace, as in our guide to noise reduction in digital ICs.
If the sequence is right but the LEDs are dim, look at output loading. Size each series resistor with our LED resistor calculator, and use a logic level shifter when a 3.3 V controller clocks a 5 V counter.
Where Is a Johnson Counter Used?
You use it wherever you need a short, glitch free sequence of evenly spaced pulses, such as decade counting, phase generation, motor stepping and LED sequencing.
The phase sequence of a stepper motor uses the same idea. In a PLC you can copy the pattern with bit shift and rotate instructions, inverting the bit that wraps around.
Pause the video after each clock pulse and compare its pattern with our truth table. Then try a 5 stage version on paper and check that you get 10 states.
Johnson Counter FAQ
A ring counter feeds Q of the last flip flop back to the first and gives N states, while the Johnson type feeds back the inverted output and gives 2N states.
With 4 flip flops the ring version is MOD 4 and the twisted version is MOD 8.
You need 5 flip flops, because N stages give 2N states and 2 x 5 = 10 states in total.
Each of the 10 states then decodes with one 2 input AND gate, which is how a decade counter IC is built.
Divide the clock frequency by 2N, where N is the number of flip flops.
For a 4 bit counter on an 8 kHz clock, 8000 / 8 gives 1000 Hz at every stage output, and each decoded state lasts 125 microseconds.
It has started in a lock out state, one of the 2^N minus 2N unused patterns that loop among themselves.
Add a power on reset that clears all stages, or a self correcting gate such as DC = QB . (QA + QC) in a 4 bit design.
Each state needs one 2 input AND gate that watches two adjacent outputs.
For example, state S2 (1100) decodes as QB . QC’ and state S0 (0000) as QA’ . QD’, so a 4 bit counter needs 8 small gates.
Related Articles
- Counters: Ripple vs Synchronous
- Flip Flop Types: SR, JK, D and T
- 74HC595 Shift Register
- Gray Code and Binary Conversion
- Encoder vs Decoder in Digital Logic
External References
- CD74HC4017 High Speed CMOS Decade Counter with 10 Decoded Outputs (PDF datasheet)
- Johnson Ring Counter and Synchronous Ring Counters
- Ring counter (Wikipedia)
What We Learn Today
- A johnson counter feeds the inverted output of its last D flip flop back to the first, so N flip flops step through 2N states.
- Every state of the 4 bit sequence differs by one bit and decodes with a single 2 input AND gate, giving glitch free outputs.
- Unused patterns can trap the counter in a lock out loop, so add a power on reset or a self correcting feedback gate.

