Monthly Archives: August 2012

So what is Pulse width modulation…

A novice finds difficult to understand the concept of Pulse width modulation.

What is PWM?

It is a technique used by micro controllers to give out a certain value of DC output(analogue ) different from 0 or +5, consists of a series of pulses at a certain frequency,where the duration of the pulses are varied for the required output level.

Why PWM ?

Simply saying,most  micro controllers have an ADC,but there are no DACs inside them.So what is the method to produce an analog output? well that’s where PWM enters the scene.The world tends to be analogue,talking precisely LED’s needs to be dimmed or brightened,Motors needs a speed control,the buzzers requires a pitch…so how we solve this need is by PWM,The duration of pulses will do all the above.

How PWM works ?

The analogue world has properties like  inertia,capacitance,inductance,friction and momentum,from the PWM point of view they all have a nature of integration.So a series of pulses of a particular duration corresponds to a particular level of voltage,lets call it an average level.Recalling the word Duty cycle,ie the percentage of time a pulse goes high,when the duty cycle increases,average level also increases and vise versa.

Just in case,if your device flickers or the motor hums…

Some systems have low response delay,so some times there is a need for extra electronics to convert the PWM to a voltage level,like in communication systems here also there is an LPF filter.

in practice,there is a strategy in designing the filter,first step is the selection of the center frequency of operation of the PWM output,that is the rate of change in the output.The relation between the frequency and the values of resistance and the capacitance is,

F=1/ 2 pi(R C)   

where F,R and C are the values of design frequency,resistance and capacitance respectively in SI. 

In practice we look for the the constant value got for R C from the relation and will select a predefined value of capacitance to calculate the needed resistance,most of the values in resistance can be fabricated using resistance network or a closest available value can be selected.

The Ripple,or the slightest variations in the output of the filter due to the changes in the vestige of PWM can be reduced but never can be removed practically .
The ripple can be reduced by selecting the lowest value for Xc,that is the capacitive reactance we know the Xc is given by

Xc=1/2pi (F C)

In other words it means the selection of a higher value for the capacitance and thus lesser value for the resistance.
The maximum value of the ripple can be found by,

r = Vmax (Xc / R)

where r is the ripple and Vmax is the maximum voltage of PWM signal.

Arduino,LED and PWM

Lets see how The PWM works,the things we need are an arduino board or clone,an LED , 33 ohm resistor and a 10 uF capacitor.Setup the Circuit as given below.Resistance and capacitance can be altered too,since Arduino PWM frequency by default is 490,the value for RC will be 3.25 x 10-4 . Here we select C=10 uF,which will give R=32.5,we use 33 ohm Std .25 W resister.

Now upload the following arduino Sketch,we can see the LED increases its brightness when the value of the a printed on screen increases.

void setup()
void loop()
int a;

LPF and Voltage drop.

During some projects, its been noticed that some but considerable energy is lost in LPFs .So Before setting up an LPF always consider about the drops across the filter.The voltage drop is given by,

Vout = Vin Xc/( Xc+R)

In cases of high voltage drops,pre-amplification is the solution.