Empowering you to understand your world

Introduction To PWM: How Pulse Width Modulation Works

An illustration of a PWM signal.
A PWM signal (square wave) with a 50% duty cycle.

By Nicholas Brown.

Definition Of Pulse Width Modulation

Pulse Width Modulation (PWM) is a nifty current control technique that enables you to control the speed of motors, heat output of heaters, and much more in an energy-efficient (and usually quieter) manner. Existing applications for PWM include, but are not limited to:

  • Variable speed fan controllers.
  • VRF HVAC compressor drives.
  • Hybrid and electric vehicle motor drive circuits.
  • LED Dimmers.

Pulse width modulation has changed the world by slashing the power consumption of appliances utilizing motors such as inverter air conditioners [PDF], inverter refrigerators, inverter washing machines, among many others. For example, inverter air conditioners can consume less than half the energy that their non-inverter counterparts do in some cases.

In this day and age, if a device is advertised as having a variable speed compressor or variable speed fan (this doesn’t include two or three-speed fans), there is a significant chance that it is utilizing PWM!

Why Use PWM?

Aspiring electrical engineers may want to know why they should use pulse width modulation to control devices, and homeowners have similar question which has the same answer: Why use inverter air conditioners, or other variable speed appliances?

The answer to both questions is: PWM varies the speed of the appliances’ motors so they only consume as much power as they need, but without the usual consequence of burning off unused current as heat. An example of an older alternative is a simple transistor circuit that varies the current passing through it by varying its resistance.

The same efficiency rule that applies to resistors also applies to transistors — Their resistance results in wasted energy because they burn off some of it as heat. They act like heaters in that regard.

Fortunately, these circuits were never mainstream. Appliances such as air conditioners and refrigerators just ran at full speed all the time, making lots of noise, and wasting lots of energy because they had to cycle on and off frequently.

PWM does make use of transistors, but in a different way, as explained below.

PWM Motor Controller Example.

If you’re looking to get started with PWM, a great entry point would be a 555 PWM circuit, Arduino PWM circuit (very convenient, as you can easily modify its behaviour via a simple source code modification), or the MSP30 PWM circuit that I wrote about on Kompulsa.

How Does PWM Work?

PWM works by pulsating DC current, and varying the amount of time that each pulse stays ‘on’ to control the amount of current that flows to a device such as an LED. PWM is digital, which means that it has two states: on and off (which correspond to 1 and 0 in the binary context, which will become more relevant to you if using microcontrollers).

The longer each pulse is on, the brighter the LED will be. Due to the fact that the interval between pulses is so brief, the LED doesn’t actually turn off. In other words, the LED’s power source switches on and off so fast (thousands of times per second) that the LED actually stays on without flickering. This is called PWM dimming, and such as circuit is just called a PWM LED dimmer circuit.

The squares in the PWM illustration below are the pulses which represent ‘on’ time, and the depressed areas represent the time that the power is ‘off’. Both the squares and depressed areas are the same ‘width’, therefore the duty cycle is 50%. PWM signals are typically square waves, like the one in the illustration below.

An illustration of a PWM signal. A PWM signal (square wave) with a 50% duty cycle.

If the duty cycle of a PWM power supply is set to 70%, then the pulse is on for 70% of the time, and it is off 30% of the time. Duty cycle refers the amount of time it is on. At a 70% duty cycle, an LED’s brightness should be near 70%. The correlation between duty cycle and brightness is not 100% linear, as the efficiency of LEDs varies with the amount of current supplied.

If the duty cycle was 0%, the entire signal would be flat, as shown below. A PWM duty cycle of 0% means that the power is off. In such a state, an LED would not be operational. It would simply be off.

PWM Signal - 0% Duty Cycle PWM signal (square wave) with a duty cycle of 0%. This means the power is off.

The key reason that PWM circuits are so efficient is that they don’t try to partially restrict the flow of current using resistance. They turn the current fully on and fully off. They just vary the amount of time that it is on instead.

PWM LED Dimmer Circuit Example

The old-fashioned transistor circuit I mentioned above in the ‘Why Use PWM’ section may be 50% on for example, and easily waste a huge chunk of the other 50% that it is blocking.

The additional heat generated by traditional transistor circuits is another consideration, as it may increase the amount of time that cooling fans have to stay on to reduce the temperature of said devices.

PWM Signal

To break things down further, PWM circuits [PDF] typically involve a very tiny power source, and a large one. The tiny power source controls the large one with the help of power transistors.

The tiny one generates the signal, and the ‘power‘ which is the large current and voltage that actually power on the LED is controlled by the aforementioned transistors. That tiny power source could be a microcontroller GPIO pin such as an Arduino I/O pin, a 555 timer’s output pin, among others.

Setting the duty cycle of the signal to 30% will also result in a duty cycle of 30% for the power, as the large current is just an amplified replica of the tiny current (which is the signal).

This concept is what enables highly sophisticated microcontrollers (often called MCUs) and other computers to control very large currents at a reasonable cost. The microcontroller/MCU generates the signal, then that signal controls a power transistor.

Further Reading

Introduction To Microcontrollers – Vienna University Of Technology [PDF].

How To Generate A PWM Signal With An Arduino – Portland State University [PDF].

How Semiconductors And Transistors Work – University Of Virginia.

How Build A PWM Fan Controller With A Safety-Critical Hercules MCU – Kompulsa.

Logic OR Gates: What Is An OR Gate

Leave a Reply
Subscribe to our newsletter
Get notified when new content is published