0% found this document useful (0 votes)
26 views6 pages

EXP10 - Miniproject Final

Uploaded by

ANAND TIWARI
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)
26 views6 pages

EXP10 - Miniproject Final

Uploaded by

ANAND TIWARI
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/ 6

‭K. J.

Somaiya College of Engineering, Mumbai-77‬


(A Constituent School of Somaiya Vidyavihar University)
‭Department of Electronics and Telecommunication‬
‭Engineering‬

A2
16010322073,16010322079

‭ ITLE: Mini project‬


T
‭AIM:‬‭The aim of this project is to design and implement‬‭a Pulse Width Modulation (PWM) using‬
‭the LPC2148 microcontroller.‬
‭OUTCOME:‬‭Students will be able to apply programming‬‭skills to develop application using‬
‭MSP430/LPC 2148‬

‭Software requirement: Keil µVision‬

‭Hardware tool: LPC2148 Launchpad‬

‭ bstract:‬‭This project focuses on the implementation‬‭of Pulse Width Modulation (PWM)‬


A
‭using the LPC2148 microcontroller. The LPC2148 has a PWM unit with 6 independent PWM‬
‭outputs (PWM1 to PWM6). It allows you to configure the frequency (period) and duty cycle‬
‭for each PWM output. The main objective is to demonstrate how PWM can control the speed‬
‭of DC motors and adjust the brightness of LEDs by varying the duty cycle. The code‬
‭initializes the PWM settings, enabling two PWM channels, and sets specific duty cycles for‬
‭each channel in an infinite loop.‬
‭By generating PWM signals, the system achieves precise control over the output devices,‬
‭making it suitable for applications in robotics, lighting, and other electronic projects.‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬
‭K. J. Somaiya College of Engineering, Mumbai-77‬
‭(A Constituent College of Somaiya Vidyavihar University)‬
‭Department of Electronics and Telecommunication‬
‭Engineering‬

‭Block diagram:‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬
‭K. J. Somaiya College of Engineering, Mumbai-77‬
‭(A Constituent College of Somaiya Vidyavihar University)‬
‭Department of Electronics and Telecommunication‬
‭Engineering‬

‭Algorithm:‬

‭1.‬ ‭PWM Initialization:‬

‭ tep 1:‬‭Configure the pin functionality by setting‬‭the appropriate bits in PINSEL0 register:‬
S
‭PINSEL0 = 0x8002: This sets the pins for PWM output (PWM1 and PWM2).‬
‭Step 2:‬‭Configure PWM control settings in the PWMPCR‬‭register:‬
‭PWMPCR = 0x600: This enables PWM1 and PWM2 outputs.‬
‭Step 3:‬‭Set the PWM cycle duration by configuring‬‭the Match Register 0 (PWMMR0):‬
‭PWMMR0 = 150000: This defines the period of the PWM cycle (frequency).‬
‭Step 4:‬‭Enable and reset the PWM counter using PWMTCR:‬
‭PWMTCR = 0x09: This enables the PWM Timer Counter and also resets it.‬
‭Step 5:‬‭Configure the Match Control Register (PWMMCR):‬
‭PWMMCR = 0x02: This resets the PWM Timer on reaching a match with PWMMR0.‬
‭2.‬ ‭Main Loop:‬
‭Step 6:‬‭Set the duty cycle for PWM1 and PWM2:‬
‭PWMMR1 = 75000: This sets the duty cycle for PWM1 to 50% (half of PWMMR0).‬
‭PWMMR2 = 90000: This sets the duty cycle for PWM2 to 60% (slightly more than half of‬
‭PWMMR0).‬
‭Step 7:‬‭Latch the new values into the PWM match registers‬‭by setting the Load Enable‬
‭Register (PWMLER):‬
‭PWMLER = 0x6: This loads the updated values of PWMMR1 and PWMMR2.‬
‭Step 8:‬‭Repeat the above process in an infinite loop‬‭(while(1)) to keep generating PWM‬
‭signals continuously.‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬
‭K. J. Somaiya College of Engineering, Mumbai-77‬
‭(A Constituent College of Somaiya Vidyavihar University)‬
‭Department of Electronics and Telecommunication‬
‭Engineering‬

‭Source code:‬

‭#include<LPC214X.h>‬

‭ oid pwm_init(void)‬
v
‭{‬
‭PINSEL0 = 0x8002;‬
‭PWMPCR = 0x600;‬
‭PWMMR0 = 150000;‬
‭PWMTCR = 0x09;‬
‭PWMMCR = 0x02;‬
‭}‬

i‭nt main (void)‬


‭{‬
‭pwm_init();‬
‭while(1)‬
‭{‬
‭PWMMR1 = 75000;‬
‭PWMMR2 = 90000;‬
‭PWMLER = 0x6;‬
‭}‬
‭}‬

‭ FRs configured in the source code:‬


S
‭1.‬‭PINSEL0 (Pin Select Register 0) Address‬‭: 0xE002C000‬
‭Function‬‭: This register is used to select the alternative‬‭functions for I/O pins. By configuring‬
‭specific bits in this register, you can assign PWM functions to the desired pins.‬

2‭ .‬‭PWMPCR (PWM Control Register) Address‬‭: 0xE002C0A4‬


‭Function‬‭: This register controls the PWM channels.‬‭It enables specific PWM channels and‬
‭configures their operation modes.‬

3‭ .‬‭PWMMR0 (PWM Match Register 0) Address‬‭: 0xE002C0A8‬


‭Function‬‭: This register sets the PWM period, defining‬‭how long each PWM cycle lasts. The‬
‭frequency of the PWM signal is determined by this value in relation to the system clock‬
‭frequency.‬

4‭ .‬‭PWMTCR (PWM Timer Control Register) Address‬‭: 0xE002C0A0‬


‭Function‬‭: This register controls the operation of‬‭the PWM timer. It can enable or reset the‬
‭timer, allowing for PWM generation.‬

‭5‬‭. PWMMCR (PWM Match Control Register) Address‬‭: 0xE002C0AC‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬
‭K. J. Somaiya College of Engineering, Mumbai-77‬
‭(A Constituent College of Somaiya Vidyavihar University)‬
‭Department of Electronics and Telecommunication‬
‭Engineering‬

‭ unction‬‭: This register defines the behavior of the PWM timer when it matches the value in‬
F
‭one of the match registers. It can reset the timer or trigger an interrupt.‬

6‭ .‬‭PWMMR1 (PWM Match Register 1)‬‭Address‬‭: 0xE002C0B0‬


‭Function‬‭: This register sets the duty cycle for PWM Channel 1. The duty cycle determines‬
‭how long the PWM signal is high within each cycle.‬

‭7.‬‭PWMMR2 (PWM Match Register 2) Address‬‭: 0xE002C0B4‬

‭Function‬‭: This register sets the duty cycle for PWM Channel 2.‬

‭8.‬‭PWMLER (PWM Load Enable Register)‬‭Address‬‭: 0xE002C0B8‬


‭ unction‬‭: This register is used to load new values into the PWM match registers (PWMMR1‬
F
‭and PWMMR2). Writing to this register causes the new duty cycle values to take effect‬
‭immediately.‬
‭Procedure:‬

‭1.‬ C ‭ reate a new project on Keil μVision and select the legacy software device as‬
‭LPC2148.‬
‭2.‬ ‭Add the file and write the code.‬
‭3.‬ ‭Build and debug the code, run the code.‬
‭4.‬ ‭Connect a USB programmer and upload the compiled code.‬
‭5.‬ ‭Setup Logic Analyzer‬
‭6.‬ ‭Monitor the PWM signals through logic analyzer.‬

‭Applications:-‬

‭ WM (Pulse Width Modulation) in the LPC2148 is widely used for motor speed control,‬
P
‭LED dimming, and power management. It adjusts the power delivered to devices by varying‬
‭the duty cycle of the signal. Applications include controlling DC motors in robotics, dimming‬
‭LEDs, regulating voltage in power supplies, generating audio signals, and controlling servo‬
‭motors for precision tasks in automation and robotics.‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬
‭K. J. Somaiya College of Engineering, Mumbai-77‬
‭(A Constituent College of Somaiya Vidyavihar University)‬
‭Department of Electronics and Telecommunication‬
‭Engineering‬

‭Observation: (Copy the screen shot for each program)‬

‭ onclusion:‬ ‭In conclusion, this project successfully demonstrates the use of Pulse Width‬
C
‭Modulation (PWM) with the LPC2148 microcontroller to control DC motors and LEDs by‬
‭varying duty cycles.‬

‭Signature of faculty in-charge with date‬

‭Department of Electronics and Telecommunication Engineering‬


‭ age No‬
P ‭Advanced Microcontroller laboratory Sem V/July-November‬
‭2024‬

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy