Driveline screen: boot into it, add engine torque, revise shaft scaling
Boot screen: land on the Driveline data screen instead of the SquareLine gauges Home screen. Done in display_init after ui_init while the backlight is still off (no flash of the wrong screen); Home stays reachable by swiping off Driveline. Engine torque added to the screen, decoded from 0x0A8 TORQ_AVL (available/ delivered torque), bits 12-23, signed x0.5 Nm. The user identified the ID and supplied the spreadsheet formula (D2*256+D1)/32, which is algebraically bits12-23 x0.5; confirmed against the repo's 0x0A8 worked example (24 Nm). Firmware masks D1's low nibble (that's the alive counter, not torque - the repo example shows ALIV=8 there) and sign-extends so overrun reads negative. 0x0AA TORQ_DVCH is the same layout but driver demand - identical at idle, diverges under load - so the delivered value is the right one to show. Output-shaft scaling revised: a direct Launch reference (output speed 128 rpm at our raw 1192) implies ~0.107, contradicting the earlier x0.125 (which would predict 149). One eyeballed cross-tool point, so nothing is adopted - the field stays raw counts - but 0.125 is downgraded in firmware and wiki, and the Launch now gives a direct rpm reference so calibration is just a multi-point sweep and a linear fit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t engine_rpm; // 0x0AA RPM_ENG (verified)
|
||||
int16_t engine_torque_x10; // 0x0A8 TORQ_AVL, available engine torque, 0.1 Nm signed
|
||||
uint16_t turbine_rpm; // 0x1A2 RPM_GRB_TURB (verified). ~engine speed in
|
||||
// P/N; collapses toward 0 when the box engages.
|
||||
uint16_t output_shaft_raw; // 0x0BA bytes 3-4, RAW COUNTS — scaling unknown.
|
||||
|
||||
@@ -183,12 +183,11 @@ typedef struct __attribute__((packed)) {
|
||||
// project's only road-speed signal — there is no DSC/wheel-speed module on this
|
||||
// bus.
|
||||
//
|
||||
// SCALING IS STILL A HYPOTHESIS: raw * 0.125 = output shaft rpm implies a
|
||||
// coherent 901->1872 rpm upshift schedule across the five 6HP26X ratios, where
|
||||
// raw-as-rpm would imply 7,200-15,000 rpm against a ~4,500 redline. But it rests
|
||||
// on "max output per gear = the upshift point", which is unproven. Carried as
|
||||
// RAW COUNTS until a capture including 0x1A2 settles it (turbine / output gives
|
||||
// each ratio directly). Do not convert to a physical unit here.
|
||||
// SCALING IS UNSETTLED. The upshift-schedule test earlier suggested raw * 0.125
|
||||
// = rpm, but a direct Launch reference reading (128 rpm at raw 1192, 2026-07-17)
|
||||
// points to ~0.107 instead and contradicts 0.125. One eyeballed point isn't a
|
||||
// calibration, so this stays RAW COUNTS until a multi-point Launch sweep fixes
|
||||
// the factor. Do not convert to a physical unit here.
|
||||
// See wiki/pages/driveline-speed-signals.md
|
||||
#define CAN_BYTE_OUTPUT_SHAFT_L 3
|
||||
#define CAN_BYTE_OUTPUT_SHAFT_H 4
|
||||
@@ -200,6 +199,14 @@ typedef struct __attribute__((packed)) {
|
||||
#define CAN_BYTE_TURBINE_L 0
|
||||
#define CAN_BYTE_TURBINE_H 1
|
||||
|
||||
// --- 0x0A8 "Torque 1" (DME/DDE, DLC 8, 10 ms) ------------------------------
|
||||
// TORQ_AVL = torque the engine has AVAILABLE/is delivering. (0x0AA's TORQ_DVCH
|
||||
// is driver DEMAND — same bit layout, so both read ~27 Nm at idle, but they
|
||||
// diverge under load. This is the one to display as "engine torque".)
|
||||
#define CAN_ID_TORQUE_1 0x0A8
|
||||
#define CAN_BYTE_TORQUE_L 1 // TORQ_AVL low (byte 1) — see can_to_torque_x10
|
||||
#define CAN_BYTE_TORQUE_H 2 // TORQ_AVL high (byte 2)
|
||||
|
||||
// --- 0x0AA "Torque 3" (DME/DDE, DLC 8, 10 ms) ------------------------------
|
||||
#define CAN_ID_TORQUE_3 0x0AA
|
||||
#define CAN_BYTE_PEDAL_POS 3 // ANG_ACPD: % = raw * 0.39063
|
||||
@@ -323,6 +330,27 @@ static inline uint16_t can_to_rpm(const uint8_t* d) {
|
||||
return (uint16_t)(raw / 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode available engine torque (TORQ_AVL) from a 0x0A8 frame.
|
||||
*
|
||||
* The field is a SIGNED 12-bit value at bits 12-23, factor 0.5 Nm. The user's
|
||||
* spreadsheet formula (D2*256 + D1)/32 lands on the same number — algebraically
|
||||
* (D2<<8|D1)/32 == ((D2<<4)|(D1>>4)) * 0.5 — but it sweeps D1's low nibble into
|
||||
* the result, and those four bits are ALIV_TORQ_1_DME (the alive counter), not
|
||||
* torque. That adds up to ~0.5 Nm of jitter. We mask it off and sign-extend so
|
||||
* overrun/braking (negative torque) reads correctly. Verified against the repo's
|
||||
* 0x0A8 worked example: C7 08 03 00 ... -> 24 Nm, with ALIV=8 in D1's low nibble.
|
||||
*
|
||||
* @param d Payload of a 0x0A8 frame (needs DLC >= 3)
|
||||
* @return Torque in 0.1 Nm units, signed
|
||||
*/
|
||||
static inline int16_t can_to_torque_x10(const uint8_t* d) {
|
||||
uint16_t raw12 = (uint16_t)((d[CAN_BYTE_TORQUE_H] << 4) | (d[CAN_BYTE_TORQUE_L] >> 4));
|
||||
int16_t s = (raw12 & 0x800) ? (int16_t)(raw12 | 0xF000) // sign-extend 12->16 bit
|
||||
: (int16_t)raw12;
|
||||
return (int16_t)(s * 5); // * 0.5 Nm, expressed in 0.1 Nm units
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode gearbox turbine (input) speed from a 0x1A2 frame.
|
||||
* RPM_GRB_TURB = raw16 (Intel) * 0.125 + 6.
|
||||
|
||||
Reference in New Issue
Block a user