Thanks! That works even when entered on the schematic. GWAVE will read the output correctly, but the LTspice waveform reader gives a bad result. I’d love to use the LTspice viewer, at least until the KiCAD or other FOSS viewer gets similar features (subplots, waveform expressions, multiple y-axis with units, undo zoom, click and integrate, save setups… a very nice viewer), but that’s a separate topic. When using “all”, I can see all voltages and currents on the top level, but not in my subcircuit. I can call out a global net (no “/” in front) for the target of the write command instead of “all”, and this works. I’ve tried using “/” and “.” to try to write a subcircuit voltage to the .raw file, but to no avail. Also, I can’t figure out how to even view (from RAM) subcircuit nodes in the KiCAD built-in viewer (which show all top level V and I by default, independent of the “write” argument, as I would expect). Any hints on how to view/plot subcircuit nodes and currents? My subcircuit is text-only. Thanks again!

Full netlist:

.title KiCad schematic

.include “/home/steve/MyKiCAD/SPICE_TRIAL/LTspiceX.lib”

I101 Net-*C101-Pad2* +5V 5

R102 +5V Net-*C101-Pad2* 1

C101 +5V Net-*C101-Pad2* 100n

I102 Net-*C101-Pad2* /IN+ 25m

R103 /IN+ Net-*C101-Pad2* 1

C102 /IN+ Net-*C101-Pad2* 100n

I103 Net-*C101-Pad2* /IN- dc 0 PWL(0 20m 100n 30m 250n 30m 350n 20m)

R104 /IN- Net-*C101-Pad2* 1

C103 /IN- Net-*C101-Pad2* 1n

XU101 /IN+ /IN- +5V Net-*C101-Pad2* OUT tlv3201aidck

C104 OUT Net-*C101-Pad2* 15p

R101 Net-*C101-Pad2* 0 1m

.save @r102[i]

.save @c101[i]

.save @r103[i]

.save @c102[i]

.save @r104[i]

.save @c103[i]

.save @c104[i]

.save @r101[i]

.save V(+5V)

.save V(/IN+)

.save V(/IN-)

.save V(0)

.save V(GND)

.save V(Net-*C101-Pad2*)

.save V(OUT)

.tran 10p 450n

.options reltol=1E-4 abstol=1E-13 vntol=1E-7 chgtol=1E-15

.options plotwinsize=0

.options numdgt=7

.options trtol=1

.control

write /home/steve/MyKiCAD/TB_TLV3201.raw all

.endc

.end

.subckt tlv3201aidck +IN -IN +V -V OUT

R_delay post N001 R=(tp-tr/2)/Cpd/1

C_power_diss post 0 {Cpd}

R_out_hi OUT +V R=(1-V(out_bin))*r_off+r_out_high
B3 +V -V I=abs(I(V1)) V(+V,-V)
R1 +in_r +IN 10
R3 -in_r -IN 10
R4 +V -V R=Vdd/Idd
D1 -in_r +V BAV99HM
D2 -V -in_r BAV99HM
D3 +in_r +V BAV99HM
D4 -V +in_r BAV99HM
C1 -in_r -V {Cin}
B10 0 pre I=0.5+0.5tanh(Avol*(V(+in_r,-in_r)/V(+V,-V)+hyst*(V(post)-0.5)))

R5 pre 0 1

B6 0 out_bin I=0.5+0.5

*tanh(Arf*(V(post)-0.5-((0.632-0.5)

*2*(V(pre)-0.5))))

R8 out_bin 0 1

R_out_lo OUT -V R=V(out_bin)*r_off+r_out_low

V1 N001 pre 0

C2 +in_r -V {Cin}

C3 out_bin 0 {Cn}

C4 pre 0 {Cn}

- hyst is hysterisis normalized to VDD
- Arf is gain to control rise and fall time (emperical)
- Subtract 2.6pF for diodes from input capacitance to get Cin
- Cn is C_Norton - delay from this should be enough to help convergence, but not enough to affect circuit significantly

.param hyst=240u r_out_low=56.3 r_out_high=42.5 r_off=10MEG Avol=100k Arf=150 tp=55n tr=5.2n Cpd=5p Vdd=5 Idd=65u Cin=1.4p Cn=200p

.MODEL BAV99HM D(Is=1.7962E-9 N=1.7555 Rs=.55113 Ikf=72.153E-3 Cjo=1.3304E-12 M=.11174 Vj=4.1020 Bv=100 tt=11.542E-9)

.ends tlv3201aidck