When calculating the output of a digital to analog converter circuit, converting a mid-scale 12-bit digital code (2048) using a standard 5.0V reference yields exactly 2.500 V. The governing formula is V_out = V_ref × (D / 2^n). Substituting our values: 5.0V × (2048 / 2^12) = 5.0 × (2048 / 4096) = 2.500V. This baseline assumes an ideal voltage-output DAC with a stable reference and zero offset error.
The Code-to-Voltage Conversion Formula & Reference Table
The fundamental assumption that fixes your DAC output answer is the Reference Voltage (V_ref) combined with the bit-depth resolution (n). Without a known, stable V_ref, the digital code is just a ratio, not an absolute voltage. Furthermore, real-world DACs introduce Integral Non-Linearity (INL) and Differential Non-Linearity (DNL), meaning the actual silicon output might deviate by a few millivolts from the ideal mathematical model.
Below is a data-dense specification table for common DAC ICs used in embedded systems, showing how bit-depth and V_ref dictate the Least Significant Bit (LSB) voltage step—the smallest voltage change the circuit can physically produce.
| DAC IC Model | Interface | Resolution (n) | Typical V_ref | Total Steps (2^n) | LSB Voltage Step |
|---|---|---|---|---|---|
| Microchip MCP4725 | I2C | 12-bit | 5.0V (VDD) | 4,096 | 1.22 mV |
| Texas Instruments DAC8562 | SPI | 16-bit | 5.0V (Internal) | 65,536 | 0.076 mV (76 µV) |
| Analog Devices AD5686 | SPI | 16-bit | 3.3V (VDD) | 65,536 | 0.050 mV (50 µV) |
| Maxim MAX5500 | SPI | 12-bit | 5.0V (VDD) | 4,096 | 1.22 mV |
For a deep dive into selecting the right interface and resolution for your microcontroller, review the Texas Instruments DAC overview guide, which breaks down settling times and glitch energy across these architectures.
How Reference Voltage and Resolution Shift the Output
In AC power theory, calculating current shifts dramatically depending on whether you are working with 120V single-phase, 230V single-phase, or 400V 3-phase systems. However, a digital to analog converter circuit operates entirely in the low-voltage DC domain. Mains phase configurations are irrelevant here. Instead, the DAC output shifts based strictly on your DC reference rail (V_ref).
If we hold our 12-bit digital code constant at 2048 (mid-scale), here is how the analog output shifts across standard logic-level reference voltages:
- 3.3V V_ref:
3.3 × (2048 / 4096) = 1.650 V(Common for ESP32 and modern ARM Cortex-M boards) - 5.0V V_ref:
5.0 × (2048 / 4096) = 2.500 V(Standard for classic Arduino Uno and 5V logic systems) - 10.0V V_ref:
10.0 × (2048 / 4096) = 5.000 V(Used in industrial PLC analog output modules)
To understand the granular behavior around our target code, here is a table showing the ±20% neighboring range of code 2048 on a 5.0V, 12-bit DAC. This is critical when tuning PID control loops or audio bias networks where small code increments dictate system stability.
| Deviation | Digital Code (D) | Binary Representation | Calculated V_out (5V Ref) | Delta from Mid-Scale |
|---|---|---|---|---|
| -20% | 1638 | 0110 0110 0110 | 1.9995 V | -500.5 mV |
| -10% | 1843 | 0111 0011 0011 | 2.2498 V | -250.2 mV |
| Baseline | 2048 | 1000 0000 0000 | 2.5000 V | 0.0 mV |
| +10% | 2253 | 1000 1100 1101 | 2.7502 V | +250.2 mV |
| +20% | 2458 | 1001 1001 1010 | 3.0005 V | +500.5 mV |
When Digital-to-Analog Conversion Becomes Meaningless
While the math above is absolute, real-world bench conditions can render the theoretical code-to-voltage conversion meaningless. You cannot rely on the V_out = V_ref × (D / 2^n) formula under the following conditions:
- Current-Output DACs: ICs like the AD5541 or generic R-2R resistor ladder networks output current, not voltage. If you attempt to measure the voltage directly at the output pin without a transimpedance amplifier (op-amp with a feedback resistor), the voltage will float or sag based entirely on the input impedance of your multimeter or load. The conversion to voltage is meaningless until you define the feedback resistor value (
V_out = I_out × R_fb). - Floating or Noisy V_ref: If your DAC uses the microcontroller's VDD as its reference (like the MCP4725 on an Arduino powered via USB), a noisy 5V USB rail (e.g., oscillating between 4.8V and 5.1V) will inject that exact noise into your analog output. The digital code remains static, but the analog voltage drifts. For precision work, always use a DAC with a dedicated internal bandgap reference or an external precision voltage reference IC like the REF3033.
- Uncalibrated Offset and Gain Errors: In cheaper 8-bit or 10-bit DACs, the factory offset error can exceed 2 or 3 LSBs. If your LSB is 1.22 mV, a 3-LSB offset means your '0' code doesn't output 0.000V; it might output 3.66 mV. In high-gain analog front-ends, this baseline error gets amplified, ruining the conversion accuracy.
FAQ: DAC Circuit Edge Cases
Q: Why does my ESP32 internal DAC output a maximum of 3.3V when I send a code of 4095?
A: The original ESP32 (non-S3) features an internal 8-bit DAC, not 12-bit. The maximum code is 255, not 4095. Furthermore, the ESP32 internal DAC is non-linear and cannot reach the full 3.3V rail; it typically tops out around 3.1V to 3.2V due to internal transistor voltage drops. For true rail-to-rail 3.3V output, use an external I2C DAC like the MCP4725.
Q: Can I use a PWM pin and an RC low-pass filter instead of a dedicated DAC IC?
A: Yes, but with severe trade-offs. A filtered PWM signal acts as a crude DAC, but the output impedance is high, and the settling time is dictated by your RC time constant. If you need fast waveform generation (like audio or high-speed PID control), the RC filter will smooth out your steps into a sluggish curve. A dedicated DAC IC provides instant, low-impedance voltage steps. See the Adafruit MCP4725 tutorial for a direct comparison of PWM filtering vs. true I2C DAC implementation.
For further reading on the architectural differences between string DACs, R-2R ladders, and sigma-delta DACs, consult the All About Circuits DAC fundamentals guide. Always verify your final circuit with a true-RMS multimeter or oscilloscope to account for the physical realities of PCB trace resistance and load regulation.






