Home / Circuits / Analog to Digital Conversion Calculator

# Analog to Digital Conversion Calculator

### Analog to Digital Conversion Overview

Microcontrollers are essentially computers. And like computers, they only understand two numbers: a 1 and a 0. So when a microcontoller needs to read a quantity with varying numbers in a period of time (a.k.a. analog), an analog-to-digital conversion is necessary.

An ADC (analog-to-digital) converter takes samples of an analog signal at equal intervals of time. These samples are used to create a digital representation of the analog signal. Another term for this process is quantization.

Moreover, an ADC has a step size or resolution, which is a representation of the smallest quantity it can detect. Resolution is often given as the number of bits. The higher the number of bits, the higher is the likeness of the digital representation to that of the original analog signal.

There’s a signed ADC and an unsigned ADC. The difference between the two is that the later considers negative quantities. However, microcontrollers can’t read negative values, hence we are only concerned with unsigned ADC. The resolution for an unsigned ADC is:

$ADC_{res} = \frac{V_{ref +}-V_{ref -}}{2^{N+1}}$

Here, Vref+ and Vref- are positive and negative voltage references, respectively. In microcontrollers, Vref- is 0 V and Vref+ is programmable but equal to the source voltage by default. N is the number of bits of the ADC which is often constant for a particular microcontroller.

### Practical Examples

A TMP36 is a temperature sensor that gives out 10 millivolts per degree Celsius. We can connect this sensor to an Arduino’s analog pin as shown:

With knowledge on ADC, we can convert the reading into temperature. The analogRead() function returns the converted voltage from the sensor. To acquire the voltage, we use:

$volts = ADC_{value} * \frac{V_{ref}}{2^{N} - 1}$

Here, ADCvalue is the the value from analogRead(), Vref is 5 V (default) and 2N-1 is equal to 1023, with N = 10.

Once the voltage is known, the temperature is now solvable, also considering the 500 mV offset for the TMP36.

$temperature = \frac{(voltage - 0.5)}{10\: x\: 10^{-3}}$

The denominator in the above equation is the 10 mV per degree C resolution of the TMP36. Note that 10 x 10-3 = 1/100, hence, a simpler formula is:

$temperature = (voltage - 0.5) \: x \: 100$

Finally, the Arduino code/sketch below prints out the temperature reading of the TMP36 on the serial monitor:

```void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

void loop() {
// read the input on analog pin 0:
// convert the input to voltage
float volts = (sensorValue * 5.0)/1023.0;
// convert voltage to temperature
float temperature = (volts - 0.5) * 100;
// print out the converted value:
Serial.println(temperature);
delay(1); // delay in between reads for stability
}```

### Analog to Digital Converter Calculator

This online calculator will compute the minimum and maximum ADC values. Place the sensor minimum and maximum voltages, the reference voltage and the ADC resolution then click “Compute”.

## Using Single-Supply Op-Amps for Microcontroller Projects

An application note on how to implement an embedded system circuit with single-supply operational amplifiers. …