PW1 Labsheet Embd System Faiz
PW1 Labsheet Embd System Faiz
PW1 Labsheet Embd System Faiz
(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.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.9 You can check your MPLAB X setting here.
Dashboard-PW1 (your project name)
Device-PIC18F45K22 (your chosen PIC)
Compiler Toolchain-XC8 (your chosen compiler)
5.13 A window named LED.c will appear as below. This is where you will write your source code.
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.
5.27 Draw circuit for LED2.c program and simulate them in Proteus.
6 TASK
Build C program to perform task below. Design its circuit in Proteus. State your observations.
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, we may programme and create the circuit to carry out the process or carry out the
progression of an operation using the PROTEUS software and the microcontroller (PIC18F45K22).
9 CONCLUSION
We must programme the coding and apply it to the microcontroller based on this practical work.
Additionally, this software integrates interactive component models, a microprocessor model, and
mixed mode circuit simulation to enable the simulation of full micro-controller-based systems.
Appendix A
#include <xc.h>
#define _XTAL_FREQ 64000000L
}
//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;
}