Link protocol v2 receiver, ESP-NOW leg, Patrol gauge outputs, gear pulse
- protocol header v2 copied byte-identical from the 5B repo - uart_receiver: processFrame() shared by the UART framing task and ESP-NOW, version check, dedupe on packet_id+timestamp, per-transport liveness, CONFIG cache with sequence number - espnow_receiver: STA mode, channel hopping while silent, locks on frames - gauge_outputs: tach on IO7 (LEDC ch2, 14-bit), coolant PWM on IO8 (LEDC ch4, 8-bit), config cached in NVS, overrides applied but not saved - main: gear label from lever + engaged/target (pulses while shifting, red on mismatch), icons driven by A's alert bits, gauge update at 5 Hz, link stats - wiki: temp_stage.cfd (user's old CANNY program) decoded as prior art; controller-link, link-redundancy, patrol-gauge-outputs, open-questions updated with the bench-verified v2 results and calibration procedure Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
---
|
||||
type: source
|
||||
tags: [gauges, cannylab, canny, pwm, calibration, prior-art]
|
||||
updated: 2026-09-21
|
||||
raw: raw/temp_stage.cfd
|
||||
---
|
||||
|
||||
# `temp_stage.cfd` — the user's earlier CannyLab program for the Patrol temp gauge
|
||||
|
||||
CannyLab project ("CANNY FUNCTIONAL DIAGRAM FILE", file-format version fields 12 / 2) written by the user some years ago for a **CANNY 5.3 pico** controller, to drive the Nissan Patrol coolant gauge from the BMW engine's CAN bus. Dropped into `raw/` 2026-09-21; file dated 2026-06-04. **This is direct prior art for [[patrol-gauge-outputs]]**: the same job the 1.3 board is about to take over.
|
||||
|
||||
## How it was read
|
||||
|
||||
The format is a proprietary binary, not documented anywhere I know of. It walks as a flat list of `[u32 type][u32 length][payload]` records — 165 of them, ending exactly at a 16-byte trailer (hash). Block names, port names, constants and a free-text comment are stored in clear. Function-block opcodes are numeric; their meaning below is **inferred** from the wiring, the constants and the comment, which agree with each other everywhere. Two diagram pages: page 1 = hardware configuration, page 2 = "Temperatura Gauge" (the logic).
|
||||
|
||||
## Page 1 — hardware configuration (read verbatim from the file)
|
||||
|
||||
| Block | Setting |
|
||||
|---|---|
|
||||
| CAN Mode | `CAN 500k` |
|
||||
| CAN RX IDL (receive ID filter) | constant **0x1D0** |
|
||||
| CAN RX data | `CAN RX D1:D0` (16-bit word, bytes 1:0) |
|
||||
| DIO Mode IO Channel 1 | `OUTPUT; VDD/gnd` (push-pull) |
|
||||
| HR PWM Period | constant **255** |
|
||||
| HR PWM 1 | Duty / Enable / Pull-up driven from page 2 |
|
||||
| UART1, UART2 Mode | `UART RX/TX 9600-8-N-1-PU`, TX LEN 1 — not used by the logic |
|
||||
|
||||
## Page 2 — the logic (inferred; every constant and the comment match)
|
||||
|
||||
```
|
||||
CAN Data Received ─┐
|
||||
AND ──▶ latch(D1:D0) ──▶ take low byte (D0) ──▶ − 48 ──▶ T ("tmp aktuale")
|
||||
CAN RX IDL == 0x1D0 ┘
|
||||
|
||||
Duty = ((T − 40) × 15 + 1100) / 10 (integer arithmetic, constants 40, 15, 1100, 10)
|
||||
Enable = Pull-up = (T > tmp_min) tmp_min constant = 0 in this file
|
||||
HR PWM 1 Duty = Enable ? Duty : 0
|
||||
```
|
||||
|
||||
The comment box (Albanian, translated): *"Calculation: D = ((T − RT) × 15 + 1100) / 10. a: D = Duty. b: T = temperature coming from the ECU. c: RT = reference temperature (40 °C). d: 15 → 1.5 (coefficient per degree) × 10. e: 1100 → 110 (duty at 40 °C) × 10. f: everything divided by 10. Note: if temp is not 40, do not activate any function."*
|
||||
|
||||
Simplified: **Duty = 1.5 × T + 50**, on a **0–255** period. Points:
|
||||
|
||||
| T °C | Duty /255 | % |
|
||||
|---|---|---|
|
||||
| 40 | 110 | 43 |
|
||||
| 60 | 140 | 55 |
|
||||
| 80 | 170 | 67 |
|
||||
| 90 | 185 | 73 |
|
||||
| 100 | 200 | 78 |
|
||||
| 110 | 215 | 84 |
|
||||
| 120 | 230 | 90 |
|
||||
| ≈137 | 255 | 100 (saturates) |
|
||||
|
||||
## What this establishes
|
||||
|
||||
- The **CAN decode is the same one the 5B verified** in 2026: ID 0x1D0, byte 0, raw − 48 °C `(sibling: 5B wiki → can-id-candidates)`. Independent confirmation from a working installation years earlier.
|
||||
- The gauge was driven by **PWM duty rising with temperature**, linearly, with a non-zero floor at 40 °C. Consistent with emulating an NTC sender (resistance falls as temperature rises) through a switch and series resistor.
|
||||
- The output was the CANNY's own IO channel 1 in push-pull mode with the PWM pull-up enabled — i.e. the gauge line was driven (or a driver stage was fed) directly from the controller pin `(source: file; external circuit unknown)`.
|
||||
- The linear duty law means the gauge + drive circuit behaved close to linear in duty over 40–120 °C, or the user accepted a linear approximation. Either way this is the °C → duty table to start from.
|
||||
|
||||
## What it does NOT tell us
|
||||
|
||||
- The **PWM frequency**: "HR PWM Period = 255" is in CANNY timer ticks of an unknown base clock `(unverified)`. Look up the CANNY 5.3 pico HR PWM clock, or scope the old unit.
|
||||
- The **external circuit** between the CANNY pin and the gauge sender wire (series resistor value, any transistor). Ask the user / inspect the old harness.
|
||||
- Whether the cluster is the same one the 1.3 board will drive (assumed yes).
|
||||
- Why `tmp_min` is 0 while the comment says 40: either edited later or the gate was relaxed. With 0 the output is enabled for any positive temperature.
|
||||
|
||||
## Relevance
|
||||
|
||||
- Answers most of [[open-questions]] #7 (temp gauge curve) — as a starting table, pending a bench check on the actual needle.
|
||||
- Sets the initial LEDC design for [[patrol-gauge-outputs]]: 8-bit duty, `duty = 1.5·T + 50` clamped to 0–255, output enabled only with a valid temperature.
|
||||
|
||||
## Related
|
||||
|
||||
[[patrol-gauge-outputs]] · [[controller-link]] · [[open-questions]]
|
||||
Reference in New Issue
Block a user