diff --git a/CLAUDE.md b/CLAUDE.md index 52b8e84..ae66abe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,7 +2,7 @@ ## Attribution -Circuit design and protocol library based on **[muki01/I-K_Bus](https://github.com/muki01/I-K_Bus)** by [@muki01](https://github.com/muki01), licensed under MIT. Optocoupler schematic, IbusSerial library, E46 command codes, and bus documentation are from that project. +Circuit design and protocol library based on **[muki01/I-K_Bus](https://github.com/muki01/I-K_Bus)** by [@muki01](https://github.com/muki01), licensed under MIT. Optocoupler schematic, IbusSerial library, E46 command codes, and bus documentation are from that project. **R2 modified from 470Ω to 220Ω** for 3.3V ESP32 compatibility (original design targets 5V Arduino). ## Project Overview @@ -89,7 +89,7 @@ Bridges the bus-side 12V to the MCU-side 12V rail. This powers the MCU (via a 3. | Ref | Value | Package | Qty | Notes | |-----|-------|---------|-----|-------| -| U1, U2 | PC817 | DIP-4 | 2 | Optocoupler, CTR >= 50% at 5mA | +| U1, U2 | PC817A+ | DIP-4 | 2 | Optocoupler, any grade (A/B/C/D). PC817A works; B+ adds margin | | Q1 | BC547 | TO-92 | 1 | Or 2N3904 — TX LED driver | | R1 | 2k | 0805/TH | 1 | RX LED current limiter | | R2 | 220 | 0805/TH | 1 | TX LED current limiter (reduced from 470 for 3.3V ESP32) | @@ -247,7 +247,11 @@ mcp__mcp-ltspice__analyze_waveform(raw_file_path, signal_name, analyses) **Simulated and validated.** Uses LTspice's built-in PC817 subcircuit (from `lib/sub/PC817.sub`) with `Igain=1m` (PC817A, ~100% CTR). Two netlists cover both signal paths: - `reference/ibus_rx_path.cir` — RX path: bus byte 0x50 at 9600 baud → U1 PC817 → ESP32 RX -- `reference/ibus_tx_path.cir` — TX path: ESP32 TX → Q1 BC547B → U2 PC817 → bus (with RX loopback) +- `reference/ibus_tx_path.cir` — TX path: ESP32 TX → Q1 BC547B → U2 PC817 → bus (R2=220Ω, with RX loopback) +- `reference/tx_validated_r2_220.cir` — TX validation at worst-case bus loading (1kΩ pull-up) +- `reference/tx_sweep_r2.cir` — R2 sweep (100–470Ω) at worst-case CTR +- `reference/tx_sweep_rpull.cir` — Bus impedance sweep (510Ω–10kΩ) +- `reference/tx_sweep_ctr.cir` — CTR grade sweep (PC817A through PC817D) **PC817 SPICE pin order:** `1=Anode, 2=Cathode, 3=Collector, 4=Emitter` — subcircuit uses a VCCS (G1) with `{Igain}` parameter to model optical coupling. @@ -307,7 +311,8 @@ The repo includes an extensive documentation collection (`Docs/`): 2. Protocol differences documented (vs OBD-II K-line for Tucker project) 3. Software reference identified (IbusSerial library, E46 command codes) 4. Module address map and message format documented -5. **SPICE simulation validated** — both RX and TX paths simulated with LTspice PC817 model at 9600 baud. RX path gives clean 0-3.13V logic at 3.3V VCC. TX path confirms signal inversion and 0.17V bus LOW. Rise/fall times within 9600 baud budget. +5. **SPICE simulation validated** — both RX and TX paths simulated with LTspice PC817 model at 9600 baud. RX path gives clean 0-3.13V logic at 3.3V VCC. TX path confirms signal inversion and 0.27V bus LOW on 1kΩ bus. Rise/fall times within 9600 baud budget. +6. **R2 optimized for 3.3V** — parameter sweeps across R2, bus impedance, and CTR grade identified R2=220Ω (down from 470Ω) as the fix for 3.3V ESP32. Doubles LED drive current to 9.71mA, supports bus pull-ups down to ~530Ω. ## What's Next @@ -323,4 +328,4 @@ The repo includes an extensive documentation collection (`Docs/`): - The optocoupler isolation protects the ESP32 from the car AND the car from the ESP32. - Sniff bus traffic (RX only) before attempting any TX operations. - The bus has no authentication — any properly formatted message will be accepted by target modules. Use responsibly. -- Parasitic drain: the interface draws ~6mA from the bus 12V through R1 and U2. Disconnect or add a sleep circuit for long-term parking. +- Parasitic drain: the interface draws ~5.4mA continuously from the bus 12V through R1 (RX LED always on when bus is idle). U2 LED only draws current during TX (~9.7mA pulses). Disconnect or add a sleep circuit for long-term parking.