0% found this document useful (0 votes)
14 views

Lecture_06_Seven Segment Display.pptx

Uploaded by

Mustaq Mujahid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture_06_Seven Segment Display.pptx

Uploaded by

Mustaq Mujahid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

EEE/ECE 365

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.

It can display digits from 0 Knowledge about how to


to 9 and quite a few interface a seven segment
characters like A, b, C, ., H, display to a micro
E, e, F, n, o, t, u, y, etc. controller is very essential
in designing embedded
systems. 2
The Pin Out and Picture of a 7-segment Display

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

LED ‘dp’ LED ‘a’


5

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

7-segment displays are Common Cathode type


• Let us see how ‘5678’ will be displayed in
4-digit display.
• Initially, the last display is only activated by
making PD.3 low, and all are high. Then digit
pattern for “8″ (digit0) is loaded to the Port C.
How does Then digit1 is activated by making PD.2 low,
it work? and “7” will appear in display of digit1 and so
on.
• This condition is maintained for around 10ms
for every case.
• This cycle is repeated for some time and due to
the persistence of vision you will feel it as
“5678″.
12
Code for 4-digit 7-segment Display (1st Part)
#include <mega32.h>
#include <delay.h>

#define data_ddr DDRC


#define data_port PORTC
#define control_ddr DDRD
#define control_port PORTD

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;

i=5678; //Number to display


digit0=i%10;
b=i/10;
digit1=b%10;
c=b/10;
digit2=c%10;
d=c/10;
14
digit3=d;
while (1) {
control_port=0b11110111;
(3rd Part)
data_port=digit_cathode[digit0];
delay_ms(10);
control_port=0b11111011;
data_port=digit_cathode[digit1];
delay_ms(10);
control_port=0b11111101;
data_port=digit_cathode[digit2];
delay_ms(10);
control_port=0b11111110;
data_port=digit_cathode[digit3];
delay_ms(10);
} 15
}
Thanks
16

You might also like