[go: up one dir, main page]

0% found this document useful (0 votes)
34 views6 pages

ES Lab Report 05

Uploaded by

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

ES Lab Report 05

Uploaded by

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

Lab Report # 05

Embedded System Lab

Submitted to:
Asad Ur Rehman

Submitted by:
Name Registration
M. Arslan Haider 210401023
M. Raza Madni 210401034
Batch-section: EE-20-A
Lab#05: Driving Multiple 7-Sgment Digits through Multiplexing Technique

Objectives:
1. To know how to interface single digit 7-segment display.
2. To realize how implement a truth table in PIC assembly language.
3. To get familiar with the multiplexing technique to interface multiple s-segment display.
Equipment:
1. MPLAB software
2. Proteus software
Theory:

Seven segment LED displays are often found in clock radios, VCRs, microwave ovens, toys and many other
household items. They are primarily used to display decimal numbers but they can also display a few alphabets
and other characters. This experiment describes interfacing a seven segment LED display to a
PIC16F877A microcontroller.

In this lab, we shall discuss about interfacing a seven segment LED display to a PIC microcontroller. The seven
segments are driven individually through separate I/O pins of the microcontroller. If we do just like that then for
4 seven segment LED displays, 28 I/O pins will be required, which is quite a bit of resources and is not
affordable by mid-range PIC microcontrollers. That’s why a multiplexing technique is used for driving multiple
seven segment displays. This lab shows how to multiplex 2 common cathode type seven segment LED displays
with a PIC16F877A microcontroller.

Multiplexing 4 common cathode seven segment LED displays

Multiplexing is used to save I/O pins. In the previous tutorial we saw how to interface a 7 Segment Display
directly with microcontroller pins. What if we want to interface more such displays? In the direct way, each
display will consume a minimum of 7 I/O pins of microcontroller(a to g). So, if we want to interface 4 displays
we should need a microcontroller with 4×7 = 28 I/O pins. In many practical situations, giving this much of I/O
pins dedicatedly just for interfacing the Display’s is not a wise choice. So, in such situations we use the
technique of multiplexing.

In Multiplexing, no matter how many displays we want to use the number of I/O pins we need is only that much
we need to interface one display. That is 7 I/O pins. These same 7 I/O pins is connected to all the display’s in a
parallel fashion.

So, if we connect the data pins parallel for all the displays how we get different data on different displays? All
the display’s will show same data right? The answer for this question is ‘NO’. Because even though the data
pins of all the display’s are connected together, the display’s are multiplexed. Means, only one display will be
ON for any time instant. When one display is ON all other displays will be OFF. And the data sent out by the
microcontroller pins to displays at that time is the data that display need to show which is in ON state at that
instant.

Circuit Diagram

The theory behind the multiplexing technique is simple. All the similar segments of multiple LED displays are
connected together and driven through a single I/O pin. In the circuit below, the seven segments are connected
to PORTB through current limiting resistors Rs. A particular segment is active when the corresponding PORTB
pin is high. However, it will not glow until it’s cathode is connected to ground. You can see the grounds of the
four LED displays are not directly connected to low. Instead,2 NPN transistors are used as switches to connect
or disconnect the cathode terminals from ground. When the base of the NPN transistor is high, the transistor
conducts and corresponding digit’s common cathode is connected to ground. Therefore, the transistor selects
which displays is active. The conduction of the transistors are controlled by RD0 through RD1 pins of PORTA.
Suppose, if we want to display 7 in the units digit place, then segments a, b, and c should be turned on first
(which means RB0, RB1, RB2 are 1 and RB3-RB6 are 0) and then RD0 should be pulled high (while keeping
RD1-low) so that only units digit display will be active. In order to display all 2 digits, each seven-segment
display is activated sequentially using an appropriate refresh frequency so that it will appear that all of them are
turned on at the same time.

Driving four 7-segment LED displays using multiplexing technique


Software
A sample program for a 2-digit up counter is developed using the assembly language. The counter starts with 0,
increments every second up to 99, and reset to zero. The value of the counter is displayed on the 2 7-segment
LED displays. The complete program is not described here. The subroutine convert takes in a numeric digit
from 0-9 and returns the value for PORTB that will turn the selected LEDs on to display that particular number.
For example, if the digit to be displayed is 1, then it requires segments b and c to be turned on. So the
subroutine convert will return value 0x06 (0b00000110) for PORTB, that will turn on the LED segments b and
c. Remember that the return values of subroutine convert would be different (complement of the current
values) if the LED display is common anode type.
Task# 01
Understand and implement the following code to show a counter output on the 7-segment display.

Procedure:
1. Write down the code in the software.
2. Run it.
3. Construct the circuit in circuit diagram.
4. Turn the switch on and off and note down the readings.

Code:
PORTD EQU 08H
TRISD EQU 88H
STATUS EQU 03H
PCL EQU 02H
OUPTUT EQU 20H

LIST P=16F877A
ORG 0 ;// starts from 0 hexadecimal
GOTO START
__CONFIG H'3F79' ;//jumps to start subroutine

CONVERT
MOVF OUPTUT,W
ADDWF PCL
RETLW B'01111110' ;//to display 1
RETLW B'00001100' ;//to display 2
RETLW B'10110110' ;//to display 3
RETLW B'10011110' ;//to display 4
RETLW B'11001100' ;//to display 5
RETLW B'11011010' ;//to display 6
RETLW B'11111010' ;//to display 7
RETLW B'00001110' ;//to display 8
RETLW B'11111110' ;//to display 9
RETLW B'11011110' ;//to display 0

START
BANKSEL TRISD ;//chooses the bank in which tristate register d is
MOVLW B'00000001' ;//all pins low except 1
MOVWF TRISD ;//moves working register's value to trisd register
BANKSEL PORTD ;//moves working register's value to trisd register
CLRF PORTD ;/clearing the port d
SW_P ;//SW_P section for switch to be pressed
BTFSS PORTD,0
GOTO SW_P
INCF OUPTUT
MOVF OUPTUT,W
SUBLW .10
BTFSC STATUS,2
CLRF OUPTUT
CALL CONVERT
MOVWF PORTD

SW_R ;//SW_R section for switch to be released


BTFSC PORTD,0
GOTO SW_R
GOTO SW_P
END

Diagram:
Task# 02
Write an assembly language program to add 2,4 bit numbers on same port (having sum less than 9) and display
their result on 7-Seg(with no BCD Decoder).User will input numbers through toggle switches
Procedure:
1. Write down the code in the software.
2. Run it.
3. Construct the circuit in circuit diagram.
4. Turn the switch on and off and note down the readings.

Code:

Diagram:

You might also like