This page has moved into the new guide: Ranger 2-Way › mBlock › mBlock 5

Laser Ranger 2-ch × mBlock 5 (Makeblock edition)

Back to Laser Ranger 2-ch

The Makeblock edition of the Laser Ranger 2-ch plugs into an RJ25 port on mBot, Ranger, Orion or MegaPi and is read with the MBC Pro Sensors extension v2 blocks. Installation and usable ports per board: Makeblock extension.

SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit

Wiring

Laser Ranger 2-ch × mBot

Sensor → mBot adapter → RJ25 port on the board (S1 = host TX, S2 = host RX). UART 38400 8N1.

Reporter blocks

Block Returns Id Meaning
Ranger 2 port [port] left distance cm 0~120 cm 01 distance from the left sensor, 0~120 cm (left = sensor 0 seen from behind the robot); 120 = nothing in range / sensor failed
Ranger 2 port [port] right distance cm 0~120 cm 02 distance from the right sensor, 0~120 cm (right = sensor 1); 120 = nothing in range / sensor failed
Ranger 2 port [port] nearer distance cm 0~120 cm 03 the smaller of left and right, 0~120 cm
Ranger 2 port [port] left distance mm 0~1200 mm 04 left sensor distance 0~1200 mm; 1200 = nothing in range / sensor failed
Ranger 2 port [port] right distance mm 0~1200 mm 05 right sensor distance 0~1200 mm; 1200 = nothing in range / sensor failed
Ranger 2 port [port] init bitmap 0~3 bit 06 bit0 = left, bit1 = right; 1 = that sensor initialised at power-on (no retry); 3 = both OK
Ranger 2 port [port] fault bitmap 0~3 bit 07 bit0 = left, bit1 = right; 1 = that sensor is currently failing (I2C error or no update for 200 ms); its distance reads 120 / 1200
Ranger 2 port [port] average distance mm 0~1200 mm 08 (left mm + right mm) / 2, 0~1200; same number as EV3 mode 3 and the 3rd value of SPIKE mode 6

Command blocks

Block Id Meaning
Ranger 2 port [port] update all values FD reads the whole value table into a cache (FD pack-all); reporter blocks within the next 10 ms use the cache instead of asking one by one

Status blocks

The extension exposes each F3 bit as a boolean block:

bit Name Meaning
b0 ready (ready) 1 once both sensors are initialised and snapshots are running
b1 any sensor failed (fault) 1 if any sensor failed to initialise, has an I2C error or no update for 200 ms (07 ≠ 0 or 06 ≠ 3)

Packet format (for your own decoder)

mBlock 3-byte packet
Action Format
Read one value 主機送 [編號] → 回 [值低][值高][編號^值低^值高]
Write command 寫入命令 E0~EE:收齊參數後回 [00][00][編號] 再執行;20 ms 內沒收齊就丟棄
Unknown id [00][80][編號^0x80](= -32768)
Pack all (FD) Send [FD] → reply [AA][08][8 × int16 LE][xor], xor = AA ^ N ^ all data bytes; content = this value table in ascending id order (shared ids and commands excluded). The extension fetches it once and serves blocks from a 10 ms cache.
Shared ids F0 device ID, F1 protocol version, F2 firmware version, F3 status flags
FD pack-all packet

Sources and assumptions

Generated by _build/gen-reference.mjs from _build/protocol/tof2.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).

  • 共識 #8:08 左右平均 mm 補進 I2C/mBlock 值表(定案 §5 已列)。
  • 0x22 命令 412 不動(4 左、5 右、6 最近、711 = 0、12 = 最近);schema 不收 11/12,所以 12 只寫在 03 的 note。
  • EV3:模式 0、2、4 鎖住(照盤點);模式 1 改 [左,右]×4(index 0/1 各代表左右)、模式 3 改平均 mm、模式 5 改 [左 mm, 右 mm];模式 1 描述表宣告 int8 −100~100,cm×100/120 在範圍內。
  • SPIKE:0/5/7/9 鎖住,另加模式 3 鎖住(網站 sensors/tof2/index.md read(3) = 左/右 cm,共識 #11);模式 6 改 [左 mm, 右 mm, 平均 mm];模式 1、2、4、8 維持不動;模式 8 v[0] 改 ID|hw[0]<<8(統一後共用函式)。
  • 「左」= 站在車後往前看的左(第 0 顆,XSHUT PA6);韌體只有 L/R 巨集名,盤點檔標為推測。
  • 沒有寫入命令;F8 換位址/EF 重開機用共用的。
  • Block wording follows the v2.0.0 extension generator build_mext.js; this page is generated from the same JSON.
Email for a quoteBuying Guide