BCD to 7-Segment Display

7-segment-display

What is BCD code?


In computing and electronic systems, binary-coded decimal (BCD) is used to encode decimal numbers (base-10 numbers) in a binary form where each decimal digit is represented by a nibble (4 bits).

For instance decimal number 5 is represented as 0101 in BCD as 5 = 4 + 1

8 4 2 1
0 1 0 1

The 10 digits in BCD:

Decimal Digit BCD Nibble
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

Numbers larger than 9, having two or more digits in the decimal system, are expressed one digit at a time using on nibble per digit. For example, the decimal number 365 is encoded as:

0011 0110 0101

7-Segment Display


A lot of electronic devices use 7-segment displays (Watch, alarm clock, calculator etc.).
Typically 7-segment displays consist of seven individual coloured LED’s (called the segments). Each segment can be turned on or off to create a unique pattern/combination. Each segment is identified using a letter between A to G as follows:

7-segment-display-connections

The 10 descimal digits can be displayed on a seven-segment display as follows:

BCD to 7-Segment Display: Truth Tables & Karnaugh Maps


We will use four inputs A,B,C and D to represent the four BCD digits as ABCD (A is the most significant digit, D is the least significant digit). When creating an electronic circuit we could use 4 switches to represent these 4 inputs.

We will need 7 outputs one for each segment. So let’s investigate each segment one at a time.

Segment ABCDEFG
Segment A should be on for the following values:

tmp-0BCD: 0000 tmp-0BCD: 0010 tmp-0BCD: 0011 tmp-0BCD: 0101
tmp-0BCD: 0110 tmp-0BCD: 0111 tmp-0BCD: 1000 tmp-0BCD: 1001

Segment A should be off for the following values:

tmp-0BCD: 0001 tmp-0BCD: 0100

Segment A should also be off for the following BCD values which are not used to represent decimal digits values from 0 to 9:

  • 1010
  • 1011
  • 1100
  • 1101
  • 1110
  • 1111

Note that these values could be used to represent hexadecimal values A to F (10 to 15). Here we will not display anything instead.

Hence the Truth Table for Segment A is as follows:

Inputs Output
A B C D Segment A
0 0 0 0 1
0 0 0 1 0
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0

This Truth table can be represented using a Karnaugh Map:

Karnaugh Map for Segment A

Karnaugh Map for Segment A

Follow the same process to define the Truth Table and Karnaugh Map of the B segment:

Follow the same process to define the Truth Table and Karnaugh Map of the C segment:

Follow the same process to define the Truth Table and Karnaugh Map of the D segment:

Follow the same process to define the Truth Table and Karnaugh Map of the E segment:

Follow the same process to define the Truth Table and Karnaugh Map of the F segment:

Follow the same process to define the Truth Table and Karnaugh Map of the G segment:

BCD to 7-Segment Display: Boolean Expressions


The Karnaugh maps will help us define the Boolean Expressions associated with each of the 7 segments.

Segment ABCDEFG
Karnaugh Map:
Karnaugh Map - Segment A

Karnaugh Map – Segment A

Boolean Expression:
Booelan Expression for Segment A

Boolean Expression for Segment A

Use the Karnaugh Map for the B segment to define the Boolean Expression of the B segment.
Use the Karnaugh Map for the C segment to define the Boolean Expression of the C segment.
Use the Karnaugh Map for the D segment to define the Boolean Expression of the D segment.
Use the Karnaugh Map for the E segment to define the Boolean Expression of the E segment.
Use the Karnaugh Map for the F segment to define the Boolean Expression of the F segment.
Use the Karnaugh Map for the G segment to define the Boolean Expression of the G segment.

BCD to 7-Segment Display: Logic Gates Diagrams


We can now convert each Boolean expression into a Logic Gates circuit to link our 4 inputs (switches) to our 7-segment display using a range of logic gates.
Segment ABCDEFG
Boolean Expression:
Booelan Expression for Segment A

Booelan Expression for Segment A

Logic Gates Diagram:
Segment A - Logic Gates Diagram

Segment A – Logic Gates Diagram

Use the Boolean Expression of the B segment to draw the logic gates diagram required to control the LED of the B segment.
Use the Boolean Expression of the C segment to draw the logic gates diagram required to control the LED of the C segment.
Use the Boolean Expression of the D segment to draw the logic gates diagram required to control the LED of the D segment.
Use the Boolean Expression of the E segment to draw the logic gates diagram required to control the LED of the E segment.
Use the Boolean Expression of the F segment to draw the logic gates diagram required to control the LED of the F segment.
Use the Boolean Expression of the G segment to draw the logic gates diagram required to control the LED of the G segment.

Testing


You can now recreate your logic gates circuit using logic.ly to test if it behaves as expected for all 16 BCD entries.
e.g. For Segment A:
Logic Gates Circuit for Segment A

Logic Gates Circuit for Segment A

BCD to 7-Segment Display Integrated Circuit


integrated-circuitAll these 7 logic gates diagrams can all be integrated into one single integrated circuit: The CD74HCT4511E is a CMOS logic high-speed BCD to 7-segment Latch/Decoder/Driver with four inputs and is used to use these 4 inputs (BCD nibble) to control the display of a 7-segment display.

Hex/BCD to 7-Segment Display Integrated Circuit


A very similar approach can be used to display hexadecimal digits as these are also based on a nibble per digit.

The extra values that we discarded previously (BCD: 1010, 1011, 1100, 1101, 1110, 1111) can be used to represent the extra 6 digits available in hexadecimal:

Did you like this challenge?

Click on a star to rate it!

Average rating 4.7 / 5. Vote count: 22

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!