Analog to Digital Converter (ADC)



An Analog-to-Digital Converter (abbreviated ADC, A/D or A to D), is an electronic device that converts an analog input to a digital Binary number. This is useful for measuring an analog value from a sensor with an digital device such as a Microcontroller.

How does an ADC work?
All ADCs work the same, they sample their input by discrete intervals. In other words, an the input is either attached onto the negative of positive input on a comparator (positive for positive input and negative for negative input) and the voltage in incremented by a set voltage until it is bigger than the input voltage.

This is where the resolution of the ADC comes to play, because the while the voltage is incrementing (positive input) or decrease(negative input) no one knows what the voltage is during this time, that is why you see, if the ADC has a low resolution you will see it resembling a funny square wave. If the ADC has a high resolution it will be able to interpret a the original signal almost perfectly.

This problem is called Aliasing.To avoid aliasing, the input to an ADC must be low-pass filtered to remove frequencies above half the sampling rate. This filter is called an anti-aliasing filter, and is essential for a practical ADC system that is applied to analog signals with higher frequency content. Although aliasing in most systems is unwanted, it should also be noted that it can be exploited to provide simultaneous down-mixing of a band-limited high frequency signal (see undersampling and frequency mixer).

Resolution of an ADC


As discussed before the ADC has a resolution. Resolution is basically how many bits the ADC is going to be converted to.

More bits = more Resolution. Say your Resolution is set to a 10 bit value, then your value that is going to be read is going to be a decimal number from (0 - 1023 (1024 distinct values)).

So if your analog reference (AREF) is set to 5v, if you Input a voltage >= AREF the value will be 1023. For more information on Resolution see ADC

Calculating the true analog input voltage
The true voltage can be calculated with the following  equations:
 * InputVoltage = (ADC Value *  AREF) / Resolution
 * ADC Value = (InputVoltage * Resolution) / AREF

For instance, if you have a 2.5V input, on an ADC with a 10 bit resolution (1024) and an AREF of 5v, the reading on the ADC would be 512 becuase 2.5v is half of 5v and half of 1024 is 512.


 * ADC Value = (2.5 * 1024) / 5
 * ADC Value = (2560) / 5
 * ADC Value = 512

ADC Implementation on a microcontroller
Most modern day microcontrollers have an ADC on-board. They may be implemented differently but they operate the same.