🔬

Ultrasonic Rangefinder Reliability and Practical Range Investigation

In the main experiment, we measured the distance to targets at approximately 10 cm, 45 cm, and 100 cm using:
  • a ruler;
  • the XRP rangefinder;
  • the Red Pitaya oscilloscope.
We will use the Red Pitaya to investigate when an ultrasonic measurement is reliable and how the target affects the measurement. We will compare the distance calculated from the Echo-pulse width with the ruler distance and the value reported by the XRP.

Materials and Setup

  • XRP Robot and 3.3V-compatible Ultrasonic Rangefinder
  • Red Pitaya (configured for LV ±1V inputs)
  • Oscilloscope probes (configured for 10x attenuation)
  • Four male-to-male jumper wires (GPIO 0, 1 and GND x2).

Measurement Configuration

  1. Verify Zero-Power State: Disconnect the XRP from USB-C and set the physical battery switch to OFF. Make all connections while the system is unpowered.
  2. Connect the Probes: Connect Red Pitaya Channel 1 to XRP GPIO 0 (Trigger) and Channel 2 to GPIO 1 (Echo) using jumper wires. Connect both probe ground clips to the same expansion-header GND pin. Ensure that the probe hooks contact the exposed metal conductors.
  3. Connection Summary:
    1. XRP GPIO 0 / Trigger ── Channel 1 probe
    2. XRP GPIO 1 / Echo ── Channel 2 probe
    3. XRP GND ── both probe ground clips
    4. Secure all connections and do not reposition them during the measurement.
  4. Probes: Set both physical probes and the Red Pitaya software attenuation to 10×.
  5. Oscilloscope: Enable Channels 1 and 2, set to 1 V/div, and set the timebase to 2 ms/div.
  6. Trigger: Select Channel 1, rising edge, approximately 1.5 V, and Normal mode.
  7. Enter Safe Testing State: Connect the USB-C cable to the XRP while leaving the battery switch OFF.

Exploration and Analysis

The XRP documentation specifies a maximum range of approximately 4 m. Investigate whether this is also the reliable range in your experimental setup.
  1. Signal capture: Run the MicroPython script to initiate a continuous sensing loop:
import time from XRPLib.defaults import * print("Continuous rangefinder routine active.") try: while True: # Measure physical distance in centimeters distance = rangefinder.distance() print("Robot reported distance:", distance, "cm") time.sleep(0.1) except KeyboardInterrupt: print("Routine stopped.")
  1. Use a large, flat, hard target, such as a piece of cardboard, wood, or plastic and place it approximately 25 cm from the XRP.
  2. Observe the Echo signal from the Red Pitaya and use the cursors to measure the Echo-pulse width, t.
  3. Calculate the distance from the pulse.
  4. Move the target further away, in steps, e.g. 25 cm, and record:
    1. XRP-reported distance,
    2. Echo-pulse width,
    3. Distance calculated from Echo,
    4. Whether the measurement is stable.
  5. Continue until the Echo signal becomes unreliable or dissapears.
  6. Change one property of the target - for example its size, material or orientation - and repeat several measurements.
  7. Explore the following questions:
    1. At what distance did the Echo signal first become unreliable?
    2. Did the ruler distance, the XRP-reported distance, and the distance calculated from the Echo pulse agree?
    3. How can you distinguish a valid long-distance measurement from an invalid maximum or timeout value?
    4. How did the target’s size, material, or orientation affect the measurement?
    5. Is the documented 4 m range a guaranteed practical range in your setup? Explain.
✅ Check your observations
At shorter distances, the ruler distance, the XRP-reported distance, and the distance calculated from the Echo-pulse width should generally agree. Small differences are expected because of sensor alignment, ruler placement, timing resolution, temperature, and the size or position of the target. Use (dcmtμs58)(d_{\text{cm}} \approx \frac{t_{\mu\text{s}}}{58}) to convert the Echo-pulse width into distance.
The measurement becomes unreliable when the Echo pulse disappears, becomes intermittent, or has a duration that does not correspond to the ruler distance. A very large value, a maximum value, or a value such as 65,535 cm does not prove that an object is located at that distance. If there is no corresponding valid Echo pulse on the Red Pitaya, the reading should be considered invalid or timeout-related.
A large, hard, flat target facing the sensor normally produces a stronger and more stable Echo. Smaller, soft, porous, irregular, or angled targets may be detected only over a shorter distance or may produce unstable readings. The nominal 4 m range is therefore not guaranteed for every target; the practical range depends on the target and the experimental setup. Visible light around the sensor or target should have no significant direct effect because the rangefinder uses ultrasound rather than light.