Range, resolution and the bits behind them
A 10-bit and a 16-bit sensor both measure 0–5 V. One sees changes 64 times smaller. Does that make it 64 times more accurate?
About 35 min · 3 goals · Checked by automated tests
1.Why should I care?
Every robot spec sheet lists range and resolution first, because they decide what a sensor can possibly see. Pick the range too small and the reading sticks at its limit exactly when it matters; pick too few bits and small changes vanish between steps. Engineers check both before they write a line of code.
- ◇ Define range, resolution and saturation for a sensor and its converter.
- ◇ Calculate the step size of an n-bit converter as range ÷ 2ⁿ, and the bits needed for a target step.
- ◇ Explain why finer resolution does not guarantee better accuracy.
2.Predict
An 8-bit converter spans 0–5 V. Roughly how small a change in voltage can it notice?
Guess first. Being wrong here is how the surprise works.
3.Discover
Start at 4 bits and slide the true input slowly: the reading jumps in steps. Raise the bits and watch the staircase shrink. Then push the input past the top of the range, and finally add bow. Which problems do extra bits fix, and which don't they touch?
Loading the interactive…
Can't use the interactive? Read a description instead
The diagram plots the reported voltage against the true input as a staircase. With 4 bits the steps are 0.31 V tall on a 5 V range; with 12 bits they are 1.2 mV and the staircase looks like a straight line. Inputs above the top of the range all read the maximum code (saturation). Adding bow curves the staircase away from the straight line by up to bow × range ÷ 4, an error extra bits cannot remove.
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
A distance sensor's range is 2–80 cm. A wall is 120 cm away. What will it most likely report?
5.Understand
Range: what it can see at all
The range is the span of inputs a sensor reports faithfully, for example 0–5 V or 2–400 cm. Outside it the output saturates: it sticks at the end value. A saturated reading is the most dangerous kind, because it looks like a normal number. Choose a range that covers the largest value you could meet, with some margin.
Resolution: the smallest step
A converter with n bits has 2ⁿ codes. Spread over the range, each step is range ÷ 2ⁿ wide (some datasheets divide by 2ⁿ − 1; the difference is tiny for large n). A 12-bit converter on 0–3.3 V has steps of 3.3 ÷ 4096 ≈ 0.81 mV. Every reading carries an extra uncertainty of up to one step, called quantisation error.
Resolution is not accuracy
Resolution says how finely the sensor divides the range. Accuracy says how close the reported value is to the truth. A sensor with a gain error, an offset or a bow in its response can report confidently in tiny steps and still be wrong by a lot. Extra bits help only when quantisation is the biggest error.
Reading a spec line
'Range 0–40 °C, resolution 0.01 °C, accuracy ±0.5 °C' tells you the readings move in hundredths but can be half a degree off. For a greenhouse that is fine; for a medical thermometer it is not. Always ask which number limits your task.
Explain it another way
A ruler marked only in centimetres can't tell 3.2 cm from 3.4 cm: that is resolution. A ruler printed slightly stretched gives tidy millimetre marks that are all a bit wrong: that is accuracy.
An ideal n-bit ADC with full-scale range FSR maps an input to code ⌊V·2ⁿ/FSR⌋, clipped to 0…2ⁿ − 1. One LSB = FSR/2ⁿ; quantisation error is uniform over one LSB, with standard deviation LSB/√12 when the signal is busy enough.
Bits needed for a step no bigger than Δ over range R: 2ⁿ ≥ R/Δ, so n = ⌈log₂(R/Δ)⌉. For R = 5 V and Δ = 1 mV: log₂(5000) ≈ 12.3, so 13 bits.
Microcontrollers commonly have 10- or 12-bit ADCs. Designers often scale a small sensor signal with an amplifier so it fills the converter's range: a 0–0.5 V signal on a 0–5 V converter wastes over 90% of the codes.
Worked example 1
A 10-bit ADC spans 0–3.3 V. What is one step, and what code does 1.00 V give?
Step = 3.3 ÷ 1024 ≈ 3.22 mV. Code = ⌊1.00 ÷ 0.003223⌋ = ⌊310.3⌋ = 310, which means 310 × 3.22 mV ≈ 0.999 V.
Worked example 2
A load cell's amplifier outputs 0–2 V and you want 0.1 mV steps. How many bits?
2 V ÷ 0.1 mV = 20,000 steps. 2¹⁴ = 16,384 is too few; 2¹⁵ = 32,768 is enough. You need 15 bits, so in practice a 16-bit converter.
Common mix-ups
- More decimal places on the display mean a more accurate sensor.
✓ Decimal places show resolution. Accuracy comes from calibration and the sensor's physics, and is stated separately on the datasheet. - A sensor at the top of its range is just measuring a big value.
✓ It may be saturated: the true value could be anything above the limit.
6.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2 · a fresh version every time
An 8-bit converter spans 0 to 10 V. Taking one step as range ÷ 2^n, how big is one step, in millivolts?
Practice 3
How many distinct codes does a 12-bit converter have?
Practice 4
A sensor has a ±2% gain error. Upgrading its converter from 10 to 16 bits will…
Practice 5
A sensor outputs 0–0.5 V into a 10-bit converter spanning 0–5 V. How many of the 1024 codes can it actually use?
7.Apply it
Pick a sensor for a line-following robot's distance check (obstacles from 5 cm to 1.5 m, needed to the nearest centimetre). Write the range and resolution you need, the bits required if the sensor outputs 0–3.3 V linearly, and one thing the spec must also tell you about accuracy.
8.Reflect
Concepts: How sensors measure · Analog-to-digital conversion