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

Pratham

The document is a practical lab file for the EC306 Embedded Systems course at Delhi Technological University, detailing various experiments using MPLAB and Proteus software tools. It includes aims, theories, codes, and results for experiments such as blinking LEDs, displaying numbers on a seven-segment display, and implementing different LED patterns using the PIC16F84A microcontroller. Each experiment demonstrates fundamental concepts in embedded systems and microcontroller programming.
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)
11 views20 pages

Pratham

The document is a practical lab file for the EC306 Embedded Systems course at Delhi Technological University, detailing various experiments using MPLAB and Proteus software tools. It includes aims, theories, codes, and results for experiments such as blinking LEDs, displaying numbers on a seven-segment display, and implementing different LED patterns using the PIC16F84A microcontroller. Each experiment demonstrates fundamental concepts in embedded systems and microcontroller programming.
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/ 20

DEPARTMENT OF ELECTRONICS AND

COMMUNICATION
DELHI TECHNOLOGICAL
UNIVERSITY
DELHI -110042

EC306: Embedded Systems


PRACTICAL LAB FILE

Submitted To: Submitted By:


Dr. Varun Sangwan Pratham Mehra
(2K22/EC/172)
INDEX
Sno. Experiment Date Signature

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.
EXPERIMENT - 1

AIM: Introduction to MPLAB and Proteus Software Tools.

TOOLS USED: MPLAB x IDE v6.15 and Proteus 8 Professional v8.7

THEORY: MPLAB X IDE v6.15 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 efficient bug identification and resolution.
With extensive device support, MPLAB X IDE v6.15 provides access to device-
specific libraries and configuration 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
specific project requirements. Moreover, its integration with version control
systems like Git facilitates collaborative development workflows, ensuring
version tracking and project synchronization. MPLAB X IDE v6.15 thus stands
as an indispensable tool for embedded application development, empowering
developers to create, debug, and deploy projects with confidence and efficiency.
MPLAB X supports the following compilers:
• MPLAB XC8 - C compiler for 8-bit PIC devices
• MPLAB XC16 - C compiler for 16-bit PIC devices
• MPLAB XC32 - C/C++ compiler for 32-bit PIC devices
• HI-TECH C - C compiler for 8-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 flow 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 firmware into devices with device programmers.

GETTING STARTED WITH MPLAB IDE:

Creating a new project in MPLAB X IDE v6.15


1. Open MPLAB x IDE v6.15

2. Choose File > New Project then choose StandAlone Project next click
Next.

3. Select the Device as PIC 16F84A then click Next.


4. Choose the Compiler as XC8 (v2.45) then click Next.

5. Give the project name as MPLAB_1 and specify the project location.
6. At last, the final project has been built successfully. Now user can start
adding files & writing codes in the given project.

SIMULATION SOFTWARE: Proteus 8 Professional v8.7

RESULT: We have successfully studied about the PIC Microcontroller, and


gained the overview of how to create Hex file in MPLAB and select the
components in Proteus Software in order to make the schematic.
EXPERIMENT - 2

AIM: To blink LEDs ON and OFF pattern using PIC

TOOLS USED: MPLAB x IDE v6.15 and Proteus 8 Professional v8.7

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 color, representing the photon's energy, is determined by the
semiconductor material's energy band gap.
The PIC microcontroller, introduced by Microchip Technologies in 1993, 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 configuring GPIO pins as outputs and
controlling their states through software, developers can implement tasks like blinking
LEDs in specific 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.

Pin Diagram of PIC16F84A Microcontroller board


CODE:

#include <xc.h>
void main(void) {
int i;
TRISB = 0;
while (1) {
PORTB = 0xff;
for (i = 0; i < 100; i++);
PORTB = 0x00;
for (i = 0; i < 100; i++);
}
return;
}

SIMULATION OUTPUT:

All LEDs are turned OFF.


All LEDs are turned ON.

RESULT: Using PIC16F84A Microcontroller and MPLAB Software tools, the


LEDs blink in ON/OFF pattern successfully.
EXPERIMENT - 3

AIM: To blink LEDs in an alternate fashion using PIC.

TOOLS USED: MPLAB x IDE v6.15 and Proteus 8 Professional v8.7

THEORY: The microcontroller used in this project is the PIC16F84A,


simulated on Proteus Software. Several LEDs are connected to the output ports
(PORTB) of the microcontroller through current-limiting resistors and grounded.
The program is written in MPLAB IDE using assembly language or embedded
C, compiled to generate a hex file. This hex file is then loaded into the
microcontroller to execute the blinking sequence.
The logic involves configuring the GPIO pins as outputs and toggling them in an
alternate fashion with a delay in between. One set of LEDs turns ON while the
others remain OFF, and after a delay, their states are reversed, creating a
continuous blinking effect. This project demonstrates basic GPIO control and can
be extended to applications like traffic lights and sequential lighting.

CODE:

#include <xc.h>
#include <pic.h>

void main(){
int i;
TRISB = 0;
while (1){
PORTB = 0xAA;
for (i = 0; i < 100; i++);
PORTB = 0x55;
for (i = 0; i < 100; i++);
}
}
SIMULATION OUTPUT:

RESULT: Using PIC16F84A Microcontroller and MPLAB Software tools, the


LEDs blink in alternate pattern successfully.
EXPERIMENT - 4

AIM: To blink LEDs in a one-by-one patterns and Sandglass pattern using PIC.

TOOLS USED: MPLAB x IDE v6.15 and Proteus 8 Professional v8.7

THEORY: The PIC16F84A microcontroller is used in this project, simulated


on Proteus Software, to implement two LED blinking patterns: one-by-one and
sandglass. Several LEDs are connected to PORTB through current-limiting
resistors and grounded.
The program is developed in MPLAB IDE using assembly language or embedded
C, compiled to generate a hex file, which is then uploaded to the microcontroller.
The GPIO pins are configured as outputs, and the LEDs are controlled by toggling
their states with appropriate delays.
In the one-by-one pattern, LEDs turn ON and OFF sequentially from one end to
the other, creating a flowing effect. In the sandglass pattern, LEDs light up in a
symmetrical hourglass-like sequence. These patterns run continuously in a loop.
This project demonstrates GPIO manipulation, sequential control, and timing
concepts, which are essential in embedded system design.

CODE:

1. One-By-One Pattern
#include <xc.h>
#include <pic.h>

void main(){
int i, j, k;
TRISB = 0;
PORTB = 0x00;
j = 00000001;
while (1){
for (i = 0; i < 8; i++){
PORTB = j << i;
for (k = 0; k < 10000; k++);
}
}
}
2. Sandglass Pattern
#include <xc.h>
#include <pic.h>

void main(void) {
int i, j, k , l;
TRISB = 0;
while (1){
j = 0b00000000;
for (i = 0; i < 9; i++){
PORTB = j;
for (k = 0; k < 10000; k++);
j = (j << 1) | 0x01;
}
}
return;
}

SIMULATION OUTPUT:
1. One-By-One Pattern
2. Sandglass Pattern
RESULT: Using PIC16F84A Microcontroller and MPLAB Software, we have
successfully simulated both one-by-one and sandglass pattern blinking of LED.
EXPERIMENT - 5

AIM: To display numbers 0-9 on seven-segment display in both common anode


and common cathode methods.

TOOLS USED: MPLAB x IDE v6.15 and Proteus 8 Professional v8.7

THEORY: The 7-segment display, also written as “seven-segment display”,


consists of seven LEDs (hence its name) arranged in a rectangular fashion as
shown. Each of the seven LEDs is called a segment because when illuminated the
segment forms part of a numerical digit (both Decimal and Hex) to be displayed.
An additional 8th LED is sometimes used within the same package thus allowing
the indication of a decimal point, (DP) when two or more 7-segment displays are
connected together to display numbers greater than ten.

The 7-segment display comes in two configurations which are common cathode & common
anode configuration.
1. The Common Cathode (CC) – In the common cathode display, all the cathode
connections of the LED segments are joined together to logic “0” or ground. The
individual segments are illuminated by application of a “HIGH”, or logic “1” signal via
a current limiting resistor to forward bias the individual Anode terminals (a-g).
2. The Common Anode (CA) – In the common anode display, all the anode connections
of the LED segments are joined together to logic “1”. The individual segments are
illuminated by applying a ground, logic “0” or “LOW” signal via a suitable current
limiting resistor to the Cathode of the particular segment (a-g).

CODE:
#include <xc.h>
void main(void) {
int i;
TRISB = 0; // Set PORTB as output
while (1) {
PORTB = 0x3F; // Display 0
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x06; // Display 1
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x5B; // Display 2
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x4F; // Display 3
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x66; // Display 4
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x6D; // Display 5
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x7D; // Display 6
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x07; // Display 7
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x7F; // Display 8
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x6F; // Display 9
for (i = 0; i < 10000; i++); // Delay
}
return;
}
SIMULATION OUTPUT:
CODE:
#include <xc.h>
void main(void) {
int i;
TRISB = 0; // Set PORTB as output
while (1) {
PORTB = 0x3F; // Display 0
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x06; // Display 1
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x5B; // Display 2
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x4F; // Display 3
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x66; // Display 4
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x6D; // Display 5
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x7D; // Display 6
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x07; // Display 7
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x7F; // Display 8
for (i = 0; i < 10000; i++); // Delay
PORTB = 0x6F; // Display 9
for (i = 0; i < 10000; i++); // Delay
}
return;
}
SIMULATION OUTPUT:

RESULT: The numbers from 0 to 9 on both Common Cathode and Common


Anode 7-segment Digital LED Display are simulated successfully.

You might also like