PWM? Pretty Weird Motors?

You may have noticed that when the robot code interfaces to motors on the robot platform, it uses the terminology “PWM”. I’ve overheard a few students guessing as to what PWM must mean – so here goes – its Pulse Width Modulation.

So what would that have to do with motors? What does it mean?

To control a motor, we could send voltage to the motor and turn it on to run at full power. However, usually we want to control the speed of the motor. The way we do that is to turn the power on and off very quickly. Literally, we send a train of pulses to the motor.

In the following drawing, at 50% power, the width of the pulse is set to half and for 25% power, the width of the pulse is set to 25%. At 100%, there is just one big pulse!

pwm

The key is that the speed of the motor is proportional to the width of the pulses. By varying the pulse width (hence pulse width modulation), we control the speed of the motor.

How many pulses are sent per second? That can vary depending on the needs of the specific motor used by might often fall in the range of about 10,000 to 25,000 pulse periods per second. As you may already know, we measure frequency in a unit called Hertz named for German physicist Heinrich Hertz. One cycle per second is one Hertz. 10,000 cycles (or pulses) is 10,000 Hertz, or 10 kilohertz, abbreviated 10 kHz. We can then say that the pulse rate might vary from 10 kHz to 25 kHz.

The microprocessor or microcontroller that is the brain of the robot has a number of input and output pins.  Software running on the microprocessor can generate the appropriate train of pulses. However, the amount of power that can be provided by a pin on the microprocessor is very small. So this signal is connected to a motor controller, which basically amplifies the signal (or uses it to switch on an off a bigger source of power) to drive the motor.

Most microprocessors can connect their output pins directly (or at least through a small electrical part called a resistor) to an LED (light emitting diode). They can use the same PWM technique to vary the light intensity of the LED from dim to bright.

So now you know what PWM is about and it does not stand for “pretty weird motors”.

Leave a comment

Your comment