Analog to digital converter. 8 output bits. 256 or 255 divisions of input voltage?

Thread Starter

WilkinsMicawber

Joined Jun 5, 2017
29
For a digital lab we used an analog to digital converter to represent a variable voltage as a binary number. The range of output values are between binary 0 and binary 255. These are 256 different binary values. I'm reading that you divide the input voltage by 256 to find the voltage per step. If 0 binary is 0v and 255 is max, shouldn't the input voltage be divided by 255, since the voltage will only get stepped up from zero 255 times? I don't understand why i'm dividing the max voltage by 256, when there are only 255 steps off of zero.
 

WBahn

Joined Mar 31, 2012
26,398
Good question... and good that you are questioning it.

One thing that you need to be clear on is what this "input voltage" is that you are talking about. The input voltage is usually taken to be an unknown voltage that you want to measure.

Are you sure you aren't talking about the reference voltage?

Your line of thinking is reasonable, but it may not match the real world. There is nothing that prevents the designer of an ADC from taking the reference voltage and treating it as the voltage that should produce a value of 256 (not the max value of 255). They might do this specifically to make things easier for the user to work with. They might do it because it is simpler to implement things that way.

You might go look at a few datasheets for some real ADCs and what you will note is that it is a very common convention to have the step increment be the reference range divided by 2ⁿ where n is the number of bits.
 

OBW0549

Joined Mar 2, 2015
3,566
If 0 binary is 0v and 255 is max, shouldn't the input voltage be divided by 255, since the voltage will only get stepped up from zero 255 times?
No.

Zero binary is not zero volts; it is zero volts up to 1/256 of Vref. Digital 1 is from 1/256 of Vref up to 2/256 of Vref. Digital 2 is from 2/256 of Vref up to 3/256 of Vref. And so on, up to digital 255, which goes from 255/256 of Vref up to Vref (and all values higher, in most ADC designs).

There are 256 steps, not 255.

I don't understand why i'm dividing the max voltage by 256, when there are only 255 steps off of zero.
Each step is Vref/256, not Vref/255.
 

WBahn

Joined Mar 31, 2012
26,398
If the bin edges are at k*lsb, then that introduces a bias in the data, which is undesirable.

Every (unipolar) n-bit ADC I've worked with (which isn't all that many) put the center of the kth bin at

Vin(k) = k * (Vref/2^n) = k*(1 lsb)

With the lower and upper edges being 0.5 lsb away from it except for the bottom bin, which starts at 0.0 V (though lower voltages will return this code as well).

So the bottom bin is from 0.0 V to 0.5 lsb and is thus only half an lsb wide. The top bin has a lower limit of Vref - 1.5 lsb.

This is the first ADC datasheet a search pulled up:

http://cds.linear.com/docs/en/datasheet/10968fc.pdf

See page 18.
 
For a digital lab we used an analog to digital converter to represent a variable voltage as a binary number. The range of output values are between binary 0 and binary 255. These are 256 different binary values. I'm reading that you divide the input voltage by 256 to find the voltage per step. If 0 binary is 0v and 255 is max, shouldn't the input voltage be divided by 255, since the voltage will only get stepped up from zero 255 times? I don't understand why i'm dividing the max voltage by 256, when there are only 255 steps off of zero.
In addition to what has been posted here, you may want to read an old thread

Why ADC/1024 is correct, and ADC/1023 is just plain wrong!

I think that discussion was very informative and I bookmarked it.
 

MrAl

Joined Jun 17, 2014
8,545
Hi,

The main point i think is that the top end is not really the top end, it's a little less than the top end voltage. The simplest example is a 1 bit ADC, then a 2 bit ADC after that, etc.

A 1 bit ADC has zero volts just like any other, and it will read 0 for Vin of 0 to 1/2, and read 1 for 1/2 to 1.
A 2 bit ADC has the following character:
0.00 to 0.25: 00 (0)
0.25 to 0.50: 01 (1)
0.50 to 0.75: 10 (2)
0.75 to 1.00: 11 (3)

and why is that? That's because the highest voltage threshold is 0.75v assuming a successive approximation or flash type ADC. So if we see a count of 2 and we divide that by 4 we get 0.50 which is valid up to 0.74v.
Some ADC's have a slight bias though, so not all will be exactly like this, but that's the main point and so we have to divide by N+1 where N is the max count.
 
Top