Ada Audits the PWM-to-DAC Selection Numbers

Ada re-derives this chapter’s own numbers step by step, at full precision

foundations
math-foundations
calculation-audit
electronics
beginner
Ada ADA · CALCULATION AUDIT

Ada Audits the PWM-to-DAC Selection Numbers

An 8-bit PWM at code 200 on a 3.3 V rail averages to 2.59 V, but a fixed 10.24 MHz timer that gives 40 kHz at 8 bits drops to 2.5 kHz at 12 bits, and a 20 kHz PWM through a 0.22 uF RC filter trades ripple for an 11 ms settling delay. Reaching for a DAC instead swaps the switching carrier for quantization steps. This audit re-derives each figure and asks which limit — average voltage, timer frequency, RC settling, or DAC quantization — is actually the active one behind a PWM-versus-DAC choice.

Companion to the chapter Applied: PWM vs DAC Output — every number here comes from that chapter.

Ada: A PWM output choice is only defensible when the arithmetic says which limit is active: average voltage, timer frequency, RC settling, or DAC quantization.

1. Duty-cycle averaging comes before load physics. The chapter's 30% and code-200 examples both start by converting a duty fraction into an average voltage.

30% LED case: D = 0.30; Vavg = 0.30 * 3.3 V = 0.990 V
8-bit code 200: D = 200 / 255 = 0.7843137; Vavg = 0.7843137 * 3.3 V = 2.588235 V, rounded at the end to 2.59 V

2. Timer resolution spends frequency. With the stated 10.24 MHz timer clock, 12-bit PWM gives 16 times more duty positions than 8-bit PWM, but the PWM carrier falls by the same factor.

8-bit PWM: 10.24 MHz / 2^8 = 10,240,000 / 256 = 40,000 Hz = 40 kHz
12-bit PWM: 10.24 MHz / 2^12 = 10,240,000 / 4096 = 2,500 Hz = 2.5 kHz; frequency ratio = 40,000 / 2,500 = 16

3. RC smoothing trades ripple for delay. The chapter's 20 kHz, 10 kohm, 0.22 uF filter pushes the carrier far above cutoff, but the same RC product sets the response time.

RC = 10,000 ohm * 0.22 uF = 10,000 * 0.00000022 F = 0.0022 s = 2.2 ms
fc = 1 / (2 * pi * 0.0022) = 72.343 Hz; carrier ratio = 20,000 / 72.343 = 276.46x
settling estimate = 5 * RC = 5 * 2.2 ms = 11.0 ms

4. A DAC removes the carrier but keeps quantization. On the same 3.3 V rail, a 12-bit DAC has small voltage steps and no 20 kHz switching component to filter.

12-bit DAC code 2048: 3.3 V * 2048 / 4095 = 1.650403 V, rounded at the end to 1.650 V
one-code step = 3.3 V / 4095 = 0.000805861 V = 0.805861 mV

Selection rule: use PWM when the load naturally averages energy and the timer still meets the frequency target. Use a DAC when switching ripple or settling delay is the dominant error.

Every number above is taken from the chapter’s own material and re-derived step by step.