🔍🔩 Parts bench
19 lessons

Rangefinders: Distance by Stopwatch

Ultrasonic and laser rangefinders play the same trick — shout, listen, halve the round trip. The differences that matter are the width of the shout and what the wall is made of.

lesson 1 of 3 in this unit

Builds on: 0.1 Sense, Think, Act: What Makes a Robot

Same idea, other course:Vector: the speed of sound, measured by echo

The stopwatch trick

Send a pulse, start a timer, catch the reflection, stop. The pulse travelled out and back, so:

d = v · t / 2half the round trip — forget the ÷2 and every wall is twice as far as it is

An ultrasonic ranger does it with a chirp of sound at v ≈ 343 m/s: a wall 1 m away answers in about 6 ms — leisurely time for a microcontroller. A time-of-flight sensor does it with light at 300,000,000 m/s, where the same wall answers in 6.7 nanoseconds — which is why ToF sensors need clever timing silicon, and why they cost more.

The cone is the catch

The sound chirp spreads as it travels — a cone of 15° or more. The sensor reports the nearest echo from anywhere inside that cone: a chair leg half a metre to the side reads as an obstacle dead ahead. The laser stays a pencil-thin line and measures what you actually pointed it at. Width is the deep difference between the two — not price, not precision.

Materials play favourites, each sensor its own: sound bounces off hard surfaces but is swallowed by curtains, foam and thick sweaters — soft rooms are sonically dark. Light bounces off almost everything but comes back weak from black velvet, or from glass, which reflects the beam away like a mirror unless hit square. Every rangefinder has a material that makes it lie.

From one beam to a picture

One rangefinder gives a number. Spin one on a turret and you get hundreds of numbers a revolution — a floor plan drawn in polar coordinates. That is all a lidar is, and it is the sensor behind every robot-vacuum map in Unit 5. Keep the humble formula in mind when the maps arrive: each pixel of them is one stopwatch click.

Why not just use a camera?

A camera sees everything and measures nothing: one image, by itself, does not contain distance. Rangefinders are the opposite — nearly blind, but every reading is a measurement. Real robots carry both and let each answer the question it is good at.

⚗️ Lab — The Echo Chamber

An ultrasonic cone and a laser beam aimed down the same corridor, with a movable target you can also re-upholster.

  • Slide the target and watch both sensors track it — and watch the ping’s round trip tick by in milliseconds vs nanoseconds.
  • Move the side obstacle into the sound cone: the ultrasonic reading jumps to the nearer object while the laser stays honest.
  • Switch the target from plywood to curtain, then to glass — find which sensor each material blinds.
2.00 m
Ultrasonic verdict
honest
Laser verdict
honest — thin beam, no cone
Rule
d = v · t / 2

Work it by hand — 0 / 2

No multiple choice here: compute the value and type it. Suffixes like 2.5k or 20m are understood; answers within ±3% count.

1. An ultrasonic sensor hears its echo after 12 ms (speed of sound 343 m/s). How far away is the wall, in metres?
2. A time-of-flight sensor measures a 20 ns round trip (light: 3×10⁸ m/s). Distance in metres?

Check your understanding

1. A rangefinder measures a 10 ms round trip. Why divide by two?

2. A chair leg 40 cm to the side of an ultrasonic sensor's aim reads as an obstacle straight ahead because…

3. Which target is nearly invisible to an ultrasonic ranger but fine for a laser?

4. A lidar is essentially…