Professional Documents
Culture Documents
7 Segment Display Appendix B
7 Segment Display Appendix B
151
Appendix B - 7-Segment LED Displays
One oI the most common ways Ior an embedded system to provide inIormation to the user is
with seven-segment displays. They are commonly used in calculators, microwaves, stereos,
VCR's, televisions, and many other household items. This appendix will give you the inIormation
needed to build a pre-Iabricated seven-segment LED display circuit and to write soItware to
display a number. You will also be introduced to the hardware contained on one oI the pre-
Iabricated 7-Segment LED Display boards which allows more than one display to be operated Irom
a single port on the C8051.
The parts contained on the pre-Iabricated 7-Segment LED Display boards are:
a seven-segment LED display chip
a latch chip (retains data Ior the display)
a display decoder chip (uses the binary data to light the correct LED's in the 7-segment
display)
Figure B.1 illustrates a pre-Iabricated 7-Segment LED Display board. The number to be
displayed is sent (in binary) to data lines 1-4 on the board. When the enable line is high, data is
transmitted through the latch chip to the decoder. The decoder converts this data into a Iorm which
will light the correct LEDs in the 7-Segment display, Iorming the decimal number. When the
enable bit is set low, the data on the data lines is stored in the latch, holding the current number on
the 7-Segment display.
The Iollowing sections describe each oI the parts contained on a pre-Iabricated 7-Segment
display board, along with an explanation oI how they work. The instructions Ior writing soItware
Ior these parts are described at the end oI this appendix.
Appendix B: The 7-Segment LED Displav Embedded Control Lab Manual
152
Figure B.1 - Pre-fabricated 7-Segment display board
The 7-Segment LED Display
Each segment oI the 7-Segment display is an individual light emitting diode (LED). A diode is
made Irom a p-n junction, and a basic characteristic oI a diode is that it will allow current to Ilow
in only one direction. In other words, when the 'p' end has a voltage at least 0.7V higher than the
'n' end, the diode will turn on` and allow current to Ilow. An LED is simply a diode that emits light
when current Ilows.
Figure B.2 - Components of a 7-segment LED
+ -
An LED
+5V
an1 an2
a
b
c
d
e
f
g
+
1
13
10
8
7
2
11
3 14
g
f
e
d
c
b
a
-
270 Ohm
0.7 V
Display Chip 7 Segments
A Single LED circuit
Embedded Control Lab Manual Appendix B: The Flip/Flop
153
The display chips are common-anode, which means that the p (positive) end oI the segments
are wired together. The 'p' end oI each segment is connected to either pin 3 or pin 14 inside the
display chip. Pins 3 and 14 are connected to the 5V connection on the board through a 270 Ohm
resistor. The resistor limits the current that Ilows through the diode to avoid destroying the display
chip. A segment will light by setting its respective pin a-g` to a low (0V) value. Further discussion
on the physics oI diodes is available Irom Volume II oI the Hallidav and Resnick Phvsics book and
in the on-line tutorials (Hardware. Circuit Components. Diodes and Light-Emitting Diodes).
The 74LS75 Latch
Figure B.3 - 1he 74LS75 latch
A latch is a chip that stores data values. Each latch is made up oI single Ilip-Ilop circuits (see
Ilip/Ilop below). Since the 75 latch has 4 Ilip/Ilops, it can store 4 binary values. Each chip enable
signal (1,2C or 3,4C) controls a pair oI the Ilip/Ilops. As long as the chip enables (1, 2C and 3, 4C)
are high, the outputs (Q`s) change with their respective inputs (D`s). The latch retains the value oI
the inputs at the moment when the chip enable goes low, so the outputs will remain the same until
the chip enable is high again.
A latch is present at each display decoder so that the appropriate values are only displayed on
the LED while the chip enable is high. When the latch enable makes the transition to a low, it will
retain the current input data. Each latch will hold the outputs at their current state, since we only
send a high value to its chip enable when we want to give a new value to that display. For more
inIormation see the Motorola Fast and LS TTL Data.
The Flip/Flop
A Ilip/Ilop is an electronic circuit which can store a single data value. A Ilip/Ilop resides in one
oI two states, called set (1`) and reset (0`). To read the data value stored in the Ilip/Ilop, you
simply determine which state it is in. To write a data value to a Ilip/Ilop, you change it`s state to
the state which corresponds to that data value. Figure B.4 shows a single D-type Ilip/Ilop. The
4D
3D
2D
1D
1,2C
3,4C
4Q
3Q
2Q
1Q
7
3
6
2
9
10
15
16
8
11
14
1
13
4
B/RBO
A
B
C
D
E
F
G
7
1
2
6
3
5
4
14
15
9
10
11
12
13
Embedded Control Lab Manual Appendix B: Hardware
155
binary number each represent a multiple oI 2. From leIt-to-right, the bits represent 8, 4, 2, and 1.
Hence, the number 0101
2
above is: 0*8 1*4 0*2 1*1 5
10
.
Since 0101
2
is the binary equivalent oI the decimal value 5
10
, we would like to light the LED
segments a, I, g, c, and d on the 7-Segment display. The decoder chip gives the appropriate values
to the pins a-g, so that the Iour digit binary representation can control the 7-Segment display.
Note: Pins 3, 4, and 5 are Ior special controls like blanking or lighting all seven segments,
which we will not be using. Since these inputs are active when connected to 0V, we connect them
to 5V.
Using the Entire Display Circuit
Figure B. - Display schematic
Figure B.6 shows an example oI how the display circuit can be implemented. Four oI the pins
oI port 3 are used as data lines to speciIy (in binary) the number that the selected display should
use. The other Iour pins oI port 3 are enable bits which can be used to select between up to Iour
separate displays.
Hardware
The seven segment display boards have been constructed in order to reduce the time and eIIort
needed to include these within your project. As is with most circuit designs, this is not necessarily
the only way to wire these components. The schematic provided in Figure B.7 is the wiring
diagram used Ior the construction oI these display boards, which can be modiIied in various ways
Ior additional seven segment components to be added.
Data 4
Data 3
Data 2
Data 1
Enable
C
8
0
5
1
E
V
B
C
o
n
n
e
c
t
o
r
Displav Unit 1
33 (P3.4)
34 (P3.5)
31 (P3.6)
32 (P3.7)
(To Additional Displav Units)
36 (P3.3)
35 (P3.2)
37 (P3.1)
38 (P3.0)
Data Bits
Enable Bits
(To Additional Displav Units)
1k
Appendix B: Software Embedded Control Lab Manual
156
Figure B.7 - Schematic for wiring a 7-segment display
Software
AIter the hardware is constructed, the soItware needs to be written to control these displays. As
shown in Figure B.8, the eight-bit output port is broken up into two parts. The low Iour bits (0-3)
are the binary number to be displayed, while the high Iour bits are used to enable the desired
display. In order Ior you to eIIectively latch the data on the selected display, it is necessary to send
the number with the selected display enable high and then send the number with the selected
display enable low. The enable opens the latch oI the appropriate display. When the enable bit is
set low, the display then latches on the data, and the display circuit will remain unchanged until the
enable is set high again.
Figure B.8 - Configuration of port 3 for the display circuit
SA74LS75 SA74LS47
+5J Power
Cround
Data 1
Data 2
Data 3
Data 4
Enable
I
g
a
b
c
d
e
a
b
c
I
270
e d
g
5V
1k
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
3.7
3.6
3.5
3.4
3.3
3.2
3.1
3.0
Pins Example:
Display
Selection
Number
(binary)
00010101
2
21
10
0001
2
-~ 0000
2
0101
2
5
10
This example will
display a 5 on the
display enabled
by P3.4
The display is enabled
and then disabled