# Calculate voltage of a 16-bit differential ADC that gives a two's complement value

I am working with a 16-bit differential ADC and I would like to know the difference between this latter and a single ended ADC especially: How to calculate voltage from the ADC value ?

Is it like this:

Voltage = IN- + Vref x Code/2^n-1


EDITED: According to the datasheet, the ADC gives a two's complement value. How to calculate voltage from this value ?

• Usually the output format is in 2's complement. – Long Pham Aug 9 '18 at 13:33
• From data sheet page 16: For example, the size of one LSB is equal to [(2 x VREF) / 2^n], which is 152.6 μV where n is 16 bits and VREF is 5V. And as LongPham has said, 2's complement format – glen_geek Aug 9 '18 at 13:55
• How to convert this 2's complement value to a voltage? – Pryda Aug 9 '18 at 14:29
• I edited my question – Pryda Aug 9 '18 at 14:57
• Note: your program doesn't need to know the voltage. Raw ADC values are fine for all purposes of writing a program. You only need to convert to volt if you plan to display the result to humans. Scaling internal data needlessly is a very common beginner bug. – Lundin Aug 10 '18 at 13:00

Differential or single ended has nothing to do with your conversion.

Differential: Voltage being converted to is (In+)-(In-)

Single Ended: Voltage being converted to is Vin

int16_t code=read_ADC();
float voltage=code*Vref/(2^16-1)


n bit devises the range to (2^n-1) "buckets", so each bucket is Vref/(2^n-1)

• (2^n -1) vs (2^n). Never-ending controversy ;) – Long Pham Aug 10 '18 at 4:05