Forums Technical Articles Developer Docs 中文区 UART Decoder Module Database Models Quotes & Orders EN · 中文 · 日本語 · DE · ES

Same frame, tenfold different distance: LRF22VB reports millimetres, LRF100H reports centimetres

Viewed 0

Frequently asked by integrators; answered by ERDI Engineering.

I wrote one 5C-frame parser and used it for an LRF22VB on the bench and an LRF100H on the vehicle. The H module reads ten times too large (or the VB ten times too small, I cannot tell which). Do both families really use the same unit?

1 Answers

No. Both modules stream the same kind of 4-byte frame, but the unit of one count differs:

Series Wire unit
VB (LRF10VB, LRF22VB, LRF50VB) millimetres
H (LRF50H, 100H, 200H, 300H, 600H) centimetres
LRF1500H centimetres, but a 3-byte distance in a 5-byte frame

The frame is 5C, distance low byte, distance high byte, checksum. The checksum is the bitwise inverse of the sum of the bytes between header and checksum. Take 5C 02 11 EC: the distance is 0x1102 = 4354 counts. Checksum check: 0x02 + 0x11 = 0x13, inverted gives 0xEC. On an LRF22VB that is 4,354 mm = 4.354 m; on an LRF100H it is 4,354 cm = 43.54 m.

Do not guess the unit from the family or from the part number. Both manuals state their unit explicitly, and our driver keeps a per-model table for exactly this reason. Per-model out-of-range markers differ as well: LRF22VB outputs 20000, LRF50VB 50000, LRF10VB and the H series 65535, and the LRF1500H 16777215. Treat a marker as "no target", never as a distance.

UNIT_M = {"LRF22VB": 0.001, "LRF50VB": 0.001, "LRF10VB": 0.001,
          "LRF50H": 0.01, "LRF100H": 0.01, "LRF200H": 0.01,
          "LRF300H": 0.01, "LRF600H": 0.01}
NO_TARGET = {"LRF22VB": 20000, "LRF50VB": 50000, "LRF10VB": 65535,
             "LRF50H": 65535, "LRF100H": 65535, "LRF200H": 65535,
             "LRF300H": 65535, "LRF600H": 65535}

def decode(model, f):          # f = 4 bytes: 5C lo hi chk
    if f[0] != 0x5C or (~(f[1] + f[2]) & 0xFF) != f[3]:
        return None
    raw = f[1] | (f[2] << 8)
    return None if raw == NO_TARGET[model] else raw * UNIT_M[model]

Default baud for both families is 460800, so a software serial port on a small MCU will not keep up; use a hardware UART or lower the baud rate with the documented command. The repository at https://github.com/ErdiTech/erdi-lrf-drivers has the tested table.

Sources:

ERDI Verified Answer — checked against the datasheet by ERDI Engineering.

ERDI Engineering Community is run by ERDI TECH LTD (Chengdu, China) · erdilrf.com · GitHub · Civil applications only · Questions about modules from any brand are welcome.