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.

analog sampling

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:

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:

ADC example tmp36

Simulate this circuit

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:

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.

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:

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:

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // 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:
  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”.




Check Also

CD4013 pinout

CD4013 Dual D Type Flip Flop | Datasheet

The CD4013 is an integrated circuit consisting of two D-type flip-flops. It has a number …

Leave a Reply

Your email address will not be published. Required fields are marked *