# Analog and Digital Conversion/Resolution and Bitrate
## Ideal Resolution

The resolution of a sampler is the number of bits that are used to represent each signal. For instance, a 12-bit sampler will output 12 bits of data for every sample. This means that there are 2$^{12}$ possible digital values that each sample can be converted to. In general, the more bits of resolution, the better (more faithful) the digital signal will be to the original. The resolution, n, is related to the number of steps, m, by the following formula:
    $2^{n}=m$

### Unipolar and Bipolar

Samplers come in two basic varieties: unipolar and bipolar. Basically, unipolar samplers only take positive values, and only output unsigned digital values. Bipolar converters can take positive and negative values, and output signed digital values. It is important to note that bipolar converters are generally symmetrical. That is, they have the same number of bits for expressing negative and positive numbers.

### Sample Range

The range of possible samples is dependent on a number of factors, including the signed/unsigned number scheme in use by the converter, the resolution, and the step size.

#### Step Size

    The step size of a sampler is the range of analog values that can be input before a bit is changed in the sampler. The step size (Δ) is given by the range (R) divided by the number of steps (m):
    $\Delta ={\frac {R}{m}}$
The range of the sampler, R, is given by the difference between the minimum value, and the maximum value:
    $R=V_{max}-V_{min}$
However, bipolar converters are generally symmetric. That is, they have the same amount of range below zero as they do above zero. If we want a converter that goes from −5V to +25V, we are going to need to get a converter that can handle from −25V to +25V, which means we are wasting at least 2/5ths of the possible range of the device.

## Example

For instance, let's say that we have a converter that only takes positive values (nothing below 0 volts), and we have a resolution of 2 bits. Also, we want to be able to handle all input values up to and including 10 volts. This means that our range is from 0 volts to 10 volts:
    $R=10-0=10$
With 2 bits of resolution, we have a total number of steps of:
    $m=2^{2}=4$
And we have a step size of:
    $\Delta ={\frac {10}{4}}=2.5$
This means that the following analog values produce the following digital output patterns:
* 0V <= V < 2.5V → 00
* 2.5V <= V < 5.0V → 01
* 5.0V <= V < 7.5V → 10
* 7.5V <= V <= 10.0V → 11

## Non-Ideal Resolution

As discussed above, the ideal resolution for a given AD converter is straightforward to compute. In practice, noise impacts the usable resolution that is available to us. Noise will be discussed in a future chapter in more detail, but we will only need a summary of these impacts to resolution for now.

### Noise Impacts on Resolution

Noise exists in various parts of the system, ranging from the input signal source, crosstalk onto the input signal from the environment, the voltage reference used by the ADC, and even the thermal noise inherent to resistors. Noise can be a random or patterned distortion that is superimposed on top of the desired signal. This noise is then read by the ADC, thereby reducing the accuracy of the ADC. Accuracy is reduced, because the actual signal's value that we care about when the ADC takes a sample is distorted by noise. The ADC then quantizes this distorted signal.
There are various methods to increase accuracy, at the expense of other performance metrics, but let's review the ways that non-ideal resolutions can be calculated. Three primary measures are often used when discussing an ADC in practice. They are Effective Resolution, Noise-Free Resolution, and Effective Number of Bits (ENOB).

### Effective Resolution

Effective resolution is used as a performance metric when the input waveform is DC. This situation would be encountered if you deployed a sensor that measured the hydraulic brake pressure on an automobile. These sensors typically convert a hydraulic pressure to a voltage or current output. While the output voltage will surely vary over time as the brake pressure builds and releases over a drive cycle, assume for now that the rate of change of the sensor's output voltage will be so significantly small compared to the sampling rate of the ADC that the input signal will appear essentially as DC.
Effective resolution is calculated by taking a ratio of the full-scale input voltage range by the ADC's RMS noise:
$Effective\,Resolution=\log _{2}{\frac {V_{IN}}{V_{RMS\,NOISE}}}$

### Noise-Free Resolution

Noise-free resolution is also used as a performance metric when the input waveform is DC. Consider a similar situation as described above for effective resolution. Assume you wanted to present the brake pressure reading onto a display for the driver to read. You may not want the brake pressure display to fluctuate or flicker while the vehicle is in park. In this case, you would like to consider what your "Noise-free" or "Flicker-free" resolution is. Flickering of LSBs can occur due to noise, but digital signal processing can remove this effect. However, the usable resolution of the ADC is reduced. How much resolution are you left with in that situation?
Noise-free resolution is calculated similarly to effective resolution, however the full-scale input voltage range is divided by the peak-to-peak noise, not the RMS:
$Noise\,Free\,Resolution=\log _{2}{\frac {V_{IN}}{V_{Pk-Pk\,NOISE}}}$

### Effective Number of Bits (ENOB)

Effective Number of Bits (ENOB) is used when the ADC input is an AC signal. ENOB takes into account not only the noise that is superimposed on the desired signal but also the distortion inherent to AC signals. These "spurious" signals show up in a spectrum analysis (typically performed by FFT) outside of the fundamental range. Harmonics are a subset of spurious signals, and they have a frequency that is a multiple of the fundamental frequency. The parameter that describes the performance of an ADC considering both total harmonic distortion (THD) (these spurious signals previously mentioned) and the signal to noise ratio (SNR) is called the Signal-to-Noise Ratio and Distortion (SINAD).
Sometimes SINAD is provided on the datasheet, but you may need to measure and/or calculate it. Measuring SINAD involves performing an FFT analysis on a near-full scale sinusoidal input to the ADC. The FFT analysis allows you to pull out both the noise and distortion components and compute the ratio between the RMS of the input voltage to the RMS of the noise & distortion components.
$SINAD=-10\times \log _{10}{\biggl10^{\tfrac {-SNR}{10}}+10^{\tfrac {THD}{10}}{\biggr )}$
$SINAD={\frac {RMS\,input\,voltage}{RMS\,noise\,voltage}}$
$ENOB={\frac {SINAD-1.76db}{6.02}}$

## Bit rate

The number of bits created per sample, times the sampling frequency, gives us the rate at which we are producing data bits. This rate is called the bit rate, and is frequently denoted as r$_b$, or simply r.
If we have a sampling time of T seconds, then the bit rate and the resolution are related as such:
    $r_{b}={\frac {n}{T}}$
Where r is measured in units of bits/second, T is measured in seconds, and n is measured in bits.

## Bandwidth

Bandwidth, denoted with a W, is the frequency range needed to transmit an analog or digital signal. This isn't directly related to the topic at hand, but is included for completeness. For more information about bandwidth, see Signals and Systems or Communication Systems. This text may use bandwidth as a constraint in example problems, but will not discuss it in any depth beyond this simple section.
Bandwidth is related to the bit rate as follows:
    $W=2r_{b}$
This is for a bare, unmodulated bit stream. This value can change depending on what modulation scheme is used, if any.

## References

* 1 2 ADC Signal-to-Noise Ratio and Distortion (SINAD) - Developer Help (microchipdeveloper.com)
* 1 2 Understanding Noise, ENOB, and Effective Resolution in Analog-to-Digital Converters | Analog Devices
* ↑ ADC Accuracy Part 1: Is accuracy different from resolution? - Precision Hub - Archives - TI E2E support forums