1. Pin connections

The 4017 decade counter has ten outputs
which go HIGH in sequence when a source of pulses is connected to the CLOCK input and when suitable logic levels are applied to the RESET and ENABLE inputs.

2. What is a decade counter?

The counting action of the 4017 can be understood from the graph below:

Counting action of the 4017 decade counter

Click the button to draw the graph.

Just one of the individual outputs is HIGH at a time. This is quite different from the
behaviour of a BCD counter like the 4510 in which it is
the combination of 0's and 1's which represents the count.

As you can see, the ÷10 output is HIGH for counts 0-4 and LOW for counts 5-9.

The 4017 is an extremely useful device for project work and is used in the Games Timer and in various DOCTRONICS construction kits
including the Light Chaser and the Matrix Die. When you are familiar with the 4017, you will
be able to think of lots of useful applications.

Internally, the 4017 contains five bistable subunits. These are interconnected in a
pattern known as a Johnson counter. The outputs of the bistables are decoded to give the
ten individvual outputs.

3. Basic operation.

Here is the circuit diagram for a 4017 test circuit:

4017 decade counter test circuit

The 4017 is designed to drive higher current loads, so it is OK to connect LEDs with series resistors directly to its outputs.

You should assemble the prototype board version of the circuit in stages, checking that each stage is working
properly before proceeding the to the next stage.

To see the 4017 in action, you need to build an astable. The easiest way to do this is using a
4093 Schmitt trigger NAND gate integrated circuit. Start by building the astable section
on your prototype board:

Buy from Rapid...

4093 Schmitt NAND astable

The Schmitt NAND astable is described in more detail in the 4093 page included in the Beastie Zone.

It is good practice with CMOS circuits to insert a decoupling capacitor, 47 µF or 100 µF, across the power supply. (This helps to
prevent the transfer of spikes along the power supply rails.)

Next add the 4017. The pulse output from the astable is connected to the CLOCK input.
For normal operation, the RESET and ENABLE inputs must be connected to 0 V:

Connecting the astable to the 4017

Beasties need power supplies! Don't forget to connect pin 16 of the 4017 to +9 V and pin 8 to 0 V.

Connect a single LED with a 680 W series resistor to output 0 of the 4017.

Count the pulses. The output 0 LED should flash once for every 10 flashes of the LED connected to the astable.

Continue, adding new resistor/LED stages for outputs 1 and 2.
Don't disconnect the power supply. It helps to see that the new connections make the LEDs
illuminate in the correct sequence:

Connecting outputs 1 and 2

Connect a second prototype board and keep on adding new LEDs
until all 10 outputs are used:

Connecting outputs 3-9

This version of the 4017 gives you a free-running light chaser. This can be useful, but
usually you will want to control the 4017, as outlined in the next section.

4. RESET and ENABLE inputs

Modify your circuit so that the RESET and ENABLE inputs are each
connected to 0 V through a 10 kW pull down resistor. Initially,
the behaviour of the circuit will be unchanged. Add 'flying leads' as indicated below:

Adding RESET and ENABLE controls

Click to open a PDF version of this drawing if you want to print it out to help with construction.

What happens when you connect the flying lead from the RESET input temporarily to +9 V?

This returns the
counter to 0 and the LED for output 0 is illuminated. Although pulses are still arriving
at the CLOCK input, counting has stopped.

Try connecting the RESET input instead to output 5, pin 1, of the 4017. Counting will
start again but not all of the outputs are active. The LEDs for outputs 0, 1, 2, 3 and 4
light up as before. You won't see anything happen at output 5 because the instant that
this output goes HIGH, the counter is reset and counting starts again from 0.

In this way, you can shorten the count for any particular application.

Disconnect the RESET flying lead so that the 4017 is free-running once more. What
happens when you connect the free end of the ENABLE lead to +9 V? Counting stops but this
time the last LED illuminated stays lit. The count stops wherever it happens to be when
ENABLE goes HIGH.

Try connecting ENABLE to output 7, pin 6, of the 4017. Counting may start briefly but
stops as soon as the count reaches 7. Now try touching the RESET lead briefly to +9 V. The
4017 resets to 0 and then counts up, stopping again when it reaches 7. This is the effect
required for a count down timer such as an egg timer, or the Games
Timer, described in detail in Design Electronics.

5. Sequencing

You can use the 4017 to control a sequence of events, for example, to generate a
traffic light sequence:

sequence step

input B

input A

output

0

0

0

1

1

0

0

1

2

0

0

1

3

0

0

1

4

0

1

0

5

1

0

0

6

1

0

0

7

1

0

0

8

1

0

0

9

1

1

0

This pattern shows the lights green or red for a suitably long time, with amber and
red+amber illuminated for shorter periods.

Here is the circuit:

Traffic light sequencer

The 1N4148 diodes are used to make OR gates which control the LEDs. Outputs 0-3
illuminate the green LED, outputs 4 and 9 illuminate the amber LED and outputs 5-9
illuminate the red LED.

The prototype board version of the circuit looks like this:

Traffic light sequencer

Can you think of other applications for this kind of sequencing?

6. Inside the 4017

6.1 Johnson counter

OK, so what is a Johnson counter?

A Johnson counter is one type of walking ring counter using a shift register circuit in which the NOT-Q, or inverse output of the final stage is connected to the serial input of the first stage. You need a diagram to help you to understand this:

3-stage Johnson counter

The behaviour of D-type flip-flops is described in the 4013 entry in the Beastie Zone. Essentially, the logic state at the D, or data input is transferred to the Q output on the rising edge of the clock signal.

For a shift register, the clock inputs of all the D-type stages are joined together so that all the flip-flops are clocked simultaneously. This results in logic states being passed along from one flip-flop to the next in sequence.

Suppose the flip-flops have all been RESET, so that the A, B, C outputs are all logic 0. The D input to the first input will be at logic 1, as indicated in the first line of the table:

clock pulses

D input

output A

output B

output C

0

1

0

0

0

1

1

1

0

0

2

1

1

1

0

3

0

1

1

1

4

0

0

1

1

5

0

0

0

1

6

1

0

0

0

sequence repeats..

Now follow the sequence of changes which will result as clock pulses are delivered to the counter.

The rising edge of the first clock pulse transfers the '1' from D to A, while B and C remain '0'. The D input is the inverse of output C, that is, D remains at '1'. Work through the rest of the table thinking about what happens at the inputs and outputs of each of the flip-flops.

As you can see, the counter has 6 distinct output states. When the sequence has been completed, counting starts again from the beginning.

Johnson counters have 2n output states, where n is the number of flip-flops in the chain. Here n=3, giving 6 different output states. How many flip-flops will be needed inside the 4017?

6.2 Decoder stage

A decoder stage is also needed. This uses 2-input NOR gates to uniquely identify each of the 6 states in the counting sequence.

Recall the truth table of a NOR gate:

input B

input A

output

0

0

1

0

1

0

1

0

0

1

1

0

NOR gate truth table

As you can see, the output is 1, only when both inputs are 0.

Look again at the 3-stage counter sequence:

clock pulses

D input

output A

output B

output C

0

1

0

0

0

1

1

1

0

0

2

1

1

1

0

3

0

1

1

1

4

0

0

1

1

5

0

0

0

1

6

1

0

0

0

sequence repeats..

The first line in the table can be uniquely decoded by connecting A and C to the inputs of a NOR gate. This is the only state in the sequence for which A=0 and C=0.

As the counter is clocked, the logic state at the D input is transferred along from one flip-flop to the next. The second line shows the only state in the sequence for which A=1 and B=0, as indicated by the shading. This line can be uniquely decoded by connecting NOT-A and B to the inputs of a NOR gate.

The third line is the only state in the sequence for which B=1 and C=0, as indicated by the shading. This line can be uniquely decoded by connecting NOT-B and C to the inputs of a NOR gate.

The remaining lines can be decoded in a similar way by detecting the pairs of values shaded in the table. Note that the D input is the same as NOT-C.

The diagram shows how the Johnson counter outputs can be decoded to give a 1 of 6 output:

You can find out about the circuit inside the 4017 from the 4017B data sheet. This has 5 D-type flip-flops (10 output states) and additional circuitry to prevent the count from becoming 'stuck' in a logic state which is not part of the Johnson counter sequence. This problem might arise when the power supply is first connected, since the logic states of the individual flip-flops cannot be predicted.

Look carefully at the data sheet circuit if you want to understand how the decoder circuit works. The result is to give 10 individual outputs which go HIGH in sequence. This is what the 4017 is supposed to do!