Electrical Engineering Department Academic Session:: Dec40053 - Embedded System Applications
Electrical Engineering Department Academic Session:: Dec40053 - Embedded System Applications
Electrical Engineering Department Academic Session:: Dec40053 - Embedded System Applications
ACADEMIC SESSION:
DEC40053 – EMBEDDED SYSTEM APPLICATIONS
INTRODUCTION TO MPLABX AND
PRACTICAL WORK 1 :
CIRCUIT SIMULATION
PRACTICAL WORK DATE : 7 FEBUARY 2023
LECTURER’S NAME: DR SEGAR A/L RAJAMANICKAM
GROUP NO. :
TOTAL
STUDENT ID & NAME : MARKS
(100%)
(2)
(3)
(4)
(5)
2 OBJECTIVE
3 THEORY
A) MPLAB
B) PROTEUS
Proteus is a design software developed by Labcenter Electronics for electronic circuit simulation,
schematic capture and PCB design. Its simplicity and user friendly design made it popular among
electronics hobbyists. Proteus is commonly used for digital simulations such as microcontrollers and
microprocessors. It can simulate LED, LDR, USB Communication and many more.
4 EQUIPMENT / TOOLS
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 (PIC18F45K22). 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 (XC8 v2.00). 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.
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.11 At file name, type LED. In extension, option c is default selection. Ignore other option.
5.14 Check setting for your compiler. Click Project Properties at dashboard or click File>Project
Properties>XC8 Global option. At C Standard, select C90.
5.15 Copy and paste program given in Appendix A into your coding window. Modify the void main (void)
block with the source code below.
5.16 To compile your source code, click Production>Build Main Project or its icon.
5.17 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.18 Double click Proteus 8 Professional icon. Then click ISIS icon as Figure 18.
5.19 Untitled Proteus 8 Professional-Schematic Capture work area will appear as below. Select button P or
Pick parts from libraries icon.
5.20 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.
When all components are selected, click Cancel button to go back to ISIS window.
5.22 Construct circuit shown in Figure 23. To set power and ground source, select Terminal Mode > Power
and Ground. Click Instruments icon and select DC Voltmeter.
To save your circuit, select File > Save Project As. Go to Desktop > P1 Folder > CIRCUIT sub folder.
Save this circuit as LAB1.
5.23 Double click your PIC18F45K22. Edit component window will appear as below. At Processor Clock
Frequency, set 64MHZ.
Load the hex file into Proteus. In MPLAB X, at the output window, copy the statement below and
paste in program file in Proteus.
5.24 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.
5.25 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 LED.c name below Source Files>Remove From
Project.
Make sure only LED2.c code remain below Source Files.
b) Make pin RB7, RB5, RB3 and RB1 ON and other Port B pins OFF. Use byte addressable
instruction.
7 RESULT
TASK A
TASK B
TASK C
8 DISCUSSION
In this lab, using the PROTEUS software and the microcontroller (PIC18F45K22),we
can program and build the circuit to carry out the process or carry out the
progress of an operation
9 CONCLUSION
Based on this practical work, we need to program the coding and applied to the
microconroller.Beside that, this sofware combines mixed mode circuitsimulation,microprocessor
model and interactive component models to allow the simulation of complete micro-controller
based designs.
Appendix A
#include <xc.h>
#define _XTAL_FREQ 64000000L
void setup(void);
void delay(unsigned int x);
}
//Your program end here
/*
BAHAGIAN INI JANGAN KACAU :)
*/
void setup(void)
{
ANSELA = 0b00000000;
ANSELB = 0b00000000;
ANSELC = 0b00000000;
ANSELD = 0b00000000;
ANSELE = 0b00000000;
VREFCON0 = 0b10110000; // Fixed Voltage Reference is enabled, x4 (4.096V)
ADCON1 = 0b00110000; //0b00110000=4.096V 0b00100000=2.048V 0b00000000=Vdd
ADCON2 = 0b10000011;
LATA = 0x00;
LATB = 0x00;
LATC = 0x00;
LATD = 0x00;
LATE = 0x00;
}