0% found this document useful (0 votes)
40 views20 pages

Embedded Pw1 Izwan.

Uploaded by

Izwan
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)
40 views20 pages

Embedded Pw1 Izwan.

Uploaded by

Izwan
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/ 20

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _1 2023/2024 _


DEC40053 – EMBEDDED SYSTEM APPLICATIONS
PRACTICAL WORK1 : INTRODUCTION TO MPLABX AND CIRCUIT SIMULATION
PRACTICAL WORK 4/9/2023
DATE :
LECTURER’S NAME: PN.NORZILAH BINTI HUSSIN
GROUP NO. :
TOTAL
STUDENT ID & NAME : MARKS
(100%)

(1)

(2))

(3)

(4)

DATE SUBMIT : 7 SEPTEMBER DATE RETURN :

Prepared By: Verified By:


(NORMAH BINTI JANTAN)
1 LEARNING OUTCOMES (LO):

1. : Construct and simulate real-time embedded system


application based on PIC16F/PIC18F microcontroller effectively

2 OBJECTIVE

1. Write program in C language in MPLABX.


2. Draw and simulate PIC circuit in Proteus.
3. Build output hardware circuit using LEDs

3 THEORY

A) MPLAB

MPLAB Integrated Development Environment (IDE) is a free, integrated


toolset for the development of embedded applications on Microchip's
PIC and dsPIC microcontrollers. MPLAB support both C and assembly
language programming. It used in development of embedded system
application using microcontroller Microchip PICmicro and PIC.Assembly
language is a language that used for programming microcontroller.
Before we programmedthese assembly language instructions into
microcontroller memory, it has to convert to machine languageso that
microcontroller easily understands. This conversion is done by software
so called assembler inMPLAB IDE. This process is described in Figure 1.In
the MPLAB IDE assembly language programming, numbers usually
represent decimal, binary andhexadecimal.

B) PROTEUS

ISIS provides the means to enter the design in the first place, the
architecture for real time interactive level simulator. This software
combines mixed mode circuit simulation, micro-processor models and
interactive component models to allow the simulation of complete
micro-controller based designs.

Major features of PROTEUS VSM include:

a) Simulation and a system for managing the source and object


code associated with each project. In addition, a number of
graph objects can be placed on the schematic to enable
conventional time, frequency andswept variable simulation to
be performed.
b) True Mixed Mode simulation based on Berkeley SPICE3F5 with
extensions for digital simulation and true mixed mode
operation.
c) Support for both interactive and graph based simulation.
d) CPU Models available for popular microcontrollers such as the
PIC and 8051 series.
e) Interactive peripheral models include LED and LCD displays, a
universal matrix keypad, an RS232 terminal and a whole library
of switches, pots, lamps, LEDs etc.
4 EQUIPMENT / TOOLS

a- Personal Computer (PC)


b- MPLAB IDE software
c- Proteus software
5.0 PROCEDURE

At desktop, create a folder named P1. In the P1 folder, create subfolder


as below.

5.1
Open MPLAB X. Click File>New Project or New Project icon.

5.2 Step 1>Choose Project. Select Microchip Embedded option in Categories


and
Standalone Project in Projects. Click Next.
5.3 Step 2>Select device. Select All Families in Family option. In device
option, select suitable PIC18F microcontroller. Click Next.

5.4 In Select tools option, select the required programmer. If none, select
Simulator. Click Next.
5.5 In Select Compiler option, select the suitable compiler. Click C18(V3.36).
Click
Next.

5.6 In Select Project Name and Folder option. In Project Location, click
Browse. Select P1 folder you created before. In Project Name, type PW1.
Ignore any other options. Click Finish.
Tick all box

5.7
A folder named PW1.X will appeared in folder P1. This folder will store all
files and source code you created in MPLAB X.

5.8 MPLAB X window will appear as below.


5.9 You can check your MPLAB X setting
here. Dashboard-PW1 (your project
name) Device-PIC18F4520 (your
chosen PIC)
Compiler Toolchain-C18(v3.36) (your chosen compiler)

5.10 To create a C programming file, Right click Source File>New>main.c


5.11
At file name, type LED. In extension, option c is default selection. Ignore
other option.

5.12
A file named LED.c will appear below Source Files.

5.13 A window named LED.c will appear as below. This is where you will write
your source code.
5.14
Write the source code below.
// Using bit addressable
#include<p18f4520.h>
void main (void)
{ TRISBbits.TRISB0=0;
//Set PortB as output
while(1)
//Loop forever
{ LATBbits.LATB0=0;
//RB0 get 5V } }
5.15 To compile your sorce code, click Production>Build Main Project or its icon.

5.16 If your program has no error, you will get BUILD SUCCESSFUL statement in output window as below.
If your program has error, you will get BUILD FAILED statement. Double click the error message and
fix your program.
5.17 Double click Proteus 8 Professional icon. Then click new project icon as Figure . Rename New Project
to PW1

5.18 Untitled Proteus 8 Professional Schematic Capture work area will appear as below. Select button P
or Pick parts from libraries icon.

5.19 Pick Device window will appear. This is where you can select your components for simulation. You
can type the components name in Keywords box or you can select in Category option.
5.20 Select icon P to select components below:
 Microprocessor ICs > PIC18F Family > PIC18F4520 Resistors > 0.6W Metal film >
MINRES330R Optoelectronics > LEDs > LED-RED

5.21 Cons truct circuit shown below. To set power and ground source, select Terminal Mode > Power and
Ground. Click Instruments icon and select DC Voltmeter.
5.22 Double click your PIC18F4520. Edit component window will appear as below. At processor Clock
Frequency, set 64MHZ
To run your circuit, click Debug > Run Simulation or click the Run Simulation button at the bottom
left of your ISIS window. To stop simulation, click Stop The Simulation button as Figure 25.

5.23 Write new programming to do task below.Right click Source File>New>main.c. In File Name option
type LED2.

Remove LED.c code from Source Files. Right click Source Files>Remove From Project.

6.0 TASK
Build C program to perform task below. Design its circuit in Proteus. State your
observations.

a) Make all Port D produce 5V. Use byte addressable instructions.

b) Make pin RB4 to RB7 HIGH and RB0 to RB3 LOW. Use bit
addressable instruction.

c) Make RE0, RA1, RB2, RC3 and RD4 HIGH. Use bit addressable instruction.
DEC 40053 –EMBEDDED SYSTEM
APPLICATIONS PRACTICAL WORK 1 / 2 /
3/4/5/6
NO Group No. REG. NO. NAME OF STUDENT Programme
S1
S2
S3
S4

PRACTICAL SKILL ASSESSMENT RUBRIC


CLO 3: Construct and simulate real-time embedded system application based on PIC16F/PIC18F microcontroller
effectively. (P4, PLO5)
SCORE Score
NO CRITERIA
1-2 3-4 5-6 7-8 9-10 S1 S2 S3 S4
Program code The program The program The program The program
is incomplete code is code is complete code is complete code is complete
with complete with with a little with a little and well
inconsistent some inconsistence inconsistent organized.
Write code typing inconsistence code typing and code typing and
1. program and not well code typing and well organized well organized
organized well organized after being with a minimum
after being after being assisted by assist by lecturer
assisted by assisted by lecturer
lecturer lecturer
The program The program The program The program The program
code still have code have code have three code have one code successfully
an error. three or more or more error. or two error. run
Compile and Student error. Student Student can Student can
2. execute
cannot fixed can fixed the fixed the error fixed the error
program
the error after error after with a minimum with a minimum
being assisted being assisted assist by lecturer assist by
by lecturer. by lecturer. lecturer
Student The circuit The circuit Can construct a Can construct a
cannot fixed connection connection have hardware circuit hardware circuit.
Construct the circuit have three or three or more one or two error. or
circuit using connection by more error. error. Student or Can produce
hardware or itself after Student can can fixed the Can produce a
3. software being assisted fixed the error error with a schematic in
neat schematic
in Proteus
(Proteus) by lecturer. after being minimum assist Proteus one or
assisted by by lecturer two error.
lecturer.
Unsuccessful Successful Successful Successful Successful
program with program and program and program and program and
completely manage to get manage to get manage to get manage to get
incorrect the correct the correct the correct the correct
output on output on output on output on output on
hardware or hardware or hardware or hardware or hardware or
Demonstrate Proteus. Proteus after Proteus with a Proteus. Proteus.
circuit using being assist by minimum assist
4. hardware or lecturer. by lecturer.
software Student Student having Student Student Student
(Proteus) having difficulties to understand understand understand the
difficulties to understand most of the most of the program and
understand the program program and program and can
the program. demonstrate can can demonstrate
the circuit. demonstrate demonstrate the circuit.
the circuit. the circuit.

TOTAL MARKS /50


6 RESULT
CIRCUIT
5.15
// Using bit addressable

#include<p18f4520.h>
void main (void)
{
TRISBbits.TRISB0=0; // RB0 as
O/P
while(1) //Loop forever
{
LATBbits.LATB0=0; //RB0 get
0V
}
}
6.0
a) Make all Port D produce 5V.
// Use byte addressable

#include <p18f4520.h>
void main (void)
{
TRISD = 0; //Set PortB as output
while (1) //Loop forever
{
LATD = 0xFF; //PortB High
}
}

b) Make pin RB4 to RB7 HIGH


and RB0 to RB3 LOW. Use
bit addressable instruction.

#include <p18f4520.h>
void main (void)
{
TRISBbits.TRISB5=0;
TRISBbits.TRISB6=0;
TRISBbits.TRISB7=0;
TRISBbits.TRISB4=0;
//Set PortB as output
while(1)
//Loop forever
{ LATBbits.LATB7=
1;
LATBbits.LATB4=1;
LATBbits.LATB5=1;
LATBbits.LATB6=1;
//RB0 get 5v
}
}
c) Make RE0, RA1, RB2, RC3
and RD4 HIGH. Use bit
addressableinstruction.

#include<p18f4520.h>
void main (void)
{
TRISEbits.TRISE0 = 0;
TRISAbits.TRISA1 = 0;
TRISBbits.TRISB2 = 0;
TRISCbits.TRISC3 = 0;
TRISDbits.TRISD4 = 0;

while(1)
{
LATEbits.LATE0 = 1;
LATAbits.LATA1 = 1;
LATBbits.LATB2 = 1;
LATCbits.LATC3 = 1;
LATDbits.LATD4 = 1;

}
}

Discussion

Discussion in this practical work MPLAB is downloaded and use to write the 4 program in C language for task 5.15,a,b and c.
Each program perform different function. For task 5.15 the program is written to make 1 led light up using bit addressable at
Port B, RB as output, LATBbits. LATBO=1 command to make the LED connected to RBO light up, while (1) is use to make it loop
forever, TRISBbits.TRISB0=0 is use to connect to the output that is the LED. Next, PROTEUS is downloaded and use to draw and
simulate the 4 circuit for all the task to get the result. PIC18F4520 is use in the circuit. After finished drawing the circuit the
program written at MPLAB is inserted at the PIC to get the intended output according to the task. Lastly simulate the circuit to
get the result.

Conclusio
n
In the end we’re able to do coding and construct the diagram by using MPLABX and proteus software. We also able to draw and
simulate PIC circuit in Proteus and build output hardware circuit using LEDS. Finally, we also learn on how to write program
language in MPLABX

You might also like