PLC Sim Lab
Industrial sensors

Ultrasonic sensor

An ultrasonic sensor measures distance by sending out a pulse of sound and timing the echo. It sees transparent, shiny, dark and liquid targets that trouble light-based sensors, so it is popular for tank levels and for detecting clear bottles.

2 min read · Updated 2026-10-02

How it works

A transducer emits a short burst of ultrasound (typically 40–400 kHz) and then listens. The time until the echo returns is proportional to the distance:

distance = (speed of sound × time) ÷ 2

Speed of sound in air is about 343 m/s at 20 °C, and changes with temperature, so good sensors have built-in temperature compensation.

Blind zone and beam angle

Outputs

OutputUse
Switching (PNP/NPN)"object closer than X", high/low level alarms
Analog 4–20 mAcontinuous level or distance into a PLC analog input; 4 mA = near, 20 mA = far (or reversed). Below about 3.6 mA indicates a fault.
Analog 0–10 Vsame, for short cable runs
IO-Linkdistance value plus diagnostics over a digital link

Good and bad targets

Good: liquids, glass, clear plastic, metal, dark objects. Difficult: foam, soft fabric and cotton (they absorb sound), steep angled surfaces (the echo misses the sensor), and heavy dust or steam.

Scaling an analog level in the PLC

If a 4–20 mA sensor is set to 0–2 m and the analog input reads 0–27648 (Siemens) for 4–20 mA, then level = raw ÷ 27648 × 2 m. Use the brand's scaling instruction (SCALE / NORM_X + SCALE_X on Siemens, SCP on Allen-Bradley).

See also level sensors and the capacitive sensor for point level.

Try it yourself. Wire sensors, contactors and a PLC, write ladder logic and press RUN in the free PLC Sim Lab Playground. Nothing to install.

Open the Playground →Guided lessons →