Home › Guide › Protocol
Nine questions to ask about a rangefinder's serial protocol
Most integration failures are not optical. They are the frame format, the latency and the thing the datasheet did not say. Ask these before you write firmware.
1. Framing
Fixed-length binary frame, delimited ASCII, or length-prefixed? Binary frames are compact and easy to checksum but painful to debug; ASCII is slower but you can watch it in a terminal. Ask for a hex dump of one measurement from the vendor — if they cannot produce one, the document is a guess.
2. Byte order and field widths
Little-endian is common; not universal. Distance in millimetres, centimetres or a raw count? A "range" field that is a raw time-of-flight count needs the clock constant, which is often only in an app note.
3. Checksum
Sum, XOR, CRC-8 or CRC-16, and over which bytes (header included or not). Get the seed value if it is a CRC variant. This is where most first-day integrations die.
4. Units and scale
Is the reported figure the slant range, the horizontal projection, or already corrected? For 1535 nm modules the raw number is slant range; any projection is your job.
5. Signalling
Level (3.3 V TTL, 5 V, RS-422 differential), baud, parity, stop bits, and whether the module drives TX during boot. Some modules emit garbage for the first few hundred milliseconds — your parser needs to resynchronise on a header, not on the first byte.
6. Trigger semantics
Command-triggered, free-running, or hardware-triggered? Edge or level sensitive? What is the latency from trigger to pulse? If you geo-reference, the emission time is the timestamp you want.
7. Status and errors
What does the module return when it gets no return: a zero, a max-value sentinel, or an error code with a reason (weak signal, multiple returns, self-test fail)? Conflating "no return" with "0 m" is a classic.
8. Multi-target output
First/last return selection, or up to N targets per shot? If N, how are the targets ordered and what is the minimum separation? Useful against foliage and clutter, useless if your parser assumes one number per frame.
9. Timing and buffering
Is the reported figure the slant range... and how long after the pulse is the frame ready? Faster is not always better: a 10 kHz stream with 20 ms of buffering is worse than 100 Hz with none. Ask for the end-to-end latency, not the update rate.