When translating between the digital and analog domains using a standard 12-bit A/D converter and D/A converter on a 3.3V reference, a mid-scale digital code of 2048 converts to exactly 1.650 V, and the analog step size (Least Significant Bit, or LSB) is 0.805 mV. If you feed 1.650 V into the ADC, it returns a digital code of 2048. This direct conversion assumes an ideal, noise-free reference voltage ($V_{REF}$) and a perfect 12-bit resolution ($2^{12} = 4096$ total steps). The governing formula for the DAC output is $V_{out} = (Code / 2^n) \times V_{REF}$. Substituting our values: $V_{out} = (2048 / 4096) \times 3.3V = 1.650 V$. For the ADC, the reverse formula is $Code = (V_{in} / V_{REF}) \times 2^n$, yielding $(1.650 / 3.3) \times 4096 = 2048$.
The Core Assumptions That Fix Your Conversion
The math above only holds true if two physical assumptions are locked in on your workbench: your bit-depth ($n$) and your reference voltage ($V_{REF}$).
Many hobbyists mistakenly assume that a microcontroller's 3.3V or 5V VCC pin is a stable $V_{REF}$. It is not. VCC rails fluctuate with GPIO switching loads and USB brownouts. If your 3.3V rail sags to 3.2V under load, your 2048 DAC code no longer outputs 1.650 V; it outputs 1.600 V, introducing a 50 mV error across your entire system. For precision work, you must use a dedicated voltage reference IC (like the TI REF3033) or an ADC with an internal bandgap reference, such as the Texas Instruments ADS1115. When using a dedicated reference, the $V_{REF}$ variable in your formula becomes a fixed constant, isolating your conversion accuracy to the silicon's inherent quantization error and thermal noise.
Neighboring Values and Mains Voltage Shifts (120V/230V/3-Phase)
When designing control loops or sensor arrays, you rarely sit exactly at mid-scale. Below is a spec-sheet-style table showing the voltage output of a 12-bit DAC across a ±20% range of the 2048 mid-scale code (1638 to 2458), comparing a 3.3V logic-level reference against a 5.0V industrial reference.
| Digital Code (12-Bit) | Voltage Output (3.3V $V_{REF}$) | Voltage Output (5.0V $V_{REF}$) |
|---|---|---|
| 1638 (-20%) | 1.318 V | 1.999 V |
| 1843 (-10%) | 1.483 V | 2.250 V |
| 2048 (Mid-scale) | 1.650 V | 2.500 V |
| 2253 (+10%) | 1.815 V | 2.750 V |
| 2458 (+20%) | 1.979 V | 3.000 V |
Shifting to High-Voltage AC Mains
Unlike AC power calculations where shifting from 120V to 230V simply changes your current draw, applying 120V or 230V directly to an A/D converter will instantly destroy the silicon. To measure 120V or 230V AC mains with an ADC, the 'conversion' shifts from a direct DC voltage calculation to a scaled measurement using a Potential Transformer (PT) or a high-impedance resistor divider.
For a 120V RMS line (which peaks at ~170V), you must step it down to fit the ADC's 0-3.3V window, requiring a divider ratio of roughly 51:1. For 230V RMS (peaking at ~325V), your divider ratio must double to protect the input pin. In 3-phase systems, you aren't just converting one channel; you must sample three ADC channels simultaneously with precise phase-shift calculations (120° apart) to capture true power. Your simple DC voltage formula becomes a continuous RMS integration over time, requiring a high-speed ADC rather than a standard low-speed I2C module like the Microchip MCP4725.
When Bit-to-Voltage Conversion Becomes Meaningless
The formulas provided above become entirely meaningless in three specific bench scenarios:
- Unknown Power Factor (PF) in AC Systems: If you are using an ADC to calculate real AC power (Watts) from a sampled voltage and current, the voltage conversion is meaningless for determining actual work done if the Power Factor is unknown. You will only calculate Apparent Power (VA), leading to drastically undersized inverters or tripped breakers.
- Source Impedance Mismatch: ADCs use internal sample-and-hold capacitors. If your analog signal source has a high output impedance (typically >10kΩ), the internal capacitor cannot charge fully during the sampling window. The digital code returned will be artificially low, regardless of how perfect your $V_{REF}$ is. You must buffer high-impedance sensors with an op-amp before the ADC pin.
- Missing Codes and DNL Errors: In cheaper or damaged DACs, Differential Non-Linearity (DNL) errors mean that stepping the digital code from 2048 to 2049 might not yield exactly one LSB of voltage change. It might jump by 1.5 LSBs or stall entirely. When DNL > 1 LSB, your theoretical formula no longer maps to physical reality.
FAQ: A/D Converter and D/A Converter Long-Tail Questions
How does sampling rate affect the voltage conversion accuracy of an A/D converter?
Sampling rate (SPS) does not change the static DC voltage formula, but it dictates your AC accuracy via the Nyquist theorem. If you are sampling a 60 Hz AC waveform, you must sample at a minimum of 120 Hz, though practically you need 10x to 20x oversampling (1.2 kSPS+) to reconstruct the sine wave and calculate true RMS. Furthermore, pushing an ADC to its maximum rated sampling rate often degrades its Effective Number of Bits (ENOB) due to internal thermal noise and clock jitter, meaning a '16-bit' ADC might only give you 14 bits of usable, noise-free resolution at high speeds.
Why does my D/A converter output voltage droop under load?
DACs have an internal output resistance (often between 1kΩ and 10kΩ for basic I2C modules). If you connect a low-impedance load (like a 100Ω resistor or a raw motor coil) directly to the DAC output, it forms a voltage divider with the internal resistance, causing the physical output voltage to droop far below your calculated theoretical value. Always buffer a DAC output with a unity-gain op-amp or a MOSFET gate driver if the load draws more than a few milliamps.
Can I use the microcontroller's internal VCC as the VREF for precision A/D conversion?
You can, but you sacrifice precision. Using VCC as VREF means your ADC measures voltage as a *ratio* of the supply rail rather than an absolute value. If your USB supply fluctuates from 5.0V to 4.8V, your ADC reading for a fixed 2.5V input will shift, triggering false thresholds in your code. For applications like battery cell monitoring or precision temperature sensing, always use the microcontroller's internal 1.1V or 2.5V bandgap reference, or an external precision reference IC.






