Ultrasonic Range Sensing: Time-of-Flight with Sound and Its Failure Modes

Capítulo 4

Estimated reading time: 10 minutes

+ Exercise

Measurement Pipeline: From Trigger to Distance

Ultrasonic range sensors estimate distance by emitting a short burst of sound (typically around 40 kHz) and measuring the time until an echo returns. The core idea is time-of-flight (ToF): sound travels to a target and back, so the measured time corresponds to a round trip.

1) Trigger (Transmit Burst)

An ultrasonic transducer converts an electrical drive signal into acoustic pressure waves. Many modules use a brief burst (e.g., 8–16 cycles at 40 kHz). The burst length is a trade-off: longer bursts increase acoustic energy (better SNR at range) but worsen minimum range due to transducer ringing.

  • Transducer types: most robotics modules use piezoelectric discs tuned near resonance (narrowband). Some designs use separate transmit/receive elements; others share one element and switch between transmit and receive.
  • Ringing: after the burst, the transducer continues vibrating for a short time. During ringing, the receiver is effectively “deaf” to nearby echoes.

2) Listening Window (Receive Gate)

After transmission, the system opens a listening window: it samples the receiver output for a limited time corresponding to the maximum desired range. The window start is delayed to avoid self-ringing; the window end prevents waiting indefinitely and defines the maximum measurable distance.

Given a maximum range d_max, the maximum listening time is approximately:

t_max ≈ 2 * d_max / c

where c is the speed of sound.

Continue in our app.
  • Listen to the audio with the screen off.
  • Earn a certificate upon completion.
  • Over 5000 courses for you to explore!
Or continue reading below...
Download App

Download the app

3) Peak/Threshold Detection (Echo Picking)

The received signal is a decaying oscillation at the transducer frequency, often after band-pass filtering and amplification. The system must decide when an echo “arrives.” Common approaches:

  • Envelope + threshold: rectify and low-pass filter to get an amplitude envelope, then detect when it crosses a threshold.
  • Matched filtering / correlation: correlate with the transmitted burst pattern to detect a peak (more robust, more compute).
  • First return vs strongest return: first return favors obstacle avoidance (nearest object); strongest return can jump to a farther reflector if it is more reflective.

Threshold choice affects false positives (noise triggers) and false negatives (missed weak echoes). Many sensors implement automatic gain control (AGC), which changes sensitivity over time; this can bias detection toward later echoes if not accounted for.

4) Time-to-Distance Conversion

Once the echo time t is estimated, distance follows from round-trip travel:

d = (c * t) / 2

In practice, you also account for fixed delays (electronics, switching time, detection latency). A simple calibration is to measure known distances and fit an offset:

d ≈ (c * (t - t0)) / 2

where t0 is an empirically determined timing offset.

Speed of Sound Variation: Why Temperature (and Humidity) Matters

The speed of sound in air is not constant. Temperature is the dominant factor; humidity has a smaller but non-negligible effect in some environments. A commonly used approximation (dry air) is:

c(T) ≈ 331.3 + 0.606 * T   [m/s],  T in °C

Implication: if you assume c = 343 m/s (about 20 °C) but the air is actually 0 °C (c ≈ 331 m/s), distance will be overestimated by roughly (343/331 - 1) ≈ 3.6%. At 2 m, that is about 7 cm error.

  • Temperature compensation: measure ambient temperature near the sensor and update c in the conversion.
  • Humidity: higher humidity slightly increases c. If you need better than a few percent accuracy over varying weather, incorporate humidity (or calibrate for your operating conditions).
  • Air gradients: near heaters, vents, or outdoors in sun/shade transitions, temperature gradients can bend sound paths slightly and change effective ToF.

Beam Pattern: Cone Angle and What You Actually Measure

Ultrasonic sensors do not measure a single ray; they emit and receive over a beam pattern (often approximated as a cone). The beam shape depends on transducer diameter, frequency, housing, and any acoustic horn.

  • Wide beam (large cone angle): better at detecting objects without precise aiming, but more prone to side-wall echoes and multi-path.
  • Narrow beam: better spatial selectivity and fewer side echoes, but more dropouts if the target is not well aligned or is angled.

Because the beam covers an area, the reported distance is typically the earliest detectable echo within that beam (or the strongest echo, depending on detection logic). This means the sensor can “see” edges, corners, and nearby side objects even when the robot is facing forward.

Minimum and Maximum Range Limits

Minimum Range (Near-Field Blind Zone)

The minimum measurable distance is constrained by transducer ringing and receiver recovery time. If the echo returns while the transducer is still ringing, it can be masked.

  • Symptoms: objects closer than a certain distance are reported as “no echo” or as an unstable reading.
  • Design lever: shorter bursts and better damping reduce ringing but can reduce maximum range.

Maximum Range (SNR and Listening Window)

Maximum range is limited by attenuation in air, target reflectivity, and receiver sensitivity. Echo amplitude decreases with distance due to spreading loss and absorption (which increases with frequency). The listening window also caps the maximum ToF you will consider.

  • Soft/porous targets (cloth, foam, plants): absorb sound and reduce echo strength, effectively reducing maximum range.
  • Outdoor wind: can add noise and turbulence, reducing detection reliability.

Update Rate Constraints: Ringing, Multi-Path, and “Don’t Ping Too Fast”

Even if your microcontroller can trigger at high frequency, ultrasonic ranging has physical timing constraints.

Ringing and Receiver Recovery

After each ping, you must wait for the transducer to settle and for the listening window to complete. Triggering too soon can cause the next measurement to be contaminated by residual vibrations or by echoes from the previous ping.

Multi-Path Echoes

Sound reflects from multiple surfaces (floor, walls, robot body), producing multiple echoes at different times. A later multi-path echo can be mistaken for a valid return if the first echo is weak or missed.

  • Example: in a hallway, the beam hits a side wall, bounces, and returns later than the direct forward path, creating a “phantom” farther obstacle.
  • Mitigation lever: choose first-return detection and enforce plausible distance change limits between frames.

Practical Update Rate Rule of Thumb

Set the measurement period longer than the maximum ToF plus margin:

period ≥ t_max + settling_margin

For d_max = 4 m and c ≈ 343 m/s, t_max ≈ 23 ms. Adding margin for ringing and processing, a 30–50 ms period (20–33 Hz) is often more reliable than pushing higher.

Failure Modes and Error Sources

1) Temperature and Humidity Effects

As discussed, incorrect c directly scales distance. Rapid temperature changes near the sensor (e.g., warm electronics, sun exposure) can cause drift. Humidity and pressure effects are smaller but can matter for longer ranges or tighter accuracy requirements.

2) Absorption by Soft Materials

Porous or fibrous materials absorb acoustic energy instead of reflecting it. The sensor may report:

  • No return (timeout), even when an object is present.
  • Intermittent returns that appear as outliers.

Common problematic targets: curtains, clothing, acoustic foam, foliage, some carpets at grazing angles.

3) Specular Reflections (Mirror-Like Behavior)

Hard flat surfaces can reflect sound specularly: the angle of reflection equals the angle of incidence. If the surface is tilted relative to the sensor, the echo may reflect away and not return.

  • Symptoms: a wall at a shallow angle “disappears,” then reappears as the robot moves.
  • Corner cases: smooth floors can create strong floor-bounce paths that confuse the reading.

4) Cross-Talk Between Multiple Sensors

When multiple ultrasonic sensors operate nearby, one sensor can hear another’s ping. This produces false ranges that can look plausible.

  • Direct cross-talk: sensor B hears sensor A’s transmit burst directly through air.
  • Echo cross-talk: sensor B hears echoes of sensor A’s ping from the environment.

Cross-talk is especially common on robots with multiple sensors facing different directions, or in multi-robot environments.

5) Angle-of-Incidence Dropouts

Even if a target is within the beam, the effective reflected energy depends on surface orientation. At high incidence angles, the return can fall below threshold. This is a major cause of sudden “no echo” readings when approaching angled furniture legs, glossy cabinets, or slanted walls.

Mitigation Patterns (Practical, Implementable)

Pattern A: Staggering Triggers to Avoid Cross-Talk

If you have multiple ultrasonic sensors, do not trigger them simultaneously. Use a schedule so only one sensor pings at a time, and ensure its listening window completes before the next sensor triggers.

Step-by-step scheduling:

  • Choose d_max per sensor (or a global maximum).
  • Compute t_max = 2*d_max/c.
  • Add margin t_margin for ringing and processing.
  • Assign each sensor a time slot of t_slot = t_max + t_margin.
  • Trigger sensors sequentially: S1, then S2, …, then repeat.
// Example: 4 sensors, d_max = 3 m, c=343 m/s => t_max≈17.5 ms, margin=5 ms => slot≈22.5 ms  (cycle≈90 ms ~11 Hz per sensor)

If you need higher per-sensor update rate, reduce d_max (shorter listening window) or use fewer sensors per cycle.

Pattern B: Filtering Out Outliers (Physics-Aware Gating)

Outliers often come from missed first echoes, multi-path, or cross-talk. A simple and effective approach is to reject measurements that violate expected motion or geometry.

Step-by-step gating:

  • Maintain the last accepted distance d_prev.
  • Compute a maximum plausible change based on robot speed v and sample time Δt: Δd_max = v*Δt + margin.
  • Reject d if |d - d_prev| > Δd_max unless you have corroborating evidence (e.g., multiple consistent readings).
  • Also reject d if it is outside sensor limits or if echo strength/confidence is low (if available).

Pattern C: Median-of-N for Robustness

Median filtering is well-suited to ultrasonic sensors because failures often produce occasional large errors (spikes) rather than small Gaussian noise.

Step-by-step median-of-N:

  • Collect N readings over a short time window (e.g., N=3 or N=5).
  • Discard timeouts (no-echo) or mark them as invalid rather than forcing a numeric value.
  • Compute the median of the valid readings.
  • If fewer than a minimum count are valid (e.g., <2 of 3), output “invalid” or fall back to the last trusted value with a decaying confidence.
NProsCons
3Low latency, removes single spikesLess robust to frequent dropouts
5More robust in reflective environmentsHigher latency, lower effective update rate

Pattern D: Confidence Thresholds and Validity Flags

Many ultrasonic front-ends can provide additional indicators such as echo amplitude, number of threshold crossings, or correlation peak value. Even if your module only provides a pulse width, you can still derive a confidence proxy.

Practical confidence checks:

  • Timeout-based invalid: if no echo before t_max, mark invalid rather than returning d_max as a real obstacle.
  • Consistency-based confidence: increase confidence when consecutive readings agree within a tolerance; decrease when they fluctuate or alternate between valid/invalid.
  • Environment-based thresholds: in known multi-path environments (hallways), require two consistent readings before acting on a sudden far obstacle.
// Example logic sketch (conceptual)  if (!echo_received) { valid=false; confidence*=0.8; } else { valid=true; if (abs(d-d_prev)<tol) confidence=min(1.0, confidence+0.1); else confidence*=0.9; }

Selection Criteria for Robotics Use

Cone Angle (Beam Width)

  • Choose wider if you need general obstacle presence detection and can tolerate side echoes.
  • Choose narrower if you need better spatial discrimination (e.g., doorway alignment) and can manage alignment and dropouts.

Range (Min/Max) and Target Types

  • Verify minimum range against your robot’s geometry (bumper-to-sensor distance, stopping distance).
  • Verify maximum range under realistic targets (soft fabrics, angled surfaces), not just a flat board.

Resolution and Repeatability

Resolution is limited by timing quantization and detection method; repeatability is often more important than absolute accuracy for control. If you need stable readings, prefer sensors/modules with better echo processing (envelope/correlation) and provide echo strength indicators.

Response Time (Update Rate) vs Reliability

Higher update rates require shorter listening windows (smaller d_max) and careful scheduling to avoid cross-talk. If your robot moves fast, you may need to trade maximum range for faster, more reliable updates.

Indoor vs Outdoor Suitability

  • Indoor: works well for many obstacle-avoidance tasks, but watch for specular reflections in corridors and dropouts on angled glossy surfaces.
  • Outdoor: performance can degrade due to wind, temperature variation, rain (droplets can scatter sound), and soft/irregular targets like vegetation. Temperature compensation and conservative confidence logic become more important.

Now answer the exercise about the content:

In a robot with multiple ultrasonic range sensors, what is the most effective way to reduce false distance readings caused by cross-talk?

You are right! Congratulations, now go to the next page

You missed! Try again.

Cross-talk happens when one sensor hears another sensor’s ping or its echoes. Staggering triggers so each sensor has an exclusive time slot (including its listening window) prevents overlapping pings and reduces false ranges.

Next chapter

Infrared Proximity Sensors: Reflectance-Based Distance and Surface Dependencies

Arrow Right Icon
Free Ebook cover Sensors in Robotics: From Signals to Reliable Measurements
29%

Sensors in Robotics: From Signals to Reliable Measurements

New course

14 pages

Download the app to earn free Certification and listen to the courses in the background, even with the screen off.