Analog-Digital: Conversion Theory

When working with A/D or D/A, the first question is what analog voltage corresponds to what digital value. The answer to this question depends on many factors. On the analog side, it depends if the conversion is single-ended or in differential mode. On the digital side, it depends on if the digital output is signed or unsigned. Regardless of these options, one essential question helps us convert digital values to analog or vice-versa. The question is this: How much the LSB, or the smallest digital step, is worth in terms of an analog value. If we know the answer to this question, we can do any other conversion based on that. To answer this question, we should look at the analog range and the number of digital labels. To start, let us assume we are working with a single-ended conversion and unsigned digital values. With n bits, we have 2^n digital labels. These labels should cover from the bottom of the analog range, the negative reference voltage (Vref-), to the top of the analog range, the positive reference voltage (Vref+). Since the relationship between analog and digital values should be as linear as possible, we divide this analog range equally between the digtal labels. 

1LSB  = (Vref+ - Vref-)/ (2^n) 

1LSB is also called LSB voltage or voltage resolution. This is essentially how much voltage is represented by an increase of 1 in the digital domain. Similar to how 2.54 centimeters is equivalent to 1 inch, the LSB voltage is how many volts would be equivalent to 1 digital increment.

Let’s define Vanalog as an analog voltage and D as a digital value corresponding to it. If Vanalog is greater than Vref+ - 1LBS , we say the output is satuarated. In this case, D assumes the maximum digital value of 2^n - 1. Oppositely, if Vanalog is lower than Vref- (thus Vanalog is less than the lower bound of our domain), then D assumes the minimum digital value of 0.

If Vanalog is in our domain, however, then we can manipulate the conversion factor to get our desired value. Based on the same linear relationship property, we can say D when compared to the digital range, 2^n should have the same proportion as analog voltage when compared to the analog range. Note that for both Vanalog and Vref+, their amplitude is compared to Vref-

D/ (2^n) = (Vanalog - Vref-) / (Vref+ - Vref-)

If we are converting from digital to analog, then, the formula turns into this:

Vanalog = D * 1LSB + Vrerf-

This means, if we wanted to convert a digital value D to an analog value Vanalog, then the first step is to multiply D by the 1LSB. This will give us an analog value, but not quite Vanalog. The reason for this is because we have to take into account the offset created by the lower bound of the analog domain. In simple terms, when D is the lowest digital value, 0, the Vanalog should be the lowest analog value, which is Vref-

If we are converting from analog to digital, then the formula turns into this:

D = (Vanalog - Vref-)/ 1LSB 

Although this is a reasonable assumption, what would happen if the result is a rational number? D is limited to only integers, so it cannot be equivalent to a rational number. When we encounter this issue, we usually round the number to the nearest integer or use the floor, or ceiling. Regardless of what choice we pick, some error is created due to digitization. Different designs might use different methods for this step.

D = (Rounded, ceiling or floor of ) ((Vanalog - Vref-)/ 1LSB)