i-k-bus-board/site/public/spice/tx_validated_r2_220.cir
Ryan Malloy 48b61f462a Add SPICE waveform plots and downloadable netlists to circuit design page
Simulated RX and TX paths via mcltspice, generated 4 SVG waveform
plots (2000 data points each), and staged all 8 netlists plus the
muki01 schematic as downloadable site assets.

Presentation: Starlight Tabs for RX/TX waveform pairs, inline
schematic image, dark mode CSS filter for white-background SVGs,
and netlist inventory with download links.
2026-02-20 13:28:03 -07:00

83 lines
2.5 KiB
Plaintext

* BMW I/K-Bus Interface - TX Path VALIDATED (R2=220 fix for 3.3V ESP32)
* Tests worst realistic scenario: PC817A typical CTR + 1k bus pull-up
* Also includes RX loopback to verify full signal path
*
* Fix: R2 reduced from 470 to 220 ohms
* Effect: LED current increases from 4.66mA to ~9.3mA
* Phototransistor base drive doubles: 9.3uA -> 18.6uA
* Max collector current: 11.2mA -> 22.4mA
* Supports bus pull-ups down to ~530 ohms
*
* PC817 pin order: 1=Anode, 2=Cathode, 3=Collector, 4=Emitter
* === Power Supplies ===
V_BAT V12 0 12
V_MCU VCC 0 3.3
* === TX Test Signal (byte 0x68 = RAD address) ===
* Inverted UART: 0V=idle, 3.3V=pulling bus LOW
* 0x68 = 01101000, LSB first = 00010110
* 3 ones -> even parity = 1
* Frame: START(1), 0,0,0,1,0,1,1,0, P(1), STOP(0)
* (inverted: start=HIGH, data inverted, stop=LOW)
V_TX TX 0 PWL(
+ 0u 0
+ 199.5u 0
+ 200u 3.3
+ 512u 3.3
+ 512.5u 0
+ 825u 0
+ 825.5u 3.3
+ 1137u 3.3
+ 1137.5u 0
+ 2000u 0)
* === Bus Model: 1k pull-up (loaded bus, worst realistic case) ===
R_PULL V12 IBUS 1k
C_BUS IBUS 0 100p
* === TX Driver: Q1 (BC547B) ===
R5 TX R5_R3 470
R3 R5_R3 Q1B 10k
Q1 Q1C Q1B 0 BC547B
* === TX Optocoupler (U2) ===
* FIX: R2 changed from 470 to 220 for 3.3V ESP32 compatibility
R2 VCC U2_A 220
XU2 U2_A Q1C IBUS 0 PC817 Igain=1m
* === RX Optocoupler (U1) for Loopback ===
R1_RX IBUS U1_A 2k
XU1 U1_A 0 VCC RX PC817 Igain=1m
R4_RX RX 0 1k
* === PC817 Subcircuit ===
.subckt PC817 1 2 3 4
R1 N003 2 2
D1 1 N003 LD
G1 3 N004 N003 2 {Igain}
C1 1 2 18p
Q1 3 N004 4 [4] NP
.model LD D(Is=1e-20 Cjo=18p)
.model NP NPN(Bf=1200 Vaf=140 Ikf=100m Rc=1 Cjc=19p Cje=7p Cjs=7p C2=3e-15)
.ends PC817
* === BC547B Model ===
.model BC547B NPN(IS=2.39E-14 NF=1.008 ISE=3.545E-15 NE=1.541 BF=294.3 IKF=0.1357 VAF=63.2 NR=1.004 ISC=6.272E-14 NC=1.243 BR=7.946 IKR=0.1144 VAR=25.9 RB=1 IRB=1.00E-06 RBM=1 RE=0.4683 RC=0.85 XTB=0 EG=1.11 XTI=3 CJE=1.358E-11 VJE=0.65 MJE=0.3279 TF=4.391E-10 XTF=120 VTF=2.643 ITF=0.7495 PTF=0 CJC=3.728E-12 VJC=0.3997 MJC=0.2955 XCJC=0.6193 TR=1.00E-32 CJS=0 VJS=0.75 MJS=0.333 FC=0.9579 Vceo=45 Icrating=100m mfg=NXP)
* === Simulation ===
.tran 0 2000u 0 0.1u
* === Measurements ===
.meas tran IBUS_HIGH MAX V(IBUS)
.meas tran IBUS_LOW MIN V(IBUS)
.meas tran IBUS_SWING PP V(IBUS)
.meas tran U2_LED_CURRENT MAX I(R2)
.meas tran Q1_VCE_SAT MIN V(Q1C)
.meas tran RX_LOOPBACK_HIGH MAX V(RX)
.meas tran RX_LOOPBACK_LOW MIN V(RX)
.meas tran BUS_RISE TRIG V(IBUS) VAL=1.0 RISE=1 TARG V(IBUS) VAL=7.0 RISE=1
.meas tran BUS_FALL TRIG V(IBUS) VAL=7.0 FALL=1 TARG V(IBUS) VAL=1.0 FALL=1
.backanno
.end