Hello,
I'm still trying to deal and understand the results of several SPICE versions and now I have a new problem simulating the same schematic, a common-emitter amplifier based on NPN 2N3904 transistor, on LTSPICE and ngspice (launched from kicad).
The schematic is the same, the SPICE model too (except for two values that ngspice does not know what to do with them) but the results both numerical and graphic are very different.
kicad schematic:
(https://i.postimg.cc/s2tNZJNQ/kicad-ngspice-BJT-amplifier.jpg)
LTSPICE schematic:
(https://i.postimg.cc/1twY0NkW/LTSPICE-BJT-amplifier.jpg)
ngspice(kicad) plotter output:
(https://i.postimg.cc/7h4tKZDq/kicad-ngspice-BJT-amplifier-plot.jpg)
LTSPICE plotter output:
(https://i.postimg.cc/FzxW8Xs3/LTSPICE-BJT-amplifier-plot.jpg)
ngspice(kicad) log: (𐄂=does not match)
vcc = 3.000000e+01 at= 5.000000e-04
𐄂 vb_min = 1.080491e-01 at= 1.452800e-04
𐄂 vb_max = 5.177824e+00 at= 4.452800e-04
𐄂 vb = 2.64294e+00
vb_t = 4.19355e+00
vin_pp = 4.999807e+00 from= 0.000000e+00 to= 0.000000e+00
vin_rms = 1.76777e+00 from= 0.00000e+00 to= 5.00000e-04
𐄂 vout_pp = 1.241313e+01 from= 0.000000e+00 to= 0.000000e+00
𐄂 vout_rms = 4.48404e+00 from= 0.00000e+00 to= 5.00000e-04
𐄂 vout_max = 5.831076e+00 at= 1.312800e-04
𐄂 gain_pp = 2.48272e+00
𐄂 gain_rms = 2.53655e+00
gain_t = -3.60000e+00
LTSPICE log: (𐄂=does not match)
vcc: MAX(v(vcc))=30 FROM 0 TO 0.0005
𐄂 vb_min: MIN(v(b))=1.51887 FROM 0 TO 0.0005
𐄂 vb_max: MAX(v(b))=6.58211 FROM 0 TO 0.0005
𐄂 vb: ((vb_max-vb_min)/2+vb_min)=4.05049
vb_t: (vcc*r2/(r1+r2))=4.19355
vin_pp: PP(v(in))=4.99595 FROM 0 TO 0.0005
vin_rms: RMS(v(in))=1.76765 FROM 0 TO 0.0005
𐄂 vout_pp: PP(v(out))=17.3435 FROM 0 TO 0.0005
𐄂 vout_rms: RMS(v(out))=5.95982 FROM 0 TO 0.0005
𐄂 vout_max: MAX(v(out))=9.01429 FROM 0 TO 0.0005
𐄂 gain_pp: (vout_pp/vin_pp)=3.47152
𐄂 gain_rms: (vout_rms/vin_rms)=3.37161
gain_t: -3.6=-3.6
ngspice(kicad) 2N3904 model:
.model Q2N3904 NPN(Is=1E-14 Vaf=100
+ Bf=300 Ikf=0.4 Xtb=1.5 Br=4
+ Cjc=4E-12 Cje=8E-12 Rb=20 Rc=0.1 Re=0.1
+ Tr=250E-9 Tf=350E-12 Itf=1 Vtf=2 Xtf=3)
LTSPICE 2N3904 model:
.model 2N3904 NPN(IS=1E-14 VAF=100
+ Bf=300 IKF=0.4 XTB=1.5 BR=4
+ CJC=4E-12 CJE=8E-12 RB=20 RC=0.1 RE=0.1
+ TR=250E-9 TF=350E-12 ITF=1 VTF=2 XTF=3 Vceo=40 Icrating=200m mfg=NXP)
theoretically this BJT amplifier should amplify a 5kHz 5V sinusoidal signal into a 5kHz 18V sinusoidal signal and, as you can see, everything on LTSPICE looks fine but ngspice(kicad) differs.
I have two questions:
1) Is there a way to reference component values (e.g. resistors or capacitors) in ngspice or LTSPICE apart from this workaround of adding parameters and defining the parameter name in curly brackets in the schematic? (I'm afraid in a real case this will affect to some others kicad's applications (as pcbnew and such)).
2) Why are the plotter output and numerical results so different? Is there anything I'm missing?
Any help will be appreciated, thank you.