diff --git a/tools/dual_serial_capture.py b/tools/dual_serial_capture.py new file mode 100644 index 0000000..82eed72 --- /dev/null +++ b/tools/dual_serial_capture.py @@ -0,0 +1,40 @@ +"""Capture N seconds from two serial ports in parallel and print what arrived.""" +import sys +import time +import threading + +import serial + +PORTS = sys.argv[1].split(",") if len(sys.argv) > 1 else ["COM8", "COM9"] +SECONDS = float(sys.argv[2]) if len(sys.argv) > 2 else 6.0 +MAX_LINES = 40 + + +def cap(port, out): + try: + s = serial.Serial(port, 115200, timeout=0.5) + end = time.time() + SECONDS + buf = b"" + while time.time() < end: + buf += s.read(4096) + s.close() + out[port] = buf + except Exception as e: + out[port] = ("ERR: %s" % e).encode() + + +out = {} +threads = [threading.Thread(target=cap, args=(p, out)) for p in PORTS] +for t in threads: + t.start() +for t in threads: + t.join() + +for p in PORTS: + data = out.get(p, b"") + print("=" * 20, p, "bytes:", len(data), "=" * 20) + lines = data.decode("utf-8", "replace").splitlines() + for ln in lines[:MAX_LINES]: + print(ln) + if len(lines) > MAX_LINES: + print("... (%d more lines)" % (len(lines) - MAX_LINES)) diff --git a/tools/serial_cmd.py b/tools/serial_cmd.py new file mode 100644 index 0000000..7e8b3d7 --- /dev/null +++ b/tools/serial_cmd.py @@ -0,0 +1,23 @@ +"""Send a command line to a serial port and print the reply. + +Usage: python tools/serial_cmd.py COM10 "cfg show" [read_seconds] +""" +import sys +import time + +import serial + +port = sys.argv[1] +cmd = sys.argv[2] +secs = float(sys.argv[3]) if len(sys.argv) > 3 else 3.0 + +s = serial.Serial(port, 115200, timeout=0.5) +s.reset_input_buffer() +s.write((cmd + "\n").encode()) +s.flush() +end = time.time() + secs +buf = b"" +while time.time() < end: + buf += s.read(4096) +s.close() +print(buf.decode("utf-8", "replace")) diff --git a/tools/serial_logger.py b/tools/serial_logger.py new file mode 100644 index 0000000..fe10d3d --- /dev/null +++ b/tools/serial_logger.py @@ -0,0 +1,66 @@ +"""Log one or more serial ports to timestamped files until Ctrl+C. + +Usage: + python tools/serial_logger.py COM9 # one port + python tools/serial_logger.py COM8,COM9 # several ports + python tools/serial_logger.py COM9 logs/ # custom output dir (default: wiki/raw/) + +Each port gets its own file, e.g. wiki/raw/serial-COM9-20260922-141503.log. +Lines are echoed to the console prefixed with the port name. Read-only: +nothing is ever written to the port, so it is safe next to a live bus. +""" +import os +import sys +import time +import threading +from datetime import datetime + +import serial + +ports = sys.argv[1].split(",") if len(sys.argv) > 1 else ["COM9"] +out_dir = sys.argv[2] if len(sys.argv) > 2 else os.path.join("wiki", "raw") +os.makedirs(out_dir, exist_ok=True) + +stop = threading.Event() +print_lock = threading.Lock() + + +def log_port(port): + stamp = datetime.now().strftime("%Y%m%d-%H%M%S") + path = os.path.join(out_dir, "serial-%s-%s.log" % (port, stamp)) + with print_lock: + print("[%s] logging to %s" % (port, path)) + try: + s = serial.Serial(port, 115200, timeout=0.5) + except Exception as e: + with print_lock: + print("[%s] ERROR opening port: %s" % (port, e)) + return + with open(path, "wb") as f: + pending = b"" + while not stop.is_set(): + data = s.read(4096) + if not data: + continue + f.write(data) + f.flush() + pending += data + while b"\n" in pending: + line, pending = pending.split(b"\n", 1) + with print_lock: + print("[%s] %s" % (port, line.decode("utf-8", "replace").rstrip())) + s.close() + with print_lock: + print("[%s] closed, log saved: %s" % (port, path)) + + +threads = [threading.Thread(target=log_port, args=(p,)) for p in ports] +for t in threads: + t.start() +try: + while any(t.is_alive() for t in threads): + time.sleep(0.2) +except KeyboardInterrupt: + stop.set() +for t in threads: + t.join() diff --git a/tools/tach_ramp.py b/tools/tach_ramp.py new file mode 100644 index 0000000..e7688e2 --- /dev/null +++ b/tools/tach_ramp.py @@ -0,0 +1,37 @@ +"""Sweep the tach via A's override: 800 -> 3500 -> 800 rpm, then override off. + +Usage: python tools/tach_ramp.py COM10 [step_rpm] [step_ms] +Sends 'cfg override rpm N' lines over A's console; A pushes each as a CONFIG +frame to B. Ctrl+C aborts and switches the override off. +""" +import sys +import time + +import serial + +port = sys.argv[1] if len(sys.argv) > 1 else "COM10" +step = int(sys.argv[2]) if len(sys.argv) > 2 else 50 +dwell = (int(sys.argv[3]) if len(sys.argv) > 3 else 150) / 1000.0 + +s = serial.Serial(port, 115200, timeout=0.1) +# Native-USB boards reset when the port opens - give A time to boot. +time.sleep(4) +s.reset_input_buffer() + + +def send(cmd): + s.write((cmd + "\n").encode()) + s.flush() + + +try: + points = list(range(800, 3501, step)) + list(range(3500, 799, -step)) + print("ramp: %d points, %d ms each (~%.0f s total)" % (len(points), dwell * 1000, len(points) * dwell)) + for rpm in points: + send("cfg override rpm %d" % rpm) + time.sleep(dwell) +finally: + send("cfg override off") + time.sleep(0.5) + s.close() + print("done, override off") diff --git a/tools/tach_ramp2.py b/tools/tach_ramp2.py new file mode 100644 index 0000000..c1baece --- /dev/null +++ b/tools/tach_ramp2.py @@ -0,0 +1,40 @@ +"""Ramp tach override 800 -> 6000 rpm, hold 5 s, ramp back down, override off. + +Usage: python tools/tach_ramp2.py COM10 [step_rpm] [step_ms] +""" +import sys +import time + +import serial + +port = sys.argv[1] if len(sys.argv) > 1 else "COM10" +step = int(sys.argv[2]) if len(sys.argv) > 2 else 25 +dwell = (int(sys.argv[3]) if len(sys.argv) > 3 else 40) / 1000.0 + +s = serial.Serial(port, 115200, timeout=0.1) +time.sleep(4) # native-USB reset on port open +s.reset_input_buffer() + + +def send(cmd): + s.write((cmd + "\n").encode()) + s.flush() + + +try: + up = list(range(800, 6001, step)) + down = list(range(6000, 799, -step)) + print("up %d pts, hold 5 s at 6000, down %d pts" % (len(up), len(down))) + for rpm in up: + send("cfg override rpm %d" % rpm) + time.sleep(dwell) + send("cfg override rpm 6000") + time.sleep(5) + for rpm in down: + send("cfg override rpm %d" % rpm) + time.sleep(dwell) +finally: + send("cfg override off") + time.sleep(0.5) + s.close() + print("done, override off") diff --git a/wiki/index.md b/wiki/index.md index c31f1a5..eaa4ab2 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -9,6 +9,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee ## Entities +- [[patrol-instrument-cluster]] — **what the Patrol cluster expects on its inputs**: tach = 2 pulses/rev (verified by calibration), temp = NTC sender 2.1–2.9 kΩ cold → ~250 Ω at 90 °C; the 1 kHz PWM needle-flutter problem and the mitigation ladder (fixed-duty test → 20 kHz → hardware damping) - [[bmw-m57n-engine]] — the 3.0L BMW diesel whose CAN bus we read; E60/E65 donor (confirmed), DDE ECU, auto box with EGS on bus - [[nissan-patrol-swap]] — the target vehicle: Patrol receiving the M57N + BMW auto; the tapped bus is a BMW island in a Nissan - [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Controller A); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas @@ -22,6 +23,7 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee ## Synthesis +- [[canny-5-3-pico-gauge-drive]] — **why the CANNY-based setup moves the Patrol needles and our ESP32 doesn't**: CANNY "negative output" = 12 V-domain low-side switch, ESP32 IO7/IO8 = 3.3 V push-pull; the low-side transistor fix, and why it's not firmware PWM polarity - [[can-id-candidates]] — **the E60/E65 CAN ID map — now decoded end-to-end**: gear (lever + engaged + mode), coolant, gearbox temp (raw−40), battery (12-bit ×0.015), RPM, turbine speed, engine state all verified; placeholder IDs verified absent; fault codes and boost not passively broadcast - [[open-questions]] — the research frontier: bench-verify the candidate IDs, operating temp, transient protection, fault-code design decision diff --git a/wiki/log.md b/wiki/log.md index 2b6e674..79095d5 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -1,4 +1,4 @@ -# Log +# Log Append-only. `grep "^## \[" log.md | tail -5` for recent activity. @@ -8,15 +8,15 @@ Created schema (`CLAUDE.md`), `index.md`, `log.md`, and five seed pages built fr ## [2026-07-15] ingest | Waveshare ESP32-S3-Touch-LCD-5 product wiki -Re-clipped `raw/ESP32-S3-Touch-LCD-5B.md` ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]]. Answered two open questions: CAN transceiver is onboard (TJA1051T/3/1J, terminal block, 120 Ω termination switch off by default) and power is solved by the 7–36 V DC wide input (vehicle 12 V direct). New concern raised: operating temp spec is 0–65 °C, marginal for automotive. Updated [[esp32-s3-touch-lcd-5b]] and [[open-questions]]; added schematic PDF to sourcing wishlist. +Re-clipped `raw/ESP32-S3-Touch-LCD-5B.md` ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]]. Answered two open questions: CAN transceiver is onboard (TJA1051T/3/1J, terminal block, 120 Ω termination switch off by default) and power is solved by the 7–36 V DC wide input (vehicle 12 V direct). New concern raised: operating temp spec is 0–65 °C, marginal for automotive. Updated [[esp32-s3-touch-lcd-5b]] and [[open-questions]]; added schematic PDF to sourcing wishlist. ## [2026-07-15] ingest | E60 VFL CAN codes spreadsheet + Listen_and_send_PID Arduino sketch -Two raw sources ingested. (1) `E60 VFL CAN-Bus Codes.xlsx` (community table, ~130 ID blocks from a real pre-facelift E60) → [[e60-vfl-can-codes-xlsx]]: independently confirms 0x1D0 coolant raw−48 (0x7A→74 °C) and 0x3B4 battery voltage (leaning 12-bit LE layout, factor ≈0.0147–0.015), adds 0x304 as a 2-byte gear-lever candidate (P=E3/R=C2/N=D1/M=C9, D value suspect), engine-running flag in 0x3B4 byte 3; contains no oil-temp or gearbox-temp rows. (2) `Listen_and_send_PID_009c` (Arduino MCP2515+ELM327, 2013) → [[listen-and-send-pid-arduino]]: transmits E46 cluster frames from OBD PID polling — filed as technique reference for a future diagnostic-request mode; no map changes. [[can-id-candidates]] updated: coolant now "very high" confidence; oil/gearbox temps flagged as weakest signals. +Two raw sources ingested. (1) `E60 VFL CAN-Bus Codes.xlsx` (community table, ~130 ID blocks from a real pre-facelift E60) → [[e60-vfl-can-codes-xlsx]]: independently confirms 0x1D0 coolant raw−48 (0x7A→74 °C) and 0x3B4 battery voltage (leaning 12-bit LE layout, factor ≈0.0147–0.015), adds 0x304 as a 2-byte gear-lever candidate (P=E3/R=C2/N=D1/M=C9, D value suspect), engine-running flag in 0x3B4 byte 3; contains no oil-temp or gearbox-temp rows. (2) `Listen_and_send_PID_009c` (Arduino MCP2515+ELM327, 2013) → [[listen-and-send-pid-arduino]]: transmits E46 cluster frames from OBD PID polling — filed as technique reference for a future diagnostic-request mode; no map changes. [[can-id-candidates]] updated: coolant now "very high" confidence; oil/gearbox temps flagged as weakest signals. ## [2026-07-15] query | Deep research: E60/E65 CAN IDs for M57N + ZF EGS -Deep-research workflow ran (interrupted twice by session task-loss on Windows; ~82 agents total, 95 claims, 30 adversarial verifications completed; synthesis done manually from the journal). Result: [[can-id-candidates]] — coolant/oil temp on **0x1D0** (raw−48, DDE, 100 ms; confirmed live on a real E60), gear on **0x1D2** (EGS, 200 ms, two generation dialects that likely reconcile), gearbox oil temp on **0x0B5** byte 7 (offset disputed 0 vs +40 — bench-critical), battery voltage on **0x3B4** (layout disputed 12-bit×0.015 vs 24-bit×0.001). Fault codes are NOT passively broadcast — require 0x6F1/0x612 diagnostic requests; firmware `fault_codes` field needs a design decision. Firmware's placeholder IDs contradicted by every source. Updated [[can-bus-integration]]; index updated. Cost note: bulk of tokens spent in the initial (pre-interruption) run; resumes replayed from cache. +Deep-research workflow ran (interrupted twice by session task-loss on Windows; ~82 agents total, 95 claims, 30 adversarial verifications completed; synthesis done manually from the journal). Result: [[can-id-candidates]] — coolant/oil temp on **0x1D0** (raw−48, DDE, 100 ms; confirmed live on a real E60), gear on **0x1D2** (EGS, 200 ms, two generation dialects that likely reconcile), gearbox oil temp on **0x0B5** byte 7 (offset disputed 0 vs +40 — bench-critical), battery voltage on **0x3B4** (layout disputed 12-bit×0.015 vs 24-bit×0.001). Fault codes are NOT passively broadcast — require 0x6F1/0x612 diagnostic requests; firmware `fault_codes` field needs a design decision. Firmware's placeholder IDs contradicted by every source. Updated [[can-bus-integration]]; index updated. Cost note: bulk of tokens spent in the initial (pre-interruption) run; resumes replayed from cache. ## [2026-07-15] update | Donor and target vehicle confirmed by user @@ -24,35 +24,35 @@ User confirmed: donor chassis is **E60/E65 (2003+)**, transmission is a **BMW au ## [2026-07-16] ingest | Gear lever fully decoded & VERIFIED (0x1D2) -User captured steady byte values per lever detent (`raw/gear_box_can_revealings.csv`) → [[gear-box-can-revealings]]. **0x1D2 verified as the gear source**: byte0 = P `0xE1` / R `0xD2` / N `0xB4` / D `0x78` (all match documented codes exactly); byte0 can't split D from S/M (shared `0x78`) so byte4 does it (`0xF0` auto / `0xF1` Sport-Manual / `0xF2` downshift −); byte1 is a drive-gate flag (`0x0F`→`0x5F`); byte3 = rolling counter (confirms prediction). 0x0BA also tracks the lever but is messier (D/S-M collide) — don't use. Promoted 0x1D2 gear row to VERIFIED and rewrote the encoding-dispute section in [[can-id-candidates]]; updated index. Still open: actual engaged gear number (needs a drive capture) and the manual up-shift (+) value. Next: rewrite firmware gear map to 0x1D2 byte0 (+byte4). +User captured steady byte values per lever detent (`raw/gear_box_can_revealings.csv`) → [[gear-box-can-revealings]]. **0x1D2 verified as the gear source**: byte0 = P `0xE1` / R `0xD2` / N `0xB4` / D `0x78` (all match documented codes exactly); byte0 can't split D from S/M (shared `0x78`) so byte4 does it (`0xF0` auto / `0xF1` Sport-Manual / `0xF2` downshift −); byte1 is a drive-gate flag (`0x0F`→`0x5F`); byte3 = rolling counter (confirms prediction). 0x0BA also tracks the lever but is messier (D/S-M collide) — don't use. Promoted 0x1D2 gear row to VERIFIED and rewrote the encoding-dispute section in [[can-id-candidates]]; updated index. Still open: actual engaged gear number (needs a drive capture) and the manual up-shift (+) value. Next: rewrite firmware gear map to 0x1D2 byte0 (+byte4). ## [2026-07-17] update | Driveline screen live; torque decoded; output-shaft scaling revised -Firmware flashed and running on the car. Built a hand-coded Driveline screen (src/, boot screen, swipe to reach Home) showing gear + coolant + gearbox temp + RPM + torque + turbine + output-shaft + status chips. Three findings from the user testing it: (1) **Torque decoded & verified** — on **0x0A8 TORQ_AVL** (available engine torque; user-identified the ID). User's Excel `(D2*256+D1)/32` is algebraically bits12-23 ×0.5; confirmed against the repo's 0x0A8 worked example (24 Nm, ALIV=8 in D1 low nibble), ~27-28 Nm at idle. Firmware masks D1's low nibble (alive counter, not torque) and sign-extends. Note 0x0AA TORQ_DVCH is the same layout but driver *demand* — identical at idle, diverges under load. → [[can-id-candidates]], [[driveline-speed-signals]]. (2) **Output-shaft scaling revised**: a direct Launch reference (output speed 128 rpm at our raw 1192) **contradicts the earlier ×0.125** (would predict 149) and points to ~0.107. One eyeballed cross-tool point, so not adopted — but 0.125 is downgraded, and the Launch now gives a direct rpm reference so calibration is just a multi-point sweep + linear fit. Firmware keeps raw counts. (3) Fixed a latent display bug: main.cpp showed DEFAULT_* placeholder temps/voltage as if measured; now gated on valid_flags. Ignition decoded from 0x3B4 byte2 (user: 0x00=on/0x09=off, tracks ignition not engine — both published sources wrong here). +Firmware flashed and running on the car. Built a hand-coded Driveline screen (src/, boot screen, swipe to reach Home) showing gear + coolant + gearbox temp + RPM + torque + turbine + output-shaft + status chips. Three findings from the user testing it: (1) **Torque decoded & verified** — on **0x0A8 TORQ_AVL** (available engine torque; user-identified the ID). User's Excel `(D2*256+D1)/32` is algebraically bits12-23 ×0.5; confirmed against the repo's 0x0A8 worked example (24 Nm, ALIV=8 in D1 low nibble), ~27-28 Nm at idle. Firmware masks D1's low nibble (alive counter, not torque) and sign-extends. Note 0x0AA TORQ_DVCH is the same layout but driver *demand* — identical at idle, diverges under load. → [[can-id-candidates]], [[driveline-speed-signals]]. (2) **Output-shaft scaling revised**: a direct Launch reference (output speed 128 rpm at our raw 1192) **contradicts the earlier ×0.125** (would predict 149) and points to ~0.107. One eyeballed cross-tool point, so not adopted — but 0.125 is downgraded, and the Launch now gives a direct rpm reference so calibration is just a multi-point sweep + linear fit. Firmware keeps raw counts. (3) Fixed a latent display bug: main.cpp showed DEFAULT_* placeholder temps/voltage as if measured; now gated on valid_flags. Ignition decoded from 0x3B4 byte2 (user: 0x00=on/0x09=off, tracks ignition not engine — both published sources wrong here). -## [2026-07-17] ingest | First drive capture — 0x0BA gear ladder verified, output-shaft scaling narrowed +## [2026-07-17] ingest | First drive capture — 0x0BA gear ladder verified, output-shaft scaling narrowed -`raw/log_20260717_145930.txt` (CANNY 5.3 Pico, 1,857 frames / ~34 s, filtered to 0x0BA + 0x1D2) → [[can-capture-2026-07-17-drive]]. **First capture with the vehicle actually moving.** Closes the inference left open yesterday: **`ST_GR_GRB` values 6/7/8/9/A observed directly** (238/77/93/127/94 frames) = 2nd–6th, so **`0x0BA` D0's low nibble is a complete gear source on its own** — P/R/N + 1st–6th, reverse included; `0x1D2` is now needed only for lever + mode. Also caught `ST_CCLT` (converter lockup) live — 422 frames "controlling" in the higher gears, which matters because a locked clutch makes turbine = engine exactly, so the engagement-ratio test needs to read it before trusting a ratio ≈ 1.0 at road speed. **Output shaft identification VERIFIED** (rises monotonically 1139→16702 across gears 1→6, zero whenever the output is held). **Scaling narrowed to ×0.125** `(unverified)`: implies a coherent 901→1872 rpm upshift schedule across five independent ratios, vs 7,200–15,000 rpm for raw-as-rpm against a ~4,500 redline. User confirmed the box is a **ZF 6HP26X** — same gearset as 6HP26 so the ratio table holds, and the xDrive output variant **dates the donor to E60/E61, not E65** (partly answers open Q#2). New question #11: was the transfer case retained? The X box measures output **upstream** of it, so a Patrol transfer case in the path would make road speed high/low-range dependent. Remaining assumption on the scaling: max-output-per-gear = upshift point — **one capture including `0x1A2` closes it** (turbine ÷ output = ratio directly). Updated [[driveline-speed-signals]], [[gear-box-can-revealings]], [[can-id-candidates]], [[nissan-patrol-swap]], [[open-questions]], index. +`raw/log_20260717_145930.txt` (CANNY 5.3 Pico, 1,857 frames / ~34 s, filtered to 0x0BA + 0x1D2) → [[can-capture-2026-07-17-drive]]. **First capture with the vehicle actually moving.** Closes the inference left open yesterday: **`ST_GR_GRB` values 6/7/8/9/A observed directly** (238/77/93/127/94 frames) = 2nd–6th, so **`0x0BA` D0's low nibble is a complete gear source on its own** — P/R/N + 1st–6th, reverse included; `0x1D2` is now needed only for lever + mode. Also caught `ST_CCLT` (converter lockup) live — 422 frames "controlling" in the higher gears, which matters because a locked clutch makes turbine = engine exactly, so the engagement-ratio test needs to read it before trusting a ratio ≈ 1.0 at road speed. **Output shaft identification VERIFIED** (rises monotonically 1139→16702 across gears 1→6, zero whenever the output is held). **Scaling narrowed to ×0.125** `(unverified)`: implies a coherent 901→1872 rpm upshift schedule across five independent ratios, vs 7,200–15,000 rpm for raw-as-rpm against a ~4,500 redline. User confirmed the box is a **ZF 6HP26X** — same gearset as 6HP26 so the ratio table holds, and the xDrive output variant **dates the donor to E60/E61, not E65** (partly answers open Q#2). New question #11: was the transfer case retained? The X box measures output **upstream** of it, so a Patrol transfer case in the path would make road speed high/low-range dependent. Remaining assumption on the scaling: max-output-per-gear = upshift point — **one capture including `0x1A2` closes it** (turbine ÷ output = ratio directly). Updated [[driveline-speed-signals]], [[gear-box-can-revealings]], [[can-id-candidates]], [[nissan-patrol-swap]], [[open-questions]], index. -## [2026-07-17] ingest | E65_ReverseEngineering repo — both disputes resolved, driveline speeds discovered +## [2026-07-17] ingest | E65_ReverseEngineering repo — both disputes resolved, driveline speeds discovered -User pointed at `HeinrichG-V12/E65_ReverseEngineering` (per-ID DBC-style docs, worked example on every page) → [[e65-reverse-engineering-repo]]. Highest-value source to date; combined with re-analysis of our own `raw/can-capture-2026-07-15-gearshift.csv` it closed most of the frontier. **Resolved**: gearbox oil temp = **raw − 40** (source example + our own gearbox-31 °C-vs-coolant-37 °C warm-up cross-check; my earlier "leaning offset 0" was wrong); battery = **12-bit LE × 0.015**; engine **was running** in the 2026-07-15 capture (`ST_ENGINE_RUN`=2 in 397/397) — **cold-start capture no longer needed**; RPM = `0x0AA` ×0.25 (679–684 idle). **Discovered**: `0x1A2` `RPM_GRB_TURB` turbine speed — a *physical* engagement proof (P/N ≈634/628 free-spinning vs D ≈70, R ≈0 stalled — textbook converter behaviour), plus `0x0BA` bits 20–39 output shaft (undocumented anywhere; zero in every stationary frame incl. engaged-in-D, non-zero once wheels turn), plus `ANG_ACPD` pedal % and `ST_CLCTR_V` cruise state. New page [[driveline-speed-signals]] — emphasized per user: **no DSC on this bus ⇒ output shaft is our only road-speed source**, hence the feedback variable for a future cruise-control PoC (safety envelope documented; actuation = transmitting torque requests, a different risk class from everything read-only so far). **Corrected three of my own 2026-07-16 claims**: `0x1D2` D1 is the *engaged gear* (not a "drive-gate flag" — it read 1 because the car was stationary); D4 `0xF2` is a persistent *Manual mode* (not a "downshift event" — it holds across gears 2–6); `0x0BA` is **not** to be dismissed (I'd read D7, an alive counter, instead of D0's `ST_GR_GRB` — which is the only source of engaged **reverse**, `0x1D2` D1 staying `0x0F` in R). Also: boost is **not** broadcast (`AIP_ENG` caps at 1108 hPa = barometric) — confirms the Launch must poll. Updated [[can-id-candidates]], [[gear-box-can-revealings]], [[open-questions]], index. Next: firmware pass over the whole verified map. +User pointed at `HeinrichG-V12/E65_ReverseEngineering` (per-ID DBC-style docs, worked example on every page) → [[e65-reverse-engineering-repo]]. Highest-value source to date; combined with re-analysis of our own `raw/can-capture-2026-07-15-gearshift.csv` it closed most of the frontier. **Resolved**: gearbox oil temp = **raw − 40** (source example + our own gearbox-31 °C-vs-coolant-37 °C warm-up cross-check; my earlier "leaning offset 0" was wrong); battery = **12-bit LE × 0.015**; engine **was running** in the 2026-07-15 capture (`ST_ENGINE_RUN`=2 in 397/397) — **cold-start capture no longer needed**; RPM = `0x0AA` ×0.25 (679–684 idle). **Discovered**: `0x1A2` `RPM_GRB_TURB` turbine speed — a *physical* engagement proof (P/N ≈634/628 free-spinning vs D ≈70, R ≈0 stalled — textbook converter behaviour), plus `0x0BA` bits 20–39 output shaft (undocumented anywhere; zero in every stationary frame incl. engaged-in-D, non-zero once wheels turn), plus `ANG_ACPD` pedal % and `ST_CLCTR_V` cruise state. New page [[driveline-speed-signals]] — emphasized per user: **no DSC on this bus ⇒ output shaft is our only road-speed source**, hence the feedback variable for a future cruise-control PoC (safety envelope documented; actuation = transmitting torque requests, a different risk class from everything read-only so far). **Corrected three of my own 2026-07-16 claims**: `0x1D2` D1 is the *engaged gear* (not a "drive-gate flag" — it read 1 because the car was stationary); D4 `0xF2` is a persistent *Manual mode* (not a "downshift event" — it holds across gears 2–6); `0x0BA` is **not** to be dismissed (I'd read D7, an alive counter, instead of D0's `ST_GR_GRB` — which is the only source of engaged **reverse**, `0x1D2` D1 staying `0x0F` in R). Also: boost is **not** broadcast (`AIP_ENG` caps at 1108 hPa = barometric) — confirms the Launch must poll. Updated [[can-id-candidates]], [[gear-box-can-revealings]], [[open-questions]], index. Next: firmware pass over the whole verified map. -## [2026-07-16] ingest | First live CAN capture — research map CONFIRMED +## [2026-07-16] ingest | First live CAN capture — research map CONFIRMED -First real dump off the swap's bus, taken with the board's **own new raw-frame logger** (`(repo)`; USB-CDC stream, serial mutex, ~486 frame/s, ~1.4% line loss). Raw filed at `raw/can-capture-2026-07-15-gearshift.csv` (20,596 frames) → [[can-capture-2026-07-15]]. Findings: 15 IDs live incl. **all four researched signal IDs** (0x1D0, 0x1D2, 0x0B5, 0x3B4) + bonus 0x0AA/0x0BA; firmware's placeholder IDs (0x4F/0x55/0x201/0x1001/0x101F) **verified absent**; researched-but-absent: 0x130/0x304/0x192. **0x1D0 b0** drifts 0x55→0x58 (coolant −48, ~37→40 °C); **0x1D0 b1 = 0xFF** (oil temp unpopulated). **0x1D2 gear encoding resolved**: DLC 6, byte0 whole-byte codes (0xE1=P, 0xB4=N, 0x78=D seen live). **0x3B4** at ~5 s rate but payload dormant (0xFF) — engine state unconfirmed. Updated [[can-id-candidates]], [[can-bus-integration]], [[esp32-s3-touch-lcd-5b]], [[open-questions]], index. Also corrected a firmware fact across pages: driver runs **`TWAI_MODE_NORMAL` (ACKs the bus), not LISTEN_ONLY**; TJA1051 is non-isolated → must share vehicle ground. Next: cold-start + confirmed-engine-running capture to lock coolant/battery scaling; use differential (per-position) captures for gear. +First real dump off the swap's bus, taken with the board's **own new raw-frame logger** (`(repo)`; USB-CDC stream, serial mutex, ~486 frame/s, ~1.4% line loss). Raw filed at `raw/can-capture-2026-07-15-gearshift.csv` (20,596 frames) → [[can-capture-2026-07-15]]. Findings: 15 IDs live incl. **all four researched signal IDs** (0x1D0, 0x1D2, 0x0B5, 0x3B4) + bonus 0x0AA/0x0BA; firmware's placeholder IDs (0x4F/0x55/0x201/0x1001/0x101F) **verified absent**; researched-but-absent: 0x130/0x304/0x192. **0x1D0 b0** drifts 0x55→0x58 (coolant −48, ~37→40 °C); **0x1D0 b1 = 0xFF** (oil temp unpopulated). **0x1D2 gear encoding resolved**: DLC 6, byte0 whole-byte codes (0xE1=P, 0xB4=N, 0x78=D seen live). **0x3B4** at ~5 s rate but payload dormant (0xFF) — engine state unconfirmed. Updated [[can-id-candidates]], [[can-bus-integration]], [[esp32-s3-touch-lcd-5b]], [[open-questions]], index. Also corrected a firmware fact across pages: driver runs **`TWAI_MODE_NORMAL` (ACKs the bus), not LISTEN_ONLY**; TJA1051 is non-isolated → must share vehicle ground. Next: cold-start + confirmed-engine-running capture to lock coolant/battery scaling; use differential (per-position) captures for gear. ## [2026-09-21] update | .docs folder retired; UART spec moved to docs/; board photo ingested -The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Controller B) moved to `docs/UART_PROTOCOL.md` as the single copy; Controller B's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed. +The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Controller B) moved to `docs/UART_PROTOCOL.md` as the single copy; Controller B's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed. -**Missing source**: the schematic PDF (`ESP32-S3-Touch-LCD-5-Sch.pdf`) was in `.docs/` at the start of the 2026-09-21 session and was not on disk by the time of this cleanup (never git-tracked). Its net list was read earlier that session and is reflected in [[esp32-s3-touch-lcd-5b]]; re-download it into `raw/` — still on the sourcing wishlist in [[open-questions]]. +**Missing source**: the schematic PDF (`ESP32-S3-Touch-LCD-5-Sch.pdf`) was in `.docs/` at the start of the 2026-09-21 session and was not on disk by the time of this cleanup (never git-tracked). Its net list was read earlier that session and is reflected in [[esp32-s3-touch-lcd-5b]]; re-download it into `raw/` — still on the sourcing wishlist in [[open-questions]]. -Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Controller B (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`. +Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Controller B (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`. ## [2026-09-21] update | Link protocol v2: ESP-NOW second transport, gear/rpm/alerts on the wire, tunables console -Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Controller B: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv). +Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Controller B: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv). ## [2026-09-21] update | Gauge Tuning screen @@ -62,14 +62,30 @@ New hand-coded screen `src/modules/tuning_screen.cpp` (swipe right from Drivelin User decision: the Home screen (three arc meters + battery) is not needed. Deleted `include/ui/screens/ui_Home_Screen.c/h`, its four image assets and `src/modules/meters_manager.*`; `ui_init()` now loads an empty placeholder and `display_init.cpp` shows the hand-coded Driveline screen; the generated Settings screen's right-swipe calls a new C entry point `app_show_driveline()`; Driveline swipes left to Settings and right to Gauge Tuning; Tuning swipes left back. Firmware flash shrank ~100 KB. If SquareLine re-exports a Home screen it must be deleted from the SquareLine project, not wired back in. Built and flashed. -## [2026-09-21] ingest | Google AI clipping "dde7m57 pids" — diagnostic-polling page created, 0x612 direction corrected +## [2026-09-21] ingest | Google AI clipping "dde7m57 pids" — diagnostic-polling page created, 0x612 direction corrected -User clipped a Google AI Mode conversation into `Clippings/` (Obsidian Web Clipper default folder; schema updated to treat it like `raw/`) → [[google-ai-dde7m57-pids]]. Uncited generative summary, filed `(unverified)` throughout. Two things of value: the Ediabas result names for boost/rail/MAF/injection, and the user's own observation embedded in it — **`0x612` appears on the tapped bus while the Launch is connected**, proving diagnostic traffic reaches our tap. The clipping calls `0x612` the *tester request* and `0x6F2` the reply; that contradicts dieslg8 (real M57 code) and the BMW `0x6F1` → `0x600+address` convention — flagged, and the wiki keeps **tester `0x6F1` → DDE `0x612`** until our own capture shows the pair. Its `22 D1 xx` identifiers are uncited and must not be implemented from. Created the long-dangling [[obd-diagnostic-polling]] page (broadcast vs polled, addressing table, DDE6 vs DDE7.3 variant table, capture-with-Launch procedure, firmware implications: polling = transmitting on PT-CAN, a design decision). Side finding: the search term "dde7 m57" describes DDE7.3/EDC17CP09 on the later M57N2 (E90/E70); our E60/E61 donor with a 6HP26X should carry a DDE6/EDC16 — the Launch's ECU-identification page closes [[open-questions]] #2 in one screen. Updated [[bmw-m57n-engine]] (E60/E61, 6HP26X, stale firmware-placeholder warning removed), [[open-questions]] #2/#7 + wishlist, index. +User clipped a Google AI Mode conversation into `Clippings/` (Obsidian Web Clipper default folder; schema updated to treat it like `raw/`) → [[google-ai-dde7m57-pids]]. Uncited generative summary, filed `(unverified)` throughout. Two things of value: the Ediabas result names for boost/rail/MAF/injection, and the user's own observation embedded in it — **`0x612` appears on the tapped bus while the Launch is connected**, proving diagnostic traffic reaches our tap. The clipping calls `0x612` the *tester request* and `0x6F2` the reply; that contradicts dieslg8 (real M57 code) and the BMW `0x6F1` → `0x600+address` convention — flagged, and the wiki keeps **tester `0x6F1` → DDE `0x612`** until our own capture shows the pair. Its `22 D1 xx` identifiers are uncited and must not be implemented from. Created the long-dangling [[obd-diagnostic-polling]] page (broadcast vs polled, addressing table, DDE6 vs DDE7.3 variant table, capture-with-Launch procedure, firmware implications: polling = transmitting on PT-CAN, a design decision). Side finding: the search term "dde7 m57" describes DDE7.3/EDC17CP09 on the later M57N2 (E90/E70); our E60/E61 donor with a 6HP26X should carry a DDE6/EDC16 — the Launch's ECU-identification page closes [[open-questions]] #2 in one screen. Updated [[bmw-m57n-engine]] (E60/E61, 6HP26X, stale firmware-placeholder warning removed), [[open-questions]] #2/#7 + wishlist, index. -## [2026-09-21] ingest | DWR's 335d Torque PID set — generic OBD-II route documented +## [2026-09-21] ingest | DWR's 335d Torque PID set — generic OBD-II route documented -User dropped `raw/BMW 335d.csv` and clipped page 1 of the e90post/6post thread "Extended BMW 335d PIDs for Torque" (DWR, 2009 335d = M57N2 on DDE7.3/EDC17CP09) → [[dwr-335d-torque-pids]]. **Every entry is a generic SAE J1979 mode-01 PID** (DWR says so in post 21; header `Auto` = `0x7DF`); nothing BMW-proprietary, nothing broadcast. Two revisions compared: the CSV in `raw/` is the corrected 2017 one (boost ×0.3125 = the J1979 0.03125 kPa/bit; fuel rate ×0.0938 lb/hr; post-#2's ×0.296 and ×5.64 were wrong); residual typos noted (`000031` for 0.0000305, one `+33`). Decoded his table back to SI with the J1979 byte positions. Consequence for us: the generic route is the **cheapest polling experiment** — one `01 00` supported-PID query on `0x7DF` tells whether our DDE answers EOBD on the PT-CAN and which PIDs it has — but the diesel-specific PIDs he relies on for boost (`70`), exhaust pressure (`73`), EGT (`78`), DPF (`7A`), NOx (`83`) are 2007+ J1979 additions an EDC16 almost certainly lacks `(unverified)`, and PID `0B` clips at 255 kPa. [[obd-diagnostic-polling]] restructured into Route A (generic, PID table, first test) and Route B (BMW `0x6F1`/`0x612`). Wishlist: DWR's Testo parameter list (post 175 of the Testo thread). Updated [[open-questions]] #7 + wishlist, index. +User dropped `raw/BMW 335d.csv` and clipped page 1 of the e90post/6post thread "Extended BMW 335d PIDs for Torque" (DWR, 2009 335d = M57N2 on DDE7.3/EDC17CP09) → [[dwr-335d-torque-pids]]. **Every entry is a generic SAE J1979 mode-01 PID** (DWR says so in post 21; header `Auto` = `0x7DF`); nothing BMW-proprietary, nothing broadcast. Two revisions compared: the CSV in `raw/` is the corrected 2017 one (boost ×0.3125 = the J1979 0.03125 kPa/bit; fuel rate ×0.0938 lb/hr; post-#2's ×0.296 and ×5.64 were wrong); residual typos noted (`000031` for 0.0000305, one `+33`). Decoded his table back to SI with the J1979 byte positions. Consequence for us: the generic route is the **cheapest polling experiment** — one `01 00` supported-PID query on `0x7DF` tells whether our DDE answers EOBD on the PT-CAN and which PIDs it has — but the diesel-specific PIDs he relies on for boost (`70`), exhaust pressure (`73`), EGT (`78`), DPF (`7A`), NOx (`83`) are 2007+ J1979 additions an EDC16 almost certainly lacks `(unverified)`, and PID `0B` clips at 255 kPa. [[obd-diagnostic-polling]] restructured into Route A (generic, PID table, first test) and Route B (BMW `0x6F1`/`0x612`). Wishlist: DWR's Testo parameter list (post 175 of the Testo thread). Updated [[open-questions]] #7 + wishlist, index. ## [2026-09-21] update | `diag` console probe: Controller A can now send OBD-II requests -User decision: build the Route A probe. New module `src/modules/diag_probe.cpp` and a single sanctioned transmit function `CANDriver::transmit()` (single-shot frames, `CANTX,` console echo mirroring `CANRAW,`). Console: `diag pids` (mode-01 supported-PID bitmap scan, blocks 00/20/40…, per-responder summary with PID names), `diag pid ` (one request, decoded for the Route A table incl. PID 70 boost and 78 EGT), `diag vin`, `diag ecu` (mode 09), `diag status`. ISO-TP single/first/consecutive frames reassembled with a `30 00 00` flow control to the responder's physical ID. Guards: one request in flight, refused for 3 s after any foreign tester frame (`0x7DF`/`0x7E0–7`/`0x6F1`), services 01 and 09 only. Console dispatch chained through `Tunables::setExtraCommandHandler()`. Built (1.49 MB) and flashed to COM11; bench check with no bus attached: `diag pids` sent `02 01 00` on `0x7DF`, the TWAI controller reported the single-shot frame un-ACKed, and the probe reported "not ACKed - no other node saw it" rather than blaming the ECU (the summary distinguishes un-ACKed from ACKed-but-silent). CAN-task warnings now take the serial lock so they no longer splice into `CANTX` lines. The wiki's "firmware never transmits" statements are now qualified on [[can-bus-integration]] and [[obd-diagnostic-polling]] (test-day procedure and the three possible outcomes written there). Root `CLAUDE.md` and `docs/UART_PROTOCOL.md` console section updated. Procedure rewritten as numbered steps with all four outcomes (un-ACKed / ACKed-silent / one responder / two responders) and the log-capture command. +User decision: build the Route A probe. New module `src/modules/diag_probe.cpp` and a single sanctioned transmit function `CANDriver::transmit()` (single-shot frames, `CANTX,` console echo mirroring `CANRAW,`). Console: `diag pids` (mode-01 supported-PID bitmap scan, blocks 00/20/40…, per-responder summary with PID names), `diag pid ` (one request, decoded for the Route A table incl. PID 70 boost and 78 EGT), `diag vin`, `diag ecu` (mode 09), `diag status`. ISO-TP single/first/consecutive frames reassembled with a `30 00 00` flow control to the responder's physical ID. Guards: one request in flight, refused for 3 s after any foreign tester frame (`0x7DF`/`0x7E0–7`/`0x6F1`), services 01 and 09 only. Console dispatch chained through `Tunables::setExtraCommandHandler()`. Built (1.49 MB) and flashed to COM11; bench check with no bus attached: `diag pids` sent `02 01 00` on `0x7DF`, the TWAI controller reported the single-shot frame un-ACKed, and the probe reported "not ACKed - no other node saw it" rather than blaming the ECU (the summary distinguishes un-ACKed from ACKed-but-silent). CAN-task warnings now take the serial lock so they no longer splice into `CANTX` lines. The wiki's "firmware never transmits" statements are now qualified on [[can-bus-integration]] and [[obd-diagnostic-polling]] (test-day procedure and the three possible outcomes written there). Root `CLAUDE.md` and `docs/UART_PROTOCOL.md` console section updated. Procedure rewritten as numbered steps with all four outcomes (un-ACKed / ACKed-silent / one responder / two responders) and the log-capture command. + +## [2026-09-22] query | CANNY 5.3 pico vs ESP32 gauge drive - tach dead / temp frozen explained + +First in-car test of the dual-controller rig: A reads the bus fine, B receives fine, but the Patrol tach never moves and the temp needle parks mid-scale ignoring the override slider. User disclosed the known-good reference: the same cluster works from a CANNY 5.3 pico using "Default Negative Output" (DIO mode, ch 7). Researched the CANNY docs (cannylogic.com/canny.ru): its channels are 12V-domain configurable-polarity switches - "negative output" = low-side sink to GND, letting the cluster's internal pull-up define the ~12V high level. Our ESP32 IO7/IO8 push-pull 3.3V output can't reach the tach's input threshold and biases the temp sender line to a fixed level. Not a firmware PWM polarity issue (50% square is its own inverse). Fix: logic-level N-MOSFET/NPN low-side stage per channel, temp duty law re-derived after (logic inverts). Filed [[canny-5-3-pico-gauge-drive]]; user corrected the channel to 8 (contact 4, the HR-PWM-capable one), matching the 5.3 pico docs. Index updated. + +## [2026-09-22] query | Patrol cluster signal research - tach 2 ppr verified, temp sender curve, flutter plan + +First day driving the real cluster from Controller B through the 2SK3069 low-side stage. Tach: needle tracked at double with ppr=4; user set ppr=2 -> tracks correctly (verified). 2 ppr matches an ECU-driven 4-cyl-style tach input (ZD30-era Y61 hint, unverified) rather than the TD42 alternator-W-terminal scheme. Temp gauge on IO8: needle flutters at temp_pwm_hz=1 kHz. Researched: stock Patrol sender is an NTC (2.1-2.9k @ 20C, 0.68-1k @ 50C, 236-260R @ 90C; patrol4x4/sensorgal), gauge is current-measuring; community PWM-gauge experience says flutter dies at ~40-50 kHz. Mitigation ladder filed: fixed-duty override test (data vs electrical), cfg set temp_hz 20000 (firmware clamp), then raise clamp / series drain resistor (~100-240R, also bounds full-on beyond-hot short) / gauge-side cap. Temp law must be re-derived after (FET inverts duty sense). Filed [[patrol-instrument-cluster]]; index updated. Earlier same day: [[canny-5-3-pico-gauge-drive]] hypothesis effectively confirmed by the needles moving through the FET; gauge-output disable bits found off during bench test (B console "disabled") - re-enabled via tuning screen. + +## [2026-09-22] update | Temp gauge flutter resolved: temp_hz 1 kHz -> 20 kHz + +User raised temp_pwm_hz to 20000 via the tuning screen; needle now steady at fixed override duty (verified). A confusing intermediate "gauge dead at 20 kHz" turned out to be a disconnected car-ground during rewiring - grounds first, then debug. [[patrol-instrument-cluster]] updated (flutter section marked resolved; drain series resistor kept as optional hardening). Remaining gauge work: re-derive temp_slope/temp_offset against the real needle through the FET stage (duty sense inverted vs the old direct-drive law). + +## [2026-09-23] update | Tach steppy-needle saga resolved; trim -13; temp gauge stable + +Full day of override-ramp experiments (ignition on, engine off; tools/tach_ramp.py + tach_ramp2.py drive A over serial). Four-layer diagnosis on B, all firmware in the 1.3 repo: (1) 5 Hz staircase -> slew limiter; (2) Arduino ledcChangeFrequency() re-inits the timer mid-period -> replaced LEDC with esp_timer toggle; (3) esp_timer task jitter from WiFi bursts -> hardware-timer ISR, phase-continuous; (4) the floor: the cluster counts pulses in ~150 rpm quanta (alternating +100/+200 needle steps on a clean ramp) -> random dither +/-45 rpm with an adaptive envelope that fades at steady rpm. Scale: cluster over-reads x1.20 low / x1.15 high (nonlinear); user settled tach_trim = -13%. Also found mid-session: user trim change via touchscreen had never registered (B stayed on cfg v99) - config state now verified over serial before every test. [[patrol-instrument-cluster]] rewritten with the saga; new tools: serial_logger.py, serial_cmd.py, tach_ramp*.py, dual_serial_capture.py. Status: RPM and temp gauges "fairly good", tach dither constants may get a future pass. diff --git a/wiki/pages/canny-5-3-pico-gauge-drive.md b/wiki/pages/canny-5-3-pico-gauge-drive.md new file mode 100644 index 0000000..60d93e6 --- /dev/null +++ b/wiki/pages/canny-5-3-pico-gauge-drive.md @@ -0,0 +1,60 @@ +--- +type: synthesis +tags: [hardware, gauges, nissan-patrol, controller-b, electronics] +updated: 2026-09-22 +--- + +# CANNY 5.3 pico vs ESP32-S3: driving the Patrol cluster + +Why the user's old CANNY-based setup moves the Patrol tach and our ESP32 (Controller B, IO7) does not. Researched 2026-09-22 after the first in-car test of the dual-controller rig: temp needle parked mid-scale, tach dead ([[dual-controller-architecture]]). + +## The working reference setup `(verified)` + +The user previously drove this same instrument cluster with a **CANNY 5.3 pico** (Russian visual-PLC automotive controller, cannylogic.com / canny.ru), using **"Default Negative Output" in DIO mode on IO channel 8** (contact 4 — the channel that also carries the high-resolution PWM function). The cluster's needles respond in that setup — this is our known-good electrical reference. + +## What the CANNY output stage is (source: cannylogic.com/docs/c53pico, canny.ru) + +- Channels are **12 V-domain**: "output operating voltage on the controller channels matches the supply voltage" (7–16 V, 18 V abs max). +- Each channel is a **configurable-polarity switch**: "positive" mode connects the line to +12 V (high-side source), **"negative" mode connects the line to GND (low-side sink)**. Two strengths: weak ~1 mA (pull) and strong 100 mA. +- Rated for inductive/resistive/capacitive loads, 100 mA per channel, 300 mA total, automatic shutoff on over-current. +- "Negative output" therefore produces the classic automotive sender signal: the line is **pulled to ground when active and floats up to the cluster's own internal pull-up (~battery) when released** — a 0 ↔ ~12 V swing without the controller ever sourcing voltage. + +## What our ESP32-S3 GPIO is + +- **3.3 V push-pull** logic pin, absolute max ~3.6 V, source/sink a few tens of mA, no protection `(unverified — standard ESP32-S3 datasheet values)`. +- LEDC PWM on B's IO7 (tach square wave) and IO8 (temp duty) drives the line **actively to 3.3 V and 0 V** `(repo)`. + +## Why this explains the test-day symptoms `(verified 2026-09-22 for the tach — needle tracks rpm through the 2SK3069 low-side stage; see [[patrol-instrument-cluster]] for calibration)` + +- The Patrol tach input expects negative-going pulses on a line it pulls up internally toward battery. With the ESP32 push-pull output attached, the "high" half of every cycle is **3.3 V instead of ~12 V** — likely below the input threshold, so the tach sees no edges at all → dead needle, exactly what the CANNY's negative output provides and we don't. +- The temp gauge input is a sender-resistance-to-ground circuit. A 3.3 V push-pull PWM can bias it to some fixed effective level — a needle that parks at one position and ignores duty changes is consistent with this (mid-scale at 89 °C may have been coincidence, not the duty law working). Re-test after the drive stage is fixed before trusting the temp calibration in [[dual-controller-architecture]]. +- **It is not PWM polarity in firmware**: a 50 % square wave is its own inverse, and inverted temp duty would move the needle backwards, not freeze it. + +## The fix (per channel): replicate "negative output" + +Small low-side switch between the ESP32 pin and the gauge line: + +``` +gauge line ──────────────┬──── (cluster's internal pull-up to ~12 V) + │ + D (drain/collector) +ESP32 IOx ──[R ~1k]── G/B N-MOSFET (logic-level, e.g. 2N7002/AO3400) or NPN (2N2222 + base R) + S (source/emitter) + │ + GND (common with cluster!) +``` + +- ESP32 high → line pulled to GND; ESP32 low → line released to the cluster's pull-up. This **inverts the logic**: tach unaffected (50 % square), temp duty becomes 255 − duty at the gauge — recalibrate `temp_slope`/`temp_offset` ([[dual-controller-architecture]] tunables) or invert in B's firmware. +- If the cluster input turns out to have no internal pull-up, add an external ~4.7–10 kΩ to +12 V. +- On hand (2026-09-22): a **2SK3069** (N-ch, 60 V / 75 A, 4 V-drive class) — hugely oversized but suitable; planned for the tach channel with 220 Ω gate series + 10 kΩ gate pulldown `(source: alltransistors.com 2SK3069)`. +- **Never** connect the 12 V-pulled gauge line directly to an ESP32 pin, including in open-drain mode — the pin is not 12 V tolerant. +- Grounds must be common: cluster GND ↔ Controller B GND. + +## Open items + +- Scope or multimeter the tach line at rest: does it float high (~12 V) with nothing attached? Confirms the internal pull-up assumption. +- After the transistor stage: re-run the override test (Force tach rpm / Force coolant duty on A's tuning screen) and re-derive the temp duty law; promote this page's hypothesis to `(verified)`. + +## Related + +[[dual-controller-architecture]] · [[nissan-patrol-swap]] · [[open-questions]] diff --git a/wiki/pages/patrol-instrument-cluster.md b/wiki/pages/patrol-instrument-cluster.md new file mode 100644 index 0000000..61f24b2 --- /dev/null +++ b/wiki/pages/patrol-instrument-cluster.md @@ -0,0 +1,55 @@ +--- +type: entity +tags: [hardware, gauges, nissan-patrol, controller-b, electronics] +updated: 2026-09-22 +--- + +# Patrol instrument cluster — signal expectations + +What the target vehicle's cluster ([[nissan-patrol-swap]]) needs on its tach and temp inputs, from the first day of driving it with Controller B's outputs through the low-side FET stage ([[canny-5-3-pico-gauge-drive]]). Patrol generation still unidentified — Y60/GQ vs Y61/GU matters for gauge internals → [[open-questions]]. + +## Tachometer + +- **Empirical calibration `(verified 2026-09-22)`: 2 pulses per revolution.** With the firmware's original `tach_ppr=4` the cluster read double; `cfg` ppr set to 2 makes it track the BMW's CAN rpm. Signal: 50 % square wave, low-side switched (2SK3069), i.e. 3000 rpm → 100 Hz. +- Background on what these clusters normally get `(source: patrol4x4.com / nissanpatrol.com.au threads)`: + - TD42 diesels had **no factory tach signal**; aftermarket/factory tachs run from the **alternator W terminal** (a phase tap — frequency scales with pulley ratio × pole pairs, far more than 2/rev, usually via an adapter box). + - A clean **2 ppr** expectation matches an **ECU-driven 4-cylinder-style tach input** (e.g. ZD30-era Y61) `(unverified)` — a hint the cluster may be from that generation, worth checking against the actual vehicle. +- Practical consequence: the doubled reading at ppr=4 was calibration, not a signal-quality problem. The FET stage works. +- **Scale calibration `(verified 2026-09-23, override ramps)`**: with ppr=2 the cluster over-reads by a factor that shrinks with rpm — ×1.20 at 1000–2000, ×1.15 at 6000 (commanded 6000 with trim −20 read exactly 5500). The response is mildly nonlinear, so a linear trim cannot be exact everywhere; **`tach_trim = −13 %` chosen as the realistic compromise** (user-tuned on the dial). Saved on A, pushed in CONFIG. + +### The steppy-needle saga (2026-09-22/23) — resolved + +Observed on the road: needle holds then jumps 200–500 rpm. Diagnosis took four firmware iterations on B, each eliminating one layer `(repo, verified by override ramp tests with ignition on / engine off)`: + +1. **5 Hz staircase**: B refreshed the tach frequency once per 200 ms packet. Added a slew limiter (glide 25 %/20 ms). *Result: worse* — because of layer 2. +2. **LEDC restarts**: Arduino 2.x `ledcChangeFrequency()` re-inits the timer and truncates the waveform mid-period; calling it 50×/s corrupted the counting window constantly. Replaced LEDC with an esp_timer toggling IO7. *Result: better, not smooth* — because of layer 3. +3. **Task-dispatch jitter**: esp_timer callbacks run in a task; WiFi/ESP-NOW bursts on core 0 delay edges by ms and bunch them. Replaced with a **hardware-timer ISR** (1 MHz, auto-reload): phase-continuous, immune to scheduling. *Result: rock-steady at fixed rpm, but ramps still stepped* — because of layer 4, which is the cluster itself. +4. **Cluster count quantization** — the floor: on a clean 25 rpm/40 ms synthetic ramp the needle jumped alternately +100/+200 → the cluster counts pulses in **~150 rpm quanta** on a dial that rounds to 100. A perfectly stable synthetic frequency parks on a quantum and snaps to the next; a real engine's pulse jitter straddles the boundary so the damped needle averages in between — factory setups are smooth *because* their signal is dirty. Emulated with **random dither ±45 rpm (±1.2 Hz) per 20 ms tick**, with an **adaptive envelope** (full while the target moves, fades to zero within ~1.2 s at rest) so steady rpm stays flicker-free. + +Final state (2026-09-23): sweep and hold "fairly good" per user; possible future refinement of dither constants (`DITHER_HZ`, envelope times in B's `gauge_outputs.cpp`). Also explains the CANNY's high-rpm jumpiness ([[canny-5-3-pico-gauge-drive]]): a PLC toggling on a ms-resolution timer gets coarse at ≥100 Hz output `(unverified)`. + +## Temperature gauge + +- The stock sender is an **NTC thermistor to ground** `(source: patrol4x4.com forum, sensorgal.com)`: + + | Coolant | Sender resistance | + |---|---| + | 20 °C | 2.1–2.9 kΩ | + | 50 °C | 0.68–1 kΩ | + | 90 °C | 236–260 Ω | + + The gauge is a current-measuring device; its useful span is roughly the "tens of Ω to a few kΩ" region. Duty-cycle PWM through a low-side switch emulates an average conductance in this range `(repo)`. +- **Needle flutter at `temp_pwm_hz` = 1 kHz — RESOLVED at 20 kHz `(verified 2026-09-22)`.** At 1 kHz the needle fluttered at any duty between the endpoints (steady at 0 and 255 — i.e. it was following the chopping itself); raising `temp_hz` to 20000 (the current firmware clamp) removed the fluctuation completely. Matches community experience that PWM-driven automotive gauges need tens-of-kHz `(source: allaboutcircuits.com, pjrc forum)`. +- Lesson from the same session: a **missing chassis/board common ground makes the gauge read nothing at all** — check grounds before debugging frequencies. +- Still open as optional hardening: a series resistor in the FET drain (~100–240 Ω) to bound the current swing to the sender's real range (full-on duty = dead short, i.e. "hotter than the sender can ever read"). +- After the flutter is fixed, re-derive `temp_slope`/`temp_offset` against the sender table above (the FET inverts duty sense vs the direct-drive law used before). + +## Open items + +- Identify the Patrol generation / cluster origin (2 ppr hint above; ask the user / photograph the cluster). +- Temp law recalibration table (duty ↔ needle position ↔ implied °C) — gauge works and is stable at 20 kHz; the slope/offset mapping to real °C has not been re-derived since the FET stage inverted the duty sense. +- Tach dither constants may deserve another tuning pass ("maybe in the future we will get back to RPMs" — user, 2026-09-23). + +## Related + +[[canny-5-3-pico-gauge-drive]] · [[nissan-patrol-swap]] · [[dual-controller-architecture]] · [[open-questions]]