Power amplifier THD vs. output voltage RMS ngspice template

This commit is contained in:
ivandi 2025-01-04 08:14:52 -05:00
parent c56bb4f966
commit 434930e9be

View File

@ -0,0 +1,194 @@
<Qucs Schematic 24.4.1>
<Properties>
<View=2,-136,1511,748,1.0431,0,0>
<Grid=10,10,1>
<DataSet=PwrAmpTHD.dat>
<DataDisplay=PwrAmpTHD.dpl>
<OpenDisplay=0>
<Script=PwrAmpTHD.m>
<RunScript=0>
<showFrame=0>
<FrameText0=Title>
<FrameText1=Drawn By:>
<FrameText2=Date:>
<FrameText3=Revision:>
</Properties>
<Symbol>
</Symbol>
<Components>
<_BJT Q2N3905_2 1 550 470 -74 -26 0 2 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<_BJT Q2N3904_1 1 370 170 8 -26 0 0 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<_BJT Q2N3904_2 1 550 170 -74 -26 1 2 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<R R11 1 580 230 -71 -26 1 1 "1.8Meg" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R12 1 370 230 15 -26 0 1 "22k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R5 1 370 410 15 -26 0 1 "22k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R6 1 580 410 -71 -26 1 1 "1.8Meg" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<_BJT Q2N3905_1 1 370 470 8 -26 1 0 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<R R23 1 620 200 15 -26 0 1 "2.7k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R22 1 620 440 15 -26 0 1 "2.7k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 620 290 0 0 0 0>
<GND * 1 620 350 0 0 0 2>
<C C13 1 620 260 20 -26 1 3 "47u" 1 "" 0 "polar" 0>
<C C14 1 620 380 20 -26 1 3 "47u" 1 "" 0 "polar" 0>
<R R18 1 370 660 15 -26 0 1 "2.2k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R13 1 340 690 -26 -49 1 0 "470" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C8 1 250 660 20 -26 1 3 "10u" 1 "" 0 "polar" 0>
<Lib D1 1 190 660 -109 -32 1 3 "Z-Diodes" 0 "1N4742A" 1>
<C C12 1 620 660 17 -26 0 1 "680p" 1 "" 0 "neutral" 0>
<_BJT Q2N3904_3 1 710 10 8 -26 0 0 "npn" 0 "1.4e-14" 0 "1" 0 "1" 0 "0.025" 0 "0" 0 "100" 0 "0" 0 "3e-13" 0 "1.5" 0 "0" 0 "2" 0 "300" 0 "7.5" 0 "0" 0 "0" 0 "2.4" 0 "0" 0 "0" 0 "4.5e-12" 0 "0.75" 0 "0.33" 0 "3.5e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "4e-10" 0 "0" 0 "0" 0 "0" 0 "2.1e-08" 0 "26.85" 0 "9e-16" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.5" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<R R29 1 820 -20 15 -26 0 1 "100" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R16 1 820 100 15 -26 0 1 "330" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 820 130 0 0 0 0>
<GND * 1 710 130 0 0 0 0>
<R R20 1 710 100 15 -26 0 1 "2.2k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R28 1 970 10 -26 15 0 0 "4.7" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R21 1 370 -20 15 -26 0 1 "2.2k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R14 1 340 -50 -26 15 0 0 "470" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C9 1 250 -20 20 -26 1 3 "10u" 1 "" 0 "polar" 0>
<Lib D2 1 190 -20 -109 -32 1 3 "Z-Diodes" 0 "1N4742A" 1>
<C C11 1 620 -20 17 -26 0 1 "680p" 1 "" 0 "neutral" 0>
<R R26 1 970 630 -26 15 0 0 "4.7" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R24 1 1000 470 -26 15 1 2 "47k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C15 1 1000 440 -26 -51 1 0 "22p" 1 "" 0 "neutral" 0>
<R R25 1 1000 170 -26 -49 0 2 "47k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C16 1 1000 200 -26 17 0 0 "22p" 1 "" 0 "neutral" 0>
<R R31 1 1030 270 15 -26 0 1 "0.47" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R30 1 1030 370 15 -26 0 1 "0.47" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R17 1 940 270 -43 -26 1 1 "22" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C17 1 940 370 -55 -26 1 1 "10u" 1 "" 0 "polar" 0>
<R R39 1 1110 350 15 -26 0 1 "3.3" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C18 1 1110 410 17 -26 0 1 "47n" 1 "" 0 "neutral" 0>
<GND * 1 1110 440 0 0 0 0>
<GND * 1 1140 630 0 0 0 2>
<Vdc VEE 1 1140 660 18 -26 0 1 "20" 1>
<Vdc VCC 1 1140 -20 18 -26 0 1 "20" 1>
<GND * 1 1140 10 0 0 0 0>
<GND * 1 190 10 0 0 0 0>
<GND * 1 250 10 0 0 0 0>
<GND * 1 190 630 0 0 0 2>
<GND * 1 250 630 0 0 0 2>
<_BJT Q2N2955_1 1 1030 10 8 -26 1 0 "pnp" 0 "4.66e-12" 0 "1" 0 "1" 0 "0.25" 0 "0" 0 "100" 0 "0" 0 "3.339e-11" 0 "1.5" 0 "5e-09" 0 "2" 0 "360" 0 "2" 0 "0.4" 0 "0.001" 0 "0.04" 0 "0" 0 "3" 0 "5.802e-10" 0 "1.2" 0 "0.45" 0 "2.121e-10" 0 "0.75" 0 "0.4" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "8e-08" 0 "1" 0 "0" 0 "3" 0 "2.55e-06" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "120" 0 "1" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<_BJT Q2N3055_1 1 1030 630 8 -26 0 0 "npn" 0 "4.66e-12" 0 "1" 0 "1" 0 "0.25" 0 "0" 0 "100" 0 "0" 0 "3.339e-11" 0 "1.5" 0 "5e-09" 0 "2" 0 "360" 0 "2" 0 "0.4" 0 "0.001" 0 "0.04" 0 "0" 0 "3" 0 "5.802e-10" 0 "1.2" 0 "0.45" 0 "2.121e-10" 0 "0.75" 0 "0.4" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "8e-08" 0 "1" 0 "0" 0 "3" 0 "2.55e-06" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "120" 0 "1" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<_BJT BD136_138_140_1 1 820 40 8 -26 1 0 "pnp" 0 "2.9537e-13" 0 "1" 0 "1.021" 0 "1.0993" 0 "0.1" 0 "137" 0 "8.41" 0 "1.8002e-13" 0 "1.5" 0 "7.0433e-12" 0 "1.38" 0 "201.4" 0 "23.765" 0 "0.01" 0 "0.011" 0 "0.01" 0 "0.1109" 0 "1.98" 0 "2.1982e-10" 0 "0.7211" 0 "0.3685" 0 "6.8291e-11" 0 "0.5499" 0 "0.3668" 0 "0.5287" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "0" 0 "0" 0 "0" 0 "0" 0 "0" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.4883" 0 "3" 0 "1.2343" 0 "26.85" 0 "1" 0 "yes" 0>
<R R10 1 310 230 15 -26 0 1 "1k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R7 1 310 410 15 -26 0 1 "1k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<C C7 1 250 290 20 -26 1 3 "1u" 1 "" 0 "polar" 0>
<C C6 1 250 350 20 -26 1 3 "1u" 1 "" 0 "polar" 0>
<GND * 1 250 440 0 0 0 0>
<GND * 1 250 200 0 0 0 2>
<C C5 1 160 350 17 -26 0 1 "330p" 1 "" 0 "neutral" 0>
<R R4 1 130 320 -26 -49 1 0 "3.3k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 160 380 0 0 0 0>
<R R3 1 100 350 -57 -26 1 1 "100k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<GND * 1 100 380 0 0 0 0>
<GND * 1 100 200 0 0 0 2>
<R R8 1 250 410 -50 -26 1 1 "47k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R9 1 250 230 -50 -26 1 1 "47k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<_BJT Q2N3905_3 1 710 630 8 -26 1 0 "pnp" 0 "1.05e-15" 0 "1" 0 "1" 0 "0.1" 0 "0" 0 "240" 0 "0" 0 "1.003e-09" 0 "4" 0 "1.003e-09" 0 "4" 0 "220" 0 "1" 0 "0" 0 "0" 0 "0.2" 0 "0.5" 0 "3" 0 "5.7e-12" 0 "0.75" 0 "0.33" 0 "4.32e-12" 0 "0.75" 0 "0.33" 0 "1" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "3.35e-10" 0 "0" 0 "0" 0 "0" 0 "1.7e-07" 0 "26.85" 0 "4e-15" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "0" 0 "3" 0 "1.11" 0 "26.85" 0 "1" 0 "yes" 0>
<R R27 1 820 660 15 -26 0 1 "100" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R15 1 820 540 15 -26 0 1 "330" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<R R19 1 710 540 15 -26 0 1 "2.2k" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<_BJT BD135_137_139_1 1 820 600 8 -26 0 0 "npn" 0 "2.3985e-13" 0 "1" 0 "1.007" 0 "1.1863" 0 "0.1445" 0 "98.5" 0 "7.46" 0 "1.0471e-14" 0 "1.2" 0 "1.9314e-11" 0 "1.45" 0 "244.9" 0 "78.11" 0 "0.001" 0 "0.031" 0 "0.01" 0 "0.0832" 0 "2.14" 0 "2.92702e-10" 0 "0.67412" 0 "0.33" 0 "4.8831e-11" 0 "0.5258" 0 "0.3928" 0 "0.5287" 0 "0" 0 "0.75" 0 "0" 0 "0.5" 0 "0" 0 "0" 0 "0" 0 "0" 0 "0" 0 "26.85" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1" 0 "1" 0 "0" 0 "1.1398" 0 "3" 0 "1.2105" 0 "26.85" 0 "1" 0 "yes" 0>
<GND * 1 710 510 0 0 0 2>
<GND * 1 820 510 0 0 0 2>
<GND * 1 1110 200 0 0 0 2>
<R RL 1 1110 230 15 -26 0 1 "8" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0>
<SpicePar SpicePar1 1 1250 -40 -27 18 0 0 "vin=600m" 1>
<.CUSTOMSIM CUSTOM1 1 1230 30 0 40 0 0 "\ncompose vin start=100m stop=1 step=100m\nlet n=length(vin)\nlet thd=vector(n)\nlet out_rms=vector(n)\n\nset nfreqs=20\n\nlet i=0\nrepeat $&n\n let vin_i=vin[i]\n alterparam vin=$&vin_i\n reset\n\n tran 10u 10m\n fourier 1k v(out)\n meas tran orms_i rms out\n let out_rms[i]=orms_i\n\n let j=2\n let sum_i=0\n let f=i+1\n while j < $nfreqs\n let sum_i=sum_i+fourier{$&f}1[1][j]^2\n let j=j+1\n end\n let thd_i=100*sqrt(sum_i)/fourier{$&f}1[1][1]\n let thd[i]=thd_i\n\n destroy $curplot\n let i=i+1\nend\n\nsetscale out_rms\n\ndestroy all\nreset" 0 "thd;vin" 0 "" 0>
<S4Q_V V1 1 100 230 19 5 1 3 "sin(0 {vin} 1k)" 1 "" 0 "" 0 "" 0 "" 0>
</Components>
<Wires>
<370 440 550 440 "" 0 0 0 "">
<370 200 550 200 "" 0 0 0 "">
<580 170 580 200 "" 0 0 0 "">
<370 260 470 260 "" 0 0 0 "">
<370 380 460 380 "" 0 0 0 "">
<580 440 580 470 "" 0 0 0 "">
<580 470 620 470 "" 0 0 0 "">
<580 170 620 170 "" 0 0 0 "">
<370 500 370 630 "" 0 0 0 "">
<250 690 310 690 "" 0 0 0 "">
<190 690 250 690 "" 0 0 0 "">
<370 690 620 690 "" 0 0 0 "">
<370 630 620 630 "" 0 0 0 "">
<710 -50 710 -20 "" 0 0 0 "">
<710 -50 820 -50 "" 0 0 0 "">
<710 40 790 40 "" 0 0 0 "">
<710 40 710 70 "" 0 0 0 "">
<820 10 940 10 "" 0 0 0 "">
<820 -50 1030 -50 "" 0 0 0 "">
<1030 -50 1030 -20 "" 0 0 0 "">
<370 10 370 140 "" 0 0 0 "">
<250 -50 310 -50 "" 0 0 0 "">
<190 -50 250 -50 "" 0 0 0 "">
<370 -50 620 -50 "" 0 0 0 "">
<370 10 620 10 "" 0 0 0 "">
<620 10 680 10 "" 0 0 0 "">
<620 -50 710 -50 "" 0 0 0 "">
<470 260 580 260 "" 0 0 0 "">
<470 260 470 510 "" 0 0 0 "">
<620 470 940 470 "" 0 0 0 "">
<1030 660 1030 690 "" 0 0 0 "">
<1030 470 1030 600 "" 0 0 0 "">
<1030 440 1030 470 "" 0 0 0 "">
<620 170 940 170 "" 0 0 0 "">
<1030 40 1030 170 "" 0 0 0 "">
<1030 170 1030 200 "" 0 0 0 "">
<1030 300 1030 320 "" 0 0 0 "">
<1030 200 1030 240 "" 0 0 0 "">
<1030 400 1030 440 "" 0 0 0 "">
<940 300 940 340 "" 0 0 0 "">
<940 200 970 200 "" 0 0 0 "">
<940 200 940 240 "" 0 0 0 "">
<940 170 970 170 "" 0 0 0 "">
<940 170 940 200 "" 0 0 0 "">
<940 440 970 440 "" 0 0 0 "">
<940 400 940 440 "" 0 0 0 "">
<940 470 970 470 "" 0 0 0 "">
<940 440 940 470 "" 0 0 0 "">
<460 380 580 380 "" 0 0 0 "">
<1030 320 1030 340 "" 0 0 0 "">
<1030 320 1110 320 "" 0 0 0 "">
<1030 690 1140 690 "" 0 0 0 "">
<1030 -50 1140 -50 "" 0 0 0 "">
<160 320 250 320 "" 0 0 0 "">
<250 260 310 260 "" 0 0 0 "">
<310 170 310 200 "" 0 0 0 "">
<310 170 340 170 "" 0 0 0 "">
<250 380 310 380 "" 0 0 0 "">
<310 440 310 470 "" 0 0 0 "">
<310 470 340 470 "" 0 0 0 "">
<620 690 710 690 "" 0 0 0 "">
<820 630 940 630 "" 0 0 0 "">
<820 690 1030 690 "" 0 0 0 "">
<620 630 680 630 "" 0 0 0 "">
<710 660 710 690 "" 0 0 0 "">
<710 600 790 600 "" 0 0 0 "">
<710 690 820 690 "" 0 0 0 "">
<710 570 710 600 "" 0 0 0 "">
<460 130 460 380 "" 0 0 0 "">
<310 130 460 130 "" 0 0 0 "">
<310 -50 310 130 "" 0 0 0 "">
<550 130 550 140 "" 0 0 0 "">
<460 130 550 130 "" 0 0 0 "">
<310 510 310 690 "" 0 0 0 "">
<310 510 470 510 "" 0 0 0 "">
<550 500 550 510 "" 0 0 0 "">
<470 510 550 510 "" 0 0 0 "">
<1110 260 1110 320 "" 0 0 0 "">
<100 260 100 320 "" 0 0 0 "">
<1110 320 1110 320 "out" 1070 290 0 "">
<100 320 100 320 "in" 70 300 0 "">
</Wires>
<Diagrams>
<Rect 1230 270 240 160 3 #c0c0c0 1 00 1 1.08481 2 10.7141 1 -0.0601316 0.5 0.68536 1 -1 1 1 315 0 225 1 0 0 "" "" "">
<"ngspice/thd" #0000ff 2 3 0 0 0>
</Rect>
<Tab 1230 525 154 205 3 #c0c0c0 1 00 1 0 1 1 1 0 1 1 1 0 1 1 315 0 225 1 0 0 "" "" "">
<"ngspice/thd" #0000ff 0 3 1 0 0>
<"ngspice/vin" #0000ff 0 3 1 0 0>
</Tab>
</Diagrams>
<Paintings>
<Text 540 -90 20 #000000 0 "Musical Fidelity A1">
</Paintings>