Before you blame the rangefinder: a field checklist and the 1000-frame log

2026-11-28来源 dev.toEnglish

Our field-troubleshooting note opens with a sentence I wrote down because I got tired of repeating it by email: most reported "bad sensor" cases turn out to be wiring, parsing or target conditions. I am Tommy Yu, an engineer at ERDI TECH LTD, the manufacturer of these laser rangefinder modules, and I handle the support queue. I will not give you a percentage, because I have not counted the cases rigorously and a made-up ratio is worse than none. What I can give you is the order in which to check things, and a small script that turns the one log I ask everyone for into a pointer at the right row.

The table

This is the symptom table from our notes, in the order I work through it. "First check" is what to do before touching the code.

Symptom First check Typical cause
No bytes at all TX idle level, ground, baud rate Wrong pin order, missing ground, host pin configured as output
Bytes arrive, checksum fails on most frames Logic level, cable, motor noise 5 V TX into a 3.3 V host, long unshielded run, shared ground with an ESC
A few good frames, then silence Supply during the measurement Brown-out on peak current; add bulk capacitance or a separate regulator
Distance stuck at maximum Target and window Low-reflectivity target, dirty or wrong window, beam missing the target
Distance stuck near zero Window and mounting Internal reflection from a tilted or too-close window
Plausible but offset distance Reference plane Measuring from the housing face when the module datum is the front window
Random long outliers in sunlight Ambient light and threshold Sunlight in the receiver field, no bandpass window
Readings drift as the unit warms Thermal test Accuracy not specified across the operating temperature; re-test at temperature
Works on the bench, fails on the vehicle Grounding and supply Motor noise, ground loop, shared rail
Two hosts, garbage data Bus topology Two readers on one UART; UART is point-to-point

Three of these rows are worth a closer look because they trip people who have already read the datasheet.

Logic level is not supply voltage. A module that runs from 5 V may still use 3.3 V UART levels, and the reverse can be true. Read both rows of the electrical table, for the exact model, before connecting the host. If the host is 3.3 V and the module output is 5 V, use a level shifter or a divider on the module's TX line. Do not assume a host pin is 5 V tolerant. For several models the manual does not state the signal level at all; in that case I would ask before wiring rather than infer it from the supply range.

Peak current, not average. Size the regulator for the peak, and put 10 to 100 µF of bulk capacitance near the module plus 100 nF of ceramic at the connector. The LRF50H, as an example, lists 34 mA average and 100 mA peak current. Our hardware notes also warn that some units emit a valid-looking frame with a zero or maximum distance during start-up, so a brown-out can look exactly like the "stuck near zero" or "stuck at maximum" rows. If the module shares a rail with a motor or a servo, give it its own regulator.

Measure at the connector. The supply voltage that counts is the one at the module's connector, not the one at the power supply. The same goes for the UART: measure the TX idle level and the baud rate with a scope or logic analyser, and do not trust the voltage a USB-serial adapter claims.

The diagnostic sequence

This is the order that makes me ask for the least back and forth:

  1. Physical. Supply voltage at the module connector.
  2. Electrical. TX idle level and baud rate on a scope or analyser.
  3. Protocol. Raw bytes captured, with header, length and checksum verified independently of your parser.
  4. Optical. A cooperative target at a known distance, indoors, no window.
  5. Environmental. Repeat with the real window, the real light and the real motor running.
  6. Log. Keep 1,000 raw frames and the parser's rejection reasons.

Step 6 is the one people skip, and it is the cheapest. At the LRF50H default of 1 kHz, 1,000 frames is one second of data. At a 10 Hz rate it is 100 seconds. Either way it fits in a file you can attach to an email.

Turning the log into a verdict

The script below reads a raw 5C capture (the free-running 4-byte stream used by the H and VB series), classifies each byte or frame, and prints a counter set plus a pointer into the table. It does not decide anything for you. The thresholds are mine: "most" is half the bytes lost, and "stuck" is 90% of frames.

MODELS = { # metres per count, out-of-range marker, rated min m, rated max m "LRF50H": (0.01, 65535, 0.05, 50.0), "LRF22VB": (0.001, 20000, 0.05, 20.0), } def triage(data, model="LRF50H"): scale, marker, min_m, max_m = MODELS[model] c = dict(bytes=len(data), frames=0, no_header=0, bad_checksum=0, marker=0, beyond_max=0, below_min=0, ok=0) i = 0 while i < len(data): if data[i] != 0x5C: c["no_header"] += 1; i += 1; continue if i + 4 > len(data): break lo, hi, chk = data[i+1], data[i+2], data[i+3] if chk != (~(lo + hi)) & 0xFF: c["bad_checksum"] += 1; i += 1; continue raw = lo | (hi << 8); m = raw * scale; i += 4 c["frames"] += 1 if raw == marker: c["marker"] += 1 elif m > max_m: c["beyond_max"] += 1 elif m < min_m: c["below_min"] += 1 else: c["ok"] += 1 v = [] if c["bytes"] == 0: v.append("No bytes at all: TX idle level, ground, baud rate, wrong pin order.") else: lost = 1 - 4 * c["frames"] / c["bytes"] if lost >= 0.5: v.append("Most bytes are not part of a valid frame: logic level, cable, motor noise, baud rate.") elif lost > 0.005: v.append("%.1f%% of bytes are outside valid frames: a few checksum failures point at noise or a marginal level; log the count." % (lost * 100)) if c["frames"]: if c["marker"] >= 0.9 * c["frames"]: v.append("Distance stuck at the out-of-range marker: target and window.") if c["below_min"] >= 0.9 * c["frames"]: v.append("Distance stuck below the rated minimum: window and mounting.") if c["beyond_max"]: v.append("%d frame(s) beyond the rated maximum: count them, do not average them." % c["beyond_max"]) if not v: v.append("Nothing wrong at the frame level in this log: repeat with a cooperative target, then with the real window.") return c, v 

How to read the output:

  • Most bytes lost. This is the "checksum fails on most frames" row, and it is also what a wrong baud rate looks like. The H series ships at 460800 baud by default; a host set to 115200 will see almost nothing that passes. Check level and baud before you check cabling.
  • Stuck at the marker or below the minimum. The frames are fine and the optics are not. The rated minimum is 0.05 m for these two models, so a raw count that converts to less than that is not a distance. Look at the window and the target.
  • Frames beyond the rated maximum. The table's usual suspect is sunlight. I would not stop there. In a factory bench capture of an LRF50H against a wall 1.9 m away, 3 of 2000 checksum-valid frames read between 315 and 397 m on a 50 m module, and I have no explanation for them. Count them and drop them. Do not average them.
  • Nothing wrong. Then the problem is not in the byte stream. Go back to steps 4 and 5.

The script cannot see timing, so it cannot see the "a few good frames, then silence" row. That one shows up on a scope looking at the supply at the connector, not in a byte log.

What I ran

The script runs under Python with assertions on synthetic logs, not on a live module:

  • 1,000 good frames of 196 (1.96 m on LRF50H) give 1,000 ok and the "nothing wrong" verdict.
  • An empty file gives the "no bytes" verdict.
  • 4,000 pseudo-random bytes give the "most bytes" verdict (about 16 checksum rejections and no frame passes).
  • 1,000 frames of the 65535 marker give "stuck at the marker"; 1,000 frames of raw count 2 (0.02 m) give "stuck below minimum".
  • 997 good frames plus raw counts 31496, 36977 and 39688 give 3 beyond-max and 997 ok.
  • Every second frame with one flipped checksum bit gives the "most bytes" verdict; 10 corrupted frames in 1,000 give "1.0% of bytes are outside valid frames".
  • A single corrupted frame in 1,000 is below my 0.5% line and the log reads as clean.
  • LRF22VB: 10 frames of 1709 give 10 ok, and 10 frames of 20000 give 10 markers.

I have not tested it against a real wiring fault. The synthetic logs only show that the classifier does what the table says.

What to send if you do need us

Model and document revision; a raw hex capture of at least 20 frames including the failing ones; the parser or checksum code you use; the supply voltage measured at the connector and the UART logic level; target material, distance and ambient light for the failing case; and whether it reproduces on the bench with a cooperative target. Please do not send only a filtered plot. A smoothed distance curve cannot tell me whether the fault is a checksum or a timing problem.

Where to look next

Send captures to tommy@erdimail.com.

Disclosure: I am Tommy Yu, an engineer at ERDI TECH LTD (erdilrf.com), the manufacturer of the modules discussed. Data checked against our field-troubleshooting and hardware notes, the LRF50H model record and the 2026-11-06 factory bench capture on 2026-11-18.

原文:https://www.a8q9.cn/en/article/before-you-blame-the-rangefinder-a-field-checklist-and-the-1000-frame-log-fc4910.html

相关文章