Lecture_06_Seven Segment Display.pptx
Lecture_06_Seven Segment Display.pptx
Microprocessor
Lecture #6
7 Segment Display
Md Rakibul Hasan
Lecturer, Dept. of EEE, BRAC University
Slide Courtesy of Imtiaz Ahmed, Lecturer, Dept. of EEE, BRAC University
7-segment Display: Introduction
Seven segment displays are Many common devices like A seven-segment display is
very common for electronic calculators, lift, watches, so named because it is
product to display electronic weighing scales, divided into seven different
numerical output. ovens etc use them. segments that can be
switched on or off.
2 4
a
d
b f b b
g g g c
e c e 3
d d
Two types of 7-segment
display
• Common cathode: the cathodes (N side) of all
LEDs are tied together to a single terminal,
which is usually labeled as 'com' and the
anodes (P side) of all LEDs are left alone as
individual pins labeled as a, b, c, d, e, f, g & h (or
dot).
• Common anode: the anode of all LEDs are tied
together as a single terminal, and cathodes are
left alone as individual pins.
4
Interfacing 7 segment display
+5V
PB.0
b
c
d
e
Common
f 330
g 330 Cathode
PB.7
GND
a
f g b
e c
d dp
0 1 2 3 4 5 6 7 8 9
dp g f e d c b a Hex dig
7-Segment Display
0 0 1 1 1 1 1 1 3F 0
0 0 0 0 0 1 1 0 06 1
0 1 0 1 1 0 1 1 5B 2
0 1 0 0 1 1 1 1 4F 3
0 1 1 0 0 1 1 0 66 4
0 1 1 0 1 1 0 1 6D 5
0 1 1 1 1 1 0 1 7D 6
0 0 0 0 0 1 1 1 07 7
0 1 1 1 1 1 1 1 7F 8
0 1 1 0 1 1 1 1 6F 9
Interfacing
Circuit
7
Code for 7-segment Display
#include <mega32.h>
#include <delay.h>
char digit_cathode[10] ={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07,0x7F,0x6F};
char i;
void main(void) {
DDRB=0xFF;
while (1) {
for(i=0;i<10;i++)
{
PORTB=digit_cathode[i];
delay_ms(1000);
}
}
}
• Suppose you need a four-digit display connected to ATmega32.
• Each 7-segment display have 8 pins and so a total amount of
32 pins are to be connected to the microcontroller. There will be
Multiple no pin left with the microcontroller for other input output
7-Segment applications.
• Moreover, four displays will be ON always and this consumes a
Display considerable amount of power.
• All these problems associated with the straightforward method
can be solved by multiplexing.
9
Multiplexing 7-Segment Display
• In multiplexing, all displays are connected in parallel to one port
and only one display is allowed to turn ON at a time for a short
period.
• This cycle is repeated for at a fast rate and due to the persistence
of vision of human eye, all digits seems to glow.
• The main advantages of this method are
– Fewer number of port pins are required .
– Consumes less power.
– More number of display units can be interfaced.
• The circuit diagram for multiplexing 2 seven segment displays to
the AVR ATmega32 is shown in the next slide. 10
Connection Diagram of Multi-Digit 7-segment
Display
ATmega 32
Digit 3 Digit 2 Digit 1 Digit 0
PC.0 a a a a
PC.1 b b b b
PC.2 c c c c
PC.3 d d d d
PC.4 e e e e
PC.5 f f f f
g g g g
PC.6 dp dp
PC.7 dp dp
PD.0
PD.1
PD.2
PD.3
11
char
digit_cathode[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07
,0x7F,0x6F};
char digit0, digit1, digit2, digit3;
int i,b, c, d;
void main(void) {
(2nd Part)
data_ddr=0xFF;
control_ddr=0x0F;