# 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
• 2's complement is the standard way to represent a number that can go positive or negative. Just make sure the Voltage variable is a signed integer, and it will give you a positive/negative voltage. No conversion required. The formula you provided is correct. – Oliver Aug 9 '18 at 15:03

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