0% found this document useful (0 votes)
29 views96 pages

LECTURE 4 - IO - 7 Segment Display

The document discusses interfacing a 7-segment display with a PIC microcontroller. It describes what a 7-segment display is, the common anode and common cathode types, and how to configure and code a PIC to display numbers and implement up/down counters on the display.

Uploaded by

s221091638
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views96 pages

LECTURE 4 - IO - 7 Segment Display

The document discusses interfacing a 7-segment display with a PIC microcontroller. It describes what a 7-segment display is, the common anode and common cathode types, and how to configure and code a PIC to display numbers and implement up/down counters on the display.

Uploaded by

s221091638
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 96

INPUT AND OUTPUT INTERFACING

7 SEGMENTS DISPLAY
WHAT WILL BE COVER?

 What is the 7 segments display?

 How to control 7 segments display using PIC microcontroller?

ZMI 2023 2
I/O INTERFACING: 7 SEGMENTS DISPLAY

 A 7 segments display (SSD), or 7 segments indicator, is a form of electronic display device


for displaying decimal numerals that is an alternative to the more complex dot-matrix
displays.
 7 segments displays are widely used in digital clocks, electronic meters, and other electronic
devices for displaying numerical information
 A 7 segments display may have 7, 8, or 9 leads on the chip. Usually leads 8 and 9 are
decimal points.

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

1. Exercise 1: Display Numbers on 7 Segments Display


 Objective: Objective: Learn how to configure and display numbers (0 – 9) on 7 segments display for CCD and CAD type.
There are two exercises: 1.1 is using CCD type and 1.2 is using CAD type.
2. Exercise 2: Count Up and Count Down Counter
 Objective: Learn how to use switch with 7 segments display to create a count up and count down counter. There are two
exercises: 2.1 is auto counting when switch is pressed and 2.2 is single increment or decrement depends on which
switch has been pressed.

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)

 2 PUSH BUTTON – RB0 & RB1


 Mode: Active Low

 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)

 2 PUSH BUTTON – RB0 & RB1


 Mode: Active Low

 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

Button Button Button Button


Button
UP UP UP UP
DOWN

Button Button Button Button


DOWN DOWN DOWN DOWN Button Button
Button DOWN UP
Button Button Button
UP UP UP UP

Button Button Button Button Button


UP ZMI 2023 DOWN DOWN DOWN DOWN 37
I/O INTERFACING: BCD TO 7 SEGMENTS DECODER

 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

VDD 16 Power Supply Voltage (+3 to +15V)

GND 8 Power Ground (0V)

a-f 9-15 Output Outputs for the 7 segments display

D0-D3 7, 1, 2, 6 Input 4-bit BCD data input

Lamp Test. Turns on all segments


LT 3 Input
when LOW.

Blanking Test. Turns off all segments


BL 4 Input
when LOW.
Latch Enable. Stores the current state
LE 5 Input
when LOW.
ZMI 2023 39
I/O INTERFACING: BCD TO 7 SEGMENTS DECODER – CD4511

ZMI 2023 40
EXERCISE

3. Exercise 3: Display Numbers on 7 Segments Display using BCD to 7 Segments Decoder


 Objective: Learn how to configure and display numbers (0 – 9) on 7 segments display using BCD to 7 segments
decoder. There are three exercises: 3.1 connect Latch Enable control pin to Ground (no control pin), 3.2 used different
port for BCD input and Latch Enable control pin and 3.3 used same port.

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)

 2 PUSH BUTTON – RB0 & RB1


 Mode: Active Low

 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)

 2 PUSH BUTTON – RB0 & RB1


 Mode: Active Low

 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)

 2 PUSH BUTTON – RB0 & RB1


 Mode: Active Low

 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

4. Exercise 4: Display Numbers on Three 7 Segments Displays


 Objective: Objective: Learn how to configure and display numbers (0 – 999) on 7 segments display for CCD and CAD
type. There are two exercises: 4.1 is using CCD type and 4.2 is using CAD type.

ZMI 2023 70
EXERCISE 4.1 – CIRCUIT CONNECTION

ZMI 2023 71
EXERCISE 4.1 - HARDWARE CONFIGURATION IN PICSIMLAB

 Configuration

 7 Segments input– PORTC


 Type: CCD (Active High)

 7 Segments control pin


 D1 - Connect to Ground (Not Used)
 D2 – RD2
 D3 – RD1
 D4 – RD0

 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

 7 Segments input– PORTC


 Type: CAD (Active Low)

 7 Segments control pin


 D1 - Connect to Ground (Not Used)
 D2 – RD2
 D3 – RD1
 D4 – RD0

 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

 The 74XX573 is an 8-bit D-type transparent latch with 3-state


outputs.
 The device features latch enable (LE) and output enable (𝑂𝑂𝑂𝑂) inputs.
 When LE is HIGH, data at the inputs enter the latches.
 In this condition the latches are transparent, a latch output will
change each time its corresponding D-input changes.
 When LE is LOW the latches store the information that was present at
the inputs a set-up time preceding the HIGH-to-LOW transition of LE.
 A HIGH on 𝑶𝑶𝑶𝑶 causes the outputs to assume a high-impedance OFF-
state.
 Operation of the 𝑂𝑂𝑂𝑂 input does not affect the state of the latches.
ZMI 2023 85
I/O INTERFACING: MULTIPLE 7 SEGMENTS DISPLAY – USING LATCH

 Using latch will eliminate the requirement of fast switching on every


digits since it has the capabilities to hold data.
 Therefore, we just need to latch desired digit and the data will remain
until we latched new data.
 No changes in all segments pin connection.
 When using latch, the 7 segments display common pin is directly
connected to VCC (CAD) or Ground (CCD).
 For controlling pin (digits selection), the LE pin will be used.

ZMI 2023 86
EXERCISE

5. Exercise 5: Display Numbers on TWO 7 Segments Displays with Latch


 Objective: Learn how to configure and display numbers (0 – 99) on 7 segments display for CCD type with Latch.

ZMI 2023 87
EXERCISE 5 – CIRCUIT CONNECTION

ZMI 2023 88
EXERCISE 5 - HARDWARE CONFIGURATION IN PICSIMLAB

 Configuration

 74xx573 input– PORTC

 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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy