Twisted ring counter: 2n states with n flip-flops, changing a single bit each time
Choose the number of bits and step with the clock. You can type the state or the code, or click a flip-flop in the drawing to change its bit, as if noise had changed it.
Each clock pulse shifts the bits one place to the left; the inverted most significant bit enters on the right (Q0). Ones enter until the register is full, then zeros enter until it is empty.
In red, the only bit that changes from the previous state. The two-input AND gate in each row is 1 only in that state. Click a row to load it into the counter.
If at power-up, or because of noise, the register holds a code that is not in the sequence, the shift with inverted feedback does not fix it: the counter runs round another cycle and the decoding gates give false outputs. Click a cycle to load it into the counter, or change a bit in the drawing.
There are three remedies: reset the register at power-up, detect an invalid code and force a reset, or change the feedback. The simulator's correction uses \(D_0 = \overline{Q_{n-1}}\cdot(Q_0 + \overline{Q_{n-2}})\): in valid states it equals \(\overline{Q_{n-1}}\), but it breaks the lock-up cycles. It is enough up to 5 bits, the case of the CD4017, which has similar logic; with more bits some cycles remain and another solution is needed.
The Johnson code, also called twisted ring or Möbius code, is the sequence of a shift register whose input receives the inverted output of the last flip-flop. Starting from all zeros, ones enter until it is full and then zeros until it is empty: with 3 bits, 000, 001, 011, 111, 110, 100 and back to 000.
1100 has Q0 = 0 and two ones: it is state 8 − 2 = 6. The boundary between ones and zeros is between Q2 and Q1, so it is detected by the gate \(Q_2\cdot\overline{Q_1}\). No other code in the sequence has Q2 = 1 and Q1 = 0.
| Counter | States with n flip-flops | Flip-flops for 10 states | Decoding one state | Bits changing per step |
|---|---|---|---|---|
| Binary | 2ⁿ | 4 | n-input AND | up to n |
| Gray | 2ⁿ | 4 | n-input AND | 1 |
| Johnson | 2n | 5 | 2-input AND | 1 |
| Ring | n | 10 | None: one output per state | 2 |
Related: shift registers, flip-flops, counters and Gray code.