Add wiki second brain and root CLAUDE.md; retire .docs

- New wiki/ (Obsidian vault) following the LLM Wiki pattern: schema, index, log,
  entity page for the board, concept pages for the A->B link, wired+wireless
  redundancy, and Patrol gauge outputs, open questions, two sources
- New CLAUDE.md distilled from the surviving .docs content: verified pins,
  brightness/receiver/debug APIs, SquareLine rules, CH343 serial notes,
  gear-enum drift warning, Waveshare demo and schematic URLs
- Delete .docs/ (14 files): stale pin-hunting and troubleshooting guides,
  wrong header table, finished phase roadmap, duplicate UART spec (now in the
  5B repo at docs/UART_PROTOCOL.md)
- README.md repointed to CLAUDE.md and wiki/

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-21 10:57:05 +02:00
parent b6fb01ba73
commit 3613387d41
31 changed files with 869 additions and 3965 deletions
+49
View File
@@ -0,0 +1,49 @@
---
type: concept
tags: [gauges, pwm, ledc, nissan-patrol, hardware, design]
updated: 2026-09-21
---
# Driving the Patrol Cluster Gauges
Goal (user, 2026-09-21): generate signals from Controller B to drive the Nissan Patrol instrument cluster's **RPM (tachometer)** and **engine coolant temperature** gauges, fed by the BMW data that arrives over the [[controller-link]].
## Why B and not A
Controller A (5B) has no free native GPIO on any header: the RGB LCD, I2C, CAN, RS485, USB and PSRAM consume every pin, and its two "DO" terminals are optocoupled outputs driven through a CH422G I2C expander — no hardware timer can reach them `(sibling: 5B wiki → esp32-s3-touch-lcd-5b; schematic reviewed 2026-09-21)`. B exposes 13 free GPIOs on headers ([[esp32-s3-lcd-1-3]]), all usable by the ESP32-S3 LEDC peripheral.
## Two very different signals
| Gauge | What the cluster expects | What B must generate | Status |
|---|---|---|---|
| Tachometer | a pulse train whose **frequency** tracks engine speed; the source and pulses-per-revolution depend on the cluster variant | variable-frequency square wave at ~50 % duty, on one LEDC channel with its **own timer** | source data (RPM from CAN 0x0AA) verified on A `(sibling: 5B wiki → can-id-candidates)`; **not yet in the packet** |
| Coolant temp | a moving-coil/bimetal gauge that reads the **resistance to ground** of the sender | fixed-frequency PWM with variable **duty** into a low-side switch, so the gauge integrates it as an average resistance | coolant already in the packet as 0.1 °C |
The two need separate LEDC timers because one varies frequency and the other varies duty. ESP32-S3 LEDC has 8 channels on 4 timers `(unverified — datasheet figure from memory, confirm)`.
## Proposed pin assignment (unverified — proposal only)
- **IO7** → tachometer pulse output
- **IO8** → coolant gauge PWM output
Both on the right header, adjacent to GND-free pins, so add a ground wire from the left header. IO3 deliberately avoided (strapping pin). IO1 stays the UART RX.
## Electrical interface — mandatory external stage (unverified)
3.3 V logic drives neither gauge directly.
- **Tach input**: Patrol clusters expect roughly 12 V-level pulses (ignition-coil negative or ECU tach output, open-collector with the cluster's internal pull-up). Use an NPN or logic-level N-MOSFET as an open-collector pulling the tach wire to ground; if the cluster has no internal pull-up, add one to +12 V (a few kΩ). Never feed 12 V back into IO7.
- **Temp gauge**: sender wire goes to ground through the sender's thermistor. Emulate it with a logic-level N-MOSFET (or NPN) pulling the sender wire to ground under PWM, plus a series resistor sized so 100 % duty corresponds to the hottest resistance you want to show. The gauge's thermal/mechanical lag averages the PWM; use a few hundred Hz to 1 kHz so nothing flickers. Calibration is a lookup table from °C → duty, built empirically against the needle.
- Optocouplers between B and the 12 V cluster side are cheap insurance; the 5B's own DO stage (PC817 → transistor) is a reasonable pattern to copy.
## What must be established before any of this is wired
1. **Which Patrol cluster** (Y60/Y61, petrol vs diesel). Diesel clusters were fed from the alternator W-terminal at a much higher frequency and often have a calibration trimmer; petrol clusters expect ~3 pulses/rev for a 6-cylinder from the ignition system `(unverified)`. This fixes the frequency range and therefore the LEDC resolution/prescaler. → [[open-questions]]
2. Whether the cluster's tach input has an internal pull-up, and to what voltage (meter it).
3. The temp sender's resistance-vs-temperature curve as the gauge sees it (meter the original sender at cold/hot, or sweep a pot until the needle sits at known marks).
4. Protocol change: add `engine_rpm` (u16, 1/min) and a `valid_flags` bit to the packet; bump the version on both repos → [[controller-link]].
5. The outage policy: what the needles do when the link is lost → [[link-redundancy]].
## Related
[[esp32-s3-lcd-1-3]] · [[controller-link]] · [[link-redundancy]] · [[open-questions]]