i-k-bus-board/site/public/spice/ibus_tx_path.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

81 lines
2.5 KiB
Plaintext

* BMW I/K-Bus Interface - TX Path (ESP32 to Bus) - PC817 + BC547
* MCU TX drives Q1 (BC547B) which drives U2 (PC817) LED
* U2 phototransistor pulls bus LOW against 4.7k pull-up to 12V
* Test pattern: alternating 3-bit-time (312us) pulses
* TX 0V = bus idle (HIGH), TX 3.3V = bus active (LOW via U2)
* Includes U1 RX path for loopback observation
* Signal inversion: TX HIGH -> bus LOW (documented in design)
*
* 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 ===
* 0V=idle (U2 OFF, bus HIGH), 3.3V=active (U2 ON, bus LOW)
* Alternating ~3 bit times (312us) to show inversion
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 ===
* Idle pull-up: represents combined impedance of other modules' inputs
* No active driver — only U2 phototransistor drives the bus here
R_PULL V12 IBUS 4.7k
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) ===
* LED path: VCC -> R2 -> U2 anode(1) -> U2 cathode(2) -> Q1 collector
* Phototransistor: collector(3) = IBUS, emitter(4) = GND
R2 VCC U2_A 220
XU2 U2_A Q1C IBUS 0 PC817 Igain=1m
* === RX Optocoupler (U1) for Loopback ===
* Shows what the MCU sees on RX when it transmits
R1_RX IBUS U1_A 2k
XU1 U1_A 0 VCC RX PC817 Igain=1m
R4_RX RX 0 1k
* === PC817 Subcircuit (inlined from LTspice library) ===
.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
* === Transistor 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 TX_TO_BUS_DELAY TRIG V(TX) VAL=1.65 RISE=1 TARG V(IBUS) VAL=6 FALL=1
.meas tran U2_LED_CURRENT MAX I(R2)
.meas tran RX_LOOPBACK_HIGH MAX V(RX)
.meas tran RX_LOOPBACK_LOW MIN V(RX)
.meas tran Q1_BASE_CURRENT MAX I(R3)
.backanno
.end