PowerElecHub

RC Filter for a PWM DAC: Ripple, Settling Time and the Second Pole

By the Power Electronics Hub editor · Published 2026-11-12 · Updated 2026-11-14

A microcontroller has no spare DAC, so a timer output at 3.3 V is meant to set the trip threshold of an analog comparator. The timer runs from 64 MHz and the threshold should have 10-bit resolution, which fixes the PWM period at 1024 counts and the frequency at 62.5 kHz. One LSB is 3.22 mV. A single 10 kΩ, 470 nF low-pass (470 nF is the next standard value above the 410 nF minimum) keeps the ripple at 2.8 mV peak to peak, inside one LSB, but after a full-scale change the output needs 33 ms to come within one LSB of its final value. Replacing it with 10 kΩ and 10 nF (rounded up from the 9.0 nF minimum) followed by 100 kΩ and 1 nF gives 2.6 mV of ripple and settles in 1.05 ms. The parts cost the same. The difference is the second pole.

Resolution and ripple come from the same clock

A PWM DAC with N bits needs 2^N timer counts per period, so f_pwm = f_clk/2^N. Every extra bit halves the PWM frequency and also halves the size of the LSB the ripple has to stay below. Both changes make the filter's job harder at the same time.

For a single RC the ripple has a closed form. It is largest at 50 % duty, where the output swings V·tanh(T/4τ) peak to peak. At 25 % or 75 % duty it is about three quarters of that, since the ripple scales roughly with D·(1 − D). Requiring the 50 % ripple to stay below one LSB gives τ ≥ T/(4·atanh(2^−N)), which for any useful N is almost exactly 2^N·T/4.

PWM frequency
f_pwm = f_clk / 2^N, T = 1/f_pwm
Ripple, single RC, duty D = 0.5
ΔV_pp = V·tanh(T / 4τ)
Time constant for ripple ≤ 1 LSB
τ ≥ T / (4·atanh(2^−N)) ≈ 2^N·T / 4 = 4^N / (4·f_clk)
Settling of a full-scale step to 1 LSB
t_s = τ·ln(2^N) = N·ln2·τ

With f_clk fixed, τ grows by a factor of four for every extra bit and the settling time by a bit more than that, because the step also has to settle to a finer level. At 64 MHz a single RC settles in 1.4 ms for 8 bits, 28 ms for 10 bits and 545 ms for 12 bits. A reference that takes half a second to move is fine for a fan-speed setpoint and useless for a current limit that firmware adjusts at start-up.

A second pole buys ripple attenuation without slowing the step

Above its corner a single RC attenuates by a factor proportional to f_c/f. Two RC sections give (f_c/f)², so the same ripple needs a far smaller time constant per stage. For the 10-bit case, two buffered sections each need τ = 90 µs instead of 4.1 ms, and a full-scale step settles to one LSB in 0.84 ms.

Without a buffer the second stage loads the first. Making the second stage ten times the impedance (R2 = 10·R1, C2 = C1/10) keeps the same per-stage τ and settles in 0.95 ms. Two identical sections with no buffer still meet the ripple target with the same τ, because the attenuation far above the corner is the same, but the step settles in 1.68 ms since the loaded poles split apart. All three are an order of magnitude faster than the single RC.

PWM frequency: 62.50 kHz · 1 LSB (3.3 V): 3.22 mV

Single RCτ = 4.10 ms · Settling to 1 LSB: 28.4 ms
Two RC, bufferedτ = 90.5 µs · Settling to 1 LSB: 838 µs
Two RC, unbuffered (k)τ = 90.5 µs · Settling to 1 LSB: 954 µs

The chart sweeps the time constant for each topology and plots the ripple at 50 % duty against the time a full-scale step takes to settle to one LSB. The dots mark the design that just meets one LSB of ripple. Changing N shows how quickly the single RC falls behind: the gap between the curves widens with every bit. A third pole, or an active second-order filter such as a Sallen-Key stage, moves the curve further left, at the price of an op-amp.

Ripple is computed for the PWM waveform itself, from 0 V to V. The 2-stage values sum the odd harmonics up to the 99th; they match a state-space simulation of the circuit to better than 0.1 %. Settling is computed for the filtered average, without the ripple riding on it.

What the second stage costs: output impedance

The filter's output resistance is its last resistor in series with everything before it, and whatever is connected to the output forms a divider with it. The 10 kΩ single RC driving a 1 MΩ input loses 1 % of its value, which at 10 bits is ten LSB. The two-stage version with 110 kΩ total source resistance needs at least about 113 MΩ of load to stay within one LSB; a 10 MΩ load already costs 11 LSB.

A comparator or op-amp with a CMOS input is usually fine, since its input current is in the picoampere to nanoampere range. An ADC input is not: its sampling capacitor draws a charge every conversion, and a 1 nF filter capacitor recovers slowly through 100 kΩ. A unity-gain buffer after the filter removes both problems and lets the stages use any impedance, which is why the buffered curve in the chart is the reference case.

Errors the filter cannot remove

A PWM DAC multiplies the duty cycle by the voltage the pin swings between. That voltage is the I/O supply, so its tolerance appears directly as a gain error: a 3.3 V rail that is good to ±2 % moves full scale by about ±20 LSB at 10 bits. The pin's output resistance adds to R1 and is different for the high and low states, which shifts the average slightly with duty. Unequal rise and fall times matter most at very small and very large duty cycles.

The usual remedies are to feed the PWM through a buffer or logic gate supplied from a voltage reference, or to make the measurement ratiometric, so that whatever reads the threshold uses the same supply as its reference. If the 10 bits have to be absolute rather than relative, a PWM DAC with an RC filter is the wrong tool and a real DAC or a reference-based design is needed.

Design sequence

  1. 1Choose N from the resolution you need and compute f_pwm = f_clk/2^N.
  2. 2Set the ripple limit, usually one LSB peak to peak at 50 % duty, and decide how fast a full-scale change has to settle.
  3. 3Check a single RC first: τ ≈ 2^N·T/4 and t_s = N·ln2·τ. If that settling time is acceptable, stop there.
  4. 4Otherwise use two RC stages with about the per-stage τ from the chart, either buffered or with the second stage about ten times the impedance of the first.
  5. 5Compare the filter's output resistance with the input that reads it, and add a buffer if the divider error exceeds a fraction of an LSB.
  6. 6Account for the supply tolerance of the pin; decide whether the result needs to be ratiometric or absolute.

Sources

  • Texas Instruments, SPRAA88A, "Using PWM Output as a Digital-to-Analog Converter on a TMS320F280x Digital Signal Controller" (PWM used as a DAC on a C2000 controller: output filter and achievable resolution versus bandwidth).
  • Microchip Technology, AN538, "Using PWM to Generate Analog Output" (filtering a PIC PWM output into an analog voltage).
  • Linear Technology, Design Note 538, "Accurate, Fast Settling Analog Voltages from Digital PWM Signals" (the settling-time problem of filtered PWM and a dedicated PWM-to-voltage converter).
  • All numbers in this article were computed in Python: the single-RC ripple from its closed form, the two-stage ripple from a state-space solution of the periodic steady state, and settling times from the step responses. They are cross-checked against the chart's own calculation.

This guide explains general engineering principles. Always verify your design with datasheets, simulation and measurement.

Calculators for this topic

More guides