ADCs ( Analog to Digital Converts ) find their application almost everywhere, ranging from our cell phone to rocket science. The world that we perceive is basically analog in nature, and when we need to capture these worldly changes and process them with our digital world, ADCs come in handy. Almost all sensors make use of ADCs, to bridge the gap between the digital and analog world. The sensors in our mobile phone like the accelerometer, gyro sensor, magnetometer, ambient light sensor etc have ADC in them. These sensors use electro-mechanical systems, or

The sensors in our mobile phone like the accelerometer, gyro sensor, magnetometer, ambient light sensor etc have ADC in them. These sensors use electromechanical systems, or electrochemical systems to convert mechanical or chemical changes into an equivalent electrical signal in the form of voltage. The ADC senses the voltage level and gives a binary output. Performing reverse calculations on this digital value gives us the actual value of the analog signal.

## What is ADC?

Analog to Digital Converter, as the name suggests is a device/circuit that converts analog signals (continuous) to digital ones (discrete) i.e. 1’s and 0’s. ADC provides a link between the analog world of sensors and transducers and the digital world of signal processing and data handling. Earlier ADC modules had to be integrated separately with the microcontroller circuit, but modern day controllers have on-chip ADCs with multiple channels (thanks to the advancement in VLSI designs). Microcontrollers commonly have 8, 10, 12 or 16 bit ADCs.

What are bits in ADC?

ADC bits are actually the number of bits in the output data from the ADC. An 8, 12, 16 or 24 bit ADC will convert the analog signal into a discrete time-based data which will have 8, 12, 16 or 24 bits respectively. To know more about ADC bits, I highly recommend you to view this post.

## Process

Conversion process involves 2 steps:

- Sampling and Holding (S/H):
- Quantising and Encoding (Q/E)

## Sampling and Holding (S/H)

To convert a continuous signal into a discrete one, a sample and hold circuit is used. But why convert it to discrete? Our computers, however fast and continuous they may seem, are discrete in nature. They work on clock pulses at very high frequencies in MHz and GHz. So it is necessary to convert natural continuous signals into sample based ones so that the computer systems can easily process the fluctuating signal at particular intervals.

As shown in the image above, S/H is represented using a switch in series and a capacitor connected to ground in parallel. The switch is closed (sample) as per the sampling frequency creating samples(discrete) of a continuous waveform. The **sampling frequency** or **sampling rate, f _{s},** is the average number of samples obtained in one second (

*samples per second*). Or in other words, it’s the speed at which samples are taken. When the switch closes, the input signal in the form of voltage is stored temporarily (hold) on the capacitor resulting in a holding circuit.

What frequency should we prefer? Visit next post.

## Resolution of ADC

Before understanding Q/E, let’s understand what ADC resolution is. Resolution tells us about the depth of information contained in something. Incase of our mobile or television screens, resolution tells us about now densely the pixels are arranged and how detailed the displayed image will be. Similarly in the context of analog converters, resolution tells us about how detailed the captured signal will be.

**Resolution can be expressed in terms of bits as well as in terms of voltage.** But to avoid confusion certain documents prefer resolution in terms of bits and the term ‘voltage step’ or ‘step size’ for denoting resolution in terms of voltage.

**Voltage step: **Δ** = V _{ref }/ 2^{n}**

Where,

**Vref **= Reference voltage, it is the range across which the voltage measurement is to be made. (Vref= Vmax-Vmin)

**n** = ADC resolution in bits.

** **In simple terms, Resolution is the smallest change in an analog signal that will result in a change in the digital output.

Let’s take an example of an 8-bit ADC, that can convert values from 0V to the 8V. This voltage range is divided into ( 2^{n} , n=8, therefore, 2^{8 }=) 256 values, or steps. The step size for such ADC would be:

Δ** = **8V/256 = 0.03125V or 31.2mV

Wait a minute, is the step size formula

**Voltage step = Vref _{ }/ 2^{n } or Voltage step = Vref_{ }/ 2^{n}-1^{ }?**Visit my next post to know more.

## Quantising and Encoding

**Quantizing** is the process which involves partitioning the reference signal range into a number of discrete quanta and then matching the input signal to the correct quantum.

Let’s take another simple example of a 3-bit ADC, with reference voltage range from 0V to the 8V. This voltage range is divided into ( 2^{n} , n=3, therefore, 2^{3}=) 8 values, or steps. The step size for such ADC would be:

Δ** = **8V/8 = 1V

so the quantization would be like

0 < Vin < 1 = 0Δ = 0V

1 < Vin < 2 = 1Δ = 1V

2 < Vin < 3 = 2Δ = 2V

3 < Vin < 4 = 3Δ = 3V

4 < Vin < 5 = 4Δ = 4V

5 < Vin < 6 = 5Δ = 5V

6 < Vin < 7 = 6Δ = 6V

7 < Vin < 8 = 7Δ = 7V

So any value between 0 and 1 would take value 0, similarly input value between 1 and 2 will take value 1 and so on. If you notice, even a 0.9V signal will be interpreted as 0V because of quantization. This error is called the quantization error. The topic has been covered in the next post.

**Encoding** is assigning a unique digital code to each quantum, thereby allocating the digital code to the input signal. The image below elucidates the concept.

The whole process of A/D conversion can be easily understood by understanding the waveform after each stage. Here a 3 bit ADC sensing a signal ranging from 0-5 V is assumed.

In the image above, the signal denoted by the orange line is the sensed signal and the blue line denotes the actual signal. We can see the quantization error evidently here as the ADC has a resolution of 3 bits only. In a practical case, we generally use 8, 12 or 16 bit ADC, where this quantization error is diminished drastically.

## Accuracy of A/D conversion

The accuracy of A/D conversion can be improved by two ways:

- By increasing the resolution which improves the accuracy in measuring the amplitude of the analog signal.
- By increasing the sampling rate which increases the maximum frequency that can be measured.

As we can see in the image, increasing the resolution gives a finer scale along the y-axis making the voltage step size smaller. This allows more **precise sensing** of the input signal. Increasing the sampling frequency allows the ADC to sense signals at a faster rate, thus making it possible to **capture smaller changes** along the x-axis, i.e. time.

## Unipolar and Bipolar ADC

In the examples covered until now, we have used **unipolar converters**, whose analog port has only a single polarity. These are the simplest type, but **bipolar converters** are generally more useful in real-world applications. There are two types of bipolar converters: the simpler is merely a unipolar converter with an accurate 1 MSB of negative offset (and many converters are arranged so that this offset may be switched in and out so that they can be used as either unipolar or bipolar converters at will), but the other, known as a **sign-magnitude converters** are more complex, and have n bits of magnitude information and an additional bit which corresponds to the sign of the analog signal. Sign-magnitude DACs are quite rare, and sign-magnitude ADCs are found mostly in digital voltmeters (DVMs). The **unipolar, offset binary and sign-magnitude** representations are shown in the image above.