Electronics & Circuits · Study deck
DAC and PWM: Loads, Filters, and Code
PWM switches a signal on and off in short cycles.
Voltage Vera is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Calculate PWM ripple for an RC filter and load.
- Implement DAC and PWM output on Arduino and ESP32.
- Explain: Switch to PWM + RC filter, then increase capacitance; the output gets smoother but responds more slowly.
- Explain: Result: The ideal 100 Hz design gives 0.159uF.
Major section
Load Experience with PWM/DAC
Switch to PWM + RC filter, then increase capacitance; the output gets smoother but responds more slowly.
- Lower PWM frequency below the filter cutoff; the ripple warning should appear.
Major section
PWM to Analog Conversion (RC Filter)
Result: The ideal 100 Hz design gives 0.159uF.
- A common 0.22uF capacitor with 10k ohm resistance gives about 72 Hz cutoff, which is still low enough to smooth a 1 kHz PWM signal but responds more slowly.
- f_cutoff should be 10-20x below PWM frequency.
Major section
DAC Resolution vs Accuracy
An 8-bit DAC has 12.9 mV steps at 3.3V, but typical INL of +/-1 LSB means actual output can deviate by +/-12.9 mV from the ideal.
- For precision applications, use a higher-resolution DAC (12-bit or 16-bit) and calibrate against a known reference voltage.
Major section
PWM Frequency Too Low
Cameras recording at 30-60 fps can capture individual PWM cycles, and human hearing extends to ~20 kHz.
- On ESP32, use ledcSetup(channel, freq, resolution) to set custom PWM frequency.
Major section
For Kids: Meet the Sensor Squad!
DACs are like translators who speak the language of motors and lights!
- the microcontroller had a new challenge. "I know the motor needs to spin at 50% speed, and I can think in numbers like 128 out of 255.
- the battery was impressed. "So you are a reverse translator!".
Major section
For Kids: Meet the Sensor Squad! (continued)
But Temperature Terry noticed something. "Wait, Danny, you are not on every microcontroller.
- I want to glow at half brightness, but I need a smooth amount of power, not a number!".
- Danny pointed to his friend PWM Pete. "Pete has a clever trick!
- Lila blinked. "I had no idea!
Major section
DAC/PWM Actuator Control
DAC Resolution (8-bit) -> ADC Resolution: Both use the same 2n idea.
- An 8-bit DAC has 256 output levels, while a 12-bit ADC has 4,096 input levels.
- Cross-module connection: PWM Actuator Control: Explains how DC motors respond to PWM average voltage via back-EMF and inductance.
Deck summary
Key takeaways
Switch to PWM + RC filter, then increase capacitance; the output gets smoother but responds more slowly.
- Result: The ideal 100 Hz design gives 0.159uF.
- An 8-bit DAC has 12.9 mV steps at 3.3V, but typical INL of +/-1 LSB means actual output can deviate by +/-12.9 mV from the ideal.
- Cameras recording at 30-60 fps can capture individual PWM cycles, and human hearing extends to ~20 kHz.
- DACs are like translators who speak the language of motors and lights!
Retrieval practice
Recall check 1 of 2

Voltage Vera says: answer from memory, then check your reasoning.
Q1A PWM signal at 5V with a 75% duty cycle produces what average voltage?
Show answer
Answer: C see answers page
Q2An ESP32 DAC channel outputs a value of 200 with a 3.3V reference. What is the approximate output voltage?
Show answer
Answer: A V_out = V_ref x (Digital Input / (2^n - 1)) = 3.3V x (200 / 255) = 3.3V x 0.784 = 2.59V. The ESP32 has an 8-bit DAC, so the maximum digital input is 255.
Retrieval practice
Recall check 2 of 2

Voltage Vera says: answer from memory, then check your reasoning.
Q3You're dimming 10 LEDs to 50% brightness. Your ESP32 has 2 DAC pins and 16 PWM-capable GPIOs, with 10 independent 1 kHz PWM channels available. The LED drivers and viewing conditions meet the project's flicker requirement at 1 kHz. What's the best approach?
Show answer
Answer: D The ten available 1 kHz PWM channels meet the stated flicker requirement, so each LED can have independent duty-cycle control with a suitable driver and current limit.
Print reference
Answers 1 of 2
Answer key.
- C · V_average = V_high x (Duty Cycle / 100%) = 5V x 0.75 = 3.75V. PWM creates an average voltage proportional to the duty cycle. At 75% duty cycle, the signal is HIGH for 75% of each period, producing an average of 3.75V.
- A · V_out = V_ref x (Digital Input / (2^n - 1)) = 3.3V x (200 / 255) = 3.3V x 0.784 = 2.59V. The ESP32 has an 8-bit DAC, so the maximum digital input is 255.
Print reference
Answers 2 of 2
Answer key.
- D · The ten available 1 kHz PWM channels meet the stated flicker requirement, so each LED can have independent duty-cycle control with a suitable driver and current limit.