From 662266e875fb3752518ee3c7fab3eb25df1ecbfd Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Wed, 15 Jul 2026 17:16:27 +0200 Subject: [PATCH] wiki: Ingest E60 VFL CAN spreadsheet + PID-request Arduino reference --- wiki/index.md | 2 + wiki/log.md | 4 + wiki/pages/can-id-candidates.md | 11 +- wiki/raw/E60 VFL CAN-Bus Codes.xlsx | Bin 0 -> 42724 bytes .../Listen_and_send_PID_009c/A_OBDII_Dec.ino | 60 +++ .../A_declarations.ino | 68 +++ .../Listen_and_send_PID_009c/A_mcp_dec.ino | 149 ++++++ .../Listen_and_send_PID_009c/B_main.ino | 310 ++++++++++++ .../Listen_and_send_PID_009c/C_ELM_init.ino | 76 +++ .../Listen_and_send_PID_009c/C_OBDII.ino | 249 ++++++++++ .../Listen_and_send_PID_009c/C_can.ino | 444 ++++++++++++++++++ .../Listen_and_send_PID_009c/D_mcp2515.ino | 204 ++++++++ .../Listen_and_send_PID_009c/E_testvalues.ino | 152 ++++++ .../Listen_and_send_PID_009c.ino | 51 ++ wiki/sources/e60-vfl-can-codes-xlsx.md | 36 ++ wiki/sources/listen-and-send-pid-arduino.md | 22 + 16 files changed, 1834 insertions(+), 4 deletions(-) create mode 100644 wiki/raw/E60 VFL CAN-Bus Codes.xlsx create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_OBDII_Dec.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_declarations.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_mcp_dec.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/B_main.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_ELM_init.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_OBDII.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_can.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/D_mcp2515.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/E_testvalues.ino create mode 100644 wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/Listen_and_send_PID_009c.ino create mode 100644 wiki/sources/e60-vfl-can-codes-xlsx.md create mode 100644 wiki/sources/listen-and-send-pid-arduino.md diff --git a/wiki/index.md b/wiki/index.md index 41c9b35..00b4247 100644 --- a/wiki/index.md +++ b/wiki/index.md @@ -26,3 +26,5 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee ## Sources - [[esp32-s3-touch-lcd-5b-waveshare-wiki]] — official Waveshare product wiki (ingested 2026-07-15); answered CAN-transceiver and power questions, raised the 0–65 °C operating-temp concern +- [[e60-vfl-can-codes-xlsx]] — community E60 pre-facelift CAN table (ingested 2026-07-15); E60-specific confirmation of 0x1D0/0x3B4, new 0x304 gear-lever candidate +- [[listen-and-send-pid-arduino]] — Arduino ELM327→E46-cluster sketch (ingested 2026-07-15); technique reference for a diagnostic-request fallback, not ID evidence diff --git a/wiki/log.md b/wiki/log.md index 305f222..d602cb0 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -10,6 +10,10 @@ Created schema (`CLAUDE.md`), `index.md`, `log.md`, and five seed pages built fr 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. + ## [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. diff --git a/wiki/pages/can-id-candidates.md b/wiki/pages/can-id-candidates.md index 5b7d7ea..5226a56 100644 --- a/wiki/pages/can-id-candidates.md +++ b/wiki/pages/can-id-candidates.md @@ -12,12 +12,12 @@ Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sou | Signal | CAN ID | Bytes | Scaling | Sender | Rate | Confidence | |--------|--------|-------|---------|--------|------|------------| -| Coolant temp | **0x1D0** | byte 0 | °C = raw − 48 | DME/DDE | 100 ms | **High** — verified verbatim in E65 docs, present in E90-gen DBC, confirmed live on a real E60 545i, and an E60 tool32 table lists 0x1D0 "Motordaten" from DDE1 (diesel!) | +| Coolant temp | **0x1D0** | byte 0 | °C = raw − 48 | DME/DDE | 100 ms | **Very high** — verified verbatim in E65 docs, present in E90-gen DBC, confirmed live on a real E60 545i, E60 tool32 table lists 0x1D0 "Motordaten" from DDE1 (diesel!), and the [[e60-vfl-can-codes-xlsx]] sheet shows 0x7A→74 °C on a real E60 VFL (raw−48 checks out) | | Engine oil temp | **0x1D0** | byte 1 | °C = raw − 48 | DME/DDE | 100 ms | **High** — same sources as coolant | | Gearbox oil temp | **0x0B5** ("Torque_request_EGS") | byte 7 | ⚠ disputed: raw + 0 vs raw + 40 | EGS | ? | **Medium** — in the E9x community DBC; absent from the E65 repo's decoded EGS messages. Offset must be settled on the bench (a ~40 °C error is dangerous — resolve before trusting) | | Gear lever position | **0x1D2** ("TransmissionDataDisplay") | byte 0 | ⚠ two encodings, see below | EGS | 200 ms | **High that the ID is right**, medium on layout | -| Current gear number | **0x1D2** byte 1 upper nibble (GearAct, −4 offset) or **0x0BA** bits 0–3 (E65: values P/R/N…6th) | | | EGS | 20–200 ms | **Medium** — two candidate messages; also 0x304 "Status Gang" (event-driven, from E60 tool32 table) | -| Battery voltage | **0x3B4** ("Powermanagement Batteriespannung") | ⚠ disputed layout | 12-bit LE × 0.015 V (E65, verified: 0x3D9→14.775 V) vs 24-bit BE × 0.001 V (E90 DBC) | Power module / DDE | 5 s (E65) | **High on ID** (E60 tool32 table confirms, sender DDE1), layout must be settled on bench | +| Current gear number | **0x1D2** byte 1 upper nibble (GearAct, −4 offset) or **0x0BA** bits 0–3 (E65: values P/R/N…6th) | | | EGS | 20–200 ms | **Medium** — two candidate messages; also **0x304** "Gear lever" — the E60 VFL sheet shows a 2-byte lever message: P=0xE3, R=0xC2, N=0xD1, M=0xC9 (its D=0xC2 duplicates R — likely a sheet typo) | +| Battery voltage | **0x3B4** ("Powermanagement Batteriespannung") | ⚠ disputed layout | 12-bit LE × 0.015 V (E65, verified: 0x3D9→14.775 V) vs 24-bit BE × 0.001 V (E90 DBC) | Power module / DDE | 5 s (E65) | **High on ID** (E60 tool32 table + E60 VFL sheet: `64 F3`→12.76 V, consistent with the 12-bit LE layout though implying factor ≈0.0147 vs 0.015). Bonus from the sheet: byte 3 = engine running flag (0x09 on / 0x00 off) | | Engine RPM (bonus) | **0x0AA** | bytes 4–5 | RPM = raw / 4 | DME/DDE | 10 ms | High — cross-generation (E65 + E90 comment) | | Ignition/terminal status (bonus) | **0x130** | byte 0 bitmasks | 0xD5/0xC5/0xC1 | CAS | 100 ms | Medium — used by an M57 project as its only passive decode | @@ -42,6 +42,8 @@ Also useful: an E60 forum claim `(unverified)` that arbitration IDs are identica ## Sources +- [[e60-vfl-can-codes-xlsx]] — **E60 VFL community spreadsheet (ingested)**: E60-specific confirmation of 0x1D0 (−48 scaling), 0x3B4, 0x1D2 DLC 6; adds 0x304 gear lever; contains NO oil-temp or gearbox-temp rows +- [[listen-and-send-pid-arduino]] — technique reference (ingested): ELM327 PID-request pattern for the fault-code fallback; E46 cluster frames, not E60 evidence - `HeinrichG-V12/E65_ReverseEngineering` (GitHub) — E65 760Li PT-CAN, docs verified verbatim by the adversarial pass (0x1D0, 0x3B4, 0x192, 0x1D2, 0x0BA, 0x1A2) - `damienmaguire/BMW-E65-CANBUS` (GitHub) — live E65 735i captures + working EGS emulator code (0x1D2 encoding, 0x192, 0x0AA) - `TimesNewRomanZ/e60-canbus` (GitHub, community `bmw_e9x_e8x.dbc`) — author runs a real E60 545i; 0x1D0 confirmed live on E60 @@ -52,7 +54,8 @@ Also useful: an E60 forum claim `(unverified)` that arbitration IDs are identica ## Caveats -- No source used an actual **E60 M57N diesel** end-to-end; the closest anchors are the E60 tool32 table (lists DDE1 as sender for 0x1D0/0x3B4) and the M57 dieslg8 project (different chassis generation). Engine-side layouts are inferred from petrol DME captures of the same bus generation. +- No source used an actual **E60 M57N diesel** end-to-end; the closest anchors are the E60 tool32 table (lists DDE1 as sender for 0x1D0/0x3B4), the E60 VFL spreadsheet (real pre-facelift E60, engine variant unknown), and the M57 dieslg8 project (different chassis generation). Engine-side layouts are inferred from petrol DME captures of the same bus generation. +- **Oil temp and gearbox oil temp remain the weakest signals** — absent from both E60-specific sources; only the E9x DBC and E65 docs place oil temp at 0x1D0 byte 1, and only the E9x DBC has gearbox temp (0x0B5 byte 7, offset disputed). - Firmware's current IDs (`0x4F`, `0x55`, `0x201`, `0x1001`, `0x101F`) are contradicted by every source — confirmed placeholders. → [[can-bus-integration]] - Promotion to `(verified)` requires a live capture from the swap's bus: warm the engine and watch 0x1D0 byte 0 climb, shift through P/R/N/D and watch 0x1D2. diff --git a/wiki/raw/E60 VFL CAN-Bus Codes.xlsx b/wiki/raw/E60 VFL CAN-Bus Codes.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..8d2ddcc8847239f2d4d9b6152f26ded79341e1a8 GIT binary patch literal 42724 zcmeFabySqy+6RmX(jg$yBLWK2(m4VWg3=*f0us`lN-EM_Qc_AvI5YxM0)liS64DJr z&CGWX>T{6iocCMnTkBiryyw+FfMMVJ+Sl*O-@b0vQc>V zXICrsNA`v;=GJBozkc9kbA4j#8cbXz;VKe%f|>`Av=N`&ryrF=`54u8X@ES8bqci6zMO-d)C z#rn9MoTsp-Huw6PhhA>!Wv`HCEm?ID!LPS*7yHZc=C0*L3BJMle9u|^bN;gA_8rV5 zkB^mUH@+=5UQD_;y90kP?Ejtz8!GmS>WH7#pVa6G9cucu;0;ERl8EBTg;pP5u3*$4 z-nd(pD@>y@;xJ(>emKS6WV>?xr$PPpNs_h;)C$ckRTA#)LGNzp)km91xvW2fJibW% zth2q6|6q3V-K`GZ3PxtDcY0HWU1irH`igQGm>5Rpe&`oaP%ti{peX*onbO6^-qPW* ziHV~F`{}n+Q`Sz7$5BbgO$aQXTzfRriYX$Z#-f6QCi{Jy3&Twb+F5jx#&@v;wW zMc1*g(N@xPlg6tCqaUEk^l+4IY+$C5SCrF7?#<$dw?DBfd9rSO%!g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Tk`_-Aqf_%<&0gcn{IcQnk0| zTIcS5+xRlka`+Qm^;?lqtDOTI{_}nHzdb?w%M-t7)n$MD z1*17uU#*6%3;oh!(JjfYn^=1xC5H9*3r$thFrD@@Z=DZBxJ>;mx4!wa$+GA5z80Wm z@Vf^xHoeD`)VD}w6JLJ|dHh;1L%bw2QKQ4;1ZxqOj7zI8g5_W+dAGvY=wTa)Y@prF z@z<)^A&m&cU2?zXI z!GBXe8RAeV326A7@>%a|yI92K*9fvZ5-~n`31^Wmv8(9Z*wBtA$Vfff4SZUe;e&*H zvtZ_V((h(&OR?HPi}hi@MG`=ub(fC=&1v2P@T}t!5F5yJmX&H~zlsbCzOCT3BvHy} zLnGv7JNopR)L)qjsD@PgG~6Tpw+GX0beaK~mG7|q3kl3O*0z}*H92c~vwA*$*ULnK zh+$JfLGcaQPuZkqqkDPt+bdFnBn)4j?+@^mB2+#z`g|gs{|NcW&hIdWqntggoIMb_ zJ}y@7rWes$r~B7M^!^Avg)cc!(D{~@KWNYA>wBra3a0jhv;Ii=Aboi3e6)7&hz_s4=z zWd!VSXkAK-KOU>)qzc>|^?W9lY0N42ws7h(x{|`SS|nY$0g+BuGrkDfI246{xMeL&lqZC5sLjvixBFTMmAeaY> zYJR{j_l+b6MqYVmE6IrcsB_e*8}n7yg*-Rv@Of-gpL^u*b`GNNxmkE!@Ynx4`H7(aRJn|{|E{8PuKjnM{TpQesd5<(UtsXx z))@b%%72C8e+pjiiZ7V*Z+n&SQ}90s^PdWr%jre;{M#t9e<}QbFa77x%k}G`-u^bm zyq`n=v-yzMT6{kIhq{MXReQ~}{$+=PFA + int slaveSelectPin = 10; +#include //Library file for software serial connenction (Used to comunicate with ELM327) +#include +#include //for power off mode +#include //for power off mode + +#define DEFAULT_CAN_ID 0x0555 +// added for filter and can changes +#define MASK_0 0x20 +#define MASK_1 0x24 +#define FILTER_0 0x00 +#define FILTER_1 0x04 +#define FILTER_2 0x08 +#define FILTER_3 0x10 +#define FILTER_4 0x14 +#define FILTER_5 0x18 + +#define WRITE 0x02 //read and write comands for SPI + +/* Mcp2515 Operation Modes */ +enum CAN_MODE { + CAN_MODE_NORMAL, /* Transmit and receive as normal */ + CAN_MODE_SLEEP, /* Low power mode */ + CAN_MODE_LOOPBACK, /* Test mode; anything "sent" appears in the receive buffer without external signaling */ + CAN_MODE_LISTEN_ONLY, /* Receive only; do not transmit */ + CAN_MODE_CONFIG, /* Default; Allows writing to config registers */ + CAN_MODE_COUNT +}; + +//variables for checking MPG time + +unsigned long MPG; //Calculated MPG step value based on input +long MPG_correct = 100; //correction factor for MPG guage + +//variables to capture RPM pulse. +int rLSB; //RPM Least significant pit from RPM calc +int rMSB; //RPM most significant pit from RPM calc + +long del; //Delay time + +//Variables for temperature light +int tempValue; +int tempLight; + +//CanMessage message; +byte i; +int x; +uint8_t message; + +/** A flag indicating whether this is an extended CAN message */ +uint8_t extended; + +/** The ID of the CAN message. The ID is 29 bytes long if the + * extended flag is set, or 11 bytes long if not set. */ +uint32_t id; + +/** The number of bytes in the data field (0-8) */ +uint8_t len; + +/** Array containing the bytes of the CAN message. This array + * may be accessed directly to set or read the CAN message. + * This field can also be set by the setTypeData functions and + * read by the getTypeData functions. */ +uint8_t data[8]; +uint8_t LSBdata; +uint8_t MSBdata; +uint8_t ErrorState; diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_mcp_dec.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_mcp_dec.ino new file mode 100644 index 0000000..3cb3463 --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/A_mcp_dec.ino @@ -0,0 +1,149 @@ + //******************************************mcp2515 declarations************************************** + #include + +/** For each increment of the BRP, our time quanta goes up this many + * nanoseconds (for our 16MHz crystal) */ +#define TIME_QUANTUM_STEP 125 + +/** The minimum bit width in time quanta (1, 1, 1, 2) */ +#define QUANTUM_WIDTH_MIN 5 + +/** The maximum bit width in time quanta (1, 8, 8, 8) */ +#define QUANTUM_WIDTH_MAX 25 + +/** The highest possible BRP value */ +#define BRP_MAX 63 + +/** The SYNC_JUMP_WIDTH is always 1 time quantum */ +#define SYNC_JUMP_WIDTH 1 + + +/* SPI Commands */ +enum { + MCP2515_CMD_RESET = 0xC0, + MCP2515_CMD_READ = 0x03, + MCP2515_CMD_WRITE = 0x02, + MCP2515_CMD_RTS = 0x80, + MCP2515_CMD_READ_STATUS = 0xA0, + MCP2515_CMD_BIT_MODIFY = 0x05, +}; + +#define FIELD_MASK(w) ((1 << w) - 1) + +/* Registers and bits */ +#define RXM0SIDH 0x20 +#define RXM1SIDH 0x24 + +#define CANSTAT 0x0E +#define OPMOD 5 +#define ICOD 1 + +#define CANCTRL 0x0F +#define REQOP 5 +#define REQOP_MASK (FIELD_MASK(3) << REQOP) +#define ABAT 4 +#define CLKEN 2 +#define CLKPRE 0 + +#define CNF3 0x28 +#define PHSEG2 0 +#define WAKFIL 6 + +#define CNF2 0x29 +#define PRSEG 0 +#define PHSEG1 3 +#define SAM 6 +#define BTLMODE 7 + +#define CNF1 0x2A +#define BRP 0 +#define SJW 6 + +#define CANINTF 0x2C +#define MERRF 7 +#define WAKIF 6 +#define ERRIF 5 +#define TX2IF 4 +#define TX1IF 3 +#define TX0IF 2 +#define RX1IF 1 +#define RX0IF 0 + +/** + * For registers that are duplicated across multiple RX and TX buffers, + * use the REG macro. + * @param dir - Direction, either "RX" or "TX" + * @param num - Number of the buffer, 0 or 1 for RX; 0, 1, or 2 for TX. + * @param reg - The register of the buffer, defined below. + * @return The address of the register + */ +#define REG(dir,num,reg) (((dir) + ((num) << 4)) | (reg)) +#define TX 0x30 +#define RX 0x60 + +#define CTRL 0x00 +#define SIDH 0x01 +#define SIDL 0x02 +#define EID8 0x03 +#define EID0 0x04 +#define DLC 0x05 +#define D0 0x06 +#define D1 0x07 +#define D2 0x08 +#define D3 0x09 +#define D4 0x0A +#define D5 0x0B +#define D6 0x0C +#define D7 0x0D + +/* TX CTRL bits */ +#define ABTF 6 +#define MLOA 5 +#define TXERR 4 +#define TXREQ 3 +#define TXP 0 + +/* TXB SIDL bits */ +#define EXIDE 3 + +/* TX DLC bits */ +#define RTR 6 +#define DLC0 0 + +/* RX CTRL bits */ +#define RXM 5 +#define RXRTR 3 +#define BUKT 2 +#define BUKT1 1 +#define FILHIT0 0 + +/* RXB SIDL bits */ +#define IDE 3 + +/* RX DLC bits */ +#define RTR 6 +#define RB 4 +// #define DLC0 0 // Duplicate of TX + +/* Operation Modes */ +#define MCP2515_MODE_NORMAL 0x00 +#define MCP2515_MODE_SLEEP 0x01 +#define MCP2515_MODE_LOOPBACK 0x02 +#define MCP2515_MODE_LISTEN_ONLY 0x03 +#define MCP2515_MODE_CONFIG 0x04 + +/** + * CAN bus speeds. These are the bit-times for common frequencies. + */ +enum { + MCP2515_SPEED_500000 = 2000, + MCP2515_SPEED_250000 = 4000, + MCP2515_SPEED_125000 = 8000, + MCP2515_SPEED_100000 = 10000, + MCP2515_SPEED_62500 = 16000, + MCP2515_SPEED_50000 = 20000, + MCP2515_SPEED_31250 = 32000, + MCP2515_SPEED_25000 = 40000, + MCP2515_SPEED_20000 = 50000, + MCP2515_SPEED_15625 = 64000 +}; diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/B_main.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/B_main.ino new file mode 100644 index 0000000..f2afe8e --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/B_main.ino @@ -0,0 +1,310 @@ +SoftwareSerial ELM(2, 3); // RX, TX; ELM will be serial name + +void setup() +{ + // enable debugging +// #define _DEBUG + + len= 8; //length set at 8 for all messages sent + extended = 0x0; //set as not extended format for all messages sent + + // Can bus speeds (E46 is 500 Kbps) + // 500 Kbps = MCP2515_SPEED_500000, + CAN_begin(MCP2515_SPEED_500000); // set can baud rate + CAN_setMode (CAN_MODE_NORMAL); // set can mode + + //set up serial port for debugging with data to PC screen + Serial.begin(115200); + + // start serial communication at the adapter defined baudrate + ELM.begin(38400); //ELM to Arduino start + + Init(); // initiate ELM327 connection to car + + del = 3; // minimum delay time between sends for Can bus messages (limited by program speed obviously) + // if using "delay" command it is milliseconds + //time_PID_o = millis(); + Serial.println("begin main void"); + IGN_status = 1; + time_CAN_in = millis(); +} + +void loop() +{ + //The main loop calls subroutines to send the actual messages + + //the commented out section used for Debugging + //***************************RPM print***************** + // Serial.print(time_PID); + // Serial.print(" "); + // Serial.println(RPM); + //****End RPM print **************************************** + + //***************************MPG Print***************** + // Serial.print(timeMPG); + // Serial.print(" "); + // Serial.println(RPM); + //****End MPG print **************************************** + + // send_fuel();//ARBID: 545 100ms-400ms + // send_temp(); //ARBID: 329 20ms-30ms + // send_RPM(); //ARBID: 316, 40ms-60ms + +if(IGN_status >0) +{ + if (PID_flag == 0) PID_send(); //send PID for RPM at regular intervals && millis() - time_PID > 50 + if(millis() - time_test > 150) set_testvalues(); //after x second get new values. //debug +} + if (PID_flag > 0) PID_rec(); //check for message ELM if a PID has been sent (flag > 0). Use timer or other means instead of flag? + + if (millis() - time_CAN > del) CAN_bus_send(); //send CAN bus messages at regular intervals + + if (CAN_available()) //check to see if MCP2551 has a message + { + CAN_getMessage(); //Read the mesage + if(id == 0x613) CAN_ProcessMessage(); //if ARBID is 615 (from IKE) process message + } //end if CAN available +if ((millis() - time_CAN_in) > 1000) // if time since last IKE can message was > 1 second +{ + Serial.println("shut down"); + IGN_status = 0; + sleepNow(); // sleep function called here +} + +}// End of Main Void + +//*************************************************************************** +void CAN_bus_send() // Send CAN bus messages at regular intervals +{//rotates through 3 different messages. Sends the RPM twice (every other one) + + if(CAN_flag == 0 || CAN_flag == 2) send_RPM(); //ARBID: 316 + if(CAN_flag == 1) send_temp(); //ARBID: 329 20ms + //if(CAN_flag == 2) send_RPM(); //ARBID: 316 + if(CAN_flag == 3) send_fuel(); //ARBID: 545 + + CAN_flag ++; //increment flag + if(CAN_flag > 3) CAN_flag = 0; //if flag exceeds max reset to 0 (should this be zero or 1)? + time_CAN = millis(); //reset timer for RPM send +} + +//*************************************************************************** +void PID_send() // ELM_send("01 XX 1\r"); //Sends pid to ELM XX being the PID +{ + if(PID_flag_o == 0) ELM_send("01 0C 1\r"); //RPM send PID to ELM + if(PID_flag_o == 1) ELM_send("01 05 1\r"); //Sends pid ENGINE_COOLANT_TEMP + if(PID_flag_o == 2) ELM_send("01 0C 1\r"); //RPM send PID to ELM + if(PID_flag_o == 3) ELM_send("01 10 1\r"); //Sends pid ENGINE_maf + if(PID_flag_o == 4) ELM_send("01 0C 1\r"); //RPM send PID to ELM + if(PID_flag_o == 5) ELM_send("01 01 1\r"); //Sends pid ENGINE_MIL status + if(PID_flag_o == 6) ELM_send("01 0C 1\r"); //RPM send PID to ELM + if(PID_flag_o == 7) ELM_send("01 11 1\r"); //Sends pid ENGINE_TPS status + + + PID_flag_o ++; //Pid >1 set PID flag so program will listen for response. Increment do send next message + if(PID_flag_o > 7) PID_flag_o = 0; //if flag exceeds max reset to 0. back to start + PID_flag = 1; //set flag to know to wait for ELM response + time_PID = millis(); //reset timer for RPM send +} +/* +void PID_send_others() // ELM_send("01 0C 1\r"); //Sends pid to ELM + { + if(PID_flag_o == 0) ELM_send("01 05 1\r"); //Sends pid ENGINE_COOLANT_TEMP + if(PID_flag_o == 1) ELM_send("01 10 1\r"); //Sends pid ENGINE_maf + if(PID_flag_o == 2) ELM_send("01 01 1\r"); //Sends pid ENGINE_MIL status + if(PID_flag_o == 3) ELM_send("01 11 1\r"); //Sends pid ENGINE_TPS status + + PID_flag = 1; //set PID flag so program will listen for response + PID_flag_o ++; //increment flag + if(PID_flag_o > 3) PID_flag_o = 0; //if flag exceeds max reset to 0 + time_PID_o = millis(); //reset timer for RPM send + }*/ + +//*************************************************************************** +void send_RPM() //ARBID 316, RPM +{ + id = 0x316; //From ECU + data[0]= 0x05; + data[1]= 0x62; + data[2]= rLSB; //RPM LSB0xFF + data[3]= rMSB; //RPM MSB "0x0F" = 600 RPM0x4F + data[4]= 0x65; + data[5]= 0x12; + data[6]= 0x0; + data[7]= 0x62; + CAN_send(); +}//end RPM Loop + +void send_temp() //ARBID 329, Temperature, Throttle position +{ + //********************temp sense ******************************* + // The sensor and gauge are not linear. + // data[1] values and correlating needle position: + // 0x56 = First visible movment of needle starts + // 0x5D = Begining of Blue section + // 0x80 = End of Blue Section + // 0xA9 = Begin Straight up + // 0xC1 = Midpoint of needle straight up values + // 0xDB = Needle begins to move from center + // 0xE6 = Beginning of Red section + // 0xFE = needle pegged to the right + // MAP program statement: map(value, fromLow, fromHigh, toLow, toHigh) + + //Can bus data packet values to be sent + id = 0x329; //From ECU + data[0]= 0xD9; + data[1]= tempValue; //temp bit tdata From OBDII + data[2]= 0xB2; + data[3]= 0x19; + data[4]= 0x0; + data[5]= 0xEE; //Throttle position currently just fixed value + data[6]= 0x0; + data[7]= 0x0; + CAN_send(); + +}//end Temperature Loop + +void send_fuel()//ARBID 545 +//From ECU, MPG, MIL, overheat light, Cruise +// ErrorState variable controls: +//Check engine(binary 10), Cruise (1000), EML (10000) +//Temp light Variable controls temp light. Hex 08 is on zero off +{ + + //**************** set Error Lights & cruise light ****** + if(tempValue>0xE6){ // lights light if value is 229 (hot) + tempLight = 8; // hex 08 = Overheat light on + } + else { + tempLight = 0; // hex 00 = overheat light off + } + + // int z = 0x60; // + y; higher value lower MPG + if (LSBdata + MPG > 0xFF){ //if adding will go past max value + MSBdata = MSBdata + 0x01; //increment MSB + } + LSBdata=LSBdata + MPG; //increment values based on inj input + + //For debugging + // Serial.print(LSBdata); + // Serial.print(" "); + // Serial.println(MPG); + + //Can bus data packet values to be sent + id = 0x545; //From ECU, MPG, MIL, overheat light, Cruise + data[0]= ErrorState; //set error byte to error State variable + data[1]= LSBdata; //LSB Fuel consumption + data[2]= MSBdata; //MSB Fuel Consumption + data[3]= tempLight; //Overheat light + data[4]= 0x7E; + data[5]= 0x10; + data[6]= 0x00; + data[7]= 0x18; + + //Time captures for MPG gauge + // timeMPGp1 = micros(); + // timeMPG = timeMPGp1 - timeMPGp2; + // timeMPGp2 = timeMPGp1; + + CAN_send(); //can send 545 + +} //end send_Fuel if + +//********************* Process message *************** +void CAN_ProcessMessage() +{ + time_CAN_in= millis(); //set time for last time message recieved + // Serial.println("recd 0x615"); //debug + Serial.print(data[0],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[1],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[2],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[3],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[4],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[5],HEX); //debug + Serial.print(" "); //debug + Serial.print(data[6],HEX); //debug + Serial.print(" "); //debug + Serial.println(data[7],HEX); //debug + + //----------------- look for Ignition on ----------------- + if(bitRead(data[4],0) == 1) //look for IGN on bit + {//IGN is on + //do something + IGN_status = 1; //set flag for IGN status + Serial.println("IGN on"); + } + else //AC message from E46 is IGN off + { + //Stop ELM and stop sending can (Put elm and MCP's to sleep?) + Serial.println("IGN off"); + } + + + + //----------------- look for AC on ----------------- + if(bitRead(data[0],7) == 1) //look for ac on bit + {//AC message from E46 is AC on + //set pin x low (AC on) +// digitalWrite(AC_pin, LOW); //set AC to on; this to be changed to send can message to LS3 + Serial.println("ac just turned on"); + } + else //AC message from E46 is AC off + { + //Set pin x high (AC off) +// digitalWrite(AC_pin, HIGH); //set AC to OFF; this to be changed to send can message to LS3 + Serial.println("ac just turned off"); + } + +} //end process message + +void sleepNow() +{ + /* Now is the time to set the sleep mode. In the Atmega8 datasheet + * http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35 + * there is a list of sleep modes which explains which clocks and + * wake up sources are available in which sleep modus. + * + * In the avr/sleep.h file, the call names of these sleep modus are to be found: + * + * The 5 different modes are: + * SLEEP_MODE_IDLE -the least power savings + * SLEEP_MODE_ADC + * SLEEP_MODE_PWR_SAVE + * SLEEP_MODE_STANDBY + * SLEEP_MODE_PWR_DOWN -the most power savings + * + * the power reduction management is described in + * http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html + */ + + set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here + + sleep_enable(); // enables the sleep bit in the mcucr register + // so sleep is possible. just a safety pin + + power_adc_disable(); + power_spi_disable(); + power_timer0_disable(); + power_timer1_disable(); + power_timer2_disable(); + power_twi_disable(); + + + sleep_mode(); // here the device is actually put to sleep!! + + // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP + sleep_disable(); // first thing after waking from sleep: + // disable sleep... + + power_all_enable(); + +} + + + + + diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_ELM_init.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_ELM_init.ino new file mode 100644 index 0000000..d2fcc03 --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_ELM_init.ino @@ -0,0 +1,76 @@ +//**************** ELM INIT ********************** +void Init() +{ + boolean passive; + unsigned char n; + char prompted; + + + for (i = 0; i < INIT_CMD_COUNT; i++) { //Loop enough times to send all init comands + if (!passive) { + char cmd[MAX_CMD_LEN]; + strcpy_P(cmd, s_initcmd[i]); // copy first string from S_initcmd to cmd + ELM_send(cmd); // Send cmd string to ELM + // Serial.println(cmd); //debug + } + ELM_rec(OBD_RECV_BUF_SIZE); //call ELM recieve + } // end INIT command send loop + return; +} // end Init subroutine + + +//*************************** ELM_REC **************************** +// currently using Serial read to get data. To read elm just swtich. +//buffer array and string size (max number of characters to catch) +void ELM_rec(int String_size) +{ + // int String_size = 2; //# of characters per array value to be read + // int OBD_RECV_BUF_SIZE = 6; //max data bit pairs to be read + long OBD_TIMEOUT_INIT = 100000; + int n; + char c; + // char buffer[String_size-2]; + unsigned long currentMillis; + unsigned long elapsed; + + Prompted =0; //set propmpt ">" recieved flag to zero + n = 0; + currentMillis = millis(); + while (n < String_size) { //keep looping until recieved # of characters (String length) + if (ELM.available()) { //do nothing if no data avail + c = ELM.read(); + Serial.write(c); + // ---------------- switch ------------------------ + switch (c) { + + case '>': // if command prompt clear buffer and end both loops + buffer[n] = 0; + n = String_size; //set n to max size to end loop + Prompted = 1; + break; + + case ' ': //if space discard + case '\r': //if space discard + break; + + default: //if not command prompt + buffer[n] = c; //move c to array. needed for conversion + n++; // increment counter for reading in + } //end switch + } //end ELM available + else { //check elapsed time in case elm read errors + elapsed = millis() - currentMillis; + if (elapsed > OBD_TIMEOUT_INIT) { + // init timeout + //WriteData("\r"); + buffer[n] = 0; + n = String_size; + i = OBD_RECV_BUF_SIZE; + Serial.print(elapsed); //debug + elapsed = 0; + Serial.println(" timeout "); //debug + } //end if time out + } //end if serial avilable else (time out check) + } // end read increment n loop +}//end void + diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_OBDII.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_OBDII.ino new file mode 100644 index 0000000..35a54cd --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_OBDII.ino @@ -0,0 +1,249 @@ +//*************************** PID_REC **************************** +// Extra commands to take ELM data and put into PID array +int PID_rec() +{ + int bn = 0; //bit counter + char c; + // char buffer[String_size-2]; + int x = 398; //initialize x to no bytes + + + while (ELM.available()>0){//If ELM has bytes to read + c = ELM.read(); +#if defined(_DEBUG) + //Serial.print("C");//debug + // Serial.print(c); //debug + //Serial.print(" "); //debug +#endif + + switch (c) { + + case ' ': //if space discard + x = 303; //flag leaving on space or carriage return + break; + + case '\r': //if space discard + x = 303; //flag leaving on space or carriage return + break; + + case '>': // if command prompt clear buffer and end both loops + PID_SIZE = iE; //set string size variable to current length of message + iE=0; + PID_flag = 0; //flag set to OK to send another PID command +#if defined(_DEBUG) + Serial.println(" "); + Serial.println(" prompt recieved with message "); //debug +#endif + Decode(); //decode pid response + return 300; // return good message + + + default: + //if not command prompt, space or return + buffer[bn] = c; //store bite in temporary array + // Serial.print(buffer[n]); + // Serial.print("n= "); + // Serial.print(bn); + bn++; // increment counter for reading in + if(bn > 1){//if we have a full byte, 2 characters +// Serial.print("b1="); +// Serial.print(buffer[0]); +// Serial.print(" b2="); +// Serial.print(buffer[1]); +// Serial.print(" iE= "); +// Serial.print(iE); +// Serial.print(" "); + + dataPID[iE] = toHex(buffer[0],buffer[1]); //convert 2 characters read in to hex + bn = 0; // reset bit counter + iE++; //index for next PID byte + } + + if(iE >10) + { + Serial.println("something has gone wrong with ELM"); + iE = 0; + PID_flag = 0; //flag to ready to send PID command + ELM.flush(); + return 401; //error + } + } // end switch + x = 399; //byte recieved but not finished + }//end ELM available + + return x; //return 399 if partial message 398 if no bytes + +}//end void get pid + +// for(i=0 ;i< PID_response_SIZE ;i++){ //clear PID's +// dataPID[i]=0; //clear PID's +// } //end for //clear PID's + +// for(i=0 ;i< OBD_RECV_BUF_SIZE ;i++){ //clear buffer's +// buffer[i]=0; //clear PID's +// } //end for //clear PID's + +//******************** decode ************************** +//Decode for temp and RPM are ready to use. Other PID's need checked. +void Decode() //Decode the data recieved in PID_rec Data is stored in dataPID[] +{ + float engine_data; + String message; + +#if defined(_DEBUG) + for(i=0; i< PID_SIZE; i++){ //debug + Serial.print(dataPID[i],HEX); //debug + Serial.print(" "); //debug + }//debug + Serial.println(" = finished dataPID[i]"); //debug +#endif + + // ************The switch ****** + switch(dataPID[1]) + { /* Details from http://en.wikipedia.org/wiki/OBD-II_PIDs */ + case ENGINE_RPM: // ((A*256)+B)/4 [RPM] + engine_data = ((dataPID[2]*256) + dataPID[3])/4; + //=DEC2HEX(HEX2DEC(G3)/4*6.42/256) + // data[3] = engine_data / 40 ; //RPM BMW MSB RPM / 40 + rMSB = engine_data / 40; //RPM BMW MSB RPM / 40 then to MSB hex (256) + // data[2] = engine_data - (data[2] / 6.4 * 256); //RPM LSB + rLSB = (engine_data - (rMSB * 40)) * 6.4; //RPM LSB subtract MSB portion then comvert to BMW value + message = "ENGINE_RPM rpm = "; //debug + break; + + case ENGINE_COOLANT_TEMP: // A-40 [degree C] + engine_data = dataPID[2] - 40; //Calculate output value + // data[1] = (dataPID[3] + 8.373) / .75; //convert to BMW scale + tempValue = (dataPID[2] + 8.373) / .75; //convert to BMW scale + // Serial.print("BMW temp value = hex ");/debug + // Serial.println(tempValue,HEX);//debug + message ="engine coolant temp (degC) = ";//debug + break; + + case VEHICLE_SPEED: // A [km] + // currently not used + engine_data = dataPID[2]; + message ="VEHICLE_SPEED km ";//debug + break; + + case MAF_SENSOR: // ((256*A)+B) / 100 [g/s] + engine_data = ((dataPID[2]*256) + dataPID[3])/100; + message ="MAF_SENSOR g/s ";//debug + break; + + case MIL_CODE: // A * 0.005 (B-128) * 100/128 (if B==0xFF, sensor is not used in trim calc) + engine_data = bitRead(dataPID[2],7); + + if(engine_data != 0 || tempValue>229) { + ErrorState = 0x02; //Set check engine. Binary 0010 (hex 02) + } + else { + ErrorState = 0x00; // No error light (zero) + } + message ="MIL = ";//debug + + break; + + case THROTTLE: // Throttle Position + engine_data = (dataPID[2]*100)/255; + message ="THROTTLE %% ";//debug + break; + + } //End Switch case + +#if defined(_DEBUG) + // Serial.print("message, engine data"); + // Serial.print(message); + // Serial.println(engine_data); //print output +#endif + + return; + // Serial.println(" end of subroutine "); + +} //end decode void + + + + + +// ********* converts 2 charachter ascii to equivalent hex ********* +uint8_t toHex(char hi, char lo) +{ + uint8_t b; + hi = toupper(hi); + if( isxdigit(hi) ) { + if( hi > '9' ) hi -= 7; // software offset for A-F + hi -= 0x30; // subtract ASCII offset + b = hi<<4; + lo = toupper(lo); + if( isxdigit(lo) ) { + if( lo > '9' ) lo -= 7; // software offset for A-F + lo -= 0x30; // subtract ASCII offset + b = b + lo; + return b; + } // else error + } // else error + return 0; +} + +//************* write data to ELM ****************** +void ELM_send(const char* s) +{ + ELM.write(s); + // Serial.print("writing this (s): "); //Debug + // Serial.println(s); //Debug +} + +//************* write data to ELM ****************** +void ELM_send(const char c) +{ + ELM.write(c); // send command over serial bus to ELM + // Serial.print("writing this (c): "); //Debug + // Serial.println(c); //Debug +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_can.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_can.ino new file mode 100644 index 0000000..211a391 --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/C_can.ino @@ -0,0 +1,444 @@ +//*********************** Can cpp *************************************** +//Below is Can bus library and programming. Not specific to E46 +/* + * Copyright (c) 2010-2011 by Kevin Smith + * MCP2515 CAN library for arduino. */ + + +void CAN_CanMessage () +{ + extended = 0; + id = DEFAULT_CAN_ID; + len = 0; +} +// **************************** setByteData ******************* +void CAN_setByteData (byte b) +{ + len = 1; + + data[0] = b; +} + +//******************* setIntData *************************** +void setIntData (int i) +{ + len = 2; + + /* Big-endian network byte ordering */ + data[0] = i >> 8; + data[1] = i & 0xff; +} + +//******************* setLongData *************************** +void CAN_setLongData (long l) +{ + len = 4; + + /* Big-endian network byte ordering */ + data[0] = (l >> 24) & 0xff; + data[1] = (l >> 16) & 0xff; + data[2] = (l >> 8) & 0xff; + data[3] = (l >> 0) & 0xff; +} + +//*********************** setData ***************************** +void CAN_setData (const uint8_t *data, uint8_t len) +{ + byte i; + + // this->len = len; + len = len; + for (i=0; idata[i] = data[i]; + + } +} + +//*********************** setData ************************** +void CAN_setData (const char *data, uint8_t len) +{ + CAN_setData ((const uint8_t *)data, len); +} + +//********************* send ****************************** +void CAN_send () +{ + //mcp2515_set_msg (0, id, data, len, extended); + + uint8_t tx_buf = 0; + + uint8_t buf[5]; + + if (extended) { + buf[0] = (uint8_t)(id >> 21); + buf[1] = (uint8_t)(((id >> 13) & 0xE0) | + (1 << EXIDE) | + ((id >> 16) & 0x03)); + buf[2] = (uint8_t)(id >> 8); + buf[3] = (uint8_t)(id); + } else { + buf[0] = (uint8_t)(id >> 3); + buf[1] = (uint8_t)(id << 5); + } + + if (len > 8) + len = 8; + + buf[4] = len << DLC0; + + mcp2515_write_regs (REG(TX, tx_buf, SIDH), buf, 5); + mcp2515_write_regs (REG(TX, tx_buf, D0), data, len); + + // mcp2515_request_tx (0); + + mcp2515_bit_modify (REG(TX, tx_buf, CTRL), 1 << TXREQ, 1 << TXREQ); +} + +//****************** getByteFromData ********************** + +byte CAN_getByteFromData() +{ + return data[0]; +} + +//**************** getIntFromData ************************ +int CAN_getIntFromData () +{ + int val; + + val |= (uint16_t)data[0] << 8; + val |= (uint16_t)data[1] << 0; + + return val; +} + +//**************** getLongFromData +long CAN_getLongFromData () +{ + long val; + + val |= (uint32_t)data[0] << 24; + val |= (uint32_t)data[1] << 16; + val |= (uint32_t)data[2] << 8; + val |= (uint32_t)data[3] << 0; + + return val; +} + +//********************** getData ******************* +void CAN_getData (uint8_t *data) +{ + byte i; + + for (i=0; idata[i]; + } +} + +//******************** getData *********************** +void CAN_getData (char *data) +{ + CAN_getData ((uint8_t *)data); +} + +/* + * CANClass + */ + +//********************** Begin *********************** +void CAN_begin(uint32_t bit_period) { + SPI.begin(); + SPI.setDataMode(SPI_MODE0); + SPI.setBitOrder(MSBFIRST); + SPI.setClockDivider(SPI_CLOCK_DIV4); + + //mcp2515_init (bit_time); mcp2515_init (uint32_t bit_period) +uint8_t brp; + uint8_t bit_width; + uint8_t prop_seg; + uint8_t phase_1_seg; + uint8_t phase_2_seg; + + /* Calculate BRP and bit width */ + brp = calc_brp (bit_period, &bit_width); + + if (bit_width < QUANTUM_WIDTH_MIN) + bit_width = QUANTUM_WIDTH_MIN; + + /* Calculate segment widths based on bit width. This algorithm keeps + * the segments as even as possible, favoring phase2, then phase1 + * to be bigger. */ + phase_2_seg = (bit_width + 1) / 3; + bit_width -= phase_2_seg; + + phase_1_seg = bit_width >> 1; + + prop_seg = bit_width - phase_1_seg - 1; + + /* Set registers */ + mcp2515_write_reg (CNF1, + (brp << BRP) | + ((SYNC_JUMP_WIDTH - 1) << SJW) ); + + mcp2515_write_reg (CNF2, + ((prop_seg - 1) << PRSEG) | + ((phase_1_seg - 1) << PHSEG1) | + (0 << SAM) | /* Sample once */ + (1 << BTLMODE) ); /* Phase 2 set by CNF3 */ + + mcp2515_write_reg (CNF3, + ((phase_2_seg - 1) << PHSEG2) | + (0 << WAKFIL) ); + + mcp2515_write_reg (REG(RX, 0, CTRL), + (0x0 << RXM) | + (0 << BUKT) ); + CAN_resetFiltersAndMasks(); +} + + +//******************************** reset filters and Masks **************** +// added to set filters -- from another program (not from Kevin Smith ) +void CAN_resetFiltersAndMasks() { + //disable first buffer + CAN_setMaskOrFilter(MASK_0, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_0, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_1, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + + //disable the second buffer + CAN_setMaskOrFilter(MASK_1, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_2, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_3, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_4, 0b00000000, 0b00000000, 0b00000000, 0b00000000); + CAN_setMaskOrFilter(FILTER_5, 0b00000000, 0b00000000, 0b00000000, 0b00000000); +} + +//***************************** set mask or FIlter ********************** +void CAN_setMaskOrFilter(byte mask, byte b0, byte b1, byte b2, byte b3) { + CAN_setMode(CAN_MODE_CONFIG); // 1= Configuration, 2 = NORMAL, 3 = SLEEP, 4 = LISTEN, 5 = LOOPBACK + CAN_setRegister(mask, b0); + CAN_setRegister(mask+1, b1); + CAN_setRegister(mask+2, b2); + CAN_setRegister(mask+3, b3); + CAN_setMode(CAN_MODE_LISTEN_ONLY); // (was 1) 1= Configuration, 2 = NORMAL, 3 = SLEEP, 4 = LISTEN, 5 = LOOPBACK +} + +//************************** Set register ****************************** +void CAN_setRegister(byte reg, byte value) { + // mcp2515_write_reg (reg, value); this should be instead to write the registers + //static void mcp2515_write_reg (uint8_t addr, uint8_t buf) + // used from other program. Replaced by above + digitalWrite(slaveSelectPin, LOW); + delay(10); + SPI.transfer(WRITE); + SPI.transfer(reg); + SPI.transfer(value); + delay(10); + digitalWrite(slaveSelectPin, HIGH); + delay(10); + +} +// end from another program + + + +///*********************** end *********************** +void CAN_end() { + SPI.end (); +} + +//********************* setMode ********************* +void CAN_setMode (uint8_t mode) +{ + // mcp2515_set_mode (mode); + mcp2515_bit_modify (CANCTRL, REQOP_MASK, mode << REQOP); +} + +//******************** ready ********************** +uint8_t CAN_ready () +{ + //return mcp2515_msg_sent (); + uint8_t byte; + + mcp2515_read_regs (REG(TX, 0, CTRL), &byte, 1); + + return (!(byte & (1 << TXREQ))); + + +} + +//****************** Available ********************* +boolean CAN_available () +{ + //return (boolean)mcp2515_msg_received(); + uint8_t byte; + + mcp2515_read_regs (CANINTF, &byte, 1); + + return (byte & ((1 << RX1IF) | (1 << RX0IF))); + + + +} + +//***************** getMessage *********************** +void CAN_getMessage () +{ + // uint8_t test; + uint8_t extended; + // CanMessage m; + //test = mcp2515_get_msg (0, &id, data, &len); + extended = mcp2515_get_msg (0, &id, data, &len); + + // return m; +} + +//CANClass CAN; + +/* +/** + * A class representing a single CAN message. The message can be built + * using the sendData functions, or the bytes of the message can + * be set directly by accessing the public data[] array. This class is + * also used to retrieve a message that has been received. The data + * can be read using the getData functions, or can be read directly + * by accessing the public data[] array. + */ +//class CanMessage { +// public: +/** A flag indicating whether this is an extended CAN message */ +// uint8_t extended; +/** The ID of the CAN message. The ID is 29 bytes long if the + * extended flag is set, or 11 bytes long if not set. */ +// uint32_t id; +/** The number of bytes in the data field (0-8) */ +// uint8_t len; +/** Array containing the bytes of the CAN message. This array + * may be accessed directly to set or read the CAN message. + * This field can also be set by the setTypeData functions and + * read by the getTypeData functions. */ +// uint8_t data[8]; + +// CanMessage(); + +/** + * Simple interface to set up a CAN message for sending a byte data + * type. When received, this message should be unpacked with the + * getByteData function. This interface only allows one byte to be + * packed into a message. To pack more data, access the data array + * directly. + * @param b - The byte to pack into the message. + */ +// void setByteData (byte b); + +/** + * Simple interface to set up a CAN message for sending an int data + * type. When received, this message should be unpacked with the + * getIntData function. This interface only allows one int to be + * packed into a message. To pack more data, access the data array + * directly. + * @param i - The int to pack into the message. + */ +// void setIntData (int i); + +/** + * Simple interface to set up a CAN message for sending a long data + * type. When received, this message should be unpacked with the + * getLongData function. This interface only allows one long to be + * packed into a message. To pack more data, access the data array + * directly. + * @param l - The long to pack into the message. + */ +// void setLongData (long l); + +/** + * A convenience function for copying multiple bytes of data into + * the message. + * @param data - The data to be copied into the message + * @param len - The size of the data + */ +// void setData (const uint8_t *data, uint8_t len); +// void setData (const char *data, uint8_t len); + +/** + * Send the CAN message. Once a message has been created, this + * function sends it. + */ +// void send(); + +/** + * Simple interface to retrieve a byte from a CAN message. This + * should only be used on messages that were created using the + * setByteData function on another node. + * @return The byte contained in the message. + */ +// byte getByteFromData (); + +/** + * Simple interface to retrieve an int from a CAN message. This + * should only be used on messages that were created using the + * setIntData function on another node. + * @return The int contained in the message. + */ +// int getIntFromData (); + +/** + * Simple interface to retrieve a long from a CAN message. This + * should only be used on messages that were created using the + * setLongData function on another node. + * @return The long contained in the message. + */ +// long getLongFromData (); + +/** + * A convenience function for copying multiple bytes out of a + * CAN message. + * @param data - The location to copy the data to. + */ +// void getData (uint8_t *data); +// void getData (char *data); +//}; + +//class CANClass { +// public: +/** + * Call before using any other CAN functions. + * @param bit_time - Desired width of a single bit in nanoseconds. + * The CAN_SPEED enumerated values are set to + * the bit widths of some common frequencies. + */ +// static void begin(uint32_t bit_time); + +/** Call when all CAN functions are complete */ +// static void end(); + +/** + * Set operational mode. + * @param mode - One of the CAN_MODE enumerated values */ +// static void setMode(uint8_t mode); + +/** Check whether a message may be sent */ +// static uint8_t ready (); + +/** + * Check whether received CAN data is available. + * @return True if a message is available to be retrieved. + */ +// static boolean available (); + +/** + * Retrieve a CAN message. + * @return A CanMessage containing the retrieved message + */ +// static CanMessage getMessage (); */ + + + + + + + + + + + diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/D_mcp2515.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/D_mcp2515.ino new file mode 100644 index 0000000..8c32d38 --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/D_mcp2515.ino @@ -0,0 +1,204 @@ + +void mcp2515_read_regs (uint8_t addr, uint8_t* buf, uint8_t n) +{ + int i; + + digitalWrite (slaveSelectPin, LOW); + SPI.transfer (MCP2515_CMD_READ); + SPI.transfer (addr); + for (i=0; i BRP_MAX) + brp_min = BRP_MAX; + if (brp_max > BRP_MAX) + brp_max = BRP_MAX; + + total_steps = bit_period / TIME_QUANTUM_STEP; + + for (i = brp_min; i <= brp_max; i++) { + error = total_steps % (i + 1); + + /* If the number of quanta that make the correct bit rate at this + * prescalar is an integer, this is an exact match. */ + if (error == 0) { + best_brp = i; + best_width = total_steps / (i + 1); + break; + } + + /* If rounding up, the error is the difference between the divisor + * and the remainder */ + if ((i + 1) - error < error) { + error = (i + 1) - error; + } + + /* Store the settings at this BRP if they are the best yet */ + if (error < best_error) { + best_error = error; + best_width = (total_steps + ((i + 1) >> 1))/ (i + 1); + best_brp = i; + } + } + + /* Return the best match */ + *bit_width = best_width; + return best_brp; +} + + + + + +/* + * Set the operating mode of the MCP2515 + */ +//void mcp2515_set_mode (uint8_t mode) +//{ +// mcp2515_bit_modify (CANCTRL, REQOP_MASK, mode << REQOP); +//} + +/* + * Reads a message from the receive buffer and marks it as read. + */ +uint8_t mcp2515_get_msg (uint8_t rx_buf, uint32_t *id, + uint8_t *data, uint8_t *len) +{ + uint8_t buf[5]; + uint8_t extended; + + mcp2515_read_regs (REG(RX, rx_buf, SIDH), buf, 5); + *len = buf[4] & 0x0f; + if (*len > 8) + *len = 8; + mcp2515_read_regs (REG(RX, rx_buf, D0), data, *len); + + extended = buf[1] & (1 << IDE); + if (extended) { + *id = ((uint32_t)(buf[0]) << 21) | + ((uint32_t)(buf[1] & 0xE0) << 13) | + ((uint32_t)(buf[1] & 0x03) << 16) | + ((uint32_t)(buf[2]) << 8) | + ((uint32_t)(buf[3]) << 0); + } else { + *id = ((uint32_t)buf[0] << 3) | + ((uint32_t)buf[1] >> 5); + } + + mcp2515_bit_modify (CANINTF, 1 << (RX0IF + rx_buf), 0); + + return extended; +} + + + +void mcp2515_set_rx_mask (uint8_t mask_num, uint32_t mask, uint8_t extended) +{ + uint8_t reg; + uint8_t buf[4]; + + if (mask_num == 0) + reg = RXM0SIDH; + else + reg = RXM1SIDH; + + if (extended) { + buf[0] = (uint8_t)(mask >> 21); + buf[1] = (uint8_t)(((mask >> 13) & 0xE0) + | ((mask >> 16) & 0x03)); + buf[2] = (uint8_t)(mask >> 8); + buf[3] = (uint8_t)(mask >> 0); + } else { + buf[0] = (uint8_t)(mask >> 3); + buf[1] = (uint8_t)(mask << 5); + buf[2] = 0; + buf[3] = 0; + } + + mcp2515_write_regs (reg, buf, 4); +} + +void mcp2515_set_rx_filter (uint8_t filter_num, uint32_t filter, uint8_t extended) +{ + uint8_t reg; + uint8_t buf[4]; + + /* Calculate correct register */ + reg = filter_num * 4; + if (reg >= 12) + reg += 4; + + if (extended) { + buf[0] = (uint8_t)(filter >> 21); + buf[1] = (uint8_t)(((filter >> 13) & 0xE0) + | ((filter >> 16) & 0x03) + | (1 << EXIDE)); + buf[2] = (uint8_t)(filter >> 8); + buf[3] = (uint8_t)(filter >> 0); + } else { + buf[0] = (uint8_t)(filter >> 3); + buf[1] = (uint8_t)(filter << 5); + buf[2] = 0; + buf[3] = 0; + } + + mcp2515_write_regs (reg, buf, 4); +} diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/E_testvalues.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/E_testvalues.ino new file mode 100644 index 0000000..c211fed --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/E_testvalues.ino @@ -0,0 +1,152 @@ + +void set_testvalues() +{ + + + + // RPM (put the hex number together then convert to DEC and divide by 6.4) + // rLSB; //RPM LSB0xFF + // rMSB; //RPM MSB "0x0F" = 600, 0x19 = 1000 add 25 decimal to get next 1000, 7000 = 0xAF + rLSB = 0x00; + + // *************RPM + + if(test_up == 0) + rMSB = rMSB + 1; + if(test_up == 1) + rMSB = rMSB - 1; + + if( rMSB < 0x01) + { + rMSB = rMSB + 2; //set initial value for rMSB + test_up = 0; //set needle direction to increasing + } + if(rMSB > 0xAF) // if beyond 7000 rpm change direction + { + rMSB = rMSB - 2; + test_up = 1; //set needle direction to decreasing + } + Serial.print("RPM MSB = "); + Serial.println(rMSB,HEX); + + if(test_flag > 2) //increment more slowly than RPM + { + // ************* temperature + // tempValue; //temp bit tdata + // values and correlating needle position: + // 0x56 = First visible movment of needle starts + // 0x5D = Begining of Blue section + // 0x80 = End of Blue Section + // 0xA9 = Begin Straight up + // 0xC1 = Midpoint of needle straight up values + // 0xDB = Needle begins to move from center + // 0xE6 = Beginning of Red section + // 0xFE = needle pegged to the right +/* if(temp_up == 0) + tempValue = tempValue + 1; + if(temp_up == 1) + tempValue = tempValue - 1; + + if( tempValue < 0x56) + { + tempValue = tempValue + 2; //set initial value for rMSB + temp_up = 0; //set needle direction to increasing + } + if(tempValue > 0xFE) // if beyond 7000 rpm change direction + { + tempValue = tempValue - 2; + temp_up = 1; //set needle direction to decreasing + }*/ + test_flag = 0; + } + + +//******check engine lights Check engine(binary 10,2), Cruise (1000,8), EML (10000,16), Check eng and EML (32) + + if(rMSB > 0x0D && rMSB < 0x19) //if RPM between 500 and 1000 +{ +ErrorState = 0x01; //Set B0 +tempLight = 0x01; //set B3 +} + + if(rMSB > 0x19 && rMSB < 0x26) //if RPM between 1000 and 1500 +{ +ErrorState = 0x02; //Set B0 check engine. Binary 0010 (hex 02) +tempLight = 0x02; //set B3 +} + + if(rMSB > 0x26 && rMSB < 0x32) //if RPM between 1500 and 2000 +{ +ErrorState = 0x04; //Set B0) +tempLight = 0x04; //set B3 +} + +if(rMSB > 0x32 && rMSB < 0x3F) //if RPM between 2000 and 2500 +{ +ErrorState = 0x08; //Set B0 Cruise +tempLight = 0x08; //set B3 Overheat +} + +if(rMSB > 0x3F && rMSB < 0x4B) //if RPM between 2500 and 3000 +{ +ErrorState = 0x10; //Set B0 EML +tempLight = 0x10; //set B3 +} + +if(rMSB > 0x4B && rMSB < 0x58) //if RPM between 3000 and 3500 +{ +ErrorState = 0x20; //Set B0 +tempLight = 0x20; //set B3 +} + +if(rMSB > 0x58 && rMSB < 0x64) //if RPM between 3500 and 4000 +{ +ErrorState = 0x40; //Set B0 +tempLight = 0x40; //set B3 +} + +if(rMSB > 0x64 && rMSB < 0x71) //if RPM between 4000 and 4500 +{ +ErrorState = 0x80; //Set B0 +tempLight = 0x80; //set B3 +} + +if(rMSB > 0x71&& rMSB < 0x7D) //if RPM between 4500 and 5000 +{ +ErrorState = 0x100; //Set B0 +tempLight = 0x100; //set B3 +} + +//PAST 10 CHECKS +if(rMSB > 0x7D && rMSB < 0x8A) //if RPM between 5000 and 5500 +{ +ErrorState = 0x03; //Set B0 +tempLight = 0x00; //set B3 +} + +if(rMSB > 0x8A && rMSB < 0x96) //if RPM between 5500 and 6000 +{ +ErrorState = 0x06; //Set B0 +tempLight = 0x00; //set B3 +} + +if(rMSB > 0x96 && rMSB < 0xA3) //if RPM between 6000 and 6500 +{ +ErrorState = 0xFF; //Set B0 +tempLight = 0x00; //set B3 +} + +if(rMSB > 0xA3 && rMSB < 0xAF) //if RPM between 6050 and 7000 +{ +ErrorState = 0x00; //Set B0 +tempLight = 0xFF; //set B3 +} + + + + test_flag++;//increment flag +// if(test_flag==10) test_flag=0; //if past end of range reset + time_test = millis(); //set timer +}//end void + + diff --git a/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/Listen_and_send_PID_009c.ino b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/Listen_and_send_PID_009c.ino new file mode 100644 index 0000000..e4313db --- /dev/null +++ b/wiki/raw/Listen_and_send_PID_009c/Listen_and_send_PID_009c/Listen_and_send_PID_009c.ino @@ -0,0 +1,51 @@ +/* +Listen_and_sendPID +(b) is with test output +009 28 Dec 2013 Adding sleep feature (also will capture AC on request). +008 24 dec 2013 Corrected delay to give aprox 15mSec between can sends +007 15 Nov 2013 Reworked PID send to sequence between RPM and others. fixed mil light(007a) +006 22 Aug 2013 Revised to use timers to send PID's and Can bus messages. Reworked recieve routine to not stop if a partial message is recieved (similar to IPOD controler program) +005 started a rewrite to have elm updates not slow loop and less frequent and include AFM +004 April 2013 works with Laguna and E46 cluster for RPM. Temp dropped so shortend delay from 10 to 8 shorter delay will require the MPG calculation to be altered. + Currently no MPG calculation exists. (shortening delay did not fix temp see version 005 for fix) + + Arduino Connections: +ELM wires go in pins D2 and D3, RX,TX +Also connect to the ELM, 5V Power and ground. No other connections needed + + This program is designed to extract the RPM, temp etc using PID's using the ELM327 clone +then output the signals on CAN bus for a BMW E46 instrument cluster + +A_declarations :has variables and constants +A_OBDII_Dec :Global Declarations that are needed for the OBDII subroutines +A_MCP_DEC :Declarations needed for the MCP2515 subroutines +B_main :has void setup,loop,send_rpm,send_temp,send_fuel, +C_ELM_init :Intializes the ELM comunication with the ECU +C_OBDII :Subroutines for using PID's +C_can :Can message subroutines +D_MCP2515 :MCP2515 library converted to subroutine for easy altering + + + + + + + + + + + + + + + + + + + + + + + +*/ + diff --git a/wiki/sources/e60-vfl-can-codes-xlsx.md b/wiki/sources/e60-vfl-can-codes-xlsx.md new file mode 100644 index 0000000..84b9f57 --- /dev/null +++ b/wiki/sources/e60-vfl-can-codes-xlsx.md @@ -0,0 +1,36 @@ +--- +type: source +tags: [can-bus, e60, reverse-engineering] +updated: 2026-07-15 +raw: "raw/E60 VFL CAN-Bus Codes.xlsx" +origin: Community spreadsheet, E60 pre-facelift (VFL) CAN codes; credits Trevor Cook, CarX24 +--- + +# Source: E60 VFL CAN-Bus Codes (spreadsheet) + +Community-compiled table of ~130 CAN ID blocks observed on a **pre-facelift E60** — exactly our donor generation. Mixed content (much of it body/K-CAN: doors, windows, lights), with per-byte example payloads and computed values. All claims `(source: e60-vfl-xlsx)`. + +## Hits for our target signals + +| ID | Sheet says | Notes | +|----|-----------|-------| +| **0x1D0** | "Engine temp, pressure, handbrake" — B1=0x7A with computed value **74** | 0x7A = 122; 122 − 48 = 74 °C → **independently confirms the raw−48 coolant scaling on a real E60** (matches [[can-id-candidates]]) | +| **0x1D2** | "Anzeige Getriebedaten", DLC 6, example `F0 0F FF 2C F0 FF` | Byte 0 = 0xF0 fits the nibble scheme (low nibble 0 = Off, high nibble = inverted copy); DLC 6 matches the E90-gen layout, not the E65's DLC 5 | +| **0x304** | "Gear lever", DLC 2: P=0xE3, R=0xC2, N=0xD1, D=0xC2, M1–M7=0xC9 | **New candidate**: a compact E60 gear-lever message. ⚠ D and R share 0xC2 in the sheet — almost certainly a transcription error; bench-check | +| **0x3B4** | "Battery- & engine status": B1=0x64 B2=0xF3 → **12.76 V**; byte 3: engine on=0x09 / off=0x00 | 12-bit LE raw would be 0x364=868; ×0.015 gives 13.02 V vs the sheet's 12.76 (implied factor ≈0.0147). **Supports the E65-style 12-bit little-endian layout** over the E90 24-bit BE one; exact factor needs bench check. Engine-running flag in byte 3 is a useful bonus | +| 0x130 | Ignition/engine status, DLC 5, per-position byte values | Matches the dieslg8 finding (`0x130` terminal status) | +| 0xAA | RPM + throttle | Matches research (0x0AA) | +| 0x2CA / 0x366 / 0x32E | Outside/inside temperature | Ambient display data, not engine — nice-to-have | + +## What's absent + +**No engine oil temperature and no gearbox oil temperature rows anywhere in the sheet** — the two signals that were already our weakest. The sheet neither confirms nor refutes 0x1D0 byte 1 (oil) or 0x0B5 byte 7 (gearbox oil). + +## Caveats + +- Body-heavy content suggests capture on K-CAN; the (unverified) forum claim that E60 arbitration IDs are identical across K-CAN/PT-CAN is what makes it transferable to our 500 kbps tap. +- Community transcription — individual byte values (e.g. the D/R duplicate on 0x304) contain errors. + +## Relevance + +Second independent, **E60-specific** confirmation of 0x1D0 coolant scaling and 0x3B4 battery voltage; adds 0x304 as a simpler gear-lever candidate. Updated: [[can-id-candidates]]. diff --git a/wiki/sources/listen-and-send-pid-arduino.md b/wiki/sources/listen-and-send-pid-arduino.md new file mode 100644 index 0000000..b37eeb9 --- /dev/null +++ b/wiki/sources/listen-and-send-pid-arduino.md @@ -0,0 +1,22 @@ +--- +type: source +tags: [arduino, e46, obd, technique-reference] +updated: 2026-07-15 +raw: "raw/Listen_and_send_PID_009c/" +origin: Arduino sketch "Listen_and_sendPID" v009, Dec 2013 (MCP2515 + ELM327) +--- + +# Source: Listen_and_send_PID_009c (Arduino sketch) + +A 2013 Arduino project that does the **reverse** of our data flow: it *requests* engine data from any OBD-compliant ECU via an ELM327 clone (standard PIDs: RPM `((A×256)+B)/4`, coolant temp, etc.) and then **transmits E46-generation cluster frames** so a BMW E46 instrument cluster shows the data — `0x316` (RPM), `0x329` (temp + throttle), `0x545` (MIL/overheat/MPG/cruise), listening to `0x613` from the cluster/IKE. All claims `(source: listen-and-send-pid)`. + +## Why it's in the collection (technique reference, not ID evidence) + +- **Not evidence for our E60 map** — its BMW IDs are the E46 *cluster input* dialect, and its ECU-side data comes from OBD PID polling, not passive DDE broadcasts. +- **Blueprint for the fault-code fallback**: it demonstrates the request/response pattern (poll PIDs → use data) that our display would need if we ever want DTCs or signals that aren't broadcast — the same conclusion as the dieslg8 finding (active requests on 0x6F1/0x612) in [[can-id-candidates]]. +- **E46 cluster needle calibration table**: temp-gauge byte values (0x56 = needle starts, 0x5D–0x80 = blue zone, 0xE6 = red zone start, 0xFE = pegged) — useful only if the Patrol build ever drives an OEM BMW gauge directly. +- Practical MCP2515 + ELM327 wiring/timing patterns (15 ms inter-frame spacing, timer-driven sends). + +## Relevance + +Filed as a technique reference for a possible future "diagnostic request mode" (fault codes, non-broadcast signals). No changes to the candidate ID map.