TactivergeLite

Lite / Building Machines That Respond / Week 22

ADC counts, quantisation and noise

A 10-bit ADC says 512. A 12-bit one says 2048. Are they measuring the same voltage?

About 35 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

Every analog sensor reading passes through an ADC, and most sensor bugs are really unit-conversion bugs. Two formulas and one idea (a step) let you read any ADC datasheet and know exactly how finely your machine can sense the world.

Predict

A 10-bit ADC with a 3.3 V reference reads 512. Roughly what voltage is that?

  1. 0.512 V
  2. 1.65 V
  3. 3.3 V
  4. 512 V
Guess first, then reveal

A 10-bit ADC has 2¹⁰ = 1,024 counts. 512 is half of 1,024, so the voltage is half of 3.3 V: **1.65 V**. A 12-bit ADC (4,096 counts) would report 2,048 for the same voltage.

Discover

Hold the temperature at 21.5 °C and step the ADC from 4 to 12 bits. Watch the count, the binary lamps and the temperature the firmware recovers. At how many bits does the error drop below 0.5 °C?

What the interactive shows (text version)

The pipeline diagram shows five stages: the real temperature; the sensor output (500 mV + 10 mV per °C); the ADC count, also shown as binary digits; the voltage firmware calculates back (count × reference ÷ 2^bits); and the temperature firmware calculates. Changing the bits from 4 to 12 makes the steps smaller, so the recovered temperature gets closer to the real one, always within one step.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Listen for how resolution and full-scale range are defined, then compare them with the formulas in this lesson.

Explains how an ADC turns a voltage into a number, and what resolution and full-scale range mean.

“ABCs of ADCs - What is an Analog to Digital Converter (ADC)” by Microchip Technology, Inc. (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Counts and steps

An ADC compares the input with a reference voltage and reports a whole number, a count. More bits give more counts and finer steps: 8 bits = 256 steps, 10 bits = 1,024, 12 bits = 4,096. With a 5 V reference, an 8-bit step is 5 ÷ 256 ≈ 19.5 mV; a 12-bit step is about 1.22 mV. Some datasheets divide by 2ⁿ − 1 instead; the difference is under one step, but check your chip.

Quantisation is rounding

The ADC cannot report 310.3; it reports 310. That rounding is quantisation: the staircase in the signal lab. Its error is always smaller than one step, and it is the same for every reading, so you can state it in advance: '±1 step, which is 0.32 °C for this sensor'.

When noise beats bits

Real signals carry noise. If the noise wiggles by 10 mV and your step is 0.8 mV, the last few bits just record the noise: extra resolution buys nothing. Then it is better to average several readings or filter the signal. Choose bits so the step is a little smaller than the noise and much smaller than the changes you care about.

Explain it another way

Intuitive

An ADC is a ruler with marks. Bits decide how many marks; the reference decides how long the ruler is. A shaky hand (noise) makes very fine marks pointless.

Technical

Real ADCs add offset, gain and nonlinearity errors and have an effective number of bits (ENOB) lower than the nominal count because of noise. Firmware often converts in integer millivolts: multiply before dividing to keep precision.

Mathematical

step = Vref/2ⁿ; V = c·Vref/2ⁿ; c = ⌊V·2ⁿ/Vref⌋ (capped at 2ⁿ − 1); resolution in physical units = step ÷ sensor slope.

Applied

A battery monitor with a 12-bit ADC and a 3.3 V reference sees 0.8 mV steps, plenty to track a battery draining from 4.2 V to 3.0 V (through a voltage divider) over a day.

Derivation: ADC resolution and conversions
  1. An n-bit ADC has 2ⁿ possible counts, from 0 to 2ⁿ − 1. 10 bits → 1,024 counts (0–1,023).

  2. It shares the reference voltage between them, so one step (1 LSB) is step = Vref ÷ 2ⁿ. 3.3 V, 10 bits: 3.3 ÷ 1,024 ≈ 3.22 mV.

  3. Count to volts: V = count × Vref ÷ 2ⁿ. Count 310 → 310 × 3.3 ÷ 1,024 ≈ 0.999 V.

  4. Volts to count: count = floor(V ÷ Vref × 2ⁿ). 1.00 V → floor(310.3) = 310. Every voltage in the same step gives the same count.

  5. So the stored value can be up to one step below the truth (this lesson's ADC rounds down): that is quantisation error.

  6. In sensor units: with a 10 mV/°C sensor, one 3.22 mV step is 0.322 °C. Each extra bit halves the step.

Worked example 1

A TMP36-style sensor (500 mV + 10 mV/°C) feeds an 8-bit ADC with a 5 V reference. It reads 38. What temperature is that, and how finely can this system measure?

V = 38 × 5 ÷ 256 ≈ 0.742 V = 742 mV. T = (742 − 500) ÷ 10 ≈ 24.2 °C. Step = 5 ÷ 256 ≈ 19.5 mV ≈ 1.95 °C: far too coarse for a greenhouse. A 10- or 12-bit ADC, or a 3.3 V reference, would do better.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

mV

V

counts

°C

Practice 5. A sensor signal has about 15 mV of noise. You are choosing between a 10-bit (3.2 mV steps) and a 16-bit (0.05 mV steps) ADC. What happens with the 16-bit one?
Practice 6. A 10-bit ADC reads 512 and a 12-bit ADC reads 2,048, both with a 3.3 V reference. Are they measuring the same voltage?

Apply it

For the greenhouse project, choose an ADC (8, 10 or 12 bits) and reference (3.3 V or 5 V) for a TMP36-style sensor. Show the step size in °C, the count you expect at 16 °C and 24 °C, and the Python function that turns a count into °C. Check the function with one hand calculation.

Reflect

Which mattered more today, the number of bits or the noise? When would the answer flip?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Sampling: how often is often enough?States, events and transitions →