A BCD to seven-segment decoder you can click through
Beginner
Or see every lesson.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
A BCD to seven-segment decoder turns a four-bit number into the pattern of segments that draws that digit. It is a staple of every digital logic course, and one of the first chips that shows logic doing something you can read.
The circuit above uses a CD4511, the CMOS version. Four DIP switches set the input bits, a 10 k resistor network pulls each one low when its switch is off, and the chip drives a common-cathode display. There is no microcontroller and no code: the decoder is the whole program. It starts on 0101, a 5. Click the switches and the digit follows.
BCD in four bits
BCD means binary-coded decimal: one decimal digit stored in four bits, worth 8, 4, 2 and 1, called D, C, B and A on the chip. 0000 is 0, 0101 is 5, 1001 is 9. Four bits can count to 15, but BCD only uses 0 to 9; the codes 1010 to 1111 are not digits.
In the circuit, switch 1 is A (worth 1), switch 2 is B (2), switch 3 is C (4) and switch 4 is D (8). Up is on.
The truth table
The segments are named a to g, clockwise from the top, with g across the middle. Here is what the CD4511 lights for each input, read off the circuit as it runs.
0 (0000): a b c d e f. 1 (0001): b c. 2 (0010): a b d e g. 3 (0011): a b c d g. 4 (0100): b c f g. 5 (0101): a c d f g. 6 (0110): c d e f g. 7 (0111): a b c. 8 (1000): all seven. 9 (1001): a b c f g. 10 to 15: nothing at all.
Look at the 6 and the 9. On a CD4511 they have no tails: the 6 leaves out segment a and the 9 leaves out segment d. Many displays driven from a microcontroller draw them with tails, so a 6 or 9 that looks short is not a wiring fault. And the 4511 blanks the display for 10 to 15 rather than showing a symbol.
Each segment is a Boolean function
Each segment output is a function of the four inputs, and finding the simplest circuit for each one is the classic Karnaugh map exercise. Segment b, for example, is on for 0, 1, 2, 3, 4, 7, 8 and 9, and off for 5 and 6. With 10 to 15 treated as don’t care, its map simplifies to b = C’ + B’A’ + BA, which you can check against the table above row by row.
Doing that for all seven segments and building it from gates is a good lab. Building it here and checking it against the chip, digit by digit, is a good way to prove the algebra is right.
The control pins: LT, BI and LE
LT, lamp test, is active low. Pull it to ground and every segment lights whatever the inputs say, which is how you check a display for dead segments. In the circuit it is tied to 5 V.
BI, blanking input, is active low too. Pull it to ground and the display goes dark. It is used to blank leading zeros in a row of digits, or to dim a display by switching it on and off quickly. Here it is tied to 5 V.
LE, latch enable, decides whether the chip follows its inputs. With LE low, as here, the display tracks the switches. Move LE to 5 V and the digit freezes, whatever the switches do, until LE goes low again. That is what lets a counter or a microcontroller set up the next digit without the display flickering in between.
CD4511 or 7447?
The 7447 (and 74LS47) is the TTL decoder found in many lab manuals. It has active-low outputs, so it drives a common-anode display, with a resistor in every segment, and it runs from 5 V only. The CD4511 has active-high outputs that source current, so it drives a common-cathode display, and it runs from 3 to 18 V. A common-anode display on a CD4511, or a common-cathode one on a 7447, stays dark.
Both draw the 6 and 9 without tails (the 74LS247 is the 7447 with tails added). They differ in what they show for 10 to 15: the 7447 shows odd symbols, the 4511 blanks. If your lab sheet names a 7447, the logic is the same; only the display type and the output polarity change.
Common mistakes
The wrong display type. A CD4511 needs common cathode. With common anode nothing lights.
Floating inputs. A CMOS input with nothing on it can read anything. Every input needs a pull-down, which is what the resistor network does when a switch is off.
LT or BI left floating. A floating CMOS input can read high or low, so the display may blank or light every segment. Tie both to 5 V.
One resistor for all segments. The circuit uses a single 100 ohm resistor in the common lead to keep it small, so a 1 (two segments) is brighter than an 8 (seven). A real build gives each segment its own resistor.
Questions
What does a BCD to 7 segment decoder do?
It turns a four-bit binary-coded decimal number, 0000 to 1001, into the seven outputs that light the right segments of a display to show that digit.
Which IC is a BCD to 7 segment decoder?
The CD4511 (CMOS, common cathode, active-high outputs) and the 7447 or 74LS47 (TTL, common anode, active-low outputs) are the common ones.
What does the CD4511 show for inputs above 9?
Nothing: it blanks the display for 1010 to 1111. You can see it in the circuit above by setting switches 2 and 4 for 10.
Is there a virtual lab for a BCD decoder?
Yes. The circuit above is one, free in the browser: click the switches, read the display, and open it in the editor to add gates, a counter or a microcontroller.
Keep going
Build this for real
Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.