Pulse Width Modulation



Introduction:


                Look in the image shown below.

                                                  


It consists of a DC power source, a switch and a resistor. When I close the switch, current flows through the resistance R and voltage drop is produced across the resistance.

                           Current (I) through the resistance =  Vin/R

                           Voltage drop across the resistance (Vo) = I x R = Vin/R x R =Vin

Voltage across the resistance will be equal to input voltage Vin. 

When I open this switch no current flows through the resistance and output voltage is zero. This process is repeated again and again. I can measure the voltage across the resistance which will be equal to input voltage when switch is closed and Zero when switch is open. If I replace the resistance with LED then LED will glow when switch is closed and it will be off when switch is open. As shown in image Vo will be high for t(on) and zero for t(off).

                                          t(on) = when switch is closed
                                          t(off) = when switch is open
                                          T = t(on) + t(off) = total time period
                           
 Now if I close and open the switch at very high frequency in the range of kHz then I can't measure high voltage or zero voltage separately. Always  there will be a voltage will be equal to average value of voltage for t(on) time and t(off) time and it will be equal to t(on)/T x Vin.

                                      Output voltage ( Vo) = t(on)/ T x Vin
                                                                Vo = D x Vin
                           where t(on)/ T is known as Duty cycle and represented by  letter D

If I Increase the t(on) time by keeping T constant then output voltage will increase and if I decrease the t(on) output voltage will decrease. 

Therefore I can change the magnitude of the output voltage by changing the duty cycle. If LED is connected instead of resistance then it will glow all the time but brightness of LED will be according to duty cycle of the pulse given to it. This technique is known as Pulse Width Modulation. This technique is used in a lot of applications in the world. 


Applications:


1.  PWM is used in controlling the servo motors. 
2.  In telecommunication, PWM is a form of signal modulation where the widths of the pulses correspond to specific data values encoded at one end and decoded at the other.
3.  PWM can be used to control the amount of power delivered to a load without incurring the losses that would result from linear power delivery by resistive means.
4.  PWM is used inSMPS(Switching Mode Power Supply) for voltage regulation.
5.  SPWM (Sine–triangle pulse width modulation) signals are used in micro-inverter design used in solar and wind power applications.
6. It is used to control the speed of DC motors.
7. It is also used to control the brightness of LED lights.





                          Microcontrollers are used for PWM. Watch the video below this post. In this video microcontroller 8051 changes the duty cycle of the pulse given to LED's from 0% to 100% and then from 100% to 0%. Brightness is low for low duty cycle and LED's glow with full brightness when duty cycle is 100. 




Visit this link to read more about it
               





Code for 8051:




I wrote a simple program for this which is given below.


#include<reg52.h>

void msdelay(unsigned int);
void main()
{
unsigned int a,b,j;
while(1)
{
b=0;
for(j=0;j<100;j++)
{
for(a=0;a<50;a++)
  {
P2=0x00;
msdelay(b);
P2=0xff;
msdelay(100-b);
}
b++;
}
for(j=0;j<100;j++)
{
for(a=0;a<50;a++)
  {
P2=0x00;
msdelay(b);
P2=0xff;
msdelay(100-b);
}
b--;
}
}
}
void msdelay(unsigned int x)
{
unsigned int i;
for(i=0;i<x;i++);
}



PWM with Arduino:


Arduino Uno has 6 PWM channels and it has a built in function for this purpose. 




Comments

Popular Posts