# Ring counter

Straight ring counter, assembled from the separate D flip-flops. The circuit will only react to the counting signal after you press the reset button.
A ring counter is a binary counter that uses a circular shift register. The signal to be counted arrives to the shift input of the register. There are multiple variations of this counter, depending on how the "data in" input is connected.

## Straight ring counter

The most straightforward way to build the counter is to connect data input to the highest digit. In this case the register performs the circular shift operation, circulating its initial content in the endless loop. The biggest problem with this design is that the initial content must be pre-set before the counter can be started, and the circuit will not recover to the consistent state if this content has been lost (for instance, because of some glitch). In the diagram below (the register is composed of individual D flip-flops) the counter will not count until you press the reset button first. This button sets the lowest digit to 1 and all other digits to 0. Then, as the counting signal arrives in the shift input, this 1 circulates over all digits in a closed loop.

The positive about this counter is that it can circulate arbitrary complex sequence in a closed loop, not just a single "1". If used as frequency divider, it can generate a repeating pre-programmed sequence in the output; the length and accuracy of this sequence depends of the number of digits in the register. The sequence can be configured by connecting either R (reset) or S (set) inputs of the flip-flops to the input of the initial reset.

This design is also called overbeck counter. If used as a frequency divider, it divides the frequency by n where n is the number of bits in the register.

## Johnson counter

Johnson counter (also called twisted ring counter, or Möbius counter (also Moebius) counter) connects the inverted output (highest digit) of the shift register to its input. This counter circulates a stream of ones followed by the stream of zeros. It can start from start from zero state rather than from quite specific "0001"-like state. This allows to implement Johnson counter with registers that have the shared reset input for all digits but have no inputs to set individual bits. However this design is also not self-initializing and not self-recovering; if the contents of the register are random the output stays a random noise and does not converge into stream of clustered zeroes and clustered ones over time.

Johnson counter

If used as a frequency divider, Johnson counter divides by 2n, twice more than the straight ring counter. This is still much less that it is possible to get with the comparable number of T flip-flops in the usual binary counter. However individual bits of the Johnson counter make the "sliding curtain" pattern that can be useful in synchronizing the work of some other parts of the circuit.

## Ring counter with NOR element

The idea of the Johnson counter can be extended observing all bits of the register rather than just a highest bit. Connecting all outputs to the OR element, and the inverted output of this element to the data input, makes a counter that is similar to the straight ring (also circulates a single bit) but with some additional positive features. Such counter can start from any initial state and returns into consistent state if disturbed (by setting flip-flops randomly). Unless very first several signals should also be counted correctly, it does not recover the initial reset and would also recover from glitches. It also has one bit more capacity than the straight ring counter, passing through the "zero" or "none" state when all bits in the register are off. The circulating bit output can be easier understood by human observer than the curtains of the Johnson counter. Such counter can also be built with NAND element; in this case it circulates through the register a single 0 rather than 1. However, unlike the straight ring, this circuit cannot generate arbitrary pre-programmed sequence. Also, for the bigger number of digits, the OR element with a number of inputs becomes a clumsy part of the implementation.

## Linear feedback shift register

Linear feedback shift register (LSFR) is a device that combines shift register with XOR gate to produce a fast, high capacity ring counter. It is described in the separate article.