PWM_LPCXpresso

September 20, 2017 | Author: manojram18 | Category: Light Emitting Diode, Electronics, Electronic Engineering, Technology, Computing
Share Embed Donate


Short Description

Download PWM_LPCXpresso...

Description

2012 Generating PWM on LPCXpresso - LPC1769

Author: Manoj

PWM Pulse Width Modulation, or PWM, is a well known technique used in power controlling delivering the preferred amount of power to the load. It outputs the analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This onoff pattern can simulate voltages in between full on (3.3 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. The longer the ON period compared to the OFF period, the higher the power supplied to the load is. To get varying analog values, you change, or modulate, that pulse width. If you repeat this onoff pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 3.3v controlling the brightness of the LED. RGB LED RGB led is nothing but three primary color LEDs namely Red, Green, Blue are cascaded in a single package. This LED's are widely used to obtain the desired colors by the additive mixing of these colors.

Figure: RGB LED

Figure: RGB LED pin out

The RGB LEDs are available either in common anode or common cathode mode If these three LEDs share the same positive (anode) terminal, which means that this RGB LED has a "common anode" connection. To control each color, simply connect its cathode pin to ground (through a resistor as a current limiter), and it will light up.

1

Demo: Controlling the Brightness of the RGB LED with PWM outputs from the controller For this demo, we are connecting a tri-color RGB LED to the microcontroller with PWM ("virtual analog") outputs to control the brightness of each color, the PWM values are continuously varied using simple looping statements within the coding hence you can see the different colors at the output.

Figure: Schematic

Code: /* ============================================================================ Name : main.c Author : Vinayak R Version : 1.0 Copyright : Copyright (C) Description : main definition ============================================================================ */ #ifdef __USE_CMSIS #include "LPC17xx.h" #endif #include #include // Variable to store CRP value in. Will be placed automatically // by the linker when "Enable Code Read Protect" selected. // See crp.h header for more information __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; // TODO: insert other include files here // TODO: insert other definitions and declarations here // Control whether debug printf are displayed via semihosting to the // debugger console window #define SEMIHOSTING_CONSOLE TRUE

2

#ifdef SEMIHOSTING_CONSOLE #include #define DBG printf #else #define DBG(x ...) #endif #define PCPWM1 (1
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF