Higher Colleges of Technology Faculty of Electrical & Electronics Engineering
Higher Colleges of Technology Faculty of Electrical & Electronics Engineering
Microcontroller System
ELE 3614
Course-Project 20%
System Modelling, Simulation and Analysis
Student Names
Students ID
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:
4
5
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
6
7
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
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.
At the end we will run our mplab code and proteus file to see if we are getting desired output
on seven segment display.
10
11
OUTPUT:
Video is submitted for more results:
11
12
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:
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