[go: up one dir, main page]

0% found this document useful (0 votes)
120 views7 pages

PSDL Theory

Uploaded by

MOVIES
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)
120 views7 pages

PSDL Theory

Uploaded by

MOVIES
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/ 7

PSDL Theory Write-Up

Experiment 1 (Group A):


Title:
Study of Embedded C Programming on PIC18F458: Addition of Two Numbers
Aim:
Introduce Embedded C programming on PIC18F458 and demonstrate a simple program for
adding two numbers.
Objective:
1. Understand the basics of Embedded C programming language.
2. Familiarize with the syntax and structure of Embedded C.
3. Implement a program for adding two numbers on PIC18F458.
Requirements:
1. MPLAB X IDE software (or any compatible IDE).
2. PIC18F458 simulator or emulator (e.g., MPLAB Simulator).
3. Knowledge of Embedded C programming language.
4. Basic understanding of PIC18F458 microcontroller architecture.
Theory:
Embedded C programming is a variant of the C programming language specifically designed
for embedded systems, where code is written to control microcontrollers or other embedded
devices. It provides a structured and efficient approach to develop software for such systems.
The PIC18F458 microcontroller is a popular choice for many embedded applications due to its
rich set of features and capabilities.
In the given experiment, the PIC18f458.h header file is included to access the specific registers
and functions of the PIC18F458 microcontroller. The TRISB register is configured to set
PORTB as an output. The program itself adds two numbers and stores the result in the 'sum'
variable, which is then displayed on the output port (PORTB) by assigning the 'sum' value to
it.
By following this experiment, learners gain practical experience in writing and executing
Embedded C programs on the PIC18F458 microcontroller, laying the foundation for further
exploration and development of complex embedded systems.
Procedure:
1. Launch the MPLAB X IDE and create a new project.
2. Set the project configuration to use the PIC18F458 microcontroller simulator.
3. Write a C program to add two numbers.
4. Include the PIC18f458.h header file for accessing PIC18F458 specific registers and
functions.
5. Configure the necessary TRIS registers for input/output direction (e.g., TRISB for
PORTB).
6. Build the project and load the program into the PIC18F458 simulator.
7. Set the input values for the numbers to be added.
8. Execute the program in the simulator and observe the output.
Code (Example: Addition of Two Numbers):
Conclusion:
This lab experiment demonstrated the implementation of Embedded C programming on the
PIC18F458 microcontroller, successfully adding two numbers and displaying the result using
stimulator

Created by Jarvis
Experiment 2 (Group A):
Title:
Embedded C Programming on PIC18F458: Addition of Array of Numbers
Aim:
Introduce Embedded C programming on PIC18F458 and demonstrate a program for adding
an array of numbers using a simulator.
Objective:
1. Understand the basics of Embedded C programming language.
2. Familiarize with the syntax and structure of Embedded C.
3. Implement a program for adding an array of numbers on PIC18F458 using a
simulator.
Theory:
In embedded systems, it is common to perform operations on arrays of data. An array is a
collection of elements of the same data type. By using loops and indexing, we can perform
calculations on array elements. In this lab, we will write an Embedded C program to add an
array of numbers on the PIC18F458 microcontroller.
Requirements:
1. MPLAB X IDE software (or any compatible IDE).
2. PIC18F458 simulator or emulator (e.g., MPLAB Simulator).
3. Knowledge of Embedded C programming language.
4. Basic understanding of PIC18F458 microcontroller architecture.
Procedure:
1. Launch the MPLAB X IDE and create a new project.
2. Set the project configuration to use the PIC18F458 microcontroller simulator.
3. Define an array to hold the numbers to be added.
4. Write a loop to iterate through the array elements and calculate the sum.
5. Include the necessary header files and configure the required TRIS registers.
6. Build the project and load the program into the PIC18F458 simulator.
7. Set the input values for the array elements.
8. Execute the program in the simulator and observe the output.
Code (Example: Addition of Array of Numbers):
Conclusion:
The lab experiment demonstrated the implementation of an Embedded C program on
PIC18F458 using a simulator to add an array of numbers, providing a fundamental
understanding of Embedded C programming for microcontroller-based systems

Created by Jarvis
Experiment 3 (Group A):
Title:
Memory Transfer using PIC18f458 Stimulator
Problem Statement:
Write an Embedded C program to transfer elements from one location to another for
following: i) Internal to internal memory transfer ii) Internal to external memory transfer
Aim:
The aim of this experiment is to understand the concept of memory transfer and to write an Embedded
C program to transfer elements from one location to another location in PIC18f458 simulator. We will
perform two types of memory transfers: internal to internal memory transfer and internal to external
memory transfer.
Objective:
1. To understand the concept of memory transfer.
2. To write an Embedded C program for internal to internal memory transfer.
3. To write an Embedded C program for internal to external memory transfer.
Requirements:
1. PIC18f458 Simulator
2. MPLAB IDE
3. Personal computer (PC)
Procedure:
Step 1: Open the MPLAB X IDE software on the computer.
Step 2: Create a new project in MPLAB X IDE software.
Step 3: In the project, create a new source file by right-clicking on the "Source Files" folder and
selecting "New" > "C Source File".
Step 4: Write a code.
Step 5: Save the code with the extension ".c".

Step 6: Build the project by clicking on the hammer icon on the toolbar or by selecting "Build
Project" from the "Project" menu.
Step 7: Once the project is built successfully, run the program by clicking on the "Debug Main
Project" button on the toolbar or by selecting "Debug Main Project" from the "Debug" menu.
Step 8: Observe the output on the MPLAB X IDE console.
Observation:
1. The program will initialize an array named "data" of size 10 with values from 0 to 9.
2. The program will then call two functions to transfer the data from "data" array to
"internal_data" array and "external_mem" array respectively.
3. After the transfer, the program will print the data stored in the "internal_data" array and
"external_mem" array on the console.
Conclusion:
In this experiment, we have successfully written an Embedded C program to transfer
elements from one location to another. We have performed two types of memory transfers:
internal to internal memory transfer and internal to external memory transfer using the
PIC18f458 simulator

Created by Jarvis
Experiment 4 (Group B):
Title:
LED blinking using PIC18f458 Stimulator
Problem Statement:
Write an Embedded C program to interface PIC 18FXXX with LED & blinking it using
specified delay.
Aim:
The aim of this experiment is to understand the concept of LED blinking and to write an
Embedded C program to interface PIC 18FXXX with LED & blinking it using specified delay.
Objective: The objective of this lab is to interface a PIC18FXXX microcontroller with an LED
and blink it using a specified delay. You will learn how to configure the microcontroller's I/O
ports, control the LED, and implement a delay using software.
Components:
1. PIC18FXXX microcontroller (PIC18F458)
2. LED
3. Resistor (appropriate value for the LED)
4. Breadboard
5. Jumper wires
Software Tools:
1. MPLAB X IDE
2. MPLAB XC8 Compiler
3. MPLAB Simulator
Procedure:
1. Circuit Setup: a. Connect the PIC18F458 microcontroller to the breadboard. b. Connect
VDD and VSS pins of the microcontroller to the power supply (+5V and GND,
respectively). c. Connect an appropriate resistor to the anode (longer lead) of the LED.
d. Connect the cathode (shorter lead) of the LED to one of the microcontroller's I/O pins
(e.g., RB0). e. Connect the other end of the resistor to the GND (common ground) of the
circuit. f. Ensure the connections are secure and there are no short circuits.
2. MPLAB X IDE Setup: a. Launch MPLAB X IDE and create a new project. b. Select the
PIC18F458 microcontroller as the target device. c. Set up the project and workspace
directories. d. Configure the oscillator settings (e.g., select Internal Oscillator, set the
frequency). e. Create a new source file for writing the C program.
3. Writing the C Program: a. Start by including the necessary header files:
#include <PIC18F458.h>
b. Implement the main function (Here Program Form void)
1. Building the Project: a. Build the project using the MPLAB X IDE. b. Check for any
compilation errors and fix them, if any.
2. Simulation: a. Configure the simulator settings in MPLAB X IDE. b. Load the program
onto the simulator. c. Start the simulation and observe the LED blinking at the specified
delay.
Conclusion: In this lab, you successfully interfaced a PIC18FXXX microcontroller with an
LED and implemented a blinking effect using a specified delay. You learned how to configure
I/O ports, control the LED using the microcontroller, and use the __delay_ms() function to
introduce a delay in the program. This fundamental knowledge will be useful in designing more
complex embedded systems and applications

Created by Jarvis
Experiment 5 (Group B):
Title:
LCD Interfacing using PIC18f458 Stimulator
Problem Statement:
Write an Embedded C program for LCD interfacing with PIC 18FXXX.
Aim:The aim of this experiment is to understand the concept of LCD interfacing and to write an Embedded
C program to interface PIC 18FXXX with LCD interfacing with PIC 18F458 .
Introduction: In this lab, you will learn how to interface an LCD (Liquid Crystal Display) with a PIC18F458
microcontroller using the MPLAB X IDE simulator. The LCD will display messages generated by the
microcontroller.
Basic concepts:1. Microcontrollers and their programming.2. Embedded C programming.3. Basic
knowledge of LCDs and their working principles.4. Familiarity with MPLAB X IDE and its simulation features.
Equipment and Software Required:
1. MPLAB X IDE with the XC8 Compiler.2. PIC18F458 microcontroller simulator in MPLAB X IDE.
3. LCD module (16x2 or 20x4).4. USB cable for connecting the PIC18F458 simulator.
Procedure:
Step 1: Setting up the MPLAB X IDE Simulator
1. Launch the MPLAB X IDE on your computer.
2. Create a new project for the PIC18F458 microcontroller simulator.
3. Configure the project settings, including the oscillator frequency and other necessary parameters.
4. Set up the simulator for the PIC18F458 microcontroller.
5. Connect the USB cable to the simulator for power and communication.
Step 2: Connecting the LCD to the PIC18F458 Simulator
1. Connect the VSS (Ground) pin of the LCD to the simulator's ground.
2. Connect the VDD (Power) pin of the LCD to the simulator's power supply.
3. Connect the RS (Register Select) pin of the LCD to a GPIO (General Purpose
Input/Output) pin of the PIC18F458 simulator.
4. Connect the RW (Read/Write) pin of the LCD to the ground.
5. Connect the E (Enable) pin of the LCD to a GPIO pin of the PIC18F458 simulator.
6. Connect the data pins (D4-D7) of the LCD to four GPIO pins of the PIC18F458 simulator.
Step 3: Writing the Embedded C Program
1. Open a new source code file in the MPLAB X IDE.
2. Write the necessary header files and define the configuration bits for the PIC18F458 microcontroller.
3. Define the required LCD control and data pin connections using macros.
4. Declare the necessary variables and LCD function prototypes.
5. Implement the LCD initialization function, which configures the LCD module.
6. Implement the LCD command and data writing functions.
7. Write the main function, where you will initialize the LCD and display messages on the screen.
8. Save the source code file with an appropriate name and extension.
Step 4: Compiling and Simulating the Program
1. Build the project in MPLAB X IDE to compile the source code.
2. Check for any compilation errors or warnings and fix them if necessary.
3. Once the code is successfully compiled, run the simulation.
4. Observe the simulator window and verify that the LCD is displaying the desired messages.
5. Debug and troubleshoot any issues if the LCD is not functioning correctly.
6. Repeat steps 3-5 as necessary until the LCD is working as expected.
Conclusion: In this lab, you have successfully interfaced an LCD with the PIC18F458
microcontroller using the MPLAB X IDE simulator. You have learned how to initialize the
LCD module and write data and commands to display messages on the screen. This exercise
provides a solid foundation for further exploration of embedded systems and hardware
interfacing

Created by Jarvis
Experiment 6 (Group C):
Title:
Generate PWM signal using PIC18f458 Simulator
Problem Statement:
Write an Embedded C program for Generating PWM signal for DC motor.
Aim:
The aim of this experiment is to understand the concept of CCP and to write an Embedded C
program for Generating PWM signal for DC motor.
Objective: The objective of this lab is to write an embedded C program to generate a Pulse
Width Modulation (PWM) signal for controlling a servo motor or a DC motor using the
PIC18F458 microcontroller on a simulator. The program will allow the user to vary the duty
cycle of the PWM signal to control the motor speed or position.
Components Required:
1. PIC18F458 microcontroller
2. Simulator software (e.g., MPLAB X IDE with Proteus simulator)
3. Servo motor or DC motor (simulation component)
Prerequisites: Before starting this lab, you should have a basic understanding of embedded C
programming, PWM, and the PIC18F458 microcontroller.
Procedure:
Step 1: Setting up the Simulator
1. Launch the simulator software (e.g., MPLAB X IDE with Proteus simulator).
2. Create a new project and select the PIC18F458 microcontroller as the target device.
3. Add the necessary simulation components, including the PIC18F458 microcontroller
and the servo motor or DC motor.
Step 2: Configuring the PWM Module
1. Open a new source file in the IDE for writing the C program.
2. Include the necessary header files for the PIC18F458 microcontroller and PWM module.
3. Configure the necessary device configuration bits, such as oscillator settings, in the CONFIG
section.
4. Configure the PWM module settings.
Step 4: Building and Simulating the Program
1. Build the project to compile the source code.
2. Run the simulation to observe the PWM signal and its effect on the motor.
Conclusion: In this lab, you have successfully written an embedded C program to generate a
PWM signal for controlling a servo motor or a DC motor using the PIC18F458 microcontroller
on a simulator. By varying the duty cycle of the PWM signal, you can control the motor speed
or position

Created by Jarvis
Experiment 7 (Group C):
Title:
Generate serial communication using PIC18f458 Simulator
Problem Statement:
Write an Embedded C program for PC to PC serial communication using UART
Aim:
The aim of this experiment is to understand the concept of serial communication and to write
an Embedded C program for PC to PC serial communication using UART.
Objective: To understand and implement PWM (Pulse Width Modulation) control using the
PIC18F458 microcontroller on a simulator.
Components:
PIC18F458 microcontroller
Simulator software (e.g., MPLAB X IDE with XC8 compiler)
Virtual oscilloscope (for visualizing the PWM signal)
Procedure:
Step 1: Setting up the Project
1. Open the MPLAB X IDE (or the simulator software of your choice).
2. Create a new project and select the PIC18F458 microcontroller as the target device.
3. Set up the project settings, including the oscillator frequency, configuration bits, and other
relevant options.
4. Create a new source file and save it as "main.c".
Step 2: Writing the Code
5. Begin by including the necessary header file: #include <pic18f458.h>
6. Define the main function: void main(void){
7. Set the TRISCbits.RC2 pin as an output to enable PWM mode: TRISCbits.RC2 = 0; // Set
RC2 as output pin
8. Configure CCP1CON for PWM operation: CCP1CONbits.CCP1M = 0b1100; // Set CCP1
module for PWM mode
9. Disable TMR2ON (Timer2): TMR2ON = 0; // Turn off Timer2
10. Enter an infinite loop: while(1){
11. Set the PR2 (Period Register) value for the desired PWM frequency: PR2 = 74; // Set
PR2 for a specific PWM frequency
12. Set the CCPR1L (PWM Duty Cycle Register) value for the desired duty cycle: CCPR1L
= 18; // Set CCPR1L for a specific duty cycle
13. Enable TMR2ON (Timer2) to start generating the PWM signal: TMR2ON = 1; // Turn
on Timer2 to start PWM generation
14. Close the infinite loop and the main function: }
Step 3: Building and Running the Simulation
1. Build the project to compile the code and check for any errors or warnings.
2. Once the build is successful, run the simulation.
3. Observe the virtual oscilloscope or any other means to visualize the generated PWM
signal on pin RC2.
Conclusion:
In this lab exercise, you have successfully implemented PWM control using the PIC18F458
microcontroller on a simulator. By adjusting the values of PR2 and CCPR1L, you can vary the
PWM frequency and duty cycle, respectively, to control various devices or systems that require
precise pulse-width modulation

Created by Jarvis

You might also like