www.learn.sparkfun.com: Wrong formula for ADC calculation

Hello,

In this link,

https://learn.sparkfun.com/tutorials/an … to-voltage

The formala and explanation are not correct.

The value of 2^resolution - 1 (1023) is used instead of the correct 2^resolution (1024)

Worst is that it pops up as the first google search result and then it is not correct.

Can someone here correct that perhaps?

Best regards

In addition, the assumption that the reference voltage is exactly 5.0V is extremely unlikely to be correct.

However, the error in dividing by 1023 instead of the correct value 1024 is probably smaller than assuming that the reference voltage is exactly 5.0V.

Most people don’t understand how a successive approximation ADC (as found in the typical MCU) actually works, and are confused by the fact that when presented with an input equal to the reference voltage, the ADC reports 1023 (for a 10 bit ADC).

What that report actually means is that the input voltage is greater than or equal to (1023/1024)*Vref.

I mentioned it because I am getting people arguing that 1023 should be used instead of 1024 and citing this here site as correct gospel.

It is not the only place where this error has been propagated either.

it is 1023… as zero is also included. Let’s use 2^3 as an example which is 8 steps/ values: 0, 1,2,3,4,5,6,7 . If it would count to 8 it would be 9 steps/values which is not correct. Same is true for 2^10.

If the ADC has 8 steps, divide by 8.

The same argument goes for using 1024, rather than incorrectly dividing by the maximum value of the count.

The math is really simple and obvious, once you understand how a successive approximation ADC works. Many people don’t.

If an 8 step successive approximation ADC reports “7”, the ONLY correct interpretation of that value is that Vin is equal to or greater than (7/8)*Vref.