Solar Products
Directly Call  Inquiry
+86 18307948875(wechat/whatsapp)

What is PWM and how does it work?

Issuing time:2012-04-04 10:54

PWM is a way to control analog devices with a digital output. Another way to put it is that you can output a modulating signal from a digital device such as an MCU to drive an analog device. It’s one of the primary means by which MCUs drive analog devices like variable-speed motors, dimmable lights, actuators, and speakers. PWM is not true analog output, however. PWM “fakes” an analog-like result by applying power in pulses, or short bursts of regulated voltage.

An example would be to apply full voltage to a motor or lamp for fractions of a second or pulse the voltage to the motor at intervals that made the motor or lamp do what you wanted it to do. In reality, the voltage is being applied and then removed many times in an interval, but what you experience is an analog-like response. If you have ever jogged a box fan by applying power intermittently, you will experience a PWM response. The fan and its motor do not stop instantly due to inertia, and so by the time you re-apply power it has only slowed a bit.

[Figure 1: An example of a PWM signal shown at several duty cycles and a high voltage level of 5 volts. The red line is the average voltage that the driven device (e.g., a motor) is experiencing. (Source: Timothy Hirzel, )】


Therefore, you do not experience an abrupt stop in power if a motor is driven by PWM. The length of time that a pulse is in a given state (high/low) is the “width” of a pulse wave.

A device that is driven by PWM ends up behaving like the average of the pulses. The average voltage level can be a steady voltage or a moving target (dynamic/changing over time). To simplify the example, lets assume that your PWM-driven fan has a high-level voltage of 24 volts. If the pulse is driven high 50% of the time, we call this a 50% duty cycle. The term duty cycle is used elsewhere in electronics, but in every case duty cycle is a comparison of onversus off.

Figure 2: The blue lines are PWM output from an MCU, and the red line is the average voltage. In this case, the pulse width (and corresponding duty cycle) change so that the average voltage looks more like an analog output that is not in a steady state such as shown in Figure 1. (Source: Zureks – Own work, CC BY-SA 3.0, )


Going back to our fan motor example, if we know that the high voltage is 24, the low is 0v, and the duty cycle is 50%, then we can determine the average voltage by multiplying the duty cycle by the pulses high level. If you want the motor to go faster, you can drive the PWM output to a higher duty cycle. The higher the frequency of high pulses, the higher the average voltage and the faster the fan motor will spin. IF you were making your own PWM output by plugging the fan in and out of a socket at equal intervals of 1 second in the socket, 1 second out, then you are acting like a digital output thats driving the fan at a steady average of 12V.

The analogy comes in when you increase the frequency of plugging in and out of the socket so that you only have it in the socket ½ a second and out of the socket an equal ½ second. At this point, your duty cycle is still 50%, but you have increased the number of cycles per second to two. In electronics, we would identify frequency as cycles per second, or Hertz (Hz.) You have increased the speed of the fan. That ½ second is the width of the pulse you are making.

You might have gathered by now that PWM, duty cycle, and frequency are interrelated. We use duty cycle and frequency to describe the PWM, and we often talk about frequency in reference to speed. For example, a variable frequency drive motor produces a response like analog device in the real world. The separate pulses that the VFD motor gets are not discernable to us; as far as we can see, the pulses are so fast (usually somewhere in the milliseconds) that by real world standards it just seems like a motor ramping up.

If you take the duty cycle and multiply it by the high voltage level (which is a digital onor 1state as far as the MCU is concerned), you will get the average voltage level that the motor is seeing at that moment.

Duty Cycle x High Voltage Level = Average Voltage

Now put the word instantaneousin there and you get the idea that things are dynamically changingwhich looks more analog (see Figure 2):

Instantaneous Duty Cycle x High Voltage Level = Instantaneous Average Voltage

The duty cycle can change to affect the average voltage that the motor experiences. The frequency of the cycles can increase. The pulse can even be increased in length. These can all happen together, too, but in general, its easier to think of as either duty cycle increasing or frequency increases to increase the speed of the motor. (Pulse width is directly related to duty cycle, so if you decide to increase the width of a pulse, you are just altering the duty cycle.)

The only thing that hasnt changed in all of this is the high voltage level, because onis always the same for the digital output; merely flicking the output on and off at varying speeds and for varying lengths of time is how you get pulse width modulation to fake an analog output. MCUs are digital. An example of something that can create a true analog output would be a transducer (something that directly translates physical phenomenon to an analog signal). But transducers are another analog discussion.

Share to:
Contact number(wechat/whatsApp)
+86-18307948875                            (Monday - Sunday :0:00-24:00)
Factory Address: Room 905, Building 1, No. 19, Guanglong Road, Huangjiang Town, Dongguan, Guangdong province, China Post  code:523516