Understanding PWM

PWM stands for Pulse Width Modulation and it basically means precisely that. You have a pulse, and if you can change the width of the pulse without changing the frequency, then you have modulated its width. Lets first take a look at what a pulse is, because for motion control purposes, it is very important to understand this very simple concept.

PWM Basics

A pulse is an electric signal whose presence is not indefinitely long. A pulse has a beginning an and end and the time from beginning to end can be measured. In essence everything is a pulse since everything has a beginning and an end, but lets assume that these pulses have a finite length in time which is considerably lower than other measurements. Per example, when you turn your computer on and then OFF in a matter of three hours, the pulse of energy that the computer consumed is 3 hours long. The pulses we will concern ourselves with are considerably shorter than this. In fact, they are way shorter than a second.

That being said, a pulse has a finite length in time and that is what we called its TIME ON. How long was the electrical signal present. Once the electric signal is removed and until the signal is applied again, is called the TIME OFF. If the electric signal changes to ON and OFF with continuous and equal intervals of TIME ON and TIME OFF, we say the pulse is periodic and its period is equal to the amount of time the electric signal was present (TIME ON) plus the amount of time the electric signal was not present (TIME OFF).

NOTE: Most of the time when we deal with PWM, we want the PERIOD to remain constant.

Another electrical measurement you may have heard about is the frequency. Frequency is how many times, on a per second basis, something happens. In other words, how many times did the pulse went ON and OFF on any given second. Taking the inverse of the PERIOD gives us the frequency. Frequency is vital understand as the system receiving the PWM signal will most likely be tolerant of a particular frequency. Slower or faster frequencies may not work or simply have undesired results as we shall see later.

We are now ready to fully understand what PWM is. A pulse is generated on a continuous basis, but we change the amount of time the electric signal was ON. Notice that if the PERIOD remains constant any change in TIME ON must also result in a change of TIME OFF. This is very important as well, as it gives us the measurement of Duty Cycle (DC%), which is the percentage of how much time was the electric signal versus how long it was OFF. The rule of thumb is that as the amount of TIME ON increases so does the DC%.


Most people are familiar with the way in which professional remote control toys (such as cars, airplanes, helicopters, boats and now robots) are controlled through a signal referred to as PWM. I like to call this RC PWM as it is very different to the PWM signal used to control DC Motor speed. It is very important that we understand the difference as most remote control robot projects will in fact use both forms of PWM. We often use a radio transmitter which sends an RC PWM signal to an RC Receiver. The receiver decomposes the received signal into a series of RC PWM signals, one per channel. If your RC system is 5 channels, you will get 5 PWM outputs. Each one of these RC PWM signals controls the position of one RC Servo.

Transmitter Receiver


Here is why I like to make the distinction between RC PWM and other forms of PWM. The RC PWM signal is only meaningful to RC based systems and it basically contains position information. The width of the pulse only offers position information. We can of course utilize this information to control whatever we want (intensity of lights, DC motor speed, rate of rotation of a stepper motor, etc.) I have done a lot of stuff with the RC PWM signal, but bottom line is that this signal can only be used to send information. We will see later, that when controlling a DC motor, it is amount of energy what we need, and not information. But let see what kind of information we are talking about.

Servo RC PWM

RC Servos has been designed to accept the RC PWM signal which is nothing more than a periodic pulse with a width of anything between 1.0 ms and 2.0 ms. Some systems with more resolution will have allow for pulses in the range of 0.5 ms to 2.5 ms. However, 1 ms to 2 ms is pretty much standard. The idea behind this position protocol is that 1.5 ms commands the servo to go to the center position. A 1.0 ms pulse commands the motor to attempt to reach its leftmost position and 2.0 ms to its rightmost position. Any pulse measuring in between 1.0 ms and 2.0 ms is decoded as a position in between leftmost and rightmost. Since the remote control is analog, practically any position can be attained.

It is very easy to generate an RC PWM signal using a micro controller or any other digital contraption. When this is done, the positions available are dependent on the timer resolution. Per example, it is possible that a pulse can only have 256 steps between 1 ms and 2 ms pulse width. Even then, 256 positions are more than enough for any fair control application. The motor itself is not as precise as to be adversely affected by this lack of infinite resolution.

DC Motor Speed Control PWM

The user may feel that the RC PWM signal may be an awesome resource to control the speed of a DC motor. And this is of course true, except that the RC PWM signal itself is pretty much useless as a direct means of controlling the DC motor speed. What needs to be done is to have an intermediate circuit to decode the position information (RC Pulse width) and generate a speed magnitude signal. In other words, if the input pulse is 1 ms, move the DC motor on reverse at maximum speed, if 1.5 ms wide stop the DC motor and if 2.0 ms, move the DC motor forward at maximum speed. Any other pulse width is then decoded to partial speed on the corresponding direction.

But how do we control speed on a DC motor? There are many ways as I have depicted before on this blog, but my favorite is with an H Bridge. As it may confuse the reader, an H Bridge utilizes PWM, as well, in order to control DC motor speed!!! However, the PWM we use to control the speed is totally different than the RC PWM signal we had been discussing previously.

Like I explained previously, the RC Servo signal encodes position on the pulse width. Notice the important aspect of the RC PWM is the TIME ON and how long this is. Any TIME ON with widths between 1.0 ms and 2.0 ms are useful. TIME OFF and Duty Cycle are of no concern. This is not true about DC Speed Control.

As it turns out, on an H Bridge, the Duty Cycle will be directly proportional to the resulting voltage applied into the load. And on a DC Motor, voltage applied is directly proportional to motor speed.

The best way to see this is to realize that with an H Bridge, TIME ON actually means the motor is ON, whereas TIME OFF actually means the motor is OFF. So imagine you are applying 12V to  your H Bridge, but the H Bridge is ON only half of the time. In other words, the motor is ON for 1 ms and then OFF for another 1 ms. To the eyes of the motor, this is pretty much identical to having 6V instead.

On the figure below I am trying to portray how speed varies by changing PWM Duty Cycle. The H Bridge is chopping the amount of time the motor is receiving energy. By varying Duty Cycle, we have an infinite amount of voltages to apply to the motor, which then results in an infinite DC motor speeds ranging from stopped to running at full speed.

Speed vs PWM DC%


I demonstrate this concept on my DC Motor Basics Part I blog. Feel free to check the video and notice how the motor speed instantaneously changes as the PWM DC% is modified. For that experiment I used my AE-MDL-DC1 and an MSP430 micro controller to supply a synthesized 32 KHz 8 bit PWM signal.

14 comments for “Understanding PWM

  1. angel
    June 29, 2010 at 2:05 am

    After reading your blog, i learned a lot useful information.
    But i still don’t know what the wave is when PWM signal goes through RC low filter.And how choose the resistor’s value and capacitor’s value. Could you help me?
    Thanks in advance.

  2. July 23, 2010 at 7:30 pm

    The PWM that goes into the RC low pass filter is precisely a square wave which TIME ON and TIME OFF respective widths are varying in time. However,what comes out is a DC voltage. The idea is for the DC voltage to be directly proportional to the duty cycle by following the equation:

    VOUT = VIN * (TON) / (TON + TOFF)

    Notice VOUT will be as high as the VIN used to generate the PWM. Hence, if the PWM magnitude is 3.3V, then the maximum VOUT (when TON = 100%) is 3.3V. As the ratio of TON to total T decreases, so voltage output.

    I am not superbly savy on how to select the R and the C and I just wing it. If you are not changing the Duty Cycle, it is not superbly important what the R and the C is, as long as the DC output ripple is very small.

    If you are modulating the Duty Cycle, however (like when you want to impose wave shapes on top of the output power waveform), then you will need a high frequency PWM (so that you can synthesize the according wave shape) and a higher cuttof frequency low pass filter.

    I am certain there is a gazillion equations out there, which will induce instant headache. At the moment, however, I have not needed my Tylenols in order to properly select the R and the C for a PWM to DC converter low pass filter.

  3. Luis
    March 15, 2011 at 4:27 pm

    Very nice and simple explanation on pulse width modulation, though I would like to know if you have any schematics you can share? I have the transmitter and receiver and would like to make my own ESC to control DC motors for my track vehicle.

  4. March 19, 2011 at 10:52 pm

    Hi Luis,

    I don’t have an schematic at the moment, but that is certainly something I can solve easily! And this looks like a very nice topic so I will get busy with it. Thanks for reading my article and asking about this important circuit!

  5. Albert
    May 30, 2011 at 12:13 pm

    Hi,now i’m on a project which need to make use of DRV8811,however,i buy a stepper motor which is uniploar. I found that it can be used as a biploar motor ,since the rate current of the uniploar stpper motor is 0.5 A, if i use it as a biploar stepper motor, whether the rate current will change or not?

    • May 30, 2011 at 1:35 pm

      Hi Albert,

      When you have a unipolar motor, the windings are center tapped to give you in essence four windings of inductance L. If you decide to ignore the center tap and treat them as a single winding, then the total inductance will be 4L. Because the inductance is mutual inductance, the resulting inductance is not 2L, as we would expect when having in ductors in series. The current the winding is rated for should be the same (as this is given by the wire properties), although it will take about 4 times longer for the inductor to charge (V = Ldi/dt) to said current.

      If you want to use the center tap instead of ignoring it, then you can ignore one of the phase wires and the stepper motor will have inductance equal to L. In this case you will see the same charge time as with unipolar, so the motor will be able to move faster than when using the entire winding. Still, on bipolar you can not go as fast as with unipolar due to the dual current swing.

      Now, your question is about current magnitude. I would use the same 0.5A current the motor is rated to. You can briefly run steppers to slightly higher currents, but the extra heating is not a good thing. You can of course use less current is that is enough to move your load.

      Hope the info helps!

  6. Albert
    May 31, 2011 at 12:31 am

    Hi Avayan,

    Thanks for teaching me all of these, this tough problem has tormented me for seveal days. I feel greatly luck to happen to this site especially your great articles on DRV8811. Since the uniploar motor’s inductance of each phase is L=6 mH,R=13 ?,then the TIMER ON=6 mH/13 ? = 0.5 ms,which was larger than TBLANK, as you said in one of your articles that ” I will expect to see the frequency to frop below 20 KHz, which may result in a high pitch squealing audible to kids in elementary school” ,from the equation?f = 1/?TIMER ON + TIMER OFF)<1/0.5ms=2 KHZ, here f will less than 2KHZ, can i just say that coordinating RC to optimize the TIMER OFF is meaningless.

    Thanks again, greatly hope for your helps!

  7. October 4, 2012 at 5:48 pm

    Can anyone help me which signal is given to esc(electronic speed controller) for run brushless motor

  8. avayan
    October 12, 2012 at 6:00 pm

    Hi Hari,

    The PWM signal offered to a BLDC Electronic Speed Controller (ESC) should be pretty much the same as any other PWM used on the RC world. I know that digital systems are different than the older analog systems, but if I am not mistaken, once the transmitter decodes the message, what comes out is a PWM command in the form of a pulse width ranging from 1 ms to 2 ms, where 1.5 ms is dead center, 1 ms is full reverse (or left) and 2 ms is full forward (or right).

    The BLDC controller is in charge of receiving this PWM command and generating a six state commutation sequence to articulate the BLDC motor in a sensorless fashion with a speed that is directly proportional to the difference from 1.5 ms. In other words, the speed will be faster as the PWM is smaller (less than 1.5 ms) or the PWM is larger (more than 1.5 ms). There is a trillion ways to do this, but at the end the result is pretty much the same.

    January 25, 2013 at 5:08 pm

    Very useful info. But please I am going to build an inverter using the sg3524 PWM IC. can u please explain all about this IC and what it does in the inverter? In great detail please cos I dont know much.

  10. Yacob Hassidim
    February 21, 2013 at 9:36 am

    Hello Avayan,

    Thanks for explanation.

    I want to learn more about RC PWM.

    Can you please send a link to RC PWM communication protocol?


    Yacob Hassidim.

  11. avayan
    February 21, 2013 at 2:30 pm

    Hi Yacob,

    As far as I know, there really is not much more to RC PWM than what I explained here. In essence, the pulse width in milliseconds is decoded by either an analog or a digital (mostly digital today) circuit which then uses that information accordingly.

    On an RC Servo, there is a potentiometer which rotates with the servo actuator. The servo microcontroller is always trying to move the actuator axis so the potentiometer resistance (or actually the voltage output from the voltage divider the potentiometer is made to be) is the one needed for a particular pulse width.

    It is always possible people are using the RC PWM signal to send more complex messages but although I tinkered with this concept a while ago, I do not think it is worthwhile. The reason is the typical RC PWM pulse has a refresh rate of about 50 HZ, which is horrendously slow to send any meaningful data packet. People wanting to control robots remotely might as well use a Bluetooth connection with their android phone. It is actually not even hard.

    I also believe there are new digital communication standards out there on RC radios. I have never had a chance to go into this technology. Do not foresee going there, when bluetooth is more than enough if your application will be close to you.

  12. Yacob Hassidim
    February 24, 2013 at 8:05 am

    Hello Avayan,

    Thank you for your fast response.

    I want to use a transmitter (e.g. see: http://www.futaba-rc.com/accessories/modules.html) to control number of PWM units.

    Can you please advise me how should I connect to the transmitter (HW and software communication protocol)?

    Can you please send your Email in order to send you a file?


    Yacob Hassidim.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.