Pulse Width Modulation: 5 Uses That Give Instant Control

Share:
Electronics Fundamentals
Pulse Width Modulation: 5 Uses That Give Instant Control

Switching a signal fully on and off very fast lets a digital pin control brightness, speed and power almost like an analog output.

Duty Cycle Frequency Average Voltage Motor and LED Control

Pulse width modulation controls power by switching a signal on and off at a fixed frequency and changing how long it stays on. The average of that fast switching behaves like a variable voltage.

Hello everyone, today we are going to understand pulse width modulation, how duty cycle sets the average voltage, and how the same idea drives LEDs, motors, servos and power supplies.
pulse width modulation

What Is Pulse Width Modulation?

Pulse width modulation, or PWM, is a technique that varies the on time of a square wave while keeping its frequency constant. The ratio of on time to period, called duty cycle, sets the average power delivered.

Because the switch is either fully on or fully off, very little power is wasted as heat. That is why PWM is the heart of efficient converters such as the buck converter.

PWM waveforms showing 0, 25, 50, 75 and 100 percent duty cycle
Image credit: SparkFun

SparkFun describes duty cycle as the percentage of time a digital signal is on over one period. A 50 percent duty cycle means equal on and off time.

The load does not see individual pulses if the frequency is high enough. It responds to the average, which is why a motor runs smoothly and an LED looks steadily dimmed.

Duty Cycle, Frequency and Average Voltage

Period TTime for one complete cycle
On TimePortion of T the signal is high
Duty CycleOn time divided by period
FrequencyOne divided by the period
Average OutputDuty cycle times peak voltage

Frequency and duty cycle are independent. You can have a 25 percent duty cycle at 100 Hz or at 20 kHz, and the average voltage is the same.

The right frequency depends on the load. SparkFun notes that LEDs need at least about 100 Hz to avoid visible flicker, while motors often use 20 kHz or more to stay above hearing range.

Resolution is set by the number of timer bits. An 8 bit PWM has 256 steps, and a 10 bit PWM has 1024, as handled by most microcontrollers.

Pulse Width Modulation Formula With a Worked Example

Duty cycle D = On time ÷ Period × 100
Average voltage = D × Peak voltage
Frequency f = 1 ÷ Period

Worked example:
Peak voltage = 12 V, f = 1 kHz, so Period = 1 ms
On time = 0.25 ms
D = 0.25 ÷ 1 × 100 = 25 percent
Average = 0.25 × 12 = 3 V
8 bit register value = 0.25 × 255 ≈ 64

The average voltage formula holds for resistive loads and for loads that filter the pulses, such as motors and LC filters. For power in a resistor, remember that power follows the RMS value instead.

For RMS details see RMS value explained. For a PWM square wave, the RMS voltage equals the peak multiplied by the square root of the duty cycle.

5 Uses That Give Instant Control

1
LED Dimming
Change brightness without changing LED color or wasting power.
2
DC Motor Speed
Vary average voltage to set motor speed efficiently.
3
Servo Position
A 1 to 2 ms pulse every 20 ms sets the servo angle.
4
Switching Power Supplies
Regulate output voltage in buck, boost and flyback converters.
5
Analog Output
Filter PWM with an RC network to make a steady DC level.

For servos, SparkFun explains that a 50 Hz signal with a 1.5 ms pulse centres the shaft at 90 degrees. Pulses of 1 ms and 2 ms move it to the ends of travel.

Use 5 relies on a low pass filter, explained in RC low pass and high pass filters. It is a cheap substitute for a DAC when speed is not critical.

Types of PWM Generation

Edge Aligned PWM

Counter resets each period and output switches once.

Best for: LEDs and general control
Simple
Center Aligned PWM

Counter counts up and down for symmetric pulses.

Best for: motor drives with less noise
Symmetric
Sine PWM

Duty cycle follows a sine wave reference.

Best for: inverters and VFDs
AC Output
Space Vector PWM

Optimized switching pattern for three phase inverters.

Best for: high performance drives
Efficient

Sine and space vector methods are used in every VFD. They create an AC motor voltage from a DC bus by modulating power transistors.

Center aligned PWM reduces harmonic content and is preferred for motor control. Edge aligned PWM is fine for lighting and simple tasks.

Switching Devices for PWM

DeviceTypical FrequencyBest Use
Logic MOSFETUp to hundreds of kHzLEDs and small motors
Power MOSFETTens to hundreds of kHzConverters and DC motors
IGBTA few kHz to about 20 kHzHigh power motor drives
Solid state relayVery low, zero cross typesHeaters with slow cycles

MOSFETs need a proper gate drive to switch fast, as described in MOSFET gate driver ICs. Slow switching wastes power in every transition.

High power drives use the IGBT because it handles high voltage and current at moderate frequencies.

Where PWM Is Used

LED Lighting
Dimming drivers and display backlights.
Fans and Pumps
Speed control of DC and brushless motors.
Robotics
Servo and actuator control.
Power Converters
Chargers, SMPS and solar controllers.
Motor Drives
VFDs for induction motors.
Heating Control
Time proportional control of heaters.

Brushless motors are driven by PWM through three phase bridges, as covered in brushless DC motor basics.

Heater control often uses very slow PWM with a period of seconds. This is called time proportional control and works well with solid state relays.

PWM Calculator

Duty Cycle, Average Voltage and Register Value
Result
Duty 25.0 percent, average 3.00 V, register 64

Increase the resolution to 10 bits and the same duty cycle needs a register value of about 256. Higher resolution gives finer control.

Advantages
  • Very high efficiency.
  • Simple digital control.
  • Works with LEDs, motors and converters.
  • Fine resolution with modern timers.
Limitations
  • Switching creates EMI.
  • Audible noise at low frequency.
  • Needs filtering for true analog output.
  • Fast edges stress insulation in motors.

Microchip PWM Tips and Tricks PDF

PDF
Pulse Width Modulation Tips and Tricks
Microchip guide to generating and using PWM in real designs

PWM Duty Cycle and Frequency Video

Pulse Width Modulation FAQ

What is pulse width modulation?
A method that controls power by changing the on time of a fixed frequency square wave.
What is duty cycle?
The percentage of each period that the signal is on.
How do I find average voltage?
Multiply the duty cycle by the peak voltage.
What frequency should I use for LEDs?
At least about 100 Hz to avoid visible flicker.
Why do motors use high PWM frequency?
Above about 20 kHz the switching noise is out of hearing range.
What PWM does a servo need?
A 50 Hz signal with a 1 to 2 ms pulse.
Can PWM make an analog voltage?
Yes, by filtering it with an RC low pass filter.

Related Articles

External References

What We Learn Today

  • Duty cycle is on time divided by period, and it sets the average voltage.
  • Frequency is chosen to suit the load, from 100 Hz for LEDs to 20 kHz for motors.
  • PWM drives LEDs, motors, servos, converters and inverters efficiently.
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!

Leave a Reply

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