跳转到内容

20260928-0908-key-expansion-units Scale Key with MCU-less expansion units instead of one MCU per eight keys

  • status: completed
  • createdAt: 2026-09-28 09:08
  • approvedAt: 2026-09-28 09:08 (owner: "最好可以容易扩展不然 mcu 很贵")
  • relatedTask: 20260928-0908-key-expansion-units

Key R0.3 sets eight keys per unit because the ESP32-C6-MINI-1 has 22 GPIOs, and scales by adding units, each a CAN node with its own module. Electronics per unit (LCSC retail, 2026-09-28): module 2.83 + TJA1463 0.66 + LP5036 0.93 = about 4.42 USD, so 40 keys cost about 22 USD in controllers, transceivers and drivers alone. The owner wants expansion to be cheap.

An expansion board needs only key inputs and LED channels. Both are I2C parts already named in the evaluation: a 16-bit I/O expander with interrupt (AW9523B 0.33, XL9555 0.39–0.53, TCA9555 0.35–0.87) and a 36-channel LED driver (IS31FL3236A 0.52, LP5036 0.93). That is 0.85–1.26 USD per eight keys.

40 keys Parts Controller, transceiver and driver cost
Five base units 5 × (module + transceiver + driver) about 22.1
One base + four expansion units 1 × 4.42 + 4 × (expander + driver) about 7.8–9.5

I2C address pins allow four boards per bus for the parts above (two address pins, or one pin with four levels), which gives 8 + 4 × 8 = 40 keys on one base unit. The address count per part must still be confirmed from the datasheets.

Limits of I2C between boards: it is a short, single-ended bus. It suits boards inside one assembly on a harness of a few tens of centimetres, at 100 kHz, with series resistors and ESD protection; it does not suit panels metres apart on a boat. Those stay separate base units on CAN.

  • Spec R0.3 (amended in place): base unit with up to eight keys and the MCU; expansion unit with eight keys and no MCU; up to four expansion units per base unit, 40 keys, one CAN node; further or distant panels use additional base units. New requirement KEY-21: loss of an expansion unit or a fault on the expansion bus must not disturb the base unit's keys or CAN control, must not generate key events, and marks the missing keys unavailable without showing stale state. KEY-02, KEY-O-11 and the §2 text follow.
  • Design R0.3 (amended): §2.2 becomes "base unit, expansion units and further base units" with the pin table (the transceiver mode pins are strapped in hardware, freeing one GPIO for the shared expansion interrupt), the expansion board parts, addressing by position-coded connector pins, bus rules (100 kHz, ≤0.3 m, series resistors, ESD, optional buffer), fault detection and the cost table; diagram and LED table updated.
  • Guide R0.4 (amended): V-06 adds expansion bus fault and hot-plug tests; quotation lists the expansion unit as its own item.
  • Brief, package index, line spec and index, product plan, open questions, evaluation page.
  • An I2C harness in a marine panel is exposed to EMC and connector faults; KEY-21 and the bus rules address this, and the harness length is capped.
  • A stuck I2C bus (a slave holding SDA low) would also block the base unit's own LED driver if they share a bus; the design must either recover the bus by clocking it free or put the expansion connector behind a buffer or switch that the MCU can disconnect.
  • All 40 keys sit behind one MCU and one CAN node: a base unit failure takes the whole assembly down, where five independent units would lose eight keys. Critical circuits should be spread over separate base units.
  • LED current of five boards comes from the base unit's 5 V rail; the buck converter and the connector must be sized for it.

Key spec, design, guide, brief, index, evaluation; line spec and line index; product plan; open questions; changelog. No change to requirement IDs other than the new KEY-21.

  • Keep one MCU per eight keys. Simplest electrically and most fault-tolerant, but about 2.5 times the controller cost at 40 keys. Remains available as "additional base units".
  • Cheaper MCU per unit (for example ESP32-H2 at 1.69 or a plain CAN MCU on the expansion units). Still one MCU, transceiver and firmware image per eight keys.
  • Matrix scanning from the base unit. Fewer parts, but ghosting needs a diode per key and the wiring between boards grows with the matrix size.
  • 2026-09-28 09:08 (owner): "最好可以容易扩展不然 mcu 很贵". Approved in the request; implemented as an amendment to the uncommitted R0.3.