DAC code-to-voltage calculator

Enter codes as decimal, 0x hex or 0b binary. Voltages accept decimal or scientific notation; a bipolar target may be negative. Changing a unit reinterprets the number.

No valid result to draw.

Show the steps

Interactive calculation is unavailable until JavaScript loads. The formulas and reference information below remain available.

Calculate DAC output voltage from a digital code, or the nearest code for a target voltage, for unipolar or bipolar outputs.

How to use

Choose Code to voltage or Voltage to code.

Enter the DAC resolution in bits and the reference voltage with its unit.

Enter the output gain if an amplifier or a ×2 output stage follows the DAC; use 1 otherwise.

Choose Unipolar for a 0 V to VREF output or Bipolar for a ±VREF output with offset binary codes.

Enter a code as decimal, 0x hex or 0b binary, or move the code slider; or enter the target voltage.

Read the output voltage or nearest code, the output step and the remaining error. The staircase shows the codes around your result.

Use Copy result for a labeled summary. Reset restores the starting values.

Science

A digital-to-analog converter produces one of 2^N output levels. In straight binary coding each code adds one step of VREF / 2^N, so code D gives VREF × D / 2^N and the highest code is one step below the reference.

A bipolar converter with offset binary coding spans −VREF to +VREF. Code 0 gives −VREF, the middle code 2^(N−1) gives 0 V, and each step is 2 × VREF / 2^N. An output gain multiplies every level and every step.

To reach a target voltage, the calculator rounds to the nearest code. The remaining error is at most half a step, unless the target lies outside the output range, where no code reaches it and the nearest end code is shown instead.

Only the power-of-two convention is used, as DAC datasheets such as the MCP4725 state it. The ADC counts-to-voltage calculator also offers the VREF / (2^N − 1) convention.

Limitations: this is an ideal model. Real DACs add offset, gain and linearity errors, reference tolerance, output loading and settling time. Some parts use two's-complement codes for bipolar outputs; convert those to offset binary by inverting the most significant bit. For reading an ADC use the ADC counts-to-voltage calculator; for noise and effective bits use the ADC quantization, ENOB and SNR estimator.

Formulas

Unipolar output: VOUT = G × VREF × D / 2^N. D is the code, N the resolution, VREF the reference voltage and G the output gain.

Bipolar output: VOUT = G × VREF × (2 × D / 2^N − 1), with offset binary codes.

Output step: Step = G × VREF / 2^N for unipolar, 2 × G × VREF / 2^N for bipolar.

Nearest code: D = round(VT × 2^N / (G × VREF)) for unipolar, round((VT / (G × VREF) + 1) × 2^(N−1)) for bipolar, limited to 0 … 2^N − 1.

Examples

12-bit, VREF = 5 V, code 2048: 2.5 V. One step is 5 / 4096 = 1.2207 mV, and 2048 steps are half the reference.

12-bit, VREF = 2.048 V, gain 2, code 1000: 1 V. 2 × 2.048 × 1000 / 4096 = 1 V. The gain doubles the step to 1 mV.

4-bit bipolar, VREF = 5 V, code 0b1111: 4.375 V. Each step is 2 × 5 / 16 = 0.625 V. Code 15 is 5 × (30/16 − 1) = 4.375 V, one step below +5 V.

12-bit, VREF = 3.3 V, target 1.0 V: No exact code: code 1241 gives 999.829 mV. 1.0 × 4096 / 3.3 = 1241.21, which rounds to 1241. The output is 170.898 μV below the target, 0.2121 of a step.

8-bit, VREF = 5 V, target 5 V: No code reaches 5 V. The highest code, 255, gives 4.98047 V, one step below the reference, so 5 V is outside the output range.

References

Microchip: MCP4725 12-bit DAC datasheet

Texas Instruments: Coding Schemes Used With Data Converters (SBAA042A)

Texas Instruments: Understanding Data Converters (SLAA013)