Actuators & Control · Study deck
PWM Control: Frequency and Driver Decisions
PWM, or pulse-width modulation, switches power on and off in short cycles.
Motor Max is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: At 50 Hz, a 1.5 ms center pulse is only 1.5 / 20 = 7.5% duty, but changing that duty changes the decoded angle rather than average motor voltage directly.
- Explain: At 20 kHz and 35% duty, on-time is 17.5 microseconds, so the current rises by about 8000 x 17.5e-6 = 0.14 A during the on-pulse.
- Explain: On an 8-bit PWM channel the requested register value is round(0.35 x 255) = 89; on a 10-bit channel it is round(0.35 x 1023) = 358.
Major section
Choosing PWM Frequency: Decision Factors
Choosing wrong creates audible noise, poor control, or wasted energy.
- The PWM frequency is not arbitrary -- it must match the actuator's physical characteristics and the application's requirements.
Major section
For Kids: Meet the Actuator Crew!
"I have a superpower," announced the microcontroller. "I can make things go fast or slow, bright or dim, even though I can only say ON or OFF!".
- "That doesn't make sense," said Temperature Terry. "How can you make something half-bright if you can only turn it fully on or fully off?".
- Max grinned. "Watch this!" He started flicking the LED on and off -- really, really fast. "Lila, how do you feel?".
- If I keep you ON for 25% of the time, you glow at quarter brightness.
Major section
For Kids: Meet the Actuator Crew! (continued)
"I feel. Kind of medium bright!" Lila said, glowing at about half her usual brightness. "But I can tell you're flickering me!".
- And the best part is, I only use as much of Bella's energy as needed.
- At 50% duty cycle, we use about half the power!".
- "I like that," said Bella, smiling. "More power saved means I last longer!".
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode
PWM is not a middle voltage.
- The switch still reaches the full supply; duty cycle changes how long that state lasts in each period.
- At 20 kHz, one PWM period is 1 / 20000 = 50 microseconds.
- The ideal average motor terminal voltage is 12 x 0.35 = 4.2 V.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
An LED dimmer should avoid visible flicker, so 500 Hz to a few kHz is usually fine.
- A 35% command keeps the switch on for 0.35 x 50 = 17.5 microseconds and off for 32.5 microseconds.
- The same arithmetic explains why PWM is efficient.
- Many drivers use mixed decay.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
If a small fan draws 0.5 A at full speed, full electrical input is about 12 V x 0.5 A = 6 W.
- Pulse height remains 12 V while high-time and the marked ideal average rise; the actuator's inductance and inertia smooth the physical response rather than turning the switch output into a literal intermediate supply voltage.
- On an 8-bit PWM channel the requested register value is round(0.35 x 255) = 89; on a 10-bit channel it is round(0.35 x 1023) = 358.
- On a motor, the off-time is not empty.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
The winding is an inductor, and an inductor resists sudden current changes.
- The motor still receives 12 V pulses, not a smooth 4.2 V source, but its winding inductance and rotor inertia make the shaft respond mostly to average torque.
- A brushed DC motor in a quiet room is often set near 20 kHz so the switching tone is above normal hearing.
- A quick ripple estimate shows why frequency matters.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
A linear regulator or series resistor would burn the unused energy as heat, while a MOSFET PWM driver spends most of its time either fully on with low resistance or fully off with almost no current.
- At 50 Hz, a 1.5 ms center pulse is only 1.5 / 20 = 7.5% duty, but changing that duty changes the decoded angle rather than average motor voltage directly.
- With 8-bit PWM there are 256 codes, so one step is 1 / 255 = 0.392%.
- The current slope is di/dt = V/L = 8 / 0.001 = 8000 A/s.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
During each on-pulse current ramps up; during the off-time it keeps flowing through a freewheeling path.
- On a 12 V motor that is about 12 x 0.00392 = 47 mV of ideal average-voltage change per step.
- With 12-bit PWM there are 4096 codes, so one step is 1 / 4095 = 0.0244%, or about 2.9 mV on the same supply.
- The power stage must also survive the switching.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
Higher resolution helps slow LED fades and low-speed motor tuning, but timer hardware usually trades frequency against resolution.
- In slow decay, the H-bridge shorts the motor terminals so current recirculates and decays gently, which improves low-speed smoothness.
- In fast decay, the driver applies reverse voltage or returns energy toward the supply, so current drops quickly; this tracks commands better but increases ripple.
- If the shaft is already spinning so back-EMF is 4 V, the on-pulse applies roughly 12: 4 = 8 V across the winding.
Major section
Deep Dive: Duty Cycle, Ripple Current, and Decay Mode (continued)
At 20 kHz and 35% duty, on-time is 17.5 microseconds, so the current rises by about 8000 x 17.5e-6 = 0.14 A during the on-pulse.
- That larger ripple can produce audible vibration, rough torque, and extra heating even though the average duty cycle is unchanged.
- The waveform is digital at the pin, but the motor current, heat, and electromagnetic noise are analog consequences.
- The output still slams between 0 V and the full supply; the actuator responds to the time average because it cannot react to every fast pulse.
Deck summary
Key takeaways
The table turns those checks into actuator-specific starting ranges rather than universal limits.
- "I have a superpower," announced the microcontroller. "I can make things go fast or slow, bright or dim, even though I can only say ON or OFF!".
- "I feel. Kind of medium bright!" Lila said, glowing at about half her usual brightness. "But I can tell you're flickering me!".
- PWM is not a middle voltage.
- An LED dimmer should avoid visible flicker, so 500 Hz to a few kHz is usually fine.
Retrieval practice
Recall check 1 of 5

Motor Max says: answer from memory, then check your reasoning.
Q1A DC motor driven by PWM runs at the right speed but emits an annoying high-pitched whine, and you want smoother low-speed current. Which two changes address these, and why?
Show answer
Answer: A Duty cycle sets the average level while frequency sets smoothness/audibility (raise above ~20 kHz to silence whine); the winding's inductance averages the current, and slow (recirculating) decay reduces ripple for smoother low-speed control.
Retrieval practice
Recall check 2 of 5

Motor Max says: answer from memory, then check your reasoning.
Q2An ESP32 is using 8-bit PWM resolution to control an LED. What PWM value should you write to achieve approximately 75% duty cycle?
Show answer
Answer: C Answer: C) 191.
Retrieval practice
Recall check 3 of 5

Motor Max says: answer from memory, then check your reasoning.
Q3What is the main advantage of using 12-bit PWM resolution (0-4095) instead of 8-bit (0-255) for LED dimming?
Show answer
Answer: B Answer: B) 12-bit resolution provides 4096 brightness levels for smoother, more gradual fading.
Retrieval practice
Recall check 4 of 5

Motor Max says: answer from memory, then check your reasoning.
Q4An ESP32 controls an LED brightness using PWM at 1 kHz with 50% duty cycle. The LED appears at roughly half brightness. If the PWM frequency is lowered to 30 Hz (still 50% duty cycle), what will the user notice?
Show answer
Answer: D PWM works for dimming because the human eye perceives the time-averaged brightness when switching is faster than the flicker fusion threshold (~60-70 Hz).
Retrieval practice
Recall check 5 of 5

Motor Max says: answer from memory, then check your reasoning.
Q5Place each PWM responsibility where it lives so you can tune average drive without mistaking a command waveform for measured actuator motion.
Show answer
Answer: A tune average drive without mistaking a command waveform for measured actuator motion.
Retrieval practice
Recall check 5 of 5

Motor Max says: answer from memory, then check your reasoning.
Q6Complete the PWM configuration to fade an LED:
Show answer
Answer: A PWM is initialized with a pin and frequency.
Print reference
Answers 1 of 2
Answer key.
- A · Duty cycle sets the average level while frequency sets smoothness/audibility (raise above ~20 kHz to silence whine); the winding's inductance averages the current, and slow (recirculating) decay reduces ripple for smoother low-speed control.
- C · Answer: 191.
- B · Answer: 12-bit resolution provides 4096 brightness levels for smoother, more gradual fading.
- D · PWM works for dimming because the human eye perceives the time-averaged brightness when switching is faster than the flicker fusion threshold (~60-70 Hz).
Print reference
Answers 2 of 2
Answer key.
- A · tune average drive without mistaking a command waveform for measured actuator motion.
- A · PWM is initialized with a pin and frequency.