From 51b4499cab4ae4faa83e5a5e468ee99ff18b41f5 Mon Sep 17 00:00:00 2001 From: jvech Date: Mon, 3 Jun 2024 07:23:35 -0500 Subject: init: ac2dc linear converter simulated --- .gitignore | 1 + README.md | 14 ++ ac2dc_01.png | Bin 0 -> 50987 bytes ac2dc_linear.gnuplot | 13 ++ ac2dc_linear.sp | 29 +++++ lib/generic.lib | 27 ++++ lib/regulators.lib | 351 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 435 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ac2dc_01.png create mode 100644 ac2dc_linear.gnuplot create mode 100644 ac2dc_linear.sp create mode 100644 lib/generic.lib create mode 100644 lib/regulators.lib diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbca225 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +results/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..10dcf6d --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Fixed AC-DC Converter + +Simulation of the following circuit + +![circuit](ac2dc_01.png) + +To simulate the cirucit run the following command: +```sh +$ ngspice -b ./ac2dc_linear.sp +``` + +ensure you have gnuplot installed to generate the plot, it will create an image +called `results/voltages.png` + diff --git a/ac2dc_01.png b/ac2dc_01.png new file mode 100644 index 0000000..8e31989 Binary files /dev/null and b/ac2dc_01.png differ diff --git a/ac2dc_linear.gnuplot b/ac2dc_linear.gnuplot new file mode 100644 index 0000000..2058a1b --- /dev/null +++ b/ac2dc_linear.gnuplot @@ -0,0 +1,13 @@ +set terminal pngcairo linewidth 1.5 +set output 'results/voltages.png' + +unset border +set zeroaxis ls -1 +set grid +set key outside + +set xlabel 'time (s)' +set ylabel 'Voltage (V)' +plot [0:0.035] 'results/voltages.raw' using 1:2 with lines title 'v_{T}', \ + 'results/voltages.raw' using 3:4 with lines title 'v_{F}', \ + 'results/voltages.raw' using 5:6 with lines title 'v_{o}' diff --git a/ac2dc_linear.sp b/ac2dc_linear.sp new file mode 100644 index 0000000..bc6954b --- /dev/null +++ b/ac2dc_linear.sp @@ -0,0 +1,29 @@ +AC-DC Linear Regulator + +.inc ./lib/generic.lib +.inc ./lib/regulators.lib + +* Transformation +Vac acp1 acp2 sin(0 155.6 50) +Xt acp1 acp2 acs1 acs2 TRANSFORMER Lout=1.19 + +* Rectification +Xr acs1 acs2 in gnd RECTIFIER + +* Filtering +C1 in gnd 100u +C2 in gnd 100u +C3 in gnd 10u + +* Regulation +Xrv in gnd out LM7805 +Rl out gnd 100 + +.control +set filetype ascii +tran 100us 35ms +shell mkdir -p results +wrdata results/voltages.raw v(acs1,acs2) v(in) v(out) +shell gnuplot ac2dc_linear.gnuplot +.endc +.end diff --git a/lib/generic.lib b/lib/generic.lib new file mode 100644 index 0000000..50d9446 --- /dev/null +++ b/lib/generic.lib @@ -0,0 +1,27 @@ +.subckt TRANSFORMER in1 in2 out1 out2 Lin=100 Lout=100 R1=1m R2=1m +* in1 .---x x---. out1 +* )||( +* )||( +* in2 .---x x---. out2 + +* Inductances +Lin in1 intin {Lin} +Lout out1 intout {Lout} + +* Resistances +R1 intin in2 {R1} +R2 intout out2 {R2} + +* Coupled Factor +K1 Lin Lout 1 + +.ends TRANSFORMER + +.subckt RECTIFIER ac1 ac2 out gnd +D1 ac1 out DI_ABS10A +D2 ac2 out DI_ABS10A +D3 gnd ac2 DI_ABS10A +D4 gnd ac1 DI_ABS10A +.MODEL DI_ABS10A D ( IS=3.47n RS=42.6m BV=1000 IBV=5.00u ++ CJO=25.2p M=0.333 N=1.70 TT=4.32u ) +.ends RECTIFIER diff --git a/lib/regulators.lib b/lib/regulators.lib new file mode 100644 index 0000000..7ced93c --- /dev/null +++ b/lib/regulators.lib @@ -0,0 +1,351 @@ +* C:\Arquivos de Programas\LTC\SwCADIII\lib\sub\regulators.lib + + +* LM7805 model. +* No need to use .inc - I've set the .asy symbol to remove the need for .inc. +* (I used the symbol of LT1084, just replaced the LT1084 by LMxxxx and LTC.LIB by regulators.lib) + +.SUBCKT LM7805 1 2 3 +* In GND Out +QT6 23 10 2 Q_NPN 0.1 +QT7 5 4 10 Q_NPN 0.1 +QT5 7 6 5 Q_NPN 0.1 +QT1 1 9 8 Q_NPN 0.1 +QT3 11 8 7 Q_NPN 0.1 +QT2 11 13 12 Q_NPN 0.1 +QT17 1 15 14 Q_NPN 10 +C2 10 23 4P +R16 12 5 500 +R12 16 2 12.1K +QT18 17 23 16 Q_NPN 0.1 +D1 18 19 D_D +R11 20 21 850 +R5 22 3 100 +QT14 24 18 2 Q_NPN 0.1 +R21 6 2 2.67K +R20 3 6 640 +DZ2 25 26 D_5V1 +R19 1 26 16K +R18 14 3 250M +R17 25 14 380 +R15 25 15 1.62K +QT16 1 20 15 Q_NPN 1 +QT15 2 24 21 Q_PNP 0.1 +*OFF +R14 21 24 4K +C1 27 24 20P +R13 19 2 4K +QT13 24 27 18 Q_NPN 0.1 +QT12 20 25 22 Q_NPN 1 +*OFF +QT11 20 28 2 Q_NPN 0.1 +*OFF +QT10 20 11 1 Q_PNP 0.1 +R10 17 27 16.5K +R9 5 4 1.9K +R8 4 23 26 +R7 10 2 1.2K +R6 29 2 1K +QT9 11 11 1 Q_PNP 0.1 +QT8 27 16 29 Q_NPN 0.1 +QT4 15 6 17 Q_NPN 0.1 +DZ1 2 9 D_5V6 +R4 1 9 80K +R3 28 2 830 +R2 13 28 4.97K +R1 8 13 7K + +.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p ) +.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p ) +.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p ) + +.ENDS LM7805 + +* Pinouts are the same as 7805. + +.SUBCKT LM7812 1 2 3 +QT6 23 10 2 Q_NPN 0.1 +QT7 5 4 10 Q_NPN 0.1 +QT5 7 6 5 Q_NPN 0.1 +QT1 1 9 8 Q_NPN 0.1 +QT3 11 8 7 Q_NPN 0.1 +QT2 11 13 12 Q_NPN 0.1 +QT17 1 15 14 Q_NPN 10 +C2 10 23 4P +R16 12 5 500 +R12 16 2 12.1K +QT18 17 23 16 Q_NPN 0.1 +D1 18 19 D_D +R11 20 21 850 +R5 22 3 100 +QT14 24 18 2 Q_NPN 0.1 +R21 6 2 2.67K +R20 3 6 5.22K +DZ2 25 26 D_5V1 +R19 1 26 16K +R18 14 3 250M +R17 25 14 380 +R15 25 15 1.62K +QT16 1 20 15 Q_NPN 1 +QT15 2 24 21 Q_PNP 0.1 +*OFF +R14 21 24 4K +C1 27 24 20P +R13 19 2 4K +QT13 24 27 18 Q_NPN 0.1 +QT12 20 25 22 Q_NPN 1 +*OFF +QT11 20 28 2 Q_NPN 0.1 +*OFF +QT10 20 11 1 Q_PNP 0.1 +R10 17 27 16.5K +R9 5 4 1.9K +R8 4 23 26 +R7 10 2 1.2K +R6 29 2 1K +QT9 11 11 1 Q_PNP 0.1 +QT8 27 16 29 Q_NPN 0.1 +QT4 15 6 17 Q_NPN 0.1 +DZ1 2 9 D_5V6 +R4 1 9 80K +R3 28 2 830 +R2 13 28 4.97K +R1 8 13 7K + +.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p ) +.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p ) +.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p ) + +.ENDS LM7812 + +* Pinouts are the same as '05 + +.SUBCKT LM7815 1 2 3 +QT6 23 10 2 Q_NPN 0.1 +QT7 5 4 10 Q_NPN 0.1 +QT5 7 6 5 Q_NPN 0.1 +QT1 1 9 8 Q_NPN 0.1 +QT3 11 8 7 Q_NPN 0.1 +QT2 11 13 12 Q_NPN 0.1 +QT17 1 15 14 Q_NPN 10 +C2 10 23 4P +R16 12 5 500 +R12 16 2 12.1K +QT18 17 23 16 Q_NPN 0.1 +D1 18 19 D_D +R11 20 21 850 +R5 22 3 100 +QT14 24 18 2 Q_NPN 0.1 +R21 6 2 2.67K +R20 3 6 7.18K +DZ2 25 26 D_5V1 +R19 1 26 16K +R18 14 3 250M +R17 25 14 380 +R15 25 15 1.62K +QT16 1 20 15 Q_NPN 1 +QT15 2 24 21 Q_PNP 0.1 +*OFF +R14 21 24 4K +C1 27 24 20P +R13 19 2 4K +QT13 24 27 18 Q_NPN 0.1 +QT12 20 25 22 Q_NPN 1 +*OFF +QT11 20 28 2 Q_NPN 0.1 +*OFF +QT10 20 11 1 Q_PNP 0.1 +R10 17 27 16.5K +R9 5 4 1.9K +R8 4 23 26 +R7 10 2 1.2K +R6 29 2 1K +QT9 11 11 1 Q_PNP 0.1 +QT8 27 16 29 Q_NPN 0.1 +QT4 15 6 17 Q_NPN 0.1 +DZ1 2 9 D_5V6 +R4 1 9 80K +R3 28 2 830 +R2 13 28 4.97K +R1 8 13 7K + +.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p ) +.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p ) +.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P ++ TF=10P TR=1N ) +.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p ) + +.ENDS LM7815 + + +* Identical. + +.SUBCKT LM7905 1 2 3 + +DD4 4 5 D_6V3_0 +DD2 6 2 D_3V9_0 +DD1 7 2 D_4V7_0 +DD3 8 3 D_6V3_0 +C2 9 10 5P +C1 2 9 15P +QTU15 10 9 3 Q_PNP_0 1.000 +R17 11 12 4.2K +QTU22 3 10 13 Q_NPN_0 3.000 +R18 8 5 15.65K +R20 13 14 1K +R19 4 14 75 +QTU31 12 11 4 Q_NPN_1 1.000 +R16 15 1 160 +R24 16 1 1.8K +C3 17 1 10P +QTU30 18 12 15 Q_NPN_1 1.000 +QTU29 10 16 1 Q_NPN_1 1.000 +R15 19 1 400 +QTU28 10 20 19 Q_NPN_1 1.000 +R14 21 1 200 +QTU27 17 20 21 Q_NPN_1 1.000 +R11 22 23 1K +R10 24 25 1K +QTU19 18 27 26 Q_NPN_1 1.000 +R9 2 18 7.1K +QTU8 16 18 2 Q_PNP_0 1.000 +QTU7 28 18 2 Q_PNP_0 1.000 +QTU6 18 18 2 Q_PNP_0 1.000 +QTU5 11 29 2 Q_PNP_0 1.000 +QTU4 20 29 2 Q_PNP_0 1.000 +QTU3 1 29 2 Q_PNP_0 1.000 +QTU2 1 29 2 Q_PNP_0 1.000 +R13 28 1 400 +R12 30 1 400 +QTU18 29 29 31 Q_NPN_1 1.000 +QTU1 29 29 2 Q_PNP_0 1.000 +R6 31 32 6.5K +R7 32 27 5.6K +R8 27 26 950 +QTU10 33 6 26 Q_PNP_0 1.000 +QTU17 34 35 33 Q_PNP_0 1.000 +R5 36 1 2K +QTU24 34 34 36 Q_NPN_1 1.000 +R1 37 6 6.3K +R2 37 38 670 +R3 38 35 550 +QTU9 38 35 6 Q_PNP_0 1.000 +R4 39 1 2K +QTU23 35 34 39 Q_NPN_1 1.000 +QTU16 1 7 35 Q_PNP_0 1.000 +JT1 7 1 1 J_2N3458_N +QTU14 3 17 23 Q_PNP_0 1.000 +QTU13 17 17 23 Q_PNP_0 1.000 +QTU12 17 17 25 Q_PNP_0 1.000 +QTU11 9 17 25 Q_PNP_0 1.000 +QTU32 3 13 14 Q_NPN_2 10.000 +QTU26 9 20 28 Q_NPN_1 1.000 +QTU25 20 20 30 Q_NPN_1 1.000 +QTU21 2 40 22 Q_NPN_1 1.000 +QTU20 2 37 24 Q_NPN_1 1.000 +R21 2 40 4.29K +R22 40 3 500 +R23 14 1 500M + +.MODEL J_2N3458_N NJF( VTO=-3.05 BETA=699.53U LAMBDA=6M RD=1 RS=1 ++ CGD=2.81P CGS=2.91P M=227.1M PB=500M IS=114.41F ++ VTOTC=-2.5M BETATCE=-500M KF=0 AF=1 ) +.MODEL D_6V3_0 D( IS=10F N=1.24 BV=6.3 IBV=1M CJ0 = 1P TT = 10p ) +.MODEL D_3V9_0 D( IS=10F N=1.24 BV=3.9 IBV=1M CJ0 = 1P TT = 10p ) +.MODEL D_4V7_0 D( IS=10F N=1.24 BV=4.7 IBV=1M CJ0 = 1P TT = 10p ) +.MODEL Q_PNP_0 PNP( IS=10F NF=1.04 NR=1.04 BF=50 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=45) +.MODEL Q_NPN_0 NPN( IS=10F NF=1.04 NR=1.04 BF=100 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=90) +.MODEL Q_NPN_1 NPN( IS=10F NF=1.04 NR=1.04 BF=100 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=90) +.MODEL Q_NPN_2 NPN( IS=10F NF=1.04 NR=1.04 BF=100 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=90) +.ENDS LM7905 + +* Identical but PIN 2 is now ADJUST instead of GND. +* LM117 seems to be the same model. + +.SUBCKT LM317 1 2 3 +D4 4 3 D_Z6V0 +D3 5 6 D_Z6V3 +D2 7 1 D_Z6V3 +D1 3 8 D_Z6V3 +QT26 1 10 9 Q_NPN 20.0 +QT25 1 11 10 Q_NPN 2.0 +QT24_2 13 12 5 Q_NPN 0.1 +QT24 13 12 14 Q_NPN 0.1 +QT23 17 16 15 Q_NPN 1.0 +QT21 19 18 3 Q_NPN 0.1 +QT19 21 3 20 Q_NPN 1.0 +QT17 23 3 22 Q_NPN 0.1 +QT13 1 25 24 Q_NPN 0.1 +QT11 16 27 26 Q_NPN 0.1 +QT7 30 29 28 Q_NPN 0.1 +QT5 29 31 3 Q_NPN 0.1 +QT3 33 31 32 Q_NPN 0.1 +QT22_2 17 17 1 Q_PNP 1.0 +QT22 16 17 1 Q_PNP 1.0 +QT20 3 19 16 Q_PNP 0.1 +QT18 21 21 16 Q_PNP 0.1 +QT16 23 21 16 Q_PNP 0.1 +QT15 3 23 25 Q_PNP 0.1 +QT12 3 24 16 Q_PNP 0.1 +QT9 27 30 34 Q_PNP 0.1 +QT6 3 29 34 Q_PNP 0.1 +QT14 25 33 35 Q_PNP 0.1 +QT10 16 33 36 Q_PNP 0.1 +QT8 34 33 37 Q_PNP 0.1 +QT4 31 33 38 Q_PNP 0.1 +QT2 33 33 39 Q_PNP 0.1 +R27 4 2 50 +R26 9 3 100M +R25 9 14 2 +R24 5 14 160 +R23 7 6 18K +R22 10 3 160 +R21 12 13 400 +R20 18 13 13K +R19 16 11 370 +R18 15 10 130 +R17 16 12 12K +C3 19 18 5P +R16 16 19 6.7K +R15 20 22 2.4K +R14 22 4 12K +C2 23 4 30P +C1 23 3 30P +R13 24 3 5.1K +R12 26 3 72 +R11 27 3 5.8K +R10 28 3 4.1K +R9 32 3 180 +R8 34 30 12.4K +R7 31 29 130 +R6 8 31 100K +R5 1 35 5.6K +R4 1 36 82 +R3 1 37 190 +R2 1 38 310 +R1 1 39 310 +JT1 1 3 8 J_N + +.MODEL D_Z6V0 D( IS=10F N=1.04 BV=6.0 IBV=1M CJ0 = 1P TT = 10p ) +.MODEL D_Z6V3 D( IS=10F N=1.04 BV=6.3 IBV=1M CJ0 = 1P TT = 10p ) +.MODEL Q_NPN NPN( IS=10F NF=1.04 NR=1.04 BF=100 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=90) +.MODEL Q_PNP PNP( IS=10F NF=1.04 NR=1.04 BF=50 CJC=1P CJE=2P ++ TF=10P TR=1N VAF=45) +.MODEL J_N NJF( VTO=-7 ) + +.ENDS LM117 -- cgit v1.2.3-70-g09d2