LECTURE 4 - IO - 7 Segment Display
LECTURE 4 - IO - 7 Segment Display
7 SEGMENTS DISPLAY
WHAT WILL BE COVER?
ZMI 2023 2
I/O INTERFACING: 7 SEGMENTS DISPLAY
ZMI 2023 3
I/O INTERFACING: 7 SEGMENTS DISPLAY
There are two types of displays available, common anode (CAD) and common cathode (CCD).
The Common Cathode Display (CCD) – In the common cathode display, all the cathode
connections of the LED’s are joined together to logic “0” or ground. The individual segments
are illuminated by application of a “HIGH”, logic “1” signal to the individual Anode terminals.
In other words, CCD is an active high device.
The Common Anode Display (CAD) – In the common anode display, all the anode
connections of the LED’s are joined together to logic “1” and the individual segments are
illuminated by connecting the individual Cathode terminals to a “LOW”, logic “0” signal. In
other words, CAD is an active low device.
ZMI 2023 4
I/O INTERFACING: 7 SEGMENTS DISPLAY
The light emitting diodes in a 7 segments display are arranged in
the following figure:
ZMI 2023 5
I/O INTERFACING: 7 SEGMENTS DISPLAY
7 segments display configuration:
CCD:
X = 1 (turn on segment)
Blank = 0 (turn off segment)
CAD:
X = 0 (turn on segment)
Blank = 1 (turn off segment)
ZMI 2023 6
I/O INTERFACING: 7-SEGMENT DISPLAY
ZMI 2023 7
EXERCISE
ZMI 2023 8
EXERCISE 1.1 – CIRCUIT CONNECTION
ZMI 2023 9
EXERCISE 1.1 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
7 Segments – PORTC
Mode: CCD (Active High)
Task:
Display counting value from 0 to 9
continuously.
ZMI 2023 10
EXERCISE 1.1: FLOWCHART
ZMI 2023 11
EXERCISE 1.1 - CODE
ZMI 2023 12
EXERCISE 1.1 - CODE
ZMI 2023 13
EXERCISE 1.1 - RESULTS
ZMI 2023 14
EXERCISE 1.2 – CIRCUIT CONNECTION
ZMI 2023 15
EXERCISE 1.2 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
7 Segments – PORTC
Mode: CAD (Active Low)
Task:
Display counting value from 0 to 9
continuously.
ZMI 2023 16
EXERCISE 1.2: FLOWCHART
ZMI 2023 17
EXERCISE 1.2 - CODE
ZMI 2023 18
EXERCISE 1.2 - CODE
ZMI 2023 19
EXERCISE 1.2 - RESULTS
ZMI 2023 20
EXERCISE 2.1 – CIRCUIT CONNECTION
ZMI 2023 21
EXERCISE 2.1 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
7 Segments – PORTC
Mode: CCD (Active High)
Task:
If UP button pressed
Display counting value from 0 to
9 continuously.
If DOWN button pressed
Display counting value from 9 to
0 continuously.
ZMI 2023 22
EXERCISE 2.1:
FLOWCHART
ZMI 2023 23
EXERCISE 2.1 - CODE
ZMI 2023 24
EXERCISE 2.1 - CODE
ZMI 2023 25
EXERCISE 2.1 - CODE
ZMI 2023 26
EXERCISE 2.1 - RESULTS
Button UP Pressed: Counting UP
ZMI 2023 27
EXERCISE 2.1 - RESULTS
Button DOWN Pressed: Counting DOWN
ZMI 2023 28
EXERCISE 2.2 – CIRCUIT CONNECTION
ZMI 2023 29
EXERCISE 2.2 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
7 Segments – PORTC
Mode: CCD (Active High)
Task:
Display counter value on 7 segments
display.
If UP button pressed
Counter will increased. If value
reached greater than 9, remain at 9.
If DOWN button pressed
Counter will decreased. If value
reached below 0, remain at 0.
ZMI 2023 30
EXERCISE 2.2:
FLOWCHART
ZMI 2023 31
EXERCISE 2.2 - CODE
ZMI 2023 32
EXERCISE 2.2 - CODE
ZMI 2023 33
EXERCISE 2.2 - CODE
ZMI 2023 34
EXERCISE 2.2 - CODE
ZMI 2023 35
EXERCISE 2.2 - CODE
ZMI 2023 36
EXERCISE 2.2 - RESULTS
A digital or binary decoder decoder is a digital combinational logic circuit which can convert one
form of digital code into another form.
BCD to 7 segments display decoder is a special decoder which can convert binary coded decimals
into another form which can be easily displayed through a 7 segments display.
Example of the BCD to 7 segment decoders IC
CD4511
can drive common cathode seven segment display only
LS7447
can drive common anode seven segment display only.
ZMI 2023 38
I/O INTERFACING: BCD TO 7 SEGMENTS DECODER – CD4511
Pins Description
Pin Name Pin # Type Description
ZMI 2023 40
EXERCISE
ZMI 2023 41
EXERCISE 3.1 – CIRCUIT CONNECTION
ZMI 2023 42
EXERCISE 3.1 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
CD4511 BCD input– PORTC –
(RC0 – RC4)
CD4511 LE control pin
D1 - Connect to Ground
D2 – D4 – Connect to VCC (Not Used)
Task:
If UP button pressed
Display counting value from 0 to 9
continuously.
If DOWN button pressed
Display counting value from 9 to 0
continuously.
ZMI 2023 43
EXERCISE 3.1:
FLOWCHART
ZMI 2023 44
EXERCISE 3.1 –
CODE : NO CONTROL
PIN
ZMI 2023 45
EXERCISE 3.1 –
CODE : NO CONTROL
PIN
ZMI 2023 46
EXERCISE 3.1 - RESULTS
Button UP Pressed: Counting UP
Continue to
ZMI 2023 47
EXERCISE 3.1 - RESULTS
Button DOWN Pressed: Counting DOWN
Continue to
ZMI 2023 48
EXERCISE 3.2 – CIRCUIT CONNECTION
ZMI 2023 49
EXERCISE 3.2 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
CD4511 BCD input– PORTC –
(RC0 – RC4)
CD4511 LE control pin
D1 - At different port – RA0
D2 – D4 – Connect to VCC (Not Used)
Task:
If UP button pressed
Display counting value from 0 to 9
continuously.
If DOWN button pressed
Display counting value from 9 to 0
continuously.
ZMI 2023 50
EXERCISE 3.2:
FLOWCHART
ZMI 2023 51
EXERCISE 3.2 –
CODE : CONTROL PIN
AT DIFFERENT PORT
ZMI 2023 52
EXERCISE 3.2 –
CODE : CONTROL PIN
AT DIFFERENT PORT
ZMI 2023 53
EXERCISE 3.2 –
CODE : CONTROL PIN
AT DIFFERENT PORT
ZMI 2023 54
EXERCISE 3.2 - RESULTS
Button UP Pressed: Counting UP
Continue to
ZMI 2023 55
EXERCISE 3.2 - RESULTS
Button DOWN Pressed: Counting DOWN
Continue to
ZMI 2023 56
EXERCISE 3.3 – CIRCUIT CONNECTION
ZMI 2023 57
EXERCISE 3.3 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
CD4511 BCD input– PORTC –
(RC0 – RC4)
CD4511 LE control pin
D1 - At same port – RC7
D2 – D4 – Connect to VCC (Not Used)
Task:
If UP button pressed
Display counting value from 0 to 9
continuously.
If DOWN button pressed
Display counting value from 9 to 0
continuously.
ZMI 2023 58
EXERCISE 3.3:
FLOWCHART
ZMI 2023 59
EXERCISE 3.3 –
CODE : CONTROL PIN
AT SAME PORT
ZMI 2023 60
EXERCISE 3.3 –
CODE : CONTROL PIN
AT SAME PORT
ZMI 2023 61
EXERCISE 3.3 –
CODE : CONTROL PIN
AT SAME PORT
ZMI 2023 62
EXERCISE 3.3 - RESULTS
Button UP Pressed: Counting UP
Continue to
ZMI 2023 63
EXERCISE 3.3 - RESULTS
Button DOWN Pressed: Counting DOWN
Continue to
ZMI 2023 64
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY
ZMI 2023 65
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY
ZMI 2023 66
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY
ZMI 2023 67
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY
Persistence of vision (POV) refers to the optical illusion that occurs when visual
perception of an object does not cease for some time after the rays of light
proceeding from it have ceased to enter the eye.
The human eye receives the light rays and sends the signals to the brain where
perception occurs.
The image you see inside your brain takes some time to fade away after it actually
disappears in front of your eyes.
Therefore, the eye could be easily tricked by changing a scene fast enough so that the
brain perceives an object in two places at the same time.
A very common example you might have seen before is the POV LED Watch.
A led bar rotating very fast with a motor mount, so we can make the LEDs “appear” to be in
multiple places, therefore we can draw whatever we want using only a strip of LEDs instead of a
huge LED matrix.
ZMI 2023 68
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY – DIRECT CONTROL
The key idea of controlling multiple 7-segment displays is to use the same 8 IO output pins for all the
segment lines.
And also an additional control pin (transistor) to activate each 7-segment unit one at a time.
And keep switching between all the digits fast enough to seemingly look as if they are lit at the same time.
In order to do the switching, the control pin required since all the segments used same 8 IO outputs.
In direct control, the simplest method is to add NPN BJT transistor to control the common pin.
ZMI 2023 69
EXERCISE
ZMI 2023 70
EXERCISE 4.1 – CIRCUIT CONNECTION
ZMI 2023 71
EXERCISE 4.1 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
Task:
Display number from 000 - 999
ZMI 2023 72
EXERCISE 4.1:
FLOWCHART
ZMI 2023 73
EXERCISE 4.1 –
CODE
ZMI 2023 74
EXERCISE 4.1 –
CODE
ZMI 2023 75
EXERCISE 4.1 –
CODE
ZMI 2023 76
EXERCISE 4.1 - RESULTS
ZMI 2023 77
EXERCISE 4.2 – CIRCUIT CONNECTION
ZMI 2023 78
EXERCISE 4.2 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
Task:
Display number from 000 - 999
ZMI 2023 79
EXERCISE 4.2:
FLOWCHART
ZMI 2023 80
EXERCISE 4.2 –
CODE
ZMI 2023 81
EXERCISE 4.2 –
CODE
ZMI 2023 82
EXERCISE 4.2 –
CODE
ZMI 2023 83
EXERCISE 4.2 - RESULTS
ZMI 2023 84
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY – USING LATCH
ZMI 2023 86
EXERCISE
ZMI 2023 87
EXERCISE 5 – CIRCUIT CONNECTION
ZMI 2023 88
EXERCISE 5 - HARDWARE CONFIGURATION IN PICSIMLAB
Configuration
LE control pin
LE1 – RD2
LE2 – RD1
LE3 – RD0
7 Segments Display
Mode: CCD (Active High)
Connect to Latch Output
Task:
Display number from 000 - 999
ZMI 2023 89
EXERCISE 5 - HARDWARE CONFIGURATION IN PICSIMLAB
Sample Setting
ZMI 2023 90
EXERCISE 5:
FLOWCHART
ZMI 2023 91
EXERCISE 5 – CODE
ZMI 2023 92
EXERCISE 5 – CODE
ZMI 2023 93
EXERCISE 5 – CODE
ZMI 2023 94
EXERCISE 5 - RESULTS
ZMI 2023 95
REFERENCES
I. https://exploreembedded.com/wiki/Interfacing_Seven_Segments_with_PIC16f877a
II. https://microcontrollerslab.com/7-segment-display-interfacing-with-pic-microcontroller/
III. https://www.electricaltechnology.org/2018/05/binary-decoder.html
IV. https://circuitdigest.com/electronic-circuits/7-segment-display-driver-using-ic-cd4511
V. https://www.engineersgarage.com/bcd-to-7-segment-display-circuit/
VI. https://components101.com/ics/cd4511-7-segment-driver-ic
VII. https://deepbluembedded.com/multiplexing-7-segment-displays-3-digit-7-segment-interfacing-with-pic-
microcontrollers/
VIII. https://microcontrollerslab.com/7-segment-display-interfacing-with-pic-
microcontroller/#:~:text=To%20display%20a%20counter%20of,via%20a%20resistor%20of%20560R.
IX. https://circuitdigest.com/microcontroller-projects/7-segment-display-interfacing-with-pic16f877a
ZMI 2023 107