TactivergeLite

Lite / Intelligent Robotic Systems / Week 19

Linearity, calibration and latency

A sensor is perfectly accurate, but its answer arrives 200 ms late. At 2 m/s, how far has the robot moved?

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

Why should I care?

Raw sensor numbers are rarely in the units you want. Calibration turns them into centimetres or newtons, and knowing a sensor's latency tells you whether its answer still describes the world by the time you use it.

Predict

A sensor reads 120 at 0 kg and 920 at 10 kg, and responds in a straight line. What does a reading of 520 mean?

  1. 5.2 kg
  2. 5.0 kg
  3. 4.0 kg
Guess first, then reveal

Each kilogram adds (920 − 120) ÷ 10 = 80 counts. 520 is 400 counts above zero, so 400 ÷ 80 = 5.0 kg. Forgetting the 120 offset gives the tempting 5.2 or 6.5.

Discover

In the Code Lab, write calibrate(raw) for the load cell in the prediction: compute the gain and offset from the two calibration points, then test it on 120, 520 and 920. Add a check that warns when a reading falls outside the calibrated span.

What the interactive shows (text version)

This lesson uses the Code Lab. Equivalent paper task: given calibration points (0 kg, 120 counts) and (10 kg, 920 counts), compute gain = 80 counts per kg, then convert readings 120, 520 and 920 to 0, 5 and 10 kg, and flag readings below 120 or above 920 as outside the calibrated span.

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

Understand

Linear response

A linear sensor's output is a straight line of its input: output = gain × input + offset. Many sensors are nearly linear over part of their range and curve near the ends. Linearity on a spec sheet says how far the real curve strays from the best straight line, often as a percentage of full scale.

Two-point calibration

Measure two known inputs and record the raw outputs. The gain is the change in raw reading per unit input: (r₂ − r₁) ÷ (x₂ − x₁). Then input = (raw − r₁) ÷ gain + x₁. Choose the two points near the ends of the span you care about, and check a third point in the middle to spot non-linearity.

Latency and bandwidth

Latency is the delay between something happening and the reading reflecting it: conversion time, filtering, communication. Bandwidth describes how fast a change the sensor can follow at all. A robot moving at speed v that acts on a reading with latency τ is acting on a world that has already moved v × τ.

Spec-sheet honesty

Most numbers on a datasheet hold only under stated conditions: temperature, supply voltage, warm-up time. Calibrate in conditions like the ones the robot will meet, and re-check after big changes.

Explain it another way

Intuitive

Calibration is like learning a friend's accent: once you know how their 'raw' sounds map to words, you understand them perfectly. Latency is like hearing thunder after the lightning.

Technical

With calibration points (x₁, r₁), (x₂, r₂): gain k = (r₂ − r₁)/(x₂ − x₁), x = x₁ + (r − r₁)/k. Residuals at extra reference points estimate non-linearity. Position error from latency τ at speed v is approximately v·τ.

Mathematical

If the true response is r = k·x + c + b·x(X − x)/X (a bow of size b over span X), a two-point fit at x = 0 and x = X leaves an error that peaks at mid-span, x = X/2, of size b·X/4 in output units.

Applied

Line-scan cameras on conveyors trigger exposures from an encoder so latency is constant, then shift the reject actuator's timing by the known delay. Without that, a 50 ms delay at 1 m/s misses the part by 5 cm.

Worked example 1

An IR distance sensor reads 3.1 V at 10 cm and 0.8 V at 40 cm. Assuming linearity between them, what distance does 1.95 V mean?

Gain = (0.8 − 3.1) ÷ (40 − 10) = −0.0767 V/cm. Distance = 10 + (1.95 − 3.1) ÷ (−0.0767) = 10 + 15.0 = 25 cm. Real IR sensors curve, so check a third point.

Worked example 2

A camera pipeline has 80 ms latency and the robot drives at 1.5 m/s. How far does it travel before it can react?

1.5 × 0.080 = 0.12 m: 12 cm before the image even reaches the controller.

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.

counts/kPa

kPa

m

Practice 4. Why check a third reference point in the middle after a two-point calibration?
Practice 5. A temperature probe takes 20 s to settle after being dipped in hot water. This mostly limits its…

Apply it

Extend your calibrate() function to take any number of reference points and report the largest residual from the best straight line through the end points. Test it on a sensor that bows by 2% at mid-span and say whether two-point calibration is good enough for ±1% accuracy.

Reflect

Which would you rather fix on a fast robot: a constant 3 cm offset or a 100 ms latency? Explain.

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

← Accurate, precise, both or neitherRandom and systematic error →