The CD4013 is an integrated circuit consisting of two D-type flip-flops. It has a number of applications in digital circuits but is primarily for latching data.
D Flip Flops
To understand how to use the CD4013, you must first know how D-type flip-flops work.
Flip-flops have a clock pin, input pin(s) and output pins. The state of the output depends on the state of the input. However, the output doesn’t change unless the clock pin changes. Hence, flip-flops store data, although only 1 bit of it.
The D flip-flop is a type of flip-flop that only has one input, the D pin, and two outputs, Q and Q.
For every rising pulse on the CLK pin, the D pin toggles and the Q pin follows its state. The Q pin is always the complement of the Q pin.
A variation of the D flip-flop is the inclusion of R (reset) and S (set) pins (shown above). This variation is precisely the type inside the CD4013. When reset is high and set is low, the output Q is always low and the output Q is always high. This is true no matter the state of CLK. Also, the D pin becomes unusable.
Conversely, when reset is low and set is high, the output Q is always high and the output Q is always low. For normal D flip-flop operation, the R and S pins must be both low.
The CD4013 contains two D flip-flop circuits each with R and S pins. Its pinout is shown below:
Being a CMOS IC, the CD4017 consumes less power than its TTL counterpart. It can operate from 3 V to 18 V while its input pins can tolerate + 0.5 V of its supply voltage.
The function table for the CD4017 is shown below:
As already mentioned, the Q pin follows the state of the D pin for every rising clock pulse. This is only true if both S and R pins are low. The Q pin is always the complement of the Q pin.
Basic CD4013 Applications
In normal D flip-flop operations, the S and R pins are tied to ground.
Consider the circuit shown below:
A 1 second pulse is applied to the CLK pin. If the button is pressed while the pulse is rising, the Q pin goes LOW while the Q pin goes high. Pressing the button while the pulse is going low will not result in any change of state.
We can modify the circuit above to create a debouncing circuit:
A common problem when dealing with buttons is that they “bounce” after pressing, resulting in an undetermined state. With this circuit, the output latches to a single state after every button press.
Here, the button connects to the CLK pin while the D pin connects to the Q pin. At button press, the Q pin follows the D pin but since its complement the Q pin is wired to D, the Q pin now complements its previous state.
Here’s an animation of the circuit above:
CD4013 Full Datasheet:cd4013b