PULSE WIDTH MODULATION (PWM)
Why use Pulse Width Modulation to control the Motor Speed ?
There are several reasons why PWM is chosen for speed control of a dc motor here are a few of them:
PWM is easy to interface to a
Micro-controller, only one output pin is needed to control the speed.
PWM is effecient. The supply to the motor is
either FULL ON or FULL OFF. If a variable voltage is used to control the
speed then the voltage regulator has to dissipate any power that the motor
isn't using. This means at low power settings, the controller will run quite
hot! Wasting lots of your valuable battery power!
PWM means maximum Motor Torque at all speeds. This is because the supply to the motor is either FULL ON or FULL OFF. With a variable voltage controller, lower speed = lower voltage = lower TORQUE! In other words at low speeds you will have to give your bot a little shove to get it moving. This is not the case with PWM.
How does PWM work ?
Have a look at the following waveforms 1 thro 4:

Waveform 1:
This is constant dc at the supply voltage Vs and thus the motor receives full power.
OK simple enough.
Waveform 2:
Now instead of pure dc the motor receives a train of pulses where the off time 'a' is equal to the on time 'b' and therefor has a PWM of 50%. As the full power is only applied for 50% of the total duration, the power to the motor is 50%.
OK I think maybe you can see where this is heading now!
Waveform 3:
This time the off time 'a' is 25% and the on pulse is 75% consequently 75% power is applied to the motor.
Waveform 4:
As a final example the off time is 75% and the on pulse is now only 25%, it then follows that the motor only receives 25% power.
The conclusion:
Hopefully you will have seen from the above waveforms that the width of the on pulse is varied with respect to the off pulse.
To give it it's proper name PULSE WIDTH MODULATION or PWM for short.
Notes:
Have a look at the waveforms again and note the vertical time reference lines 't' and 'ta+b' The difference between the time 't' and 'ta+b' is the length of the off pulse 'a' plus the length of the on pulse 'b' and this is the same for all the waves 2,3 and 4 also Wave 1. Although at first this might not be apparent, see if you can figure it out?
OK the point I'm trying to make is a+b is always the same and therefor the time period is the same and thus the frequency.
To take this a step further; if the pulse-width is constant at 50% (or any percentage for that matter) and you vary the frequency, this will have no effect on the power to the motor!
However the frequency of the PWM signal is important. If it is too Low, eg 1Hz, the motor will literally rev up a down twice a second! As a rough guide the frequency should be set to between 200Hz and 25KHz. Any thing below about 100Hz and you'll start to notice a distinctive judder!
Also note that each on pulse is at full supply voltage Vs This means the motor gets maximum starting torque with every pulse.