Introduction to PWM (Pulse Width Modulation)

Hey Guys! Welcome you onboard. Today, I'll discuss an important topic titled "Introduction to PWM". I will try to cover everything related to PWM i.e. PWM Definition, PWM generation, why we need PWM signals? how it is used in a variety of applications ranging from motors, heating systems, hydraulics, control valves, pumps etc. One important thing to mention here is "PWM can be applied on both AC and DC electrical signals". So, let's get started:

What is PWM (Pulse Width Modulation)?

As we all know, there are two main types of electrical signals i.e. AC and DC. Both of these signals are used as a power source for different types of electrical appliances. Now if we have a look at these electrical appliances, they operate at different voltage levels and may also need variable voltage supply(as in fan dimmers). So, there was a need to generate variable voltage supplies with minimal power losses, as other methods(i.e. step-down transformers etc.) dissipates energy and thus wasn't that effective. Different techniques were designed for achieving variable voltage levels and one of them is called PWM(abbreviation of Pulse Width Modulation), which is considered to be the most effective one.
  • In PWM, we simply turn on and off our power supply at equal intervals and thus reduces the average power of the signal.
  • As shown in the below figure(A), I have taken a 5V DC signal and divided it into three equal intervals, each interval representing one cycle.
  • In figure(B), for each cycle, the power is ON for the first half, while it's OFF for the second half.
  • So, we can say that we are simply switching our DC supply at equal intervals(in this case interval is 50%).
  • If we perform this switching using a manual switch(which must be really slow), we will get 5V when the switch is ON and 0V when the switch is OFF, the circuit is shown in figure(D).
  • But, if we replace this manual switch with an automatic switch(i.e. Mosfets, IGBTs, FETs etc.), we can achieve fast switching in the range of nanoseconds.
  • This fast switching of the electrical signal will reduce its average power but the output will remain continuous and for the 50% ON/OFF cycle, the output of 5V signal will be around 2.5V, as shown in figure(C).
  • In figure(C), the output signal is shown in blue color, which is of 2.5V but the actual PWM signal is switching ON/OFF and shown in orange color.
  • The percentage for which signal remains in ON state in one cycle is called the duty cycle(we will discuss it in detail later).
  • In the above example, the duty cycle of the PWM wave is 50%, that's why its output is exactly half, as we are turning it OFF for the remaining 50%.
Now let's have a look at a proper definition of pulse width modulation:

PWM Definition

  • PWM(short for Pulse Width Modulation) is a modulation technique, used to step down the voltage level(average power) of electrical signals(both AC & DC) by varying their width(ON duration) using fast-switching.
  • If a voltage source is

PWM in DC Signals

Suppose, we have a 12V DC power supply but we want to control a DC load of 5V, let's say RGB LED, as shown in the below figure. Circuit A has a manual switch in it, if we quickly turn ON and OFF this switch at equal intervals, we will get either 12V or 0V at the output and the LED will also turn ON or OFF and there's a chance it may burn out. But if we replace this manual switch with an automatic switch i.e. transistor(as in Circuit B), then we can achieve accurate and fast switching. This fast switching will be doing the same thing i.e. turning ON and OFF the electrical signal but it will be doing this switching in nanoseconds, which will reduce the average power of the electrical signal but the output will remain continuous. So, if the transistor is ON and OFF for an equal amount of time, then the output signal will reduce from 12V to 6V and the LED will glow. But if you want to be precise and want to generate an exact 5V output, then we have to further decrease the ON period of the transistor, which will reduce the output in turn. The two main factors of PWM are:
  1. Switching Frequency.
  2. Duty Cycle.

Switching Frequency

The frequency(or rate) at which the transistor is operating is termed as switching frequency. Normally microcontrollers are used to generate the PWM pulse but in small circuits, 555 Timer is also used. A normal 8-bit microcontroller can generate a PWM pulse ranging from 4MHz to 80MHz, let's say if we are generating a PWM pulse of 20MHz:

t = 1/f

t = 1/20MHz

t = 0.066us

So, the time period of a single PWM pulse is 0.066us, that's how fast it's switching.

Duty Cycle

In one cycle of PWM pulse, the ON period of pulse is termed as duty cycle. So, if the transistor is switching at 50%. If you have ever worked on a DC Motor, you must have noticed that its speed varies as we change its input voltage. If I am working on a 12V DC motor and it's rotating at 500RPM(let's say), so if I reduce its voltage from 12V to 6V, its RPM will reduce from 500RPM to 250RPM(ideally). In the PWM technique, electrical signals are passed through a fast switching device(i.e. FETs, MOSFETs, IGBTs etc.), these transistors are programmed to chop off the electrical signal at equal intervals. PWM is a process mainly used for getting an analog signal using a digital source.
  • It is nothing but a controller that controls and handles the input current applied to the load.
The PWM varies between high and low values where the high value indicates, 5V is applied and the low value indicating the ground signal is applied to the load. Note: Not necessarily, the upper-value corresponds to 5V, it can be any value based on the voltage at which load operates. I have mentioned 5V just to give you an idea of how the PWM switches between high and low values.   The PWM works like a controlled switch that mainly handles the current being delivered to the load. When the switch is off, it will indicate no current is available for the load and when a switch is On, it means the power is delivering to the load with no voltage drop. PWM controllers are mainly used where we need to keep the power losses minimum by providing the power to the load in pulses instead of continues manner.
  • PWM technique can be easily defined in terms of duty cycle and the frequency it takes to repeat the duty cycle per second. The duty cycle highlights the amount time the signal switches between ON and OFF position. It is described in percentage. If the signal remains ON half of the total duty cycle and remains OFF in another half, then the duty cycle will be 50%.
The following figure shows the duty cycle in terms of percentage that mainly relates the ON and OFF digital signal on the waveform.
  • The PWM controls the duty cycle of the signal which consequently controls the speed of the motor.
If the frequency of the duty cycle is 50 Hz, it means 50 duty cycles are completed per second, terming the ratio how fast it regulates between high and low values.
  • The frequency requires for PWM process will vary as per the nature of the applications. Some require fast duty cycle for controlling the load at a faster pace while some need a low duty cycle in order to keep the process smooth and away from power losses. More often than not, the response time of the load sets the pathway for the frequency required for the PWM.
It is important to note that the motor speed is directly proportional to the duration of the duty cycle at which the signal remains turned ON. The longer the duration of ON signal, the faster the motor terminals will rotate similarly OFF duration will lead to the slow speed of the motor.
  • Using PWM for controlling the motor has a leg over the simple varying the analog signal to the motor. As the analog signal applies the power to the motor with continuous variation, failing to keep the motor terminals completely OFF or ON, as a result, power loss occurs during this process, however, PWM delivers the power in pulses that keep the motor terminals either in fully ON or OFF state.
LED Example
Controlling the RGB LED is a perfect example for understanding the concept of PWM. By varying the amount of duty cycle of each color and playing around with their brightness will give a specific color every time. Avoid adjusting the duty cycle with the same magnitude for every color, doing this will give a white light. If you are applying red light with 10% duty cycle at 2 MHz speed, then most of the time red light will appear OFF as you see. Yes, it will turn on for the small amount of time but it appears as it is not taking part in the flash created by RGB LED. Similarly, applying red light with 10% duty cycle at 100 MHz will increase the contribution of the red light in the LED as it will turn on will greater pace as compared to applying it with lower frequency.
Computer Motherboard
The computer motherboard is another example that requires PWM signals for its fan to be running with the power pulses. If power is given continuously without PWM, it may cause a severe harm to the board, as the board will run with full speed without any pause. Pulses of power keep the board in a constant loop, where power signals are given in quick successions that keep the fan running. If you buy a new computer, you may notice a 4 pin PWM header is added in the fan that controls the cooling process of the board. The point worth mentioning here is that the PWM generated with sloped duty cycle is preferred over generating it with a flat one. As the later one is more vulnerable to creating a clicking sound when the fan runs at low speed. Similarly, when the duty cycle approaches 100%, the fan will run with full speed, creating an unpleasant ticking sound. In order to alleviate the bothering sound, some quality fans come with IC drive chips, allowing the fan to run smoothly without creating any sound. You may need extra bucks for buying the quality PWM fans that not only retain the quality but also help in increasing the overall lifetime of the board.
Applications
  • DC and Servo Motors
  • Heating systems,
  • Hydraulics
  • Control valves,
  • Pumps
  • Telecommunication
  • Computer applications
That's all for today. I hope you have found this article useful. If you are feeling dubious about PWM and how it works and the topic you may notice that I have left uncovered related to PWM, you can approach me in the comment section below. I'd love to help you according to the best of my knowledge. You are most welcome to keep us updated with your valuable suggestions, so we keep coming back with quality content as per your needs and expectation. Thanks for reading the article. [PostWidget5
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir