0% found this document useful (0 votes)
48 views13 pages

Higher Colleges of Technology Faculty of Electrical & Electronics Engineering

This document outlines a student project to interface a PIC16 microcontroller with a 7-segment display. It includes an introduction explaining microcontrollers and their uses. The objective is stated as interfacing the PIC16 and 7-segment display. The methodology involves connecting the hardware using Proteus, programming the PIC16 in MPLAB X to send commands to the display via its ports, and simulating and observing the results. The main body provides more details on the hardware connection, using a BCD to 7-segment decoder, programming code in C to loop through the digits, and explaining the code.

Uploaded by

Muhammad Yousaf
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)
48 views13 pages

Higher Colleges of Technology Faculty of Electrical & Electronics Engineering

This document outlines a student project to interface a PIC16 microcontroller with a 7-segment display. It includes an introduction explaining microcontrollers and their uses. The objective is stated as interfacing the PIC16 and 7-segment display. The methodology involves connecting the hardware using Proteus, programming the PIC16 in MPLAB X to send commands to the display via its ports, and simulating and observing the results. The main body provides more details on the hardware connection, using a BCD to 7-segment decoder, programming code in C to loop through the digits, and explaining the code.

Uploaded by

Muhammad Yousaf
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/ 13

1

Higher Colleges of Technology


Faculty of Electrical & Electronics Engineering

Microcontroller System
ELE 3614

Interface 7 segment Display using PIC 16

Course-Project 20%
System Modelling, Simulation and Analysis

Student Names

Students ID

Issue date 02/03/2021

Submission deadline 22/04/2021

Teacher Signature

1
2

Table of Contents
Introduction: ... ..................................................................................................................... 3
Objective .................................................................................................................. ...... .....3
Methodology ............................................................................................................ ..... ..... 4
Main body........................................................................................................... ..... ..... ...... 4
Observation and analysis............................................................................................ ..... ... 10
Results and discussion: ..........................................................................................................10.
Conclusion ............................................................................................................. ..... ..... ...11..
Refrences: ............................................................................................................. ..... ..... .....12

2
3

Abstract:
After connecting PIC16 with seven segment display using proteus we need to provide command
to our micro-controller by programming it so that we get desired numeric values on display
through its ports . As micro-controller works in hexa-decimal format thus it produces BCD
while for getting its correspondence output on display we can either use separate IC available in
proteus or can also embedd its effect during programming At the end we will run our mplab code
and proteus file to see if we are getting desired output on seven segment display.

Introduction:
In this project we are going to interface micro-controller with seven segment display .But before
going into that lets first reveal what micro-controller is?
A microcontroller is an integrated circuit (IC) that can be programmed to perform a set of
functions to control a collection of electronic devices. Being programmable is what makes the
microcontroller unique
Often thought of as a “tiny computer” on a single chip, the microcontroller is used in
many applications and can be found in almost every electronic device we encounter daily. The
computer’s microprocessor allows the computer to run a variety of programs and applications.
In fact, every car manufactured today has many microcontrollers incorporated into its electrical
system—antilock brakes, fuel control, air conditioning, heating, and keyless security locks. Each
microcontroller on a vehicle is designed to handle a specific function. The microcontroller, like
the computer, uses RAM to store programs and data temporarily. The amount of RAM built into
a microcontroller is minimal and is usually enough for its intended use.
In order to understand the importance of this project consider above mentioned
example of car’s electrical system that if we want to get information regarding antilock brakes,
fuel control, air conditioning, heating, and keyless security locks of our car then obviously we
can interpret them in numerical values and then to understand how micro-controller is
controlling these parameters we must interface it with seven segment display to get
communicated with machine by programming micro-controller again if desired to perform
specific task.

Objective:
Our objective is to Interface 7 segment Display using PIC 16 The 7-Segment display is a
common output device in electronic systems. The display has 7 LEDs arranged to display the
numbers from 0 to 9. We will use a decoder to operate the 7-Segment display. The decoder
converts BCD codes into the 7-Segment codes for the LEDs.

3
4

1.

Methodology:
Our project is mainly comprised of four main steps:

Step 1: Connecting PIC16 with seven segment display using proteus:


We can use proteus for hardware connections of PIC16 and display at first then after
programming in MPLAB X we can transport hex file into PIC16 for further manipulation of
results.

Step2: Using decoder for converting BCD to seven segment display:


As micro-controller works in hexa-decimal format thus it produces BCD while for getting its
correspondence output on display we can either use separate IC available in proteus or can also
embedd its effect during programming.

Step 3: Programming PIC16 in C language using MPLAB X .


After connecting PIC16 with seven segment display using proteus we need to provide
command to our micro-controller by programming it so that we get desired numeric values on
display through its ports .

Step 4:Simulation and Results:


At the end we will run our mplab code and proteus file to see if we are getting desired output
on seven segment display.

Main body of report:


 Connecting PIC16 with seven segment display using proteus:
 Using decoder for converting BCD to seven segment display:
 Programming PIC16 in C language using MPLAB X
 Simulation and Results

4
5

Connecting PIC16 with seven segment display using proteus:


We can utilize proteus for equipment associations of PIC16 and show from the outset then
subsequent to programming in MPLAB X we can move hex record into PIC16 for additional
control of results.

Using decoder for converting BCD to seven segment display:

7 Segment Display
A 7 Segment LED display generally has 8 input connections, one for each LED segment and one
that acts as a common terminal. There are 2 types of 7 Segment LED digital display.

 Common Cathode Display – all the cathode connections of the LEDs are connected to
ground. A logic '1' applied to the anode terminal of the individual segment illuminates it

5
6

 .
 Common Anode Display – all the anode connections of the LEDs are connected to VCC. A
logic '0' applied to the cathode terminal of the individual segment illuminates it

BCD to 7 Segment Display Decoder


A BCD to Seven Segment decoder is a combinational logic circuit that accepts a decimal digit in
BCD (input) and generates appropriate outputs for the segments to display the input decimal digit.

6
7

The truth table is extracted from the CD4511 IC datasheet.

Here abcdef and g are the seven LED’s of seven segment display thus if we want our PIC16 to
generate 0 at display then we should make all LED’s except g ON ,similarly to display other
numbers we follow same routine but how PIC16 will become able to perform this task?
As we know that PIC16 is 8 bit microcontroller thus each LED is actually
connectd with PIC16 8 bit thus by programming it we make it to provide Vcc at those LED’s
which we want to be ON for specific numeral output.

7
8

Programming PIC16 in C language using MPLAB X .


After connecting PIC16 with seven segment display using proteus we need to provide
command to our micro-controller by programming it so that we get desired numeric values on
display through its ports .

MPLAB C code:

# include<pic. h>
#define _XTAL_FREQ 20000000
void main()
{
unsigned int segment[10]= {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7C, 0x07, 0x7F, 0x6F };
unsigned int i=0;
TRISC=0x00;

while(1)
{
for(i=0;i<10;i++)
{

8
9

PORTC=segment[i];
__delay _ ms (1000);

}
}
}

Explanation of Code:
# include<pic. h>
#define _XTAL_FREQ 20000000
It includes libraries in our project file to use some built in functions in our code while the second
line is used to generate clock frequency of PIC16 microcontroller.

void main()
{
unsigned int segment[10]= {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7C, 0x07, 0x7F,
0x6F };
unsigned int i=0;

this is the main body function of our code in which we initialize variable having hexadecimal
equivalent values from 0 to 9. These hexadecimal values are stored in the 8 bit register and
derived from above mentioned BCD TO SEVEN SEGMENT DISPLAY table where for each
numeric output we need to make some LED’s ON and those LED’s are basically connected to
each bit of register.

TRISC=0x00;
As we want to get output from PIC16 through port C thus to make all of its pins as output we
need to make TRISC register equal to zero.

while(1)
{
9
10

for(i=0;i<10;i++)
{
PORTC=segment[i];
__delay _ ms (1000);

Now as our objective is to generate numeric values from zero to nine continuously thus we call
for loop inside while loop to call each register values stored in variable SEGMENT and then
bring it into seven segment LCD through PORTC.

Results and Discussion:

At the end we will run our mplab code and proteus file to see if we are getting desired output
on seven segment display.

Transporting hex file into PIC16.

10
11

OUTPUT:
Video is submitted for more results:

11
12

Observation and Analysis:

It is observed that how PIC microcontroller is easy to use as easily


programmable .and also we can apply several conditions on which it can be
programmed to behave differently depending upon type of condition happens Also
we can program it to behave in continuous similar fassion independent upon type
of condition.in short due to its ability of reprogrammable it has numerous kinds of
applications in the field of electrical and computer engineering. The 16F877A has
8K of memory. Most of the programs we wrote were in the 400- to 800-word range, so
considerably more sophisticated programs can be written without adding any memory.
On the other hand, adding one-wire memory is neither hard to do nor expensive.

Conclusion:
At the end it has been cleared that how microcontroller could be used after
interfacing it with external electronic circuitry .through this lab it has also been
cleared that by using advanced programming techniques and using other electronic
circuitry many other practical problems can be solved or it may help in making
life easier and comfortable where we could achieve our task by just initializing our
microcontroller means a robot is being hired for mankind.
12
13

After it’s all said and done, making an instrument or a controller is a matter of
putting together a series of components and segments of programs, each of which
provides a specific function.  Usually, the most difficult task will be getting the programs
to run fast enough to get the job done in the time available. We saw this in the programs
that had to update the seven-segment displays. However, we were running all the
programs at 4 MHz and you will find that considerably more can be done at 20 MHz.
Most of the PICs can be run at 20 MHz, while some of the newer ones can be run at 40
MHz.

Refrences:

1. You can explore TINA EDA https://www.youtube.com/watch?v=KfJlmFbcVeo for simulation.


You can get the demo version https://www.designsoftware.com/home/demos/demo_tina.php.
Project no 9 is already tested on it.

2. You can also you MPLAB, Proteus, Flowcode etc. whose demo versions are freely available on
internet.

3. For saving your time, I am adding few YouTube links for better understanding of these
simulation softwares.

 MPLAB (https://www.youtube.com/watch?v=UCVqnCiAwLw)
 Proteus (https://www.youtube.com/watch?v=X3ULSCpn7nY)
 MPLABX (https://www.youtube.com/watch?v=q2oZB50Avm4)
 Flowcode (https://www.youtube.com/watch?v=cxXGRLhGL5g) ….36 examples

4. The demo version allow you to simulate PIC microcontroller but cannot save the work. Hence
you can video tape your work while simulating the system (since you cannot save your work)
and also provide a screen shots in the report.
5. For anything else , I am always available at [email protected]

THE END

13

You might also like