Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

EE Design > In Technical
| Home | Contact |

Title: Pulse-Width-Modulation using PIC Microcontrollers
Author: Vincent Wong
Date: 29th March 2005


PWM is a method by varying the duty-cycle of a square waveform while maintaining it's period. By varying the dutycycle, we can see that the on-time(mark) and the off time(space) also varies proportionaly. So, the average output voltage varies as the dutycycle of the waveform varies. This method is usefull to vary the voltage applied to a load e.g. an LED. Let us take a look at the waveforms below.



PWM waveform at 50% duty cycle (On-time=Off-time)
PWM waveform at 50% duty cycle (On-time=Off-time)


PWM waveform at < 50% duty cycle (On-time>Off-time)
PWM waveform at < 50% duty cycle (On-time>Off-time)


PWM waveform at > 50% duty cycle (On-time < Off-time)
PWM waveform at > 50% duty cycle (On-time<Off-time)


The period is fixed to about 1ms or 1KHz. Observe the noise generated across the waveform. An LED connected to the PWM output pin gives half brightness for 50% dutycycle output followed by full brightness and least brightness as shown in the figures above.

A timer is used to vary the dutycycle of the waveform. It is fixed to 1KHz. The timer value is reloaded in the main program. When the timer times out, it will clear the output pin to logic 0 and returns to main program.

In the main program, the timer is turned off initially before reloding the timer register with a new value. Then the ouput pin is set to logic 1 before turning it on and enable timer interrupt. A delay if 1ms is given before the program loops back to the start of main program. This is to maintain a fixed period of 1ms.


| Home | Top Page | Contact |


Copyright Notice: This article, including all text, documents and schematic diagrams, are the intellectual property of Vincent Wong, and is Copyright (c) 2005. Reproduction or re-publication by any means whatsoever, whether it is electrical & electronic, mechanical or electro-mechanical, is strictly prohibited under International Copyright laws. The author (Vincent Wong) grants the reader the right to use this information for personal use only. Commercial use is prohibited without express written authorisation from Vincent Wong.

Copyright of Vincent Wong. All Rights Reserved.