ECParts Toolkit LogoECParts Toolkit

Ultrasonic Distance Calculator

Calculate ultrasonic time-of-flight distance from echo time, target distance from timeout, temperature-compensated speed of sound, timer resolution and timing or temperature error references.

SEN-008 focuses on pulse-echo ultrasonic ranging. It does not model transducer drive circuits, acoustic beam patterns, echo amplitude, target reflectivity, multipath simulation or sensor-specific firmware timing offsets.

Engineering tool

Ultrasonic Distance Calculator

Calculate ultrasonic time-of-flight distance, echo time, temperature-compensated speed of sound, timeout, timing resolution and error references.

Calculation mode

Parameter panel

Result console

Distance to Target
1.7171 m
Round-Trip Path Length
3.4342 m
One-Way Travel Time
5 ms
Echo Time Used
10 ms
Speed of Sound Used
343.42m/s
Air Temperature
20°C
Timing Type
Round-Trip Echo

Round-trip echo mode divides acoustic path length by two. Timer quantization, threshold detection, target surface, beam angle and module latency can dominate real measurement accuracy.

Ultrasonic distance formula audit

Ultrasonic distance formula audit
Timing ConventionPulse-echo ultrasonic ranging commonly measures acoustic round-trip time.
Default Timing TypeRound-Trip Echo.
Round-Trip Formulad = vt/2.
One-Way Formulad = vt.
Inverse Time Formulat = 2d/v for round-trip echo and t = d/v for one-way TOF.
Adopted Speed-of-Sound Modelv = 331.3 + 0.606T with T in °C.
Temperature Unit Convention°F and K are converted to °C before the speed model is applied.
20°C Reference Speed343.42 m/s.
Timer Resolution FormulaΔd = vΔt/2 for round-trip and Δd = vΔt for one-way.
Timing Error FormulaDistance uncertainty reference uses the same timing convention as the measurement.
Timeout FormulaRecommended timeout = round-trip time × (1 + margin%).
Timeout Margin DefinitionMargin is added to the round-trip echo time.
Temperature Error ModelT±ΔT corners are recalculated through the same speed-of-sound approximation.
Custom Speed BoundaryCustom speed is propagation math only; sensor suitability for the medium must be verified.
Humidity BoundaryHumidity is not modeled in V1.
Dead-Zone BoundaryTransducer ringing and receiver recovery are datasheet limits, not derived from d=vt/2.
Sensor-Specific Timing BoundaryInput time is assumed to be acoustic TOF; module-specific offsets are not modeled.

Formula reference

Ultrasonic Time-of-Flight Formulas

Round-trip echo timing is the default because most ultrasonic ranging sensors measure travel to the target and back.

Round-trip echo: d = vt/2One-way TOF: d = vtRound-trip inverse: t = 2d/vSpeed of sound in air: v = 331.3 + 0.606TRound-trip resolution: Δd = vΔt/2Recommended timeout = (2d/v) × (1 + margin)

Variable definitions

d
one-way distance to target
v
speed of sound or propagation speed
t
measured echo time
T
air temperature in °C
Δt
timer resolution or timing uncertainty
margin
timeout margin percentage

Ultrasonic Distance Formula Audit

Ultrasonic distance formula audit
Timing ConventionMost pulse-echo ultrasonic ranging measures round-trip acoustic time.
Default Timing TypeRound-Trip Echo.
Round-Trip Formulad = vt/2.
One-Way Formulad = vt.
Inverse Time Formulat = 2d/v for round-trip echo.
Speed Modelv = 331.3 + 0.606T m/s with T in °C.
Temperature Units°F and K are converted to °C before applying the formula.
20°C Reference343.42 m/s.
Timer ResolutionΔd = vΔt/2 in round-trip mode.
Timing Error±Δd = v±Δt/2 in round-trip mode.
TimeoutRecommended timeout = round-trip time × (1 + margin%).
Temperature ErrorTemperature corners are recalculated with T±ΔT.
Humidity BoundaryHumidity is noted but not modeled.
Dead-Zone BoundaryDead zone is a sensor datasheet behavior, not derived from TOF math.

Worked Examples

Speed at 20°C

Known: T=20°C

v=331.3+0.606×20=343.42 m/s.

1 ms echo

Known: round-trip at 20°C

d=343.42×0.001/2=0.17171 m = 17.171 cm.

10 ms echo

Known: round-trip at 20°C

d=1.7171 m.

1 m distance

Known: round-trip at 20°C

t=2/343.42≈5.82377 ms.

One-way mode

Known: 1 ms at 20°C

d=0.34342 m.

Factor-of-two check

Known: same 1 ms timing

One-way distance is 2× round-trip distance.

Speed at 0°C

Known: T=0°C

v=331.3 m/s.

Speed at 30°C

Known: T=30°C

v=349.48 m/s.

Temperature effect

Known: 10 ms at 30°C versus 0°C

Calculated distance is larger at 30°C.

Timer resolution

Known: 1 µs at 20°C round-trip

Δd≈0.17171 mm.

Timer resolution

Known: 10 µs at 20°C round-trip

Δd≈1.7171 mm.

Timing uncertainty

Known: ±5 µs at 20°C

Distance error≈±0.85855 mm.

4 m timeout

Known: 20°C, no margin

Round-trip timeout≈23.295 ms.

4 m timeout margin

Known: 20% margin

Recommended timeout≈27.954 ms.

Time conversion

Known: 1000 µs

Equals 1 ms.

Distance conversion

Known: 100 cm

Equals 1 m.

Temperature conversion

Known: 68°F

Equals 20°C.

Temperature conversion

Known: 293.15 K

Equals 20°C.

Custom speed

Known: v=340 m/s, 10 ms round-trip

d=1.7 m.

Round trip

Known: Distance→Time→Distance

Original target distance is recovered before rounding.

Zero timing error

Known: Δt=0

Distance error is 0.

Invalid echo time

Known: negative echo time

Input is rejected.

Engineering Notes

Ultrasonic distance engineering notes
Ultrasonic SensorPulse-echo sensors estimate distance from acoustic time of flight.
Time of FlightTOF is the acoustic travel time, not necessarily the trigger pulse width.
Echo TimeMany modules output a pulse width proportional to round-trip echo time.
Speed of SoundSound speed in air depends strongly on temperature.
Round TripMost ranging modules need the factor of two because the wave travels out and back.
Temperature CompensationTemperature compensation reduces one major systematic error source.
Timer ResolutionTimer tick size sets an ideal distance increment, not full accuracy.
Measurement AccuracyThreshold detection, ringing, target geometry and noise can dominate accuracy.
TimeoutTimeout should exceed expected round-trip echo time but not be unnecessarily long.
Dead ZoneClose targets may be hidden by transducer ringing and receiver recovery.
Beam AngleBeam angle changes detection area and can affect which target returns the echo.
Echo StrengthSoft, small or angled targets can return weak echoes.
Target GeometryFlat targets normal to the sensor are easier than angled or irregular surfaces.
MultipathReflections from other objects can create delayed false readings.
HumidityHumidity can alter sound speed slightly; V1 does not model it.
Custom MediumCustom speed is a math input only; verify transducer suitability for water or solids.

Common Mistakes

  • Forgetting to divide round-trip echo distance by two.
  • Dividing by two in one-way TOF mode.
  • Using a fixed 343 m/s speed at every temperature.
  • Entering °F directly into the °C speed formula.
  • Entering Kelvin directly into the °C speed formula.
  • Treating timer resolution as measurement accuracy.
  • Sizing timeout from one-way time instead of round-trip time.
  • Mixing millimeters, centimeters and meters.
  • Calculating with negative echo time.
  • Treating trigger pulse width as acoustic TOF without checking the module datasheet.
  • Assuming every ultrasonic module has the same dead zone.
  • Ignoring target angle, target material and multipath.
  • Assuming humidity never matters in higher-accuracy measurements.

Sensor Calibration Calculator

Available

Fit raw ultrasonic readings to physical reference distances.

Open calculator

Sensor ADC Resolution Calculator

Available

Check ADC resolution for analog sensor front ends.

Open calculator

Frequency Period Converter

Available

Convert timing, period and frequency references.

Open calculator

Communication Latency Calculator

Available

Compare propagation delay concepts in electronic links.

Open calculator

Accelerometer Voltage & g Calculator

Available

Convert analog accelerometer output voltage to signed acceleration.

Open calculator

Accelerometer Tilt & Vector Calculator

Available

Calculate accelerometer vector magnitude, roll, pitch and tilt.

Open calculator

Support reference

FAQ

How do I calculate ultrasonic distance from echo time?

For common pulse-echo sensors, multiply speed of sound by echo time and divide by two: d = vt/2.

Why do ultrasonic distance formulas divide by two?

The measured echo travels to the target and back. Dividing by two converts total acoustic path length into one-way target distance.

How do I calculate echo time from distance?

For round-trip echo timing, use t = 2d/v. For one-way time of flight, use t = d/v.

What is the speed of sound at 20°C?

Using v = 331.3 + 0.606T, the speed of sound at 20°C is approximately 343.42 m/s.

How does temperature affect ultrasonic distance measurement?

Warmer air increases the speed of sound, so the same echo time corresponds to a longer calculated distance.

How do I compensate an ultrasonic sensor for temperature?

Measure air temperature, convert it to °C, calculate v = 331.3 + 0.606T, then use that speed in the time-of-flight formula.

What distance corresponds to 1 ms of echo time?

At 20°C in round-trip echo mode, 1 ms corresponds to about 0.17171 m or 17.171 cm.

What is one-way versus round-trip time of flight?

One-way TOF measures travel in one direction. Round-trip echo measures travel to the target and back.

How do I calculate ultrasonic timer resolution in millimeters?

Use Δd = vΔt/2 for round-trip echo timing. At 20°C, 1 µs is about 0.17171 mm.

How do I calculate the required echo timeout?

Use the round-trip time t = 2d/v, then add a margin so the receiver waits long enough for the expected echo.

Is timer resolution the same as distance accuracy?

No. Timer resolution is only timing quantization. Accuracy also depends on temperature, ringing, threshold detection, target geometry and electronics latency.

How does humidity affect ultrasonic measurement?

Humidity can slightly change sound speed in air, but this V1 calculator uses only the common temperature approximation.

What causes the minimum ultrasonic measurement distance?

Transducer ringing and receiver recovery create a dead zone where close echoes cannot be measured reliably.

How does target angle affect ultrasonic sensors?

Angled targets may reflect sound away from the receiver, reducing echo strength or producing missed readings.

What is ultrasonic multipath?

Multipath occurs when reflections bounce from other surfaces before returning, causing false or delayed distance readings.

Can I use the calculator for water or other media?

You can enter a custom propagation speed, but the ultrasonic transducer and reflection path must be suitable for that medium.

Engineering Disclaimer

This calculator provides ideal ultrasonic time-of-flight arithmetic. Critical systems require datasheet review, calibration against a physical reference, target testing, temperature measurement, environmental validation and firmware timing verification.