Skip to content

Radar and sonar: finding things by their echoes

Make a sound, and listen for it coming back. The delay says how far away whatever sent it back is, and a small change in its pitch says how fast that thing is moving. That’s all a bat does, and all a fish finder, a ship’s sonar, a weather radar and a car’s collision radar do too. Sonar uses sound, usually in water; radar uses radio waves. The signal processing is the same for both, with a different speed in the sums.

This page builds a working sonar from your computer’s loudspeaker and microphone, and then adds the ideas that real systems use: measuring speed, measuring distance and speed together, the trick that makes car radar cheap, and finding direction.

It leans on:

A few terms first:

  • Range is the radar word for distance: how far away something is.
  • Sound travels at about 343 m/s in air (at 20 °C), and about 1,500 m/s in water. Radio travels at the speed of light, 300,000 km/s, nearly a million times faster than sound in air.
  • An echo is the signal coming back off something: a target, in radar talk, even if it’s a raindrop or a fish.

Send a short ping, and start a stopwatch. The ping spreads out, hits something, and some of it comes back. It has travelled there and back, so the distance is half the delay times the speed:

distance=speed×delay2\text{distance} = \frac{\text{speed} \times \text{delay}}{2}

Top: the sonar is at the left, with two objects in front of it. The ping (blue) goes out, and each object sends back an echo (orange). Bottom: what the microphone hears: the ping leaving, then each echo. Press Send a ping, or drag the time slider yourself.

Sound in air covers 34.3 cm in each millisecond, so a round trip takes 5.8 ms for each metre of distance. The echo from object 1, 1.2 m away, arrives after 7.0 ms; from object 2, 2.5 m away, after 14.6 ms. A radar does the same sum with light: an echo from a plane 100 km away comes back after two thirds of a millisecond.

There’s one catch already. If the sonar pings again before the last echo is back, the stopwatch can’t tell which ping an echo belongs to. Section 5 comes back to this.

Two objects close together send back two echoes close together in time. If each echo is longer than the gap between them, they overlap and blur into one. A short click keeps the echoes short, but a click carries very little energy, so a faint echo is easily lost in noise. A long tone carries plenty of energy, but its echoes are long.

The finding-signals page showed the way out: send a long chirp, a tone whose pitch sweeps, and look for it with a matched filter. The filter squeezes each echo back into a sharp spike. How sharp depends only on how far the chirp sweeps, its bandwidth B, not how long it lasts:

resolution≈speed2B\text{resolution} \approx \frac{\text{speed}}{2B}

Two objects, 1 m away and a little further, the second echoing back 0.7 times as strongly, in some noise. All three signals are equally loud at their peak, as a real loudspeaker or transmitter would have to be. Top: the recording, with time turned into distance. Bottom: the matched filter’s output. The dashed lines are where the objects really are.

With the objects 10 cm apart, the 1 ms click tells them apart: its peak is 7.8 cm wide. But its noise is the worst of the three, 28 dB below an echo. The 20 ms tone has more energy, so its noise is lower (−41 dB), but its peak is 1.57 m wide: the two objects are one blur, even a metre apart. Its two echoes overlap so much that they interfere, as on the MIMO page: at 10 cm apart they partly cancel, and the blur is weaker than either echo alone. The 20 ms chirp has both. Sweeping across 8 kHz, its peak is 2.2 cm wide, so the two objects stand apart with a 40 dB dip between them, and its noise is 16.7 dB lower than the click’s. Narrow the chirp’s sweep, and its peak widens: 1 kHz gives about 17 cm.

Now a real one. The figure plays a chirp sweeping from 2 to 10 kHz, over and over, about 11 times a second, and listens to the microphone all the time. Each ping’s recording is matched-filtered and becomes one column of a scrolling picture: distance up the side, time along the bottom, and how strong the echo is at each distance as its colour. Fish finders draw exactly this picture, with depth down the side.

The loudspeaker’s sound reaches the microphone directly, first and loudest. The figure measures every distance from that direct sound, so the computer’s own delays (often tens of milliseconds) drop out. With the loudspeaker and the microphone close together, as on a laptop, distances come out about right. Strictly, each is half of how much further the echo travelled than the direct sound.

Left: the scrolling picture, the last 8 seconds. Right: the newest ping’s echoes, in dB against the direct sound. Before you start, the figure shows a made-up room: a desk 30 cm away (about 19 dB below the direct sound), a ceiling at 1.25 m (27 dB below), a wall at 2.1 m (32 dB below), and a hand moving slowly between 0.4 and 1.0 m.

Tick Show only what moves, and each ping has the average of the ones before it taken away, phase and all. The desk, the ceiling and the wall never change, so they vanish, and the hand is left on its own. Radar calls this moving-target indication: it’s how an airport radar ignores hills and buildings and shows only planes.

Start the sonar to try your own room. Use loudspeakers, not headphones, and turn off any processing on the microphone (noise suppression and the like). Hold a book or a sheet of card a little way from the microphone and move it slowly towards it and away. Your own hand works too, but it echoes far more weakly.

With the sound card at 48 kHz, a ping every 85 ms means echoes from up to 14.6 m away arrive before the next ping goes out. Anything further than that turns up again at its distance less 14.6 m: in a big workshop, that can be a faint copy of a far wall. Two objects can be told apart if they’re more than 2.1 cm apart, from the 8 kHz sweep.

An object that moves changes the time its echo takes. That’s too small to see from one ping to the next by timing alone, but there’s a much finer ruler: the echo’s phase, where it is in its cycle. As on the MIMO page, the echo is an arrow, and a longer trip turns it.

Left: an echo of a 5 kHz tone (orange), against the echo from where the object started (dashed). Right: the echo as an arrow. Move the object, or press Move it slowly.

At 5 kHz, a wavelength in air is 6.86 cm. Moving the object 8 mm further away makes the round trip 16 mm longer, and turns the arrow 84°. Every 34.3 mm (half a wavelength, because the trip is there and back), the arrow makes a whole turn. So an object moving steadily makes the arrow turn steadily. At 1 m/s it turns 29.2 times a second, which is the same as saying the echo comes back 29.2 Hz higher (moving closer) or lower (moving away) than the tone that went out.

That change in frequency is the Doppler shift. For a tone of frequency f, and an object approaching at speed v:

fDoppler=2vfspeed of the wavef_\text{Doppler} = \frac{2 v f}{\text{speed of the wave}}

Play a steady tone, and look closely at the spectrum around it. Everything that’s still echoes back at the tone’s own frequency. Anything moving shows up beside it: above if it’s coming closer, below if it’s going away.

Left: the spectrum within 150 Hz of the tone, scrolling, the last 10 seconds. The tone itself is the line across the middle. Right: the spectrum now. Before you start, it shows a made-up hand waved towards the microphone and back, 0.6 times a second.

At 8 kHz, each metre per second shifts the echo by 46.6 Hz. The made-up hand’s top speed is 0.94 m/s, so its echo swings 44 Hz either side of the tone, about 40 dB below it. Every swing above the line is the hand coming closer; every swing below, going away.

Play the tone and listen to try it yourself: wave a hand towards the microphone and away, a hand’s length from it. A higher tone gives a bigger shift for the same speed: at 18 kHz, 1 m/s shifts it by 105 Hz, and the tone is hard to hear, if your loudspeakers and microphone reach that high.

Police speed guns, weather radars that see the wind inside a storm, and the sensors that open automatic doors all work this way.

A single steady tone gives speed but not distance, and a single ping gives distance but not speed. Send a train of pings, and you get both. Each ping’s echo from a moving object comes back at almost the same distance, but its arrow has turned a little since the last ping. Line up the pings’ outputs at each distance, and an FFT across them turns the steady turning into a speed, as section 4 turned it into a frequency.

The result is a range–Doppler map: distance one way, speed the other. Every pulse-Doppler radar, from the ones in fighter jets to the ones in some cars, makes one.

16 pings, each a chirp sweeping 2 kHz around 6 kHz, from a desk, a hand moving closer, a wall, and a bag swinging away fast. The rings are where each really is; its name is where it shows up. The grey areas are beyond what this ping rate can show.

With a ping every 10 ms, echoes from up to 1.72 m arrive before the next ping goes out. The wall, 2.4 m away, is beyond that: its echo arrives after the next ping has gone, and shows up at its distance less 1.72 m, at 0.68 m. Speeds wrap round too: the arrow can’t turn more than half a turn between pings and still be measured, which allows ±1.43 m/s. The bag, going away at 2.0 m/s, wraps round to +0.86 m/s, as if it were coming closer. This is aliasing again, exactly as on the sampling page: the pings are samples.

Ping every 20 ms, and the wall is where it should be, but the fastest speed halves to ±0.71 m/s. Ping every 5 ms, and speeds up to ±2.86 m/s are fine, but now anything beyond 0.86 m wraps: even the hand, at 0.9 m, shows up at 4 cm. The two limits multiply to 2.45 m²/s whatever the ping rate. That’s the speed of sound times the wavelength, divided by 8.

Radars live with this trade-off by changing their ping rate from moment to moment, and working out which answer fits all of them. A radar’s pings are far closer together than these, but its wavelength is far shorter too. A weather radar with a 10 cm wavelength that sees out to 230 km can only measure speeds up to about ±16 m/s before they wrap.

6 · FMCW: how car radar measures distance

Section titled “6 · FMCW: how car radar measures distance”

A car’s radar has to measure distances of a few metres to a couple of hundred, many times a second, cheaply. Chirps and matched filters at radar frequencies would need electronics that sample billions of times a second. FMCW (frequency-modulated continuous wave) avoids that with a neat trick.

The radar sends a chirp continuously: its frequency climbs steadily, starts again, and climbs again. An echo is the same climbing chirp, a little late. So at every moment, the echo’s frequency is a little below the frequency going out, by an amount that’s the delay times the rate of climb. Mix the two (multiply them) and you get that difference as a steady tone, the beat. A far object gives a high beat, a near one a low beat, and a spectrum of the beat is a picture of the distances.

Listen:

A sweep from 2 to 10 kHz, in sound, with two objects. Top: the frequency going out (blue) and the two echoes, each a little late. Middle: the mixed signal: the two beats together. Bottom: the beat’s spectrum, with frequency turned into distance; the dashed lines are where the objects really are. Listen to the beat: move an object further away, and its note rises.

Sweeping 8 kHz in 100 ms climbs 80 kHz every second. An object 1 m away echoes 5.8 ms late, so it beats at 466 Hz; one at 1.6 m beats at 746 Hz. Make the sweeps faster, and the beats rise for the same distances (1,866 Hz for 1 m with 25 ms sweeps), but the distance resolution doesn’t change: it’s still set by the 8 kHz sweep, 2.1 cm, as for the chirp in section 2.

A typical car radar works at 77 GHz, and might sweep 1 GHz in 50 µs. A car 50 m ahead echoes 333 ns late, and beats at 6.67 MHz: a frequency an inexpensive chip can sample. Yet the 1 GHz sweep tells objects apart if they’re 15 cm apart. With several sweeps in a row, the beat’s phase turns from sweep to sweep for anything moving, exactly as in section 5, so the same radar measures speed too.

Timing gives distance, but not direction. To find direction, use a beam: point it one way, listen for echoes, then step it round and do it again. Each direction gives one line of echoes, and the lines together make a picture. Old radars turned a dish to do this; modern ones steer a line of antennas (or, in water, of transducers: underwater loudspeakers and microphones) electronically, as on the MIMO page.

A sonar on a boat looks ahead across a 120° sector, 100 m deep. In the water are a rock, two buoys side by side (6° apart), a school of fish, and a wreck. The rings mark where they really are. The beam (dashed) steps across the sector, a degree at a time, and each line it draws fades slowly, as on a real screen.

With 8 elements, half a wavelength apart, the beam is 12.8° wide, so every object is smeared sideways and the two buoys are one blob. With 24 the beam is 4.2° wide, and the two buoys just come apart (a 2.7 dB dip between them); with 32 it’s 3.2°, and the dip is 8.9 dB. At a fish finder’s 200 kHz in water the wavelength is 7.5 mm, so 32 elements make an array only 116 mm across. The faint arcs beside strong echoes are the beam’s sidelobes: it never quite ignores other directions.

A real sonar couldn’t sweep this fast. Each look along the beam has to wait for the echoes from 100 m away, which takes 0.13 s in water, so a sweep of 121 looks would take 16 seconds, and the fish would have moved. Modern sonars send one wide ping and form many receive beams at once from the same recording, one for each direction, in the computer. Fish finders that draw a picture of the water to the side, and the multibeam sonars that map the seabed, work like that.

The picture still has to be turned into “something is there” or “nothing is”. As on the finding-signals page, that means a threshold, and the threshold is set by how many false alarms can be tolerated.

The difficulty in radar and sonar is that the background isn’t steady. Rain, waves, the seabed or the ground send back echoes of their own, called clutter, and they can be far stronger than the noise in another direction or at another distance. A threshold set for the quiet places fires all over the clutter.

The answer is a constant false-alarm rate detector, CFAR. For each distance, it measures the average level in the cells around it (leaving a few guard cells either side, so that a target doesn’t raise its own threshold), and sets the threshold a fixed factor above that. The threshold rises in clutter and falls in quiet.

400 distance cells of echo power (blue): noise, a stretch of clutter 15 dB stronger, and four objects (▼). The threshold is red. Green dots are found objects; red dots are false alarms. The CFAR averages 12 cells either side, skipping 2.

With the fixed threshold, set for 1 false alarm in 1,000 cells of noise, all four objects are found, but the clutter sets off 80 false alarms (81 in all). Raising it to 1 in 1,000,000 still leaves 60, and now one of the objects is missed. The adaptive threshold, at 1 in 1,000, finds all four with a single false alarm. Over 50 runs of the same scene with fresh noise, it fires on 0.14% of empty cells, close to the 0.1% asked for, in the noise and the clutter alike. Ask it for 1 in 1,000,000 and it misses two of the objects: the price of fewer false alarms is always more misses.

The same few ideas run through every radar and sonar: echo timing, wide bandwidth for sharp distance, phase for speed, and arrays for direction. What changes is the wave, its speed, and so its wavelength.

SystemWave and mediumFrequencyWavelengthWhat it’s for
Batssound in airabout 20–100 kHz3–17 mmCatching insects in the dark, with chirps
Dolphinssound in waterclicks of about 40–130 kHz1–4 cmHunting, and telling objects apart by their echoes
Fish finderssound in waterabout 50 and 200 kHz; “CHIRP” models sweep a band3 cm, 7.5 mmDepth, the bottom, and fish beneath a boat
Ships’ and submarines’ sonarsound in waterabout 1–10 kHz15 cm – 1.5 mLong range: tens of kilometres
Seismic surveyssound (vibration) in rockabout 10–100 Hztens of metres to hundredsLayers of rock kilometres down, for mining, oil and gas, and geology
Medical ultrasoundsound in the bodyabout 2–15 MHz0.1–0.8 mmPictures inside the body
Ground-penetrating radarradio in soil and rockabout 100 MHz – 2.6 GHz(in soil) a few cm to 1 mPipes, cables, voids and ore bodies near the surface
Air-traffic and weather radarradio in airabout 1–6 GHz5–30 cmPlanes, rain, and the wind in storms
Car radarradio in air76–81 GHz4 mmDistance and speed of the cars around, FMCW

A few of these are worth a closer look:

  • Seismic surveys for minerals, oil and gas are sonar into the ground. A vibroseis truck presses a heavy plate onto the ground and shakes it with a slow chirp, sweeping roughly 10 to 100 Hz over several seconds: a long, gentle signal in place of an explosion, which pulse compression turns into sharp echoes from each layer of rock. Lines and grids of thousands of geophones (ground microphones) listen, and the computer combines them into beams in every direction at once, as in section 7, to build up a 3D picture of the rock.
  • Fish finders point a beam straight down. The echo from the bottom gives the depth, a school of fish shows as a cloud between, and a single fish, passing through the cone-shaped beam, draws an arch on the scrolling picture: further away as it enters the beam, nearest at the middle, further again as it leaves. The “CHIRP” models do exactly section 2: a long chirp in place of a short ping, for the energy of one and the sharpness of the other.
  • Bats chirp, sweeping down in pitch, and some fly through wire grids in pitch darkness. Some even adjust their call’s pitch as they fly, so that the Doppler shift from their own speed doesn’t move the echo out of the band their ears are most sensitive to.
  • An echo’s delay gives distance: half the delay times the speed.
  • Telling close things apart needs bandwidth: the resolution is about the speed divided by twice the bandwidth. A chirp has the bandwidth of a click and the energy of a long tone.
  • A sonar pinging repeatedly builds a picture of distance over time, as a fish finder does, and taking the average away (moving-target indication) leaves only what moves.
  • Movement turns the echo’s arrow, a whole turn for every half wavelength: the Doppler shift.
  • A train of pings gives distance and speed together, and both wrap round: the farthest distance and the fastest speed trade against each other through the ping rate.
  • FMCW mixes the echo with the chirp going out, turning distance into a beat frequency that cheap electronics can measure.
  • Beams give direction, and a narrower beam (a wider array) tells closer directions apart.
  • CFAR thresholds follow the background, to keep false alarms steady through noise and clutter.
  • M. I. Skolnik, Introduction to Radar Systems, McGraw-Hill: the classic textbook.
  • M. A. Richards, Fundamentals of Radar Signal Processing, McGraw-Hill: pulse compression, Doppler processing, CFAR, all in more depth.
  • R. J. Urick, Principles of Underwater Sound, McGraw-Hill: sonar.
  • D. R. Griffin, Listening in the Dark, Yale University Press (1958): the discovery of bat echolocation.
  • Ö. Yilmaz, Seismic Data Analysis, Society of Exploration Geophysicists: seismic surveys, from the vibroseis sweep to the 3D picture.