0
\$\begingroup\$

I am having problems with this ADC. Here is the datasheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/22072a.pdf

I connected it in Single-Ended Input, so I have 15-bits from 0v (0x0000) to 2.048v (0x7FFF).

According to the page 8 of the datasheet, the output code is (max code + 1)*((Vin+ - Vin-)/2.048)

So if I measure 0.994v (Vin+ - Vin-) I should get 15904 (decimal), but I get 7957 instead. This rule of the "half part" is always true.

Any idea of what I am doing wrong?

Thank you.

\$\endgroup\$
4
  • \$\begingroup\$ What microcontroller are you reading it with? Maybe there's a code problem. If it's always half what you expect, perhaps you're simply not reading the final bit so everything is shifted left one place (i.e. divided by two). The datasheet says the MSB is a sign bit, which is an additional bit. \$\endgroup\$ Commented Feb 17, 2015 at 13:05
  • 1
    \$\begingroup\$ I feel stupid now. The data is read over i2c so the first byte you get are the most 8 significant bits, and then the 8 less significant ones. I was reading it with this: int ADC = (buff[0]<<7) + buff[1];. Obviously its "(buff[0]<<8)". Sorry for the dumb question, and thank you! \$\endgroup\$
    – zapeitor
    Commented Feb 17, 2015 at 13:34
  • \$\begingroup\$ No worries, it's not a dumb question. You should write your own answer and accept it ! :) \$\endgroup\$ Commented Feb 17, 2015 at 13:52
  • \$\begingroup\$ @zapeitor Well, the only reason I suggested it was because I've done the same thing myself. Dumb and dumber .... ;-) \$\endgroup\$ Commented Feb 17, 2015 at 14:07

1 Answer 1

1
\$\begingroup\$

I figured it out and as pikafu suggested I'll answer the question. I was reading the ADC badly. The 16-bit code is read over i2c with this structure: [15...8] [7...0] [config byte]. I was using this code to read it:

ADC = (buff[0]<<7) + buff[1]

And obviously, as Roger Rowland helped me to notice, it's wrong. This is the correct code:

ADC = (buff[0]<<8) + buff[1]
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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