ADC counts-to-voltage / LSB calculator

Enter codes as decimal, 0x hex or 0b binary. Voltages accept decimal or scientific notation, such as 3.3 or 3.3e0.

Solid steps: the code for each input voltage. Dashed: the ideal line. Shaded: the selected code's band. Dot: the selected code.

No valid result to draw.

Show the steps

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

Convert ADC counts to voltage, or a voltage to the expected count, from resolution and reference voltage, with the LSB size and code band.

How to use

Choose Counts to voltage or Voltage to counts.

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

Choose the LSB convention your datasheet or code uses, and Rounding or Truncation for how inputs map to codes.

Enter a code as decimal, 0x hex or 0b binary, or drag the code slider; or enter an input voltage.

Read the voltage or code, the LSB size and the band of inputs that give the code. The staircase shows the code and its neighbours.

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

Science

An analog-to-digital converter divides its input range into 2^N codes. One code step, the least significant bit (LSB), is the reference voltage divided by 2^N. A 10-bit converter with a 5 V reference has 1024 codes and an LSB of about 4.883 mV.

Each code stands for a band of input voltages, not a single voltage. With rounding, a code covers half an LSB either side of its nominal value, so an ideal reading is within ÂąÂ― LSB of the input. With truncation, a code covers one LSB above its nominal value.

Datasheets such as the ATmega328P state that the top code represents the reference minus one LSB. Some code divides by 2^N − 1 instead, so that the top code equals the reference. The two conventions differ by less than one LSB; choose the one that matches your firmware.

This calculator models an ideal single-ended unipolar ADC. It does not include offset, gain, linearity or noise errors, reference tolerance, input dividers, differential or two's-complement results, or averaging. For noise, SNR and effective bits use the ADC quantization, ENOB and SNR estimator; for converter outputs use the DAC code-to-voltage calculator.

Formulas

LSB size: LSB = VREF / 2^N, or VREF / (2^N − 1) with the full-scale-code convention. N is the resolution in bits and VREF the reference voltage in volts.

Code to voltage: V = k × LSB, where k is the code from 0 to 2^N − 1.

Voltage to code, rounding: k = floor(VIN / LSB + 0.5), limited to 0 â€Ķ 2^N − 1.

Voltage to code, truncation: k = floor(VIN / LSB), limited to 0 â€Ķ 2^N − 1.

Code band: Rounding: (k − 0.5) × LSB to (k + 0.5) × LSB. Truncation: k × LSB to (k + 1) × LSB.

Examples

10-bit, VREF = 5 V, code 512: 2.5 V. 1 LSB = 5 / 1024 = 4.88281 mV, and 512 × 4.88281 mV = 2.5 V. With rounding the input was between 2.49756 V and 2.50244 V.

12-bit, VREF = 3.3 V, code 4095: 3.29919 V. The top code is one LSB (805.664 ξV) below the reference. With the VREF / (2^N − 1) convention the same code reads 3.3 V.

10-bit, VREF = 5 V, input 1.234 V: Code 253 (rounding) or 252 (truncation). 1.234 × 1024 / 5 = 252.7232 LSB. Rounding gives 253; truncation gives 252.

12-bit, VREF = 3.3 V, input 3.3 V: Code 4095, saturated. 3.3 V is 4096 LSB, one more than the top code, so the ideal ADC saturates at 4095.

References

Microchip: ATmega328P datasheet, ADC conversion result

Texas Instruments: Understanding Data Converters (SLAA013)

BIPM: SI prefixes