diff --git a/wiki/pages/patrol-gauge-outputs.md b/wiki/pages/patrol-gauge-outputs.md index bd1d3b1..f4d5ac7 100644 --- a/wiki/pages/patrol-gauge-outputs.md +++ b/wiki/pages/patrol-gauge-outputs.md @@ -6,11 +6,11 @@ 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]]. +Goal (user, 2026-09-21): generate signals from Inst. Cluster 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. +Main CTRL (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 @@ -56,6 +56,22 @@ PWM drive from the curve: Tachometer, 4 ppr: f = rpm × 4 / 60 → ~47 Hz at 700 rpm, ~267 Hz at 4000 rpm. Before wiring: measure the tach input's open-circuit voltage with ignition on — battery voltage means the cluster has its own pull-up (open-collector output suffices); near zero means add a pull-up to 12 V. Verify the needle at two known LEDC frequencies before trusting the scaling. +## 2N2222 output stage — concrete wiring (2026-09-28, user's part choice; unverified on the cluster) + +One NPN per output, low-side open-collector switch. TO-92 P2N2222A / PN2222A with the flat face toward you: **E - B - C** left to right (metal-can 2N2222: the tab is next to the emitter). Check the datasheet of the exact part - the EBC order is not universal. + +| Pin | Goes to | Why | +|---|---|---| +| Emitter | GND, shared by B, the transistor and the cluster (chassis) | the switch pulls the cluster wire toward this ground | +| Base | B's GPIO (IO7 tach, IO8 temp) through **1 kΩ** | 3.3 V pin → ~2.6 mA base current → saturated for anything up to ~100 mA collector; without it the pin drives a diode directly | +| Base | also **10 kΩ to GND** | keeps the transistor OFF while the ESP32 boots and the pin floats | +| Collector | the cluster wire (see below) | open collector: pulls low when the GPIO is high | + +- **Tach (IO7)**: collector straight to the cluster's tach input. Meter the input first, ignition on: ~12 V = the cluster has its own pull-up, done; ~0 V = add **4.7 kΩ from the collector to +12 V**. +- **Temp (IO8)**: collector → **series resistor** → sender wire; the resistor equals the hottest sender resistance the needle should ever show (100 % duty = that value, the meter integrates lower duties). Add a **1N4148 from collector (cathode) to +12 V (anode)** — the gauge coil is inductive enough to spike the collector when the PWM switches; 40 V rating on the 2N2222 is otherwise fine. +- Never let the 12 V side reach a GPIO: the base resistor and the collector being the only 12 V-side node take care of that. No diode/resistor is needed on the GPIO itself. +- A logic-level N-MOSFET (e.g. IRLZ44N, AO3400) does the same job without base current: gate to GPIO through 100 Ω, 10 kΩ gate-to-GND, source to GND, drain as the collector above. + ## Prior art: the user's CANNY 5.3 pico program (source: temp-stage-cfd) The user drove this gauge before, from the BMW CAN bus, with a CannyLab program → [[temp-stage-cfd]]. Recovered from the file: @@ -69,7 +85,7 @@ Starting point for the LEDC implementation: 8-bit duty, `duty = clamp(1.5·T + 5 ## Tuning parameters — declared on A, executed on B (implemented 2026-09-21) -Calibration lives on Controller A (NVS; the **Gauge Tuning touchscreen page** — Home → right → Driveline → right — or the `cfg` serial console) and is pushed to B in CONFIG frames; B executes and caches the last config in its own NVS. `link_config_t` in the shared protocol header: +Calibration lives on Main CTRL (NVS; the **Gauge Tuning touchscreen page** — Home → right → Driveline → right — or the `cfg` serial console) and is pushed to B in CONFIG frames; B executes and caches the last config in its own NVS. `link_config_t` in the shared protocol header: | Group | Parameter | Default | Note | |---|---|---|---|