Pulse Width Modulation
Today we will look at controlling a small D.C. motor using Pulse Width Modulation, or PWM. Anthony Stevens wrote to me saying that he has salvaged a small D.C. motor out of an old plastic toy and that he wanted to use it in his science project but did not know how to control the speed of the motor without it stalling. Well, Anthony there are many different ways to control the speed of motors but one very simple and easy way is to use Pulse Width Modulation. But before we start looking at the in’s and out’s of pulse width modulation we need to understand a little more about how your D.C. motor works.
Next to stepper motors, the Brushed DC Motor is the most commonly used type of small direct current motor available producing a continuous rotational speed that can be easily controlled, making them ideal for use in applications were speed control is required such as small toys, models and robots etc. A D.C. motor consist basically of two parts, the stationary body of the motor called the “Stator” and the inner part which rotates producing the movement called the “Rotor”. For D.C. machines the rotor is commonly termed the “Armature”.
Generally in small light duty D.C. motors the stator consists of a pair of fixed permanent magnets producing a uniform and stationary magnetic flux inside the motor giving these types of motors their name of “permanent-magnet direct-current” (PMDC) motors. The armature however, consists of individual electrical coils connected together in a circular configuration around its metallic body producing a North-Pole then a South-Pole then a North-Pole etc, type field system configuration. The current flowing within these rotor coils producing the necessary electromagnetic field. The circular magnetic field produced by the armatures windings produces both north and south poles around the armature which are repelled or attracted by the stator’s permanent magnets producing a rotational movement around the motors central axis.
As the armature rotates electrical current is passed from the motors terminals to the next set of armature windings via carbon brushes located around the commutator producing another magnetic field and each time the armature rotates a new set of armature windings are energised forcing the armature to rotate more and more and so on. So the rotational speed of a D.C. motor depends upon the interaction between two magnetic fields, one set up by the stator’s stationary permanent magnets and the other by the armatures rotating electromagnets and by controlling this interaction we can control the speed of rotation.
The magnetic field produced by the stator’s permanent magnets is fixed and therefore can not be changed but if we change the strength of the armatures electromagnetic field by controlling the current flowing through the windings more or less magnetic flux will be produced resulting in a stronger or weaker interaction and therefore a faster or slower speed. Then the rotational speed of a D.C. motor (N) is proportional to the back emf (Vb) of the motor divided by the flux (which is a constant) times an electromechanical constant depending upon the nature of the armatures windings (Ke) giving us the equation of N ∝ V/Keϕ.
So how do we control the flow of current through the motor. Well many people attempt to control the speed of a D.C. motor using a large variable resistor in series with the motor. While this may work, as it does with Scalectrix, it generates a lot of heat and wasted power in the resistance. One simple way to control the speed of a motor is to regulate the amount of voltage across its terminals. This is achieved using “Pulse Width Modulation” or PWM by driving the motor with a series of “ON-OFF” pulses and varying the duty cycle (the fraction of time that the output voltage is “ON”) while keeping the frequency constant.
The power applied to the motor can be controlled by varying the width of these applied pulses and thereby varying the average voltage applied to the motors terminals. By changing or modulating the timing of these pulses the speed of the motor can be controlled, i.e. the longer the pulse is “ON”, the faster the motor will rotate and likewise, the shorter the pulse is “ON” the slower the motor will rotate. In other words, the more average voltage applied to the motor terminals the stronger the magnetic flux inside the armature windings and the faster the motor will rotate and this is shown below.
Pulse Width Modulated Waveform

The use of pulse width modulation to control a small motor has the advantage in that the power loss in the switching transistor is small because the transistor is either fully “ON” or fully “OFF” therefore the transistor has a much reduced power dissipation giving a linear type of control resulting in better speed stability. Also the amplitude of the motor voltage remains constant so the motor is always at full strength. The result is that the motor can be run slowly without stalling. Then how can we produce a pulse width modulation signal to control the motor. Easy, use a 555 timer circuit.
The 555 timer is connected in an “Astable Mode” as shown below.

This simple circuit based around the familiar NE555 or 7555 timer chip is used to produced the required pulse width modulation signal at a fixed frequency output. The timing capacitor C is charged and discharged by current flowing through the timing networks RA and RB as we looked at in the 555 Timer tutorial. The output signal at pin 3 of the 555 is equal to the supply voltage switching the transistors fully “ON”. The time taken for C to charge or discharge depends on the values of RA, RB and C. Capacitor C charges up through the network RA and diode D1. As soon as the capacitor is charged, it is immediately discharged through diode D2 and network RB into pin 7. During the discharging process the output at pin 3 is at 0 V and the transistor is switched “OFF”. Then the time taken for the capacitor to go through one complete charge/discharge cycle depends on the values of RA, RB and C with the time T for one complete cycle being given as:
The time, TH, for which the output is “ON” is: TH = 0.693(RA + RB).C
The time, TL, for which the output is “OFF” is: TL = 0.693(RB).C
Total cycle time, T = TH + TL
with the frequency given as F = 1/T
With the component values shown, the duty cycle of the waveform can be adjusted from about 8.3% (0.5V) to about 91.7% (5.5V) using a 6.0V supply. The Astable frequency is constant at about 256 Hz and the motor is switched “ON” and “OFF” at this rate. Resistor R1 plus the “top” part of the potentiometer, VR1 represent the resistive network RA. While the “bottom” part of the potentiometer plus R2 represent the resistive network RB above. These values can be changed to suite different applications and motors but providing that the Astable circuit runs fast enough at a few hundred Hertz minimum, there should be no jerkiness in the rotation of the motor. Diode D3 is our old favourite the flywheel diode used to protect the circuit from the inductive loading of the motor. Also if the motor load is high put a heatsink on the switching transistor or MOSFET.
Pulse Width Modulation is a great method of controlling the amount of power delivered to a load without dissipating any wasted power in it, so the above circuit can also be used to control the speed of a fan or to dim the brightness of DC lamps or LED’s. If you need to control it use pulse width modulation to do it. Good Luck with your project.:)