Electronics & Circuits · Study deck

DAC and PWM: Output Foundations

A digital pin cannot make every analog voltage on its own.

Voltage Vera is your guide for this deck.

analogdigitaloutput
Voltage Vera, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: With a 12-bit DAC (212:1=40952^{12}: 1 = 4095212:1=4095), step size shrinks to 5/4095=1.225 / 4095 = 1.225/4095=1.22 mV -- 16× finer than 8-bit, enabling smooth audio waveforms where 8-bit would sound grainy.
  • Explain: With the illustrated 5 V reference, dividing the reference range by the code count gives 5 V/16=0.3125 V5\ \text{V}/16=0.3125\ \text{V}5 V/16=0.3125 V per step, or 312.5 mV.
  • Explain: For an 8-bit DAC with Vref=5V_{ref} = 5Vref​=5 V, the step size (resolution) is Vstep=Vref/(2n:1)=5/255=19.6V_{step} = V_{ref} / (2^n: 1) = 5 / 255 = 19.6Vstep​=Vref​/(2n:1)=5/255=19.6 mV.
  • Compute DAC resolution and quantization error.
iotclass.org

Major section

Start Simple

The two open paths therefore cannot be labelled DAC or PWM until the load's ripple, delay, drive, and safety limits are known.

  • The panel leaves the two output paths unresolved.
  • The computer holds a number, but the lamp needs voltage, current, and safe timing.
  • The path between them decides whether the physical result matches the command.

Key terms

Pulse-width modulation
Pulse-width modulation means control made by changing how long a signal stays on; it is called PWM.
Modulation
Modulation means changing a signal to carry or control information.
iotclass.org

Major section

Start Simple (continued)

Modulation means changing a signal to carry or control information.

  • The lamp, reference dial, and actuator do not all respond to the same electrical property: one may tolerate switched average power, another needs a stable voltage, and another brings current, inertia, and timing constraints.
  • An analog-to-digital converter means a circuit that turns a voltage into a number; it is called an ADC.
  • An actuator means a part that creates a physical action.
iotclass.org

Major section

Start Simple (continued)

A digital-to-analog converter (DAC) means a circuit that turns a number into a voltage or current.

  • Pulse-width modulation means control made by changing how long a signal stays on; it is called PWM.
  • This runway does not size a driver or prove smooth motion.
  • A DAC produces a stepped analog voltage directly, while PWM makes a fast digital pulse train that a load or filter averages.
iotclass.org

Major section

Phoebe's Field Notes: Why PWM Can Behave Like a DAC

The mathematical gist: An 8-bit endpoint DAC on 5 V has step q=5/255=19.6q=5/255=19.6q=5/255=19.6 mV and code 153 gives 3.00 V.

  • PWM instead gives Vavg=DVhighV_{avg}=DV_{high}Vavg​=DVhigh​.

Let Eddie connect DAC codes, PWM duty, RC smoothing, ripple, and settling.

iotclass.org

Major section

Digital-to-Analog Converters (DAC)

The drawing communicates dAC conversion contract from bounded digital code through reference and transfer function to measured analog output.

  • For digital-to-analog converters (dac), these labels identify the boundary where an assumption must become a calculation or measurement.
DAC conversion contract from bounded digital code through reference and transfer function to measured analog output
DAC conversion contract from bounded digital code through reference and transfer function to measured analog output
iotclass.org

Major section

Putting Numbers to It

For an 8-bit DAC with Vref=5V_{ref} = 5Vref​=5 V, the step size (resolution) is Vstep=Vref/(2n:1)=5/255=19.6V_{step} = V_{ref} / (2^n: 1) = 5 / 255 = 19.6Vstep​=Vref​/(2n:1)=5/255=19.6 mV.

  • To output 3.0V, you need digital value D=⌊Vout×(2n:1)/Vref⌋=⌊3.0×255/5⌋=153D = \lfloor V_{out} \times (2^n: 1) / V_{ref} \rfloor = \lfloor 3.0 \times 255 / 5 \rfloor = 153D=⌊Vout​×(2n:1)/Vref​⌋=⌊3.0×255/5⌋=153.
  • Actual output is Vactual=153×5/255=3.0V_{actual} = 153 \times 5 / 255 = 3.0Vactual​=153×5/255=3.0 V exactly.
  • With a 12-bit DAC (212:1=40952^{12}: 1 = 4095212:1=4095), step size shrinks to 5/4095=1.225 / 4095 = 1.225/4095=1.22 mV -- 16× finer than 8-bit, enabling smooth audio waveforms where 8-bit would sound grainy.
iotclass.org

Major section

DAC Circuit Architecture

With the illustrated 5 V reference, dividing the reference range by the code count gives 5 V/16=0.3125 V5\ \text{V}/16=0.3125\ \text{V}5 V/16=0.3125 V per step, or 312.5 mV.

  • Each code therefore selects one discrete output level rather than an arbitrary continuous voltage.
A four-bit DAC maps sixteen digital codes to stepped analogue output levels set by a 5 V reference.
A four-bit DAC maps sixteen digital codes to stepped analogue output levels set by a 5 V reference.
iotclass.org

Major section

Quantization Error in DAC

Quantization appears because an N-bit DAC can produce only one of 2N2^N2N code levels.

  • Increasing bit depth reduces that vertical step; increasing update rate reduces the time between code changes but does not create new voltage levels.
  • A low-pass filter can attenuate step edges and PWM carrier energy, yet it also changes bandwidth, settling time, and load response.
  • Problem: DAC output is not truly analog - it's discrete steps.
iotclass.org

Major section

Worked Example: DAC vs PWM Output Tradeoff

The first panel establishes ripple and response time before a technology is chosen.

  • The third panel places the selected path on the real load and keeps it only when the trace fits those limits.

Why it matters

The second compares a true converter's stepped voltage with a PWM waveform whose filter and load create an average; neither is automatically superior because channel count, drive, noise, cost, and delay differ.

iotclass.org

Deck summary

Key takeaways

The two open paths therefore cannot be labelled DAC or PWM until the load's ripple, delay, drive, and safety limits are known.

  • Modulation means changing a signal to carry or control information.
  • A digital-to-analog converter (DAC) means a circuit that turns a number into a voltage or current.
  • The mathematical gist: An 8-bit endpoint DAC on 5 V has step q=5/255=19.6q=5/255=19.6q=5/255=19.6 mV and code 153 gives 3.00 V.
  • The drawing communicates dAC conversion contract from bounded digital code through reference and transfer function to measured analog output.
iotclass.org

Retrieval practice

Recall check 1 of 2

Voltage Vera says: answer from memory, then check your reasoning.

Q1A plant lamp receives a PWM command. What should the designer examine to predict its physical output?

AThe ADC resolution as the output-drive capability
BUse the software value because supply changes cannot alter the measured signal.
CThe command number as a measured output voltage
DDuty cycle, load response, ripple, and timing
Show answer

Answer: D PWM creates pulses that the load or filter averages; the load’s response matters.

iotclass.org

Retrieval practice

Recall check 2 of 2

Voltage Vera says: answer from memory, then check your reasoning.

Q2A design smooths PWM pulses into an analog-like control signal. What choice does the chapter ask the learner to evaluate?

AWhether a digital command removes analog constraints
BWhether sensing alone completes the control system
CPWM smoothing versus a true DAC for the load
DWhether more input samples supply load current
Show answer

Answer: C The chapter compares output methods and the trade-off introduced by filtering pulses.

Q3An ideal 8-bit DAC uses a 2.56 V reference and the chapter’s Vref/2^N convention. What is one voltage step?

A20 mV.
B2.56 mV.
C10 mV.
D256 mV.
Show answer

Answer: C In this convention, 2.56 V divided by 256 possible codes is 10 mV per code step.

iotclass.org

Print reference

Answers

Answer key.

  1. D · PWM creates pulses that the load or filter averages; the load’s response matters.
  2. C · The chapter compares output methods and the trade-off introduced by filtering pulses.
  3. C · In this convention, 2.56 V divided by 256 possible codes is 10 mV per code step.
iotclass.org