2.12. PWM

What's PWM and where can we use it?

PWM stands for Pulse Width Modulation.

As you already know, microcontrollers use digital signals which have only two values:

  • HIGH - logic '1' or 5V
  • LOW - logic '0' or 0V

Let's suppose we connect an LED to a digital pin. If the pin is HIGH the LED will be ON. If the pin is LOW the LED will be OFF. So the LED has two states either ON or OFF. But what if we want to dim the LED? Is it possible to achieve that by using only a digital pin?

To dim the light would mean to vary the voltage applied to the LED. That's where PWM give us a helping hand, because PWM is a technique used for getting analog results using digital signals.

Why is it useful?

  • Telecommunications - In telecommunications, the widths of the pulses correspond to specific data values encoded at one end and decoded at the other. Pulses of various lengths (the information itself) will be sent at regular intervals (the carrier frequency of the modulation).
  • Power delivery - PWM can be used to control the amount of power delivered to a load without incurring the losses that would result from linear power delivery by resistive means.
  • Voltage regulation - PWM is also used in efficient voltage regulators. By switching voltage to the load with the appropriate duty cycle, the output will approximate a voltage at the desired level.
  • Audio effects and amplification - PWM is sometimes used in sound (music) synthesis, in particular subtractive synthesis, as it gives a sound effect similar to chorus or slightly detuned oscillators played together. (In fact, PWM is equivalent to the difference of two sawtooth waves.)
  • Robotics - PWM signals are used to control the speed of the robot by controlling the voltage going to the DC motors. They're also used to set the angle of servo motors, to play sounds on a buzzer, or as LED dimmers.


roboticsisfun/chapter2/ch2_12_pwm.txt · Last modified: 2012/11/28 02:01 by liviu.radoi