Pulse Width Modulation Basics
Pulse Width Modulation or PWM is a way to encode data such that it corresponds to the width of the pulse given a fixed frequency. Its also a way to control motors , power circuits , etc.. using the ‘width’ of the pulse. PWM has numerous uses like Motion Control , Dimming , Encoding Analog Signal into its Digital form , in Power Regulation , etc.
Period(T) & PWM Frequency :
Period(T) can be thought of as the Time required for a new pulse to arrive – its basically the sum of ON time(T-ON) and OFF time(T-OFF) of a PWM cycle. PWM Frequency is the rate at which a PWM pulse is repeated. It can be also called as the “Repetition Rate”. Frequency is the inverse of the Period. PWM Frequency is fixed Depending on the application. As a simple example lets consider a RC Servo Motor. This type of Servos expect a new Pulse every 20ms which is the Period. Hence in this case the PWM frequency is 1/20ms = 50hz.
T-ON , T-OFF & DutyCycle :
Each Period of PWM signal is divided into T-ON and T-OFF. Where T-ON is the Time required or taken for the pulse to remain ON i.e in a HIGH state and similarly T-OFF is the Time required or taken for the pulse to remain OFF i.e in a LOW state. Now , the DUTY-CYCLE is the percentage of period required for T-ON. For example if T-ON=T-OFF then the period is divided into 2 equal parts i.e 50(TON):50(TOFF). Hence the DUTY-CYCLE will be 50%. If T-OFF is 3 Times T-ON then period is divided into 2 unequal Parts i.e 25(TON):75(TOFF) .. hence DUTY-CYCLE in this case will be 25%. DutyCycle can be expressed as a simple formula given below:
Duty Cycle = | T-ON |
T-ON + T-OFF |
DutyCycle in Percentage is :
Duty Cycle % = | T-ON | x 100 |
T-ON + T-OFF |
Example :
In PWM diagram shown above we have ,
Hence , Frequency = 100hz
T-ON = 3.5ms
T-OFF = 6.5ms
Hence , DutyCyle = 35%
PWM Edges
A PWM signal contains 2 types of Edges which are called Leading Edge and Trailing Edge. The Diagram shown below explains this:
Types of PWM
PWM Signal can be Classified in Different ways. However , I would like to classify PWM as :
1) Single Edge PWM
2) Double Edge PWM
Single Edge PWM
Single Edge PWM the Pulse can either at the Beginning or the End of the Period and hence can be further Classified into Leading Edge(Right Aligned) PWM and Trailing Edge(Left Aligned) PWM.
In Trailing Edge PWM the Leading Edge is fixed at the Beginning of a Period and the Trailing Edge is Modulated i.e. Varied. Diagram for Trailing Edge(Left Aligned) PWM:
In Leading Edge PWM the Trailing Edge is fixed at the End of a Period and the Leading Edge is Modulated i.e. Varied. Diagram for Leading Edge(Right Aligned) PWM:
Double Edge PWM
In Double Edge PWM the Pulse can be Positioned anywhere within the Period. Its called “Double Edge” because both the Edges are Modulated or Varied. In applications like Multi-Phase Motor control Double Edge PWM is used where the Pulse is Center Aligned to reduce Harmonics. Diagram for Double Edge Center Aligned PWM is as shown below:
PWM Voltage
The Average Voltage of a PWM Output depends on its Duty Cycle. Lower the Duty Cycle lower will be the Voltage and Vice-Verse. The maximum Voltage will be equal to the Value of the High State and the minimum Voltage will be equal to Low state of the Pulse. For e.g. if High state is 5V and Low state is 0v the maximum Voltage will be 5V at 100% duty cycle and min Voltage will be 0V at 0% duty cycle.
In case the Low State Represents a Negative Voltage then the above equation can be generalized as follows :
Where , V_{H} = Voltage for High State & V_{L} = Voltage for Low State
This can be converted into an Analog Voltage by Using a Simple R-C filter.