Files
ESP32-S3-Touch-LCD-5B/wiki/pages/driveline-speed-signals.md
T
julian 1cba9f30bc
Firmware / build (push) Successful in 10m49s
Reverse lights on DO0, Sport + Vehicle screens, per-DDE live data, ECU identification
- ReverseLight: isolated output DO0 (CH422G OC0 -> PC817 -> NPN sink) drives the
  reverse-lamp relay while the lever is in R on a live bus with ignition on; 10 Hz
  decision confirmed over 200 ms, written through the panel library's expander
  object so the backlight cannot undo it; `reverse status|on|off|force` console,
  default ON (NVS `revlight_en`). Wiki page reverse-lights-output with the wiring.
- Sport screen: BMW-style power + torque gauges (lv_meter on a dial-face image,
  image needle); PNG sources in assets/, tools/png2lvgl.py converter.
- Vehicle: final drive ratio + tyre circumference -> road speed, hp from torque;
  Settings > Vehicle page; `vehicle` console.
- Bench simulation (`sim` console) overlays torque / rpm / shaft on the snapshot.
- EcuIdent: KWP 1A 86 / 1A 80 read once, stored in NVS, shown on Settings >
  Vehicle, passive ECU CHANGED? check; `ecu` console.
- Ignition fallback from the 0x1D2 lever byte on buses without 0x3B4 (Patrol 2).
- Engine data: per-DDE `2C 10` identifier profiles (Patrol 1 vs Patrol 2
  rail 00C2 / boost 003A / battery 002F); DiagProbe liveConfigure().
- Wiki: Patrol 2 captures, vehicles page, obd identifier table per DDE, logs.
2026-10-28 16:46:42 +01:00

199 lines
14 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
type: concept
tags: [can-bus, egs, dde, speed, gear, cruise-control, verified]
updated: 2026-07-17
---
# Driveline Speed Signals
The three rotating speeds our bus exposes — **engine**, **turbine (gearbox input)**, and **output shaft** — and why they matter well beyond the gear display. Together they give (a) a physical proof of gear engagement that no status byte can provide, and (b) the feedback variable a **cruise-control proof of concept** would be built on.
> [!important] Why this page exists
> The swap bus carries **no DSC module** — the 2026-07-15 capture found 15 IDs and *none* of the chassis/stability IDs (`0x0CE`, `0x19E`, `0x1A0`) the [[e65-reverse-engineering-repo]] documents. **There is no wheel-speed message on this bus.** So the gearbox's own shaft speeds are not a nice-to-have — they are the *only* road-speed information available to us. Anything speed-dependent this project ever does, including cruise control, has to come from here.
## The three speeds
| What | ID | Bytes | Decode | Status |
|---|---|---|---|---|
| **Engine RPM** | `0x0AA` `RPM_ENG` | bits 32–47 | `(D4 + D5×256) × 0.25` 1/min | ✅ **verified** — 679–684 at idle |
| **Turbine (input)** | `0x1A2` `RPM_GRB_TURB` | bits 0–15 | `(D0 + D1×256) × 0.125 + 6` 1/min | ✅ **verified** — see below |
| **Output shaft** | `0x0BA` bits 20–39 | D3/D4 | ⚠ **uncalibrated** | 🔬 **hypothesis** — see below |
`0x1A2` is DLC 4 @ 20 ms; `0x0AA` is DLC 8 @ 10 ms; `0x0BA` is DLC 8 @ 20 ms. All three are fast — good for a control loop.
> [!note] Do not use `GRDT_REIN` (`0x0BA` bits 8–19)
> The repo documents it as a gearbox speed (×0.125 1/min), but on **our** bus it reads `0xFFE`/`0xFFF` — the invalid marker — across every frame of both captures. Not populated here. `0x1A2` is the turbine source that works. (verified, 2026-07-17)
## Turbine speed = physical proof of engagement ✅
The single most useful thing this ingest produced. Correlating `0x1A2` against lever position across the 2026-07-15 capture (engine idling ~680 rpm, vehicle stationary on its brakes):
| Lever | Frames | Turbine min | **avg** | max |
|---|---|---|---|---|
| P | 1370 | 6 | **634** | 652 |
| N | 95 | 6 | **628** | 649 |
| **D** | 458 | 6 | **70** | 652 |
| **R** | 2 | 6 | **~0** | 6 |
(verified, 2026-07-17 — derived from `raw/can-capture-2026-07-15-gearshift.csv`)
This is textbook torque-converter behaviour and it is unambiguous:
- **P/N** — nothing is engaged, so the turbine free-spins at roughly engine speed (~630 vs ~680; the gap is normal converter slip).
- **D/R** — the box engages, the output shaft is held by the brakes, and the turbine **stalls to near zero**.
The D column's `max` of 652 and the wide min/max spread are just the transition frames as the lever passed through — the *average* tells the story.
### Why this beats every status byte
`ST_GR_GRB` (`0x0BA`) tells you what the gearbox **intends**. `0x1D2` D0 tells you what the driver **selected**. Neither is proof that anything mechanically happened. **Turbine speed is a physical measurement of load** — the box can't fake it.
**The engagement test** is the *ratio* of turbine to engine speed, not the absolute value:
```
ratio = RPM_GRB_TURB (0x1A2) / RPM_ENG (0x0AA)
ratio ≈ 1.0 → turbine free-spinning → NOT engaged (normal in P/N)
ratio ≈ 0 → turbine stalled/loaded → engaged, output held
0 < ratio < 1 → engaged and moving (converter slip under load)
```
This directly answers the UX problem that motivated the search — *"lever says R but the car isn't moving."* With the vehicle on the ground and the brake released:
- lever = R, **ratio ≈ 0 or climbing from 0** → box engaged, it's working
- lever = R, **ratio ≈ 1.0** → **the box never took the request** ⚠ this is the fault to surface
> [!warning] The ratio is only meaningful under known output conditions
> On a **lift with the wheels free**, an engaged box spins the wheels up until the turbine approaches engine speed again — so `ratio ≈ 1.0` is normal there and does **not** indicate a fault. The test is only valid when the output is loaded (on the ground). Any firmware use of this must gate on output-shaft speed ≈ 0, or the display will cry wolf every time the car is jacked up.
>
> **Second exception: the lockup clutch.** `ST_CCLT` (`0x0BA` D0 bits 6–7) mechanically bolts the turbine to the impeller at cruise to eliminate slip — when it's closed, turbine = engine speed *exactly*. So at road speed, ratio ≈ 1.0 means "locked up", not "not engaged". Seen live in the higher gears of the 2026-07-17 capture (422 frames reading "controlling"). Any moving-vehicle use of the ratio must read `ST_CCLT` first. The standstill test is unaffected — the clutch is open at rest.
## Output shaft speed — the cruise-control variable 🔬
`0x0BA` bits **20–39** (D2 high nibble, D3, D4) are a **gap in the published source** — the [[e65-reverse-engineering-repo]] table jumps from `GRDT_REIN` at bit 19 straight to the checksum at bit 40. Its own E65 example leaves those bytes zero. **Our bus populates them.**
Evidence that they are an output-shaft/road-speed field (verified, 2026-07-17):
| Condition | D3 | D4 | Turbine | Interpretation |
|---|---|---|---|---|
| P — stationary | `00` | `00` | ~634 | output stopped |
| N — stationary | `00` | `00` | ~628 | output stopped |
| **D — stationary, brakes on** | `00` | `00` | **~70** | engaged but **output held** → zero |
| **R — wheels lifted & turning** | `A8` | `01` | — | **output turning → non-zero** |
The field is zero in *every* stationary frame **including engaged-in-D**, and non-zero the moment the wheels actually rotate. That decouples it from engine, turbine, and gear state — it tracks the **output shaft** and nothing else. Which is exactly the definition of road speed, minus a diff ratio and a tyre circumference.
### The drive capture — identification settled, scaling narrowed
The 2026-07-17 drive capture ([[can-capture-2026-07-17-drive]]) put the vehicle in motion through all six gears. Output vs `ST_GR_GRB` gear:
| Gear | Frames | Min | Avg | Max |
|---|---|---|---|---|
| 1 | 189 | 0 | 1139 | 1728 |
| 2 | 238 | 40 | 2911 | 4832 |
| 3 | 77 | 1640 | 6133 | 7888 |
| 4 | 93 | 2192 | 9152 | 11464 |
| 5 | 127 | 5160 | 12991 | 17272 |
| 6 | 94 | 13640 | 16702 | 18312 |
Monotonic with gear, overlapping at shift points, starting at zero. **The identification as output shaft speed is settled.** (verified, 2026-07-17)
### 🔬 Scaling: ×0.125 — strong hypothesis, not measured
Taking each gear's max output as its upshift instant and multiplying by the 6HP26 ratio recovers the engine speed at that shift:
| Gear | ×0.125 → rpm | ratio | **implied engine rpm** |
|---|---|---|---|
| 1 | 216 | 4.171 | **901** |
| 2 | 604 | 2.340 | **1413** |
| 3 | 986 | 1.521 | **1500** |
| 4 | 1433 | 1.143 | **1638** |
| 5 | 2159 | 0.867 | **1872** |
A smooth, gently-rising upshift schedule — textbook M57N at light throttle. Five independent ratios landing on a coherent curve is hard to get by chance. The alternative (raw = rpm) implies upshifts at **7,200–15,000 rpm** against a ~4,500 redline — ruled out.
The gearbox is a confirmed **6HP26X** (user, 2026-07-17), so the ratio table is right. The one assumption left standing is **max-output-per-gear = upshift point**.
### ⚠ Direct reference reading contradicts ×0.125
The Launch diagnostic tool reads the EGS output speed directly in rpm (it polls the box, so this is the EGS's own value in engineering units). First simultaneous-ish reading (user, 2026-07-17):
| Launch output speed | our raw `0x0BA` D3/D4 | implied factor |
|---|---|---|
| **128 rpm** | **1192** | **0.107** |
`0x125` would predict 1192 × 0.125 = **149 rpm**; the Launch showed **128**. That's 16 % off — too far to be rounding. **So ×0.125 is probably wrong**, and the true factor is nearer **0.107**. This is exactly the failure mode flagged above: the upshift-schedule test couldn't distinguish 0.107 from 0.125 (both produce a plausible-looking curve), so it never really pinned the factor — it only ruled out raw-as-rpm.
> [!warning] One eyeballed point, not a calibration
> Reading 128 on one tool and 1192 on another at the same instant, on a spinning driveline, is hard to do precisely — the two may be a second apart at slightly different speed. So this **downgrades ×0.125** but doesn't yet promote 0.107. It also can't see an offset (both go through zero, which we know, so a pure factor should hold).
>
> **The driveline screen now shows this as "OUTPUT (~rpm)"** using the provisional 0.107 factor — the `~` and the wiki caveat are how we keep an unlocked scaling from reading as exact. Firmware: `can_output_shaft_rpm()` in `automotive_data.h`. **Turbine speed (`0x1A2`) was removed from the display** — it's a diagnostic (engagement proof), not a driver number — but is still decoded.
### Finishing it (now easier — the Launch IS the reference)
The Launch gives road/output speed directly in rpm, so we no longer need the turbine-ratio inference at all — just **several simultaneous `(raw, Launch-rpm)` pairs across a speed sweep**, then a linear fit. Slope = the factor, intercept should be ~0. Three or four points settle it far better than one.
Still worth logging **`0x1A2` alongside `0x0BA`** in the same capture: turbine ÷ output cross-checks the box identity against the 6HP26 table independently, and `0x0AA` gives engine rpm. The 2026-07-17 drive capture was filtered to `0x0BA`/`0x1D2` only, which is why the ratio method couldn't run.
`docs/6HP26.pdf` in the source repo would confirm the ratios from a document rather than recollection. → [[open-questions]] wishlist.
### Raw counts → km/h
**Firmware since 2026-10-13 `(repo)`**: `~km/h = shaft rpm ÷ final drive × tyre circumference × 60 ÷ 1000`, with final drive 4.11:1 (user) and the tyre circumference as a setting (default 2440 mm, unverified) on Main CTRL's Settings → Vehicle page; shown on the Driveline and the Sport screen. The `~` is inherited from the shaft factor below.
Still needs numbers nobody has written down for the transfer case. The 6HP26**X** measures its output shaft **upstream of the transfer case**, so the conversion depends on the swap's driveline:
- BMW transfer case retained → rear output ~1:1, math unaffected
- Transfer case deleted, straight to the Patrol driveline → also fine
- A Patrol transfer case in the path → its ratio enters the calculation **and changes with high/low range**, making road speed range-dependent
Plus the Patrol's final drive ratio and tyre size. → [[nissan-patrol-swap]], [[open-questions]] #10
## Cruise control: what the bus already gives us
The DME publishes its own cruise/ACC regulation state. `0x0AA` `ST_CLCTR_V` (bits 52–55):
| Value | Meaning |
|---|---|
| `0x0` | ACC regulation, pedal not pressed |
| `0x1` | ACC regulation, pedal pressed |
| `0x4` | **CC regulation, retard** |
| `0x5` | **CC regulation, constant speed** |
| `0x6` | **CC regulation, recall** |
| `0x7` | **CC regulation, speed up** |
| `0x8` | Pedal not pressed |
| `0x9` | Pedal pressed |
| `0xA` | Pedal transgress |
| `0xB` | Pedal kickdown |
(source: [[e65-reverse-engineering-repo]]. Our capture reads `0x0` on all 3835 frames — pedal untouched, consistent with a stationary idling test. (verified, 2026-07-17))
Also available: **`ANG_ACPD`** (`0x0AA` bits 24–31, ×0.39063 %) — accelerator pedal position, `0x00` unpressed → `0xFF` floored.
> [!note] Torque decode — user's spreadsheet formula confirmed
> **Engine torque is on `0x0A8` (`TORQ_AVL`, available/delivered torque)**, bits 12–23, signed ×0.5 Nm — user-identified. `0x0AA` carries `TORQ_DVCH` (driver *demand*) in the same bit layout, so both read ~27 Nm at idle and are indistinguishable there, but they diverge under load; the delivered value (`0x0A8`) is the one to display.
> The user's Excel formula `(D2*256 + D1)/32` is algebraically identical to `bits12-23 × 0.5` — `(D2<<8|D1)/32 == ((D2<<4)|(D1>>4))×0.5`. Verified against the repo's `0x0A8` worked example (`C7 08 03 …` → 24 Nm). **One caveat**: the low nibble of D1 is `ALIV_TORQ_1_DME` (the alive counter) — the repo example literally shows `ALIV`=8 there — not torque, so the full-16-bit read sweeps in ~±0.5 Nm of jitter. The firmware masks it and sign-extends the 12-bit field (so overrun/braking reads negative). ~27–28 Nm at warm idle on our capture. (verified, 2026-07-17)
### Why a PoC is architecturally plausible
The E65 powertrain is built around **external modules requesting torque from the DME** — that is precisely what `0x0B5` ("Torque Request EGS") is, and what `0x0BA`'s repo title ("Torque Request ACC") points at. The DME arbitrates requests from the EGS, from ACC, and from itself; `ST_CLCTR_V` is it *reporting which regulator currently has the ball*. So the plumbing for "another module asks the engine for torque" is native to this bus, not something we'd have to invent.
A PoC would then need:
- **Feedback**: output shaft speed (`0x0BA` D3/D4) — *the only road-speed source we have* ⬅ the reason this page exists
- **Actual/limits**: `RPM_ENG`, `ANG_ACPD` (driver override — pedal press must instantly disengage)
- **Engagement sanity**: turbine ratio, so it can't regulate against a box in N
- **Actuation**: a torque-request frame the DME accepts
> [!danger] Actuation is a different category of risk from everything so far
> Every capability in this project to date is **read-only**. A cruise-control PoC **transmits frames that command engine torque**. Getting the ID, scaling, checksum, or alive counter wrong doesn't produce a bad reading — it produces **unintended acceleration**. Additional hazards specific to our situation:
> - The board already runs `TWAI_MODE_NORMAL` and ACKs the bus, so transmit is one function call away — there is **no accidental-write safety margin** left. → [[can-bus-integration]]
> - `0x0B5`/`0x0BA` carry **checksums and alive counters**; the DME rejects (and may fault on) malformed requests. Both algorithms are unknown to us.
> - The swap has **no DSC and no brake-pedal switch on the bus** we've found — so the usual "brake cancels cruise" interlock has no source. A PoC would have no independent way to know the driver is braking.
>
> Treat this as a **bench/lifted-wheels-only** exercise until every one of those is resolved. Nothing here should be enabled on a moving vehicle on the strength of a wiki page.
## Related
[[e65-reverse-engineering-repo]] · [[can-id-candidates]] · [[gear-box-can-revealings]] · [[can-bus-integration]] · [[nissan-patrol-swap]] · [[open-questions]]