A Digital-to-Analog Converter (DAC) is an electronic component that translates discrete digital binary codes from a microcontroller into continuous analog voltage or current signals. In a physical circuit, a DAC changes abstract logic states (1s and 0s) into measurable electrical potential, bridging the gap between digital processing and real-world analog control like audio waveforms, motor speeds, or programmable power supply thresholds. Without a DAC, a microcontroller can only output rigid HIGH or LOW states; with one, it can sculpt precise, continuous physical realities.
The Practical Definition of DAC and Resolution Math
To understand the definition of DAC in practice, you must understand resolution. A DAC does not output a perfectly smooth, infinite continuum of voltage. Instead, it outputs a "staircase" of discrete voltage steps. The height of each step is determined by the DAC's bit-resolution and its reference voltage ($V_{ref}$). The smallest possible voltage change the DAC can make is called the Least Significant Bit (LSB) voltage.
Here is how resolution scales across common embedded DAC architectures when using a standard 3.3V reference voltage:
| DAC Resolution | Total Steps ($2^n$) | LSB Voltage (at 3.3V $V_{ref}$) | Common Embedded Source |
|---|---|---|---|
| 8-bit | 256 | 12.89 mV | Original ESP32 internal DAC (GPIO 25/26) |
| 10-bit | 1,024 | 3.22 mV | STM32 / ARM Cortex-M internal DACs |
| 12-bit | 4,096 | 0.80 mV | Microchip MCP4725 (External I2C) |
| 16-bit | 65,536 | 0.05 mV (50 µV) | TI DAC8560 (Precision Industrial) |
| 20-bit | 1,048,576 | 0.003 mV (3.1 µV) | Analog Devices AD5791 (Metrology) |
Worked Numeric Example: Driving a Laser Diode
Suppose you are building a laser diode driver and need to output exactly 1.500V to set the bias current. You are using an external Microchip MCP4725 12-bit DAC over I2C, powered by a 3.3V reference.
The formula to find the required digital code is:
Digital_Code = (Target_Voltage / V_ref) * (2^n)
- Plug in the values:
(1.500 / 3.3) * 4096 - Calculate:
0.454545... * 4096 = 1861.81 - Since you cannot send a fractional binary code, round to the nearest integer: 1862.
- Verify the actual output:
(1862 / 4096) * 3.3 = 1.50019V.
Your error is 0.19 mV, which is well under the 0.80 mV LSB step size. This level of precision is impossible with standard PWM without complex analog filtering.
Internal vs. External DACs and the PWM Confusion
The most common mistake hobbyists make when searching for the definition of DAC is confusing a true DAC with Pulse Width Modulation (PWM). When you call analogWrite() on a standard Arduino Uno, you are not using a DAC. You are using PWM, which rapidly switches a digital pin between 0V and 5V. The average voltage changes based on the duty cycle, but the actual output is a harsh square wave. To get a smooth DC voltage from PWM, you must add an external RC low-pass filter, which introduces ripple, slow settling times, and high output impedance.
A true DAC, by contrast, outputs a steady, continuous DC voltage inherently.
The ESP32 Internal DAC Trap
The original ESP32 features two internal 8-bit DACs on GPIO 25 and GPIO 26, accessible via the dacWrite() function in the Arduino core. While convenient, 8-bit resolution yields 12.89 mV steps—far too coarse for precision sensor simulation or high-fidelity audio.
dacWrite() will fail silently or throw compilation errors on S3/C3 variants. You must use an external I2C/SPI DAC like the MCP4725 for modern ESP32 designs.
Where You Meet This in Practice
Understanding the definition of DAC is critical when your project leaves the digital domain and interacts with physical hardware. Here is where true DACs are mandatory in embedded design:
- Programmable Power Supplies: Setting the feedback node of a buck converter to dynamically adjust the output voltage. PWM ripple here will cause severe switching noise in your power rail.
- Analog Sensor Simulation: Testing an ADC (Analog-to-Digital Converter) or a legacy industrial PLC by feeding it a known, precise voltage generated by a DAC.
- Direct Digital Synthesis (Audio): Generating sine, triangle, or custom waveforms for synthesizers. While PWM can do basic beeps, true DACs are required for high-fidelity audio without severe harmonic distortion.
- Motor Control (Analog Input Drives): Many industrial VFDs (Variable Frequency Drives) and servo controllers accept a 0-10V analog control signal to set speed or torque.
Most basic DACs, including the MCP4725, have limited current drive capabilities (typically ~25mA) and a relatively high output impedance. If you are driving a low-impedance load (like a 50-ohm audio line or a heavy industrial relay coil), the voltage will sag. Always place a rail-to-rail op-amp (like the MCP6002 or LMV321) configured as a unity-gain buffer between the DAC VOUT pin and your load.
Troubleshooting DAC Circuits
When your DAC isn't behaving according to theory, use this decision path to isolate the fault:
Symptom: Output is stuck at VCC or GND, or reads 0.00V.
- Cause: I2C communication failure or incorrect address. The MCP4725 has a default I2C address of
0x60, but some breakout boards pull the A0 pin high, shifting the address to0x62or0x63. - Fix: Run an I2C scanner sketch. Verify your pull-up resistors (4.7kΩ) on SDA and SCL are present and tied to 3.3V, not 5V.
Symptom: Voltage sags significantly when a load is connected.
- Cause: Exceeding the DAC's internal output current limit or driving a load with impedance lower than the DAC's output impedance.
- Fix: Add an op-amp voltage follower (buffer) to the output stage.
Symptom: "Missing codes" or non-monotonic steps (voltage drops when the digital code increases).
- Cause: In internal R-2R ladder DACs, this indicates severe reference voltage noise, a failing component, or a ground loop injecting noise into the $V_{ref}$ pin.
- Fix: Decouple the $V_{ref}$ pin with a 100nF ceramic capacitor and a 10µF tantalum capacitor placed as close to the IC as possible. Ensure analog ground and digital ground are star-grounded at a single point.
Frequently Asked Questions
Can I just use a PWM pin with a capacitor instead of buying a DAC?
For basic tasks like dimming an LED or driving a slow-responding analog meter, yes. An RC filter (e.g., 10kΩ resistor and 1µF capacitor) will smooth PWM into a rough DC voltage. However, for audio, fast-changing waveforms, or precision metrology, the inherent ripple and slow settling time of filtered PWM will ruin your signal. Use a true DAC for those applications.
What is a Multiplying DAC (MDAC)?
Standard DACs use a fixed internal or external reference voltage. A Multiplying DAC allows you to feed an alternating or variable analog signal into the reference pin. The digital code then acts as a multiplier for that analog signal, which is highly useful in digital gain control and automated test equipment. Analog Devices provides excellent primers on MDAC architectures for advanced signal processing.
Does the DAC reference voltage affect accuracy?
Absolutely. The DAC's output is strictly a ratio of its reference voltage. If your 3.3V $V_{ref}$ is actually 3.25V due to a cheap voltage regulator, your maximum output will never reach 3.3V, and every step will be proportionally scaled down. For precision work, always use a dedicated, low-drift voltage reference IC (like the TI REF3033) rather than relying on the microcontroller's noisy internal 3.3V rail.






