1lytics

Using Seven-Segment LED Display

What is a Seven-Segment Display

A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot-matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters, and other electronic devices for displaying numerical information.


A 7-segment display also allows to display hexadecimal digits with some limitations: digits A,C,E,F are displayed in upper case (capital letters), and digits 'b' and 'd' are displayed as lower case letters, because the shape for letter 'B' ambiguous with shape for digit '8' , and 'D' ambiguous with '0'.

The segments of a 7-segment display are referred to by the letters A to G, as shown below: Standard nomenclature for seven-segment LED display

To display digits, we need to turn on all or some segments of LED display by putting 1 to the apropriate SSD pins. The pictures below shows the common glyphs of the ten decimal numerals and the six hexadecimal "letter digits" (A–F):

7-segment display glyph for 0 7-segment display glyph for 1 7-segment display glyph for 2 7-segment display glyph for 3 7-segment display glyph for 4 7-segment display glyph for 5 7-segment display glyph for 6 7-segment display glyph for 7 7-segment display glyph for 8 7-segment display glyph for 9 7-segment display glyph for A 7-segment display glyph for B 7-segment display glyph for C 7-segment display glyph for D 7-segment display glyph for E 7-segment display glyph for F

In digital electronics single digit numbers (both decimal and hexadecimal) usually encoded by four signals (lines), so we need to make an decoder from 4 inputs to 7 outputs to display digits on the SSD. We will use the Gorgeous Karnaugh Lua scripting feature to create the truth table for SSD decoder.

Gorgeous Karnaugh Versions with Lua Support

Note: Not all versions of Gorgeous Karnaugh software supports Lua scripting. Check you version features here.

Writing the Lua Script to Build Truth Table

First, for sample, we will create the decoder to display all digits (both decimal and hexadecimal) on the SSD.

gkAddInputVar('x', 4)
gkAddFunctionList('a', 'b', 'c', 'd', 'e', 'f', 'g')
-- reset all outputs
MaxInput = gkGetMaxInputVector()
for InputVec = 0, MaxInput do
    gkSetOutput(InputVec, 0)
end

gkSetFunctionListValue(  0, 1, 'a', 'b', 'c', 'd', 'e', 'f', '-' )
gkSetFunctionListValue(  1, 1, '-', 'b', 'c', '-', '-', '-', '-' )
gkSetFunctionListValue(  2, 1, 'a', 'b', '-', 'd', 'e', '-', 'g' )
gkSetFunctionListValue(  3, 1, 'a', 'b', 'c', 'd', '-', '-', 'g' )
gkSetFunctionListValue(  4, 1, '-', 'b', 'c', '-', '-', 'f', 'g' )
gkSetFunctionListValue(  5, 1, 'a', '-', 'c', 'd', '-', 'f', 'g' )
gkSetFunctionListValue(  6, 1, 'a', '-', 'c', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue(  7, 1, 'a', 'b', 'c', '-', '-', '-', '-' )
gkSetFunctionListValue(  8, 1, 'a', 'b', 'c', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue(  9, 1, 'a', 'b', 'c', 'd', '-', 'f', 'g' )
gkSetFunctionListValue( 10, 1, 'a', 'b', 'c', '-', 'e', 'f', 'g' )
gkSetFunctionListValue( 11, 1, '-', '-', 'c', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue( 12, 1, 'a', '-', '-', 'd', 'e', 'f', '-' )
gkSetFunctionListValue( 13, 1, '-', 'b', 'c', 'd', 'e', '-', 'g' )
gkSetFunctionListValue( 14, 1, 'a', '-', '-', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue( 15, 1, 'a', ' ', ' ', ' ', 'e', 'f', 'g' )


Script, given above, produces next fully defined truth table:

#TABLE: x1,x2,x3,x4 => a,b,c,d,e,f,g
0000 => 1111110
0001 => 0110000
0010 => 1101101
0011 => 1111001
0100 => 0110011
0101 => 1011011
0110 => 1011111
0111 => 1110000
1000 => 1111111
1001 => 1111011
1010 => 1110111
1011 => 0011111
1100 => 1001110
1101 => 0111101
1110 => 1001111
1111 => 1000111


More common task is to display only decimal digits for use in devices such as digital clocks or electronic meters. Lets modify the first script to make the truth table for decimal digits decoder:

gkAddInputVar('x', 4)
gkAddFunctionList('a', 'b', 'c', 'd', 'e', 'f', 'g')
-- prepare all outputs
MaxInput = gkGetMaxInputVector()
for InputVec = 0, MaxInput do
    if InputVec>9 then
       gkSetOutputUndefined(InputVec)
    else
       gkSetOutput(InputVec, 0)
    end
end

gkSetFunctionListValue(  0, 1, 'a', 'b', 'c', 'd', 'e', 'f', '-' )
gkSetFunctionListValue(  1, 1, '-', 'b', 'c', '-', '-', '-', '-' )
gkSetFunctionListValue(  2, 1, 'a', 'b', '-', 'd', 'e', '-', 'g' )
gkSetFunctionListValue(  3, 1, 'a', 'b', 'c', 'd', '-', '-', 'g' )
gkSetFunctionListValue(  4, 1, '-', 'b', 'c', '-', '-', 'f', 'g' )
gkSetFunctionListValue(  5, 1, 'a', '-', 'c', 'd', '-', 'f', 'g' )
gkSetFunctionListValue(  6, 1, 'a', '-', 'c', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue(  7, 1, 'a', 'b', 'c', '-', '-', '-', '-' )
gkSetFunctionListValue(  8, 1, 'a', 'b', 'c', 'd', 'e', 'f', 'g' )
gkSetFunctionListValue(  9, 1, 'a', 'b', 'c', 'd', '-', 'f', 'g' )


Truth table for decimal decoder for SSD is not fully defined, so the resulting decoder gate diagram will be more simple, than for hexadecimal decoder:

#TABLE: x1,x2,x3,x4 => a,b,c,d,e,f,g
0000 => 1111110
0001 => 0110000
0010 => 1101101
0011 => 1111001
0100 => 0110011
0101 => 1011011
0110 => 1011111
0111 => 1110000
1000 => 1111111
1001 => 1111011
1010 => -------
1011 => -------
1100 => -------
1101 => -------
1110 => -------
1111 => -------

K-Maps for Minimization

As we develop decoder only for decimal digits, K-Maps for minimization will looks like next: A-segment SSD line K-Map B-segment SSD line K-Map C-segment SSD line K-Map D-segment SSD line K-Map E-segment SSD line K-Map F-segment SSD line K-Map G-segment SSD line K-Map

Minimizing the K-Maps

Let minimize the K-Maps for Product-of-Sums (by 0):

PoS Minimized K-Maps for SSD LED


and get the functions minimal form:

a = (x1|x2|x3|!x4) (!x2|x3|x4);
b = (!x2|!x3|x4) (!x2|x3|!x4);
c = (x2|!x3|x4);
d = (x1|x2|x3|!x4) (!x2|x3|x4) (!x2|!x3|!x4);
e = (!x2|x3|x4) (!x4);
f = (x1|x2|x3|!x4) (x2|!x3|x4) (!x3|!x4);
g = (x1|x2|x3) (!x2|!x3|!x4);


Let minimize the K-Map for Sum-of-Products (by 1):

SoP Minimized K-Maps for SSD LED


and get the functions minimal form:

a = !x2 !x4 | x3 !x4 | x3 x4 | x2 !x3 x4 | x1;
b = !x2 x4 | !x2 x3 | x3 x4 | !x3 !x4;
c = !x2 x4 | x2 !x4 | x3 x4 | !x3 !x4 | x2 !x3 x4;
d = !x2 !x4 | x3 !x4 | !x2 x3 | x2 !x3 x4 | x1;
e = !x2 !x4 | x3 !x4;
f = x2 !x4 | !x3 !x4 | x2 !x3 x4 | x1;
g = !x2 x3 | x2 !x4 | x2 !x3 x4 | x1;

Building the Logic Gate Diagrams

In the “Coverage sets” pane select the needed coverage set. Next, select the “Coverages” — “Open Schematic”. In the appeared dialog window select appropriate diagram generation options, and press “Ok” button. After this, you got the logic gate diagram.

Logic gate diagrams for PoS and SoP:

Logic gate diagram for PoS minimized decoder for SSD Logic gate diagram for SoP minimized decoder for SSD

Checking Logic Gate Diagram in a Simulator

You can use “CEDAR Logic Simulator” program to check how your logic gate diagram works. For this, choose menu item “File” — “Save for CedarLogic” in the Gorgeous Schematic, save the “.CDL” file and open it in the “CEDAR Logic Simulator”.

Note: Not all versions of Gorgeous Karnaugh software supports export logic gate diagrams to CedarLogic. Check you version features here.

Gorgeous Karnaugh Versions

You can learn about Gorgeous Karnaugh features and compare diferences between Gorgeous Karnaugh versions on the Gorgeous Karnaugh features page.