News

Ultrasonic Ranging Explained: Time of Flight, Temperature Compensation and the Blind Zone

Parking sensors, level gauges, robot obstacle detection and robot vacuums all use the same idea for ultrasonic ranging: send a short burst of sound, time the echo, multiply by the speed of sound and divide by two. Making that accurate and robust is another matter. The speed of sound drifts with air temperature, so an uncompensated 1 m reading can shift by more than ten centimetres between winter and summer. Transducer ringing after the transmit pulse creates a blind zone close to the sensor. Spreading and air absorption take tens of decibels out of distant echoes, and the beam angle decides how wide the sensor "sees". Using a typical 40 kHz piezoelectric sensor as the example, this article gives the model, the numbers and the usual countermeasures for each effect.

  • 5.82 msround-trip time of flight to a target 1 m away at 20 °C
  • 0.18%/°Crelative change of the speed of sound with air temperature
  • ≈1.3 dB/mair absorption at 40 kHz, 20 °C and 50% RH

1. Time-of-flight ranging: one equation and its assumptions

Ultrasonic ranging uses the pulse-echo method. The controller drives the transducer with a short ultrasonic burst. The sound travels through the air, part of it reflects off the target, and the echo is picked up either by the same transducer (a single transceiver) or by a separate receiver. The interval between transmission and echo detection is the time of flight (ToF). Because the sound covers the distance twice:

d = c · t / 2

where d is the distance from sensor to target (m), c is the speed of sound in air (m/s), and t is the time of flight (s).

At 20 °C, c ≈ 343.4 m/s, so a target 1 m away returns its echo after 2 × 1 / 343.4 ≈ 5.82 ms, and one at 5 m after about 29.1 ms. That sets a lower limit on the measurement cycle. To catch every echo out to 5 m, and to let late echoes from farther objects die away, successive pings need to be spaced 30 to 40 ms apart. Otherwise a distant echo from the previous ping can be mistaken for a nearby target in the current one. When several sensors run together, such as the four sensors in a rear bumper, they also need time-sliced or coded transmissions to avoid crosstalk.

The equation rests on three assumptions: the speed of sound is known and uniform along the path, the arrival time of the echo can be identified precisely, and the target sits inside the beam and returns a strong enough echo.

0 1 2 3 4 5 6 7 Time t / ms Transmit drive: 8-cycle burst (200 μs) Detection threshold Received signal envelope (single transducer, schematic) Ringing falls below threshold t ≈ 1.6 ms: blind zone ≈ 28 cm Saturated Echo from a wall at 1 m Time of flight t = 5.82 ms d = c·t/2 = 343.4 × 5.82 ms / 2 ≈ 1.00 m
Figure 1Timing of a single-transducer ultrasonic ranging cycle (schematic: 40 kHz, transducer Q of 30, envelope from an exponential decay model, carrier not to scale). After the burst, ringing keeps the receiver saturated, and no echo can be resolved during that time. The result is a blind zone close to the sensor

2. Speed of sound and temperature compensation

In an ideal gas the speed of sound is c = √(γRT/M). It depends only on the absolute temperature T and is essentially independent of pressure. For air the usual expressions are:

c = 331.3 √(1 + θ/273.15)
c ≈ 331.3 + 0.606θ

where c is in m/s and θ is the temperature in °C. The second form linearises the first around 0 °C. Between −20 and +40 °C the two differ by less than 1 m/s. Over a wider range, such as the automotive −40 to +85 °C, use the square-root form.

Near 20 °C the speed of sound rises by 0.606 m/s per degree, a relative change of 0.606 / 343.4 ≈ 0.18%. If the firmware assumes the 20 °C value and the air is at some other temperature, the error is proportional to distance:

dmeas = d · c20 / c(θ)

For a true distance of 1 m at −20 °C, sound travels at only about 319.2 m/s. The longer flight time, converted with 343.4 m/s, reads 1.076 m, about 76 mm long. At 60 °C the reading is about 66 mm short. At 3 m both errors triple.

−40 −20 0 20 40 60 80 −120 −80 −40 0 +40 +80 +120 Actual air temperature T / °C Error / mm (true distance 1 m) −20 °C: +76 mm 0 °C: +37 mm 40 °C: −34 mm 60 °C: −66 mm Calibrated at 20 °C, c = 343.4 m/s Slope ≈ −1.8 mm/°C (0.18%/°C) Reads long when cold, short when hot
Figure 2Error at a true distance of 1 m versus actual air temperature when the sensor is calibrated at 20 °C and not compensated (computed with c ≈ 331.3 + 0.606θ)

Common compensation methods

Method AMost common

Real-time temperature sensing

A temperature sensor on the module or the main board measures temperature before each ping, and firmware computes the speed of sound from it. A 1 °C error in temperature costs about 0.18% in distance. The sensor must see the air along the acoustic path, not a local hot spot heated by the electronics.

Method BTanks, pipes

Reference reflector

A fixed reflector at a known distance dref sits in the acoustic path. Its flight time tref gives the current speed of sound, c = 2dref/tref. This corrects for temperature, humidity and gas composition at once, and suits closed vessels and stilling wells.

Humidity also matters slightly, because water vapour is lighter than dry air and moist air carries sound a little faster. At room temperature, though, going from dry to nearly saturated air changes the speed by only a few tenths of a percent, far less than temperature does, so most ranging applications ignore it. Temperature gradients and air flow are harder. In direct sunlight, near an engine bay or in wind, the air along the path is not uniform. A single-point temperature reading only corrects the average, and the system design has to leave margin for the rest.

3. The blind zone: where ringing comes from and how to shorten it

A piezoelectric ultrasonic transducer is a high-Q resonator. The ceramic element and its metal vibrating member form the mechanical resonator: a resonant cone in open-type sensors, the bottom of an aluminium can in sealed types. It is most efficient near resonance. Because the Q is high, it does not stop when the drive stops but keeps oscillating with an exponentially decaying amplitude. This is called ringing. For a resonator, the envelope is:

A(t) = A0 · e−πf0t/Q
tX = (X / 8.686) · Q / (πf0)

where f0 is the resonance frequency (Hz), Q is the quality factor of the mounted transducer, and tX is the time for the amplitude to fall by X dB (8.686 = 20/ln 10).

The transmit drive is often tens of volts, while an echo from a few metres away arrives at millivolts or less, a difference of more than 60 dB. With f0 = 40 kHz and Q = 30, a 60 dB decay takes about 1.65 ms. With Q = 60 it takes about 3.3 ms. In a single-transducer design the receiver stays saturated until the ringing drops below the threshold, and any echo arriving in that window is lost. The blind zone is approximately:

dblind ≈ c · (tburst + tring) / 2

In the Figure 1 example, an 8-cycle burst lasts 200 μs and the ringing drops below the threshold after about 1.6 ms. That gives a blind zone of 343.4 × 1.6 ms / 2 ≈ 0.28 m, the same order as the minimum range of typical single-transducer sensors.

MeasureHow it worksCost
Fewer burst cyclesShorter tburstLess transmitted energy, weaker long-range echoes
Parallel damping resistorAdds electrical damping, lowers effective QLower output and lower receive sensitivity
Active damping (anti-phase drive)Anti-phase pulses after the burst cancel stored energyNeeds precise phase and cycle count; sensitive to part-to-part spread
Separate transmitter and receiverReceiver is not directly hit by transmit ringingTwo transducers, more size and cost; crosstalk through air and structure remains
Higher operating frequencyAt equal Q, decay time scales with 1/f0Higher air absorption, shorter range
Tip: in a sealed (waterproof) transducer the ceramic is bonded to the inside of an aluminium can, and the whole can face vibrates. The heavier structure needs a higher drive voltage and usually rings longer than an open-type sensor, so its blind zone is larger. Outdoor applications such as parking sensors use sealed construction for water and dust protection, which puts more demands on the drive and damping circuit.

4. How weak is the echo? Spreading loss and air absorption

Echo strength sets the maximum range. Two mechanisms attenuate the sound:

  • Geometric spreading. In the far field, pressure falls as 1/r. A large flat reflector such as a wall or liquid surface acts like a mirror image source at distance 2d, so the echo pressure goes as 1/(2d) and drops 6 dB per doubling of distance. A target much smaller than the beam cross-section, such as a thin pole or small ball, adds a second spherical spread on the way back. Its echo goes as 1/d2 and drops 12 dB per doubling.
  • Air absorption. Molecular relaxation and related mechanisms turn acoustic energy into heat. The loss in dB/m grows roughly with the square of frequency and depends on temperature and humidity. ISO 9613-1 gives the standard calculation. At 20 °C and 50% relative humidity it is about 0.73 dB/m at 25 kHz, 1.3 dB/m at 40 kHz and 1.9 dB/m at 58 kHz.
Lloss = 20 lg(2d/d0) + 2αd

This applies to a large flat target, where α is the absorption coefficient (dB/m) and d0 is a reference distance. For a small target the first term becomes 40 lg(d/d0). Real echoes also lose energy at the target: soft, porous or tilted surfaces absorb the sound or reflect it elsewhere.

Distance dFlat target: spreading + absorptionSmall target: spreading + absorption
0.5 mFlat: reference, 0 dBSmall: reference, 0 dB
1 mFlat: 6.0 + 1.3 = 7.3 dBSmall: 12.0 + 1.3 = 13.4 dB
2 mFlat: 12.0 + 4.0 = 16.0 dBSmall: 24.1 + 4.0 = 28.0 dB
3 mFlat: 15.6 + 6.6 = 22.2 dBSmall: 31.1 + 6.6 = 37.7 dB
5 mFlat: 20.0 + 11.9 = 31.9 dBSmall: 40.0 + 11.9 = 51.9 dB

The table is referenced to 0.5 m and computed for 40 kHz, 20 °C and 50% RH (example values). Between 0.5 m and 5 m, a small target's echo falls by more than 50 dB. Receivers therefore use time-gain control (TGC, also called TVG): gain rises with time after the ping, so near and far echoes come out at similar amplitudes and strong close echoes do not saturate the amplifier.

5. Beam angle: the wider you look, the more clutter you see

The directivity of the radiating face decides what the sensor can see. Modelled as a rigid circular piston of radius a, the far-field pressure directivity is:

D(θ) = 2J1(ka sinθ) / (ka sinθ)

where J1 is the first-order Bessel function, k = 2π/λ is the wavenumber, and θ is the off-axis angle. D = 0.5 (−6 dB) at ka sinθ = 2.215, and the first null appears at ka sinθ = 3.832.

0 15 30 45 60 75 90 0 −6 −12 −18 −24 −30 Off-axis angle θ / ° Relative SPL / dB −6 dB a = 4 mm (ka = 2.93): −6 dB full angle ≈ 98° a = 6 mm (ka = 4.39): −6 dB full angle ≈ 61° 40 kHz, λ ≈ 8.6 mm, ideal piston model
Figure 3Directivity of an ideal circular piston (one-way pressure, schematic). A larger radius and a larger ka give a narrower beam. With ka < 3.832 there are no nulls or side lobes

At 40 kHz the wavelength is about 8.6 mm. A 4 mm radius gives ka ≈ 2.93 and a one-way −6 dB full angle of about 98°. At 6 mm, ka ≈ 4.39 and the full angle shrinks to about 61°. In pulse-echo operation the directivity applies twice, once on transmit and once on receive. For a single transducer the angular response of the echo is the square of the one-way pattern, so its dB values double, and the effective beam is narrower than the one-way curve suggests. Commercial sensors shape the beam with resonant cones, horns or shaped housings, and some have different horizontal and vertical beam angles. A parking sensor, for example, wants a wide horizontal and a narrow vertical beam so it does not detect the road surface. Select parts on the measured directivity in the datasheet; the piston model only shows the trend.

Wide beam

Large coverage

Good for obstacle and presence detection, covering an area with few sensors, but more prone to returns from the floor and side walls.

Narrow beam

Well-defined aim

Good for level measurement and point ranging, but needs careful alignment. A target that leaves the beam is lost.

Trade-off

Frequency and size together

When size is fixed, a higher frequency narrows the beam and improves resolution, but air absorption rises and range falls.

6. Detecting the echo arrival and resolution

The simplest detector is a threshold comparator: the echo arrives when its envelope first crosses the threshold. But the receiving transducer also builds up with a time constant set by its Q, and the envelope needs several cycles to reach its peak. A threshold detector therefore always fires late, and the weaker the echo, the later it fires. In the Figure 1 model the envelope takes about 0.06 ms to climb from zero to the threshold, which reads about 1 cm long. The lag varies with echo amplitude, so it becomes a systematic error that depends on target and distance.

Common improvements are a relative threshold set at a fixed fraction of the echo peak instead of an absolute level, fitting the envelope and extrapolating back to its onset, timing on zero crossings to get below half a period, and chirped or coded bursts with cross-correlation detection, which estimates arrival time accurately even in noise. One 25 μs period at 40 kHz equals about 4.3 mm of range. That is the granularity of simple cycle counting.

A related figure is range resolution, the smallest spacing at which two targets can still be separated. It is set mainly by the pulse length: Δd ≈ c·τ/2. An 8-cycle (200 μs) burst gives about 34 mm, and closer targets merge into one echo. Shorter pulses improve resolution and shrink the blind zone but carry less energy, which conflicts with maximum range. Ultrasonic ranging design comes down to balancing range, blind zone, accuracy and beam width.

Key takeaways

  • Ranging equation: d = c·t/2. At 20 °C, 1 m means a 5.82 ms round trip.
  • Temperature compensation is essential. The speed of sound changes about 0.18% per °C. Without compensation, a 1 m reading varies by about 14 cm between −20 and 60 °C.
  • The blind zone comes from ringing. Decay time scales with Q/f0; damping, active damping or separate Tx/Rx shorten it.
  • Distant echoes are weak. They lose 6 dB per doubling for flat targets and 12 dB for small ones, plus about 1.3 dB/m of air absorption at 40 kHz, so time-gain control is needed.
  • ka sets the beam. A larger face or higher frequency narrows it. Select parts on measured directivity.
References: ISO 9613-1:1993, Acoustics — Attenuation of sound during propagation outdoors — Part 1: Calculation of the absorption of sound by the atmosphere; L. E. Kinsler et al., Fundamentals of Acoustics (circular piston radiation and directivity); L. L. Beranek, Acoustics. Curves and worked examples in this article were computed from the equations above, with illustrative transducer parameters.
About us: Suyang Electronics manufactures loudspeakers, receivers, buzzers and other electroacoustic components, and also supplies ultrasonic sensors. For resonance frequency, beam angle or ringing data to support your selection, please contact us.