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

LRF0305C single-shot reply: converting Result2/Result1/Result0 to metres

Viewed 0

Frequently asked by integrators; answered by ERDI Engineering.

The LRF0305C manual gives the reply as EE 16 06 03 02 Status Result2 Result1 Result0 Check, but no worked example. How do I get metres from the three result bytes, what do the Status values mean, and how is the checksum built?

1 Answers

The reply to the single-shot command EE 16 02 03 02 05 is:

EE 16 06 03 02 Status Result2 Result1 Result0 Check

  • EE 16 is the fixed header, 06 the number of valid bytes after it (device code, command, Status and three result bytes), 03 the device code.
  • Distance in metres = Result2 x 256 + Result1 + Result0 x 0.1. Result2 is the high byte, Result1 the low byte, Result0 the decimal part.
  • Status in first/last-target mode: 0x00 single target, 0x01 a front target present, 0x02 a rear target present, 0x04 beyond range. In multi-target mode the low four bits carry the same meaning plus 0x3 for both front and rear targets, and the high four bits are the index of the current result, with at most three targets.
  • Check = low 8 bits of the sum of device code, command code and all parameters (here Status and the three result bytes).

The manual prints no numeric reply, so here is a constructed example using its formula: Status 00, Result2 01, Result1 2C, Result0 05 gives 1 x 256 + 44 + 0.5 = 300.5 m, and the check byte is 0x03 + 0x02 + 0x00 + 0x01 + 0x2C + 0x05 = 0x37. The frame would be EE 16 06 03 02 00 01 2C 05 37.

def lrf0305c_dist(f):
    assert f[0] == 0xEE and f[1] == 0x16 and f[3] == 0x03 and f[4] == 0x02
    if (sum(f[3:9]) & 0xFF) != f[9]:
        return None
    status = f[5] & 0x0F
    if status == 0x04:
        return None                       # beyond range
    return f[6] * 256 + f[7] + f[8] * 0.1

Related commands in the same table: first-target mode EE 16 03 03 03 01 07, last-target mode EE 16 03 03 03 02 08, multi-target EE 16 03 03 03 03 09, continuous ranging EE 16 02 03 04 07, stop EE 16 02 03 05 08. The datasheet does not give the byte encoding of the version and serial-number replies; email us and we confirm in writing.

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.