0% found this document useful (0 votes)
20 views

ES_lab_file

The document provides an overview of using MPLAB X IDE and Proteus for embedded systems experiments, focusing on programming PIC microcontrollers to control LED blinking patterns. It details the setup process, coding examples for various LED patterns, and the successful simulation results achieved through these tools. The document serves as a practical guide for students in the Department of Electronics and Communication Engineering at Delhi Technological University.

Uploaded by

Saurav Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

ES_lab_file

The document provides an overview of using MPLAB X IDE and Proteus for embedded systems experiments, focusing on programming PIC microcontrollers to control LED blinking patterns. It details the setup process, coding examples for various LED patterns, and the successful simulation results achieved through these tools. The document serves as a practical guide for students in the Department of Electronics and Communication Engineering at Delhi Technological University.

Uploaded by

Saurav Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Delhi Technological University

(Formerly Delhi College of Engineering)


Shahbad Daulatpur, Bawana Road, Delhi-110042

Department of Electronics and Communication


Engineering

Embedded Systems

Submitted To: Submitted By:


Saurav Singh
2K22/EC/210
EXPERIMENT - 1

Aim: Introduction to MPLAB, and Proteus.


Software: MPLAB x IDE v . and Proteus Professional
Theory:
MPLAB X IDE v . is a comprehensive integrated development environment (IDE)
crafted for Microchip microcontrollers and digital signal controllers (DSCs), adaptable
across Windows, macOS, and Linux platforms. It encompasses a suite of essential tools
including a sophisticated code editor with features like syntax highlighting and code
completion, simplifying code creation. The IDE's project management capabilities allow
seamless organization of codebases, enhancing developer productivity. Notably, its robust
debugger equips developers with advanced functionalities such as breakpoints and
variable tracing, aiding in ef cient bug identi cation and resolution. With extensive
device support, MPLAB X IDE v . provides access to device-speci c libraries and
con guration tools, streamlining development for Microchip's hardware. The IDE's
plugin ecosystem further enhances its functionality, enabling developers to customize
and extend features according to speci c project requirements. Moreover, its integration
with version control systems like Git facilitates collaborative development work ows,
ensuring version tracking and project synchronization. MPLAB X IDE v . thus stands
as an indispensable tool for embedded application development, empowering developers
to create, debug, and deploy projects with con dence and ef ciency.

MPLAB X supports the following compilers:


MPLAB XC - C compiler for -bit PIC devices
MPLAB XC - C compiler for -bit PIC devices
MPLAB XC - C/C++ compiler for -bit PIC devices
HI-TECH C - C compiler for -bit PIC devices
SDCC - open-source C compiler

The MPLAB X IDE provides the ability to:


Create and edit source code using the built-in editor.
Assemble, compile, and link source code.
Debug the executable logic by watching the program ow with the built-in simulator
or in real-time with in-circuit emulators or in-circuit debuggers.
Make timing measurements with the simulator or emulator.
View variables in watch windows.
Program rmware into devices with device programmers.

LAB FILE EMBEDDED SYSTEMS Page 1


fi
fi
8
1
3
6
2
6
2
0
6
2
8
0
fi
8
1
6
6
3
2
2
0
fi
8
fi
fi
fl
fi
fi
6
2
0
fl
Getting started with MPLAB IDE:
Creating a new project in MPLAB X IDE v .
. Open MPLAB X IDE v .

. Choose File > New Project > Standalone Project & click next.

LAB FILE EMBEDDED SYSTEMS Page 2


2
1
6
2
0
6
2
0
. Select the Device then click Next.

. Choose compiler then click Next.

LAB FILE EMBEDDED SYSTEMS Page 3


4
3
. Give Project name & specify project location.

) At last, the nal project has been built successfully. Now user can start adding
les & writing codes in the given project.

LAB FILE EMBEDDED SYSTEMS Page 4


6
5
fi
fi
Simulation Software: Proteus Professional

Proteus Schematic Window

Result: We have successfully studied about PIC Microcontroller, and gained overview of
how to create Hex le in MPLAB and select components in proteus in order to make
schematic.

LAB FILE EMBEDDED SYSTEMS Page 5


fi
8
EXPERIMENT - 2

Aim: To blink LEDs in ON/OFF pattern using PIC.


Software: MPLAB X IDE v . and Proteus Professional.
Theory:
Light-emitting diodes (LEDs) are semiconductor devices that emit light when a voltage is
applied across their terminals. Operating as p-n junction diodes, they facilitate electron-
hole recombination within the device, releasing energy in the form of photons. The
emitted light’s colour, representing the photon's energy, is determined by the
semiconductor material’s energy band gap. The PIC microcontroller, introduced by
Microchip Technologies in , initially served as part of PDP (Programmed Data
Processor) Computers. Each peripheral device of the computer was interfaced using
these microcontrollers, hence earning the name Peripheral Interface Controller (PIC).
Over time, Microchip expanded its PIC series ICs, ranging from simple lighting
applications to advanced functionalities. These microcontrollers became integral
components for various electronic projects due to their versatility and reliability. The PIC
microcontroller's adoption in diverse applications stems from its robust architecture,
offering features such as GPIO (General Purpose Input/Output) pins for interfacing with
external components like LEDs. By con guring GPIO pins as outputs and controlling
their states through software, developers can implement tasks like blinking LEDs in
speci c patterns. This process involves writing code using development tools like
MPLAB X IDE, compiling it into machine code, and programming the microcontroller to
execute the desired functionality.

PIC Microcontroller: PIC F A

LAB FILE EMBEDDED SYSTEMS Page 6


fi
1
6
6
1
8
2
9
4
0
9
3
fi
8
Code:
void main(){
TRISB = 0x00; //Port B as OUTPUT
PORTB = 0x00; //Port B set as LOW
while(1) {
PORTB = 0xFF; //Turn ON LED
delay_ms(250); //Delay of 250ms
PORTB = 0x00; //Turn OFF LED
delay_ms(250); //Delay of 250ms
}
return;
}

Simulation Results:

All LED’s are turned OFF. All LED’s are turned ON.

Results: Using PIC F A Microcontroller in Proteus and MPLAB X Software, the


LEDs blinking ON/OFF pattern was implemented successfully.

LAB FILE EMBEDDED SYSTEMS Page 7


1
6
8
4
EXPERIMENT - 3

Aim: To blink LEDs in alternate fashion using PIC.


Software: MPLAB X IDE v . and Proteus Professional.
Theory:
The Microcontroller that has been used is PIC F A on Proteus Software and then
several LEDs are connected to the output ports of the microcontroller. These LEDs are
then grounded as shown below and then we used the code on MPLAB X and generated
the hex- le for it. Now nally the hex- le is used by the microcontroller to generate the
blinking of LEDs in an alternate pattern.
Code:
void main(){
TRISB = 0x00; //Port B as OUTPUT
PORTB = 0x00; //Port B set as LOW
while(1) {
PORTB = 0x55; //Turn ON LED 1,3,5,7
delay_ms(250); //Delay of 250ms
PORTB = 0xAA; //Turn ON LED 2,4,6,8
delay_ms(250); //Delay of 250ms
}
return;
}

Simulation Results:

Results: Using PIC F A Microcontroller in Proteus and MPLAB X Software, the


LEDs blink in alternating pattern successfully.

LAB FILE EMBEDDED SYSTEMS Page 8


fi
1
6
fi
8
4
6
2
0
fi
8
1
6
8
4
EXPERIMENT - 4

Aim: To blink LEDs in a one-by-one pattern and Sandglass pattern using PIC.
Software: MPLAB X IDE v . and Proteus Professional.
Theory:
The Microcontroller that has been used is PIC F A on Proteus Software and then
several LEDs are connected to the output ports of the microcontroller. These LEDs are
then grounded as shown below and then we used the code on MPLAB X and generated
the hex- le for it. Now nally the hex le is used by the microcontroller to generate the
blinking of LEDs in one by one & sandglass pattern.
Code 1: One by One Pattern
void main(){
TRISB = 0x00; //Port B as OUTPUT
PORTB = 0x00; //Port B set as LOW
int i, j, k;
j = 0x01;
while(1) {
for (i = 0; i < 8; i++) {
PORTB = j << i;
for (k = 0; k < 800; k++);
}
}
return;
}

Simulation Results 1:

Only LED is ON Only LED is ON

LAB FILE EMBEDDED SYSTEMS Page 9


fi
1
fi
6
2
0
fi
8
1
6
8
4
2
Only LED is ON Only LED is ON

Code 2: Sandglass Pattern


void main(){
TRISB = 0x00; //Port B as OUTPUT
PORTB = 0x00; //Port B set as LOW
while(1) {
for (i = 0; i < 8; i++) {
PORTB = 0x00;
delay_ms(100);
PORTB = 0x80;
delay_ms(100);
PORTB = 0xC0;
delay_ms(100);
PORTB = 0xE0;
delay_ms(100);
PORTB = 0xF0;
delay_ms(100);
PORTB = 0xF8;
delay_ms(100);
PORTB = 0xFC;
delay_ms(100);
PORTB = 0xFE;
delay_ms(100);
PORTB = 0xFF;
delay_ms(100);
}
}
return;
}

LAB FILE EMBEDDED SYSTEMS Page 10


3
4
Simulation Results 2:

and so on…

Results: Using PIC F A Microcontroller and MPLAB X Software, we have


successfully simulated both one-by-one and sandglass pattern blinking of LED.

LAB FILE EMBEDDED SYSTEMS Page 11


1
6
8
4

You might also like