0
\$\begingroup\$

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 ?

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Usually the output format is in 2's complement. \$\endgroup\$
    – Long Pham
    Aug 9 '18 at 13:33
  • 2
    \$\begingroup\$ 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 \$\endgroup\$
    – glen_geek
    Aug 9 '18 at 13:55
  • \$\begingroup\$ How to convert this 2's complement value to a voltage? \$\endgroup\$
    – Pryda
    Aug 9 '18 at 14:29
  • \$\begingroup\$ I edited my question \$\endgroup\$
    – Pryda
    Aug 9 '18 at 14:57
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Lundin
    Aug 10 '18 at 13:00
0
\$\begingroup\$

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)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.