1. Introduction


What is PWM:
PWM stands for Pulse Width Modulation. The LPC17xx has one PWM channel, this channel consist of six PWM ports. The example program and library can be downloaded from our repository.
 
Features:
Dimming
Motor control
 
How it works:
PWM changes the average voltage and current by fast on off switching. By changing the on time, the output voltage can be 0 to 100%.
For more information see the Wikipedia page for PWM.

   
 
2. Hardware


For an LED:
For a Motor or Power LED:
3. Software
_______________________________________________________________________________________________________________________
 
There are two software parameters that need a little explanation: cycle and offset.
Cycle is the length of a PWM duty cycle and offset is the on time of a duty cycle.
 
 
For example: when the cycle time is 1000 and the offset:

  • 0, the output voltage = 0%
  • 255, the output voltage = 25.5%
  • 1000, the output voltage = 100%


3.1 Includes
Every special function needs a library. This is the command to import the PWM library:

#include "pwm.h"

 
3.2 Settings

 Two things are required to get PWM working.
  
INITIALIZING PORTS
On startup the ports of the Simplecortex are configured as normal IO pins. Each port must be declared as PWM port.
Command:    PWM_Init(PWMchannel, PWMPort, cycle);
 
PWM START
After initializing the PWM ports, the PWM function must be started.
Command: PWM_Start (PWMchannel);

3.3 Main
There is only one command to control the PWM ports. This changes the offset (on time) of a PWM cycle.
Command: PWM_SET(PWMchannel, PWMPort, offset);



Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics