ADC resolution/conversion

Thread Starter

dmarciano

Joined Oct 10, 2007
21
I'm going to be using a 10-bit ADC on a PIC to measure voltages between 3.5 and below. I'm trying to calculate what value the PIC would return for various inputs assuming my reference voltages are +5V and 0V. If I understand correctly, in this situation 1 bit = 4.89mV. I got this from:

\(Resolution = \frac{Vref_{high}-Vref_{low}}{1024}\)

And if I wanted to know what value would be returned when measuring 3.5V it would be:

\(Value = \frac{3.5}{5} * 1023\)

In this case 716.1, so the ADC would return 716. Using the same equation for 3V (using the above equation) I get 613.8, so the ADC would return 614. Are my calculations correct? If not, what am I missing? Thanks in advance.
 

bretm

Joined Feb 6, 2012
152
AVR datasheets are clear that the multiplier would be 1024 instead of 1023 but the few PIC datasheets I've seen were unclear on that point. I would think it would be 1024, but unless 5mV matters then it's a minor point.

The form of the equation is right, though.
 

Thread Starter

dmarciano

Joined Oct 10, 2007
21
The 5mV won't make a difference, I just wanted to make sure I got the form of the equation correct. Thanks for the response...I appreciate it.
 

MrChips

Joined Oct 2, 2009
30,806
Just two minor points to note. A 10-bit ADC would have 1024 different voltage levels but the range is 0 to 1023. Hence the divisor is 1023.

Secondly, if your calculation gives 613.8, the ADC result will be 613, not 614. The ADC will truncate the result, not round.
 

jwilk13

Joined Jun 15, 2011
228
Just two minor points to note. A 10-bit ADC would have 1024 different voltage levels but the range is 0 to 1023. Hence the divisor is 1023.
Are you sure? I would think that the 1024 above when finding resolution is correct, and the 1023 when finding the value in the ADC are both correct. 1024 in the first because there are 1024 distinct steps, and 1023 in the second because that's the max value available.

I know this topic has recently been hotly debated elsewhere on these forums, and I'm not trying to stir up trouble...I'm just curious.
 

MrChips

Joined Oct 2, 2009
30,806
Take a simple example. Suppose you have a 2-bit DAC. There are four levels.
Suppose the maximum value is 3V.

Digital - Voltage
3 - 3V
2 - 2
1 - 1
0 - 0

The resolution = 3V/3 = 1V

not 3V/4 = 0.75V
 

Markd77

Joined Sep 7, 2009
2,806
From the PICmicro Mid-range MCU Family Reference Manual:
ww1.microchip.com/downloads/en/devicedoc/33023a.pdf
Other ADCs can have different transfer functions.

 

Attachments

WBahn

Joined Mar 31, 2012
30,058
Take a simple example. Suppose you have a 2-bit DAC. There are four levels.
Suppose the maximum value is 3V.

Digital - Voltage
3 - 3V
2 - 2
1 - 1
0 - 0

The resolution = 3V/3 = 1V

not 3V/4 = 0.75V
What would the mappings be? In other words, what range of voltages would map to an ADC output of 0? What range of inputs would map to 1, 2, and 3?

What divisor to use depends on the answer to this, which in turn depends on where the midpoints of the end bins, which in turn varies from ADC to ADC (with two common options).
 

MrChips

Joined Oct 2, 2009
30,806
Ok, I concede. If the maximum voltage were 4V then,

3 = 3 to 4V
2 = 2 to 3V
1 = 1 to 2V
0 = 0 to 1V

So the resolution = 4V/4 = 1V.
 
Top