Ultrasonic Sensor Interface Circuit Design
An ultrasonic sensor measures distance by timing how long a burst of sound takes to travel out and back, which means the electronics has to do two quite different jobs. It has to drive a transducer with enough energy to produce a detectable echo, and it has to detect a signal that may be a million times smaller than the one it just transmitted.
How an Ultrasonic Sensor Measures Distance
The transducer converts an electrical burst into a mechanical vibration, and the same element converts the returning vibration back into a voltage. The distance follows from the time of flight and the speed of sound, which is about 343 metres per second in air at twenty degrees Celsius, and the round trip means the measured time covers twice the distance.
The speed of sound changes with temperature, by about 0.17 percent per degree Celsius, so a distance of two metres varies by three and a half millimetres per degree of temperature error. Compensating with a temperature sensor is standard practice for any measurement that has to be accurate, and it is essential outdoors.
The transducer is a resonant device with a narrow bandwidth, so it rings for a period after the drive ends. That ringing sets the minimum measurable distance, because the receiver cannot distinguish an echo from the continuing vibration of the transmitter until the ring has decayed.
Drive and Transducer Matching
The drive is usually a burst of a few cycles at the resonant frequency of the transducer, applied at a voltage high enough to produce useful acoustic energy. A transformer or an inductor is often used to step up the drive voltage and to match the capacitive transducer to the driver, and the tuning of that network affects the amplitude of the transmitted pulse.
transducer drive depends on the impedance of the element, which is largely capacitive at the resonant frequency and is compensated by the parallel inductance. When the network is tuned correctly the current through the transducer is maximum for a given drive voltage, and the acoustic output is correspondingly larger. A mistuned network produces a weak pulse and a range that falls short of the design.
The driver has to withstand the reflected energy when the transducer rings. The element generates a voltage of its own after the drive ends, and that voltage appears across the driver output, so the output stage should tolerate it or be protected against it. A series resistor limits the stress at the cost of some drive amplitude.

Echo Detection and Amplifier Design
The echo received by the transducer is a small signal, often in the microvolt range at the longer distances, riding on the residue of the transmitted pulse. The receiver therefore needs a large gain, a narrow bandwidth centred on the transducer frequency, and a means of recovering from the overload that the transmit pulse causes.
A bandpass amplifier at the transducer frequency is the usual arrangement, built either from an operational amplifier with a tuned feedback network or from a dedicated device. The bandwidth should be wide enough to pass the transducer response and narrow enough to reject the noise outside it, and the gain should be distributed over two stages so that the first stage does not have to provide both low noise and high gain.
echo detection converts the amplified signal into a logic edge at the moment the echo arrives. A comparator with a threshold set relative to the noise floor does that, and the threshold is usually made to decay with time after the transmit pulse, so that weak distant echoes are still detected while the strong near field noise is ignored.
Blanking and Range Limits
sensor blanking disables the receiver for a short period after the transmit pulse, which prevents the ringing of the transducer and the overload of the amplifier from being interpreted as an echo. The blanking time sets the minimum measurable distance, and it is a compromise between ignoring the ring and missing a genuine close echo.
The maximum range is limited by the amplitude of the echo and by the noise floor. Echo amplitude falls with distance, roughly in proportion to the spreading of the beam and to the absorption of sound in air, which itself rises with humidity and frequency. A design that works at two metres in dry air may reach further in humid conditions and less in a dusty one.
Any object that reflects sound can produce an echo, and soft or angled surfaces may return very little. A wall at an angle reflects the pulse away from the sensor, and a foam surface absorbs it. Both cases produce a missed echo rather than a wrong distance, which is why a ranging system needs a timeout and a validity check rather than trusting every measurement.

Timing and the Time of Flight Measurement
time of flight is measured with a timer that starts at the beginning of the transmit burst and stops when the echo is detected. The resolution of the timer sets the resolution of the distance, and a timer with nanosecond resolution gives a distance resolution of less than a millimetre, which is far finer than the acoustic signal justifies.
The larger errors come from the delays in the electronics. The transmit burst takes several cycles to build up, the comparator has a propagation delay, and the threshold detection triggers at a point that depends on the echo amplitude. Together these contribute a fixed offset that is best removed by calibration against a known distance rather than by calculation.
Averaging several measurements reduces random error but does not remove the systematic offsets. Taking the median of a small group of readings is more robust than the mean, because it rejects the occasional measurement corrupted by a spurious echo. The firmware should also reject readings that differ from the previous value by more than the acceleration of the object allows.
Interference and Crosstalk Between Sensors
Two ultrasonic sensors operating in the same space can hear each other. A sensor that transmits while another is listening produces a false echo at a distance corresponding to the spacing between them, and the error is intermittent because it depends on the timing of the two measurements.
The remedy is either to synchronise the sensors so that only one transmits at a time, or to give each a distinct coded burst and to detect only the matching pattern. Synchronisation is simpler and is used where the sensors share a controller, while coded bursts are used in systems where the units are independent.
Other sources of interference include air movement, which shifts the apparent speed of sound, and high frequency noise from switching supplies, which can be picked up by the receiver if the supply is not well filtered. The methods for keeping that kind of noise out of a sensitive input are described in our article on EMI immunity in mixed signal design.
Layout and Power Supply
The drive circuit and the receiver should be laid out as two distinct areas, with the receiver protected from the switching currents of the drive. A shared return path between them injects the drive current into the receiver input, and the resulting signal is much larger than the echo the receiver is trying to detect.
Keep the transducer connection short and screened where the transducer is mounted remotely. The cable carries a high voltage pulse and a microvolt echo on the same conductors, so its capacitance and its screening both matter. A coaxial or a twisted pair connection is preferable to a pair of loose wires.
The supply for the amplifier should be filtered separately from the supply for the drive. A small series element with a local capacitor at the amplifier keeps the drive transient out of the analogue supply, and the general partition between noisy and quiet areas of the board is described in mixed signal board design.
Verification and Common Faults
Verify the channel by comparing measured distances against a reference at several positions, at both temperature extremes and with the target at different angles. Recording the error against distance shows whether the offset is constant, which suggests a timing error, or grows with distance, which suggests a speed of sound or a threshold problem.
A sensor that reports a constant distance regardless of the target usually has a blanking or a threshold problem, and the fault is visible by looking at the amplified signal on a scope. If the signal contains no echo but the comparator output still changes, the threshold is set below the noise floor.
A design that works indoors and fails outdoors in sunlight is usually affected by temperature rather than by light, because the speed of sound depends on it. Adding a temperature sensor and correcting the calculation is straightforward, and the calibration and release checks in PCB design release checklist cover the documentation of that correction.
FAQ
What is the shortest distance an ultrasonic sensor can measure? It is set by the blanking time, which must cover the ring down of the transducer. Typical modules manage a few centimetres, and a design with a well damped transducer can do better.
Why does my reading change with temperature? The speed of sound changes by about 0.17 percent per degree. Compensate the calculation with a temperature measurement, or calibrate at the operating temperature.
Can two ultrasonic sensors work side by side? Yes, if their transmissions are interleaved so that only one is active at a time. Without synchronisation they will detect each other and produce occasional false readings.



