Timing diagram of each counter type and design of a frequency divider
A counter is a sequential circuit that advances one state with each clock pulse and goes through a fixed sequence: 0, 1, 2… up to its modulus and back to the start. It is built with flip-flops, one per bit. It is used to count parts or pulses, divide frequencies, generate delays and timings, step through memory addresses or share time in a multiplexed display.
To count up to a number that is not a power of 2, a state is detected and the counter is reset. With an asynchronous reset (74HC93, 74HC161) N itself is detected: the counter reaches N for an instant and is cleared at once, producing a very short and unreliable pulse. With a synchronous reset (74HC163) N − 1 is detected and the clearing happens on the next edge, with no false states. The decade counter is a modulo 10 that counts in BCD, from 0 to 9, and is chained to count in decimal, digit by digit.
In a modulo N that is not a power of 2, the highest output does not have a 50 % duty cycle. If a symmetrical square wave is needed, divide by N/2 and then by 2 with one more flip-flop. A 32.768 kHz clock, the one in quartz watches, gives exactly 1 Hz after 15 divisions by 2.
They are shift registers with feedback. The ring counter circulates a single 1: with n flip-flops it has n states and each one is decoded directly by an output, with no gates; it is used to sequence steps. The Johnson counter feeds back the inverted output and achieves 2n states with n flip-flops; each state is decoded with a two-input AND. The CD4017 is a 5-flip-flop Johnson with 10 decoded outputs, widely used for LED sequences.
| IC | Type | Notes |
|---|---|---|
| 74HC93 | 4-bit asynchronous binary | Two stages (÷2 and ÷8), asynchronous reset |
| 74HC390 | Dual asynchronous decade | Each half divides by 2 and by 5 |
| 74HC161 | 4-bit synchronous binary | Synchronous parallel load, asynchronous reset |
| 74HC163 | 4-bit synchronous binary | Synchronous parallel load and reset: the handiest for modulo N |
| 74HC193 | 4-bit up/down binary | Separate clocks for counting up and down, parallel load |
| CD4017 | Johnson decade | 10 decoded outputs |
| CD4040 / CD4060 | 12 and 14-stage binary | Frequency dividers; the CD4060 includes the oscillator |
In a microcontroller, counters are the timers: the same circuit counting the internal clock or pulses on a pin, with comparators that generate interrupts or PWM.
Related: latches and flip-flops, state machines (a counter is a state machine with no inputs), magnitude comparators and BCD to 7-segment decoder.