diff options
author | 2015-07-11 16:09:08 +0200 | |
---|---|---|
committer | 2015-07-11 16:15:17 +0200 | |
commit | 3a8d682827eb53c6747084fe3907c82ffd4f212b (patch) | |
tree | f05899cea2b7f7fee17c38402298f042c16e73f0 /nl_examples | |
parent | 82735c0e36eda2be459c39559561613e162f60e6 (diff) |
Added two more models to netlist:
OPAMP: Generic opamp model. This does all the annoying calculations.
Just pass the the datasheet values.
LVCCS: A limited current voltage control current source. This will allow
slew rate limiting going forward.
In addition:
- add a (small) parallel conductance to all capacitors to improve
convergence.
- some initial work to use "long double".
Diffstat (limited to 'nl_examples')
-rw-r--r-- | nl_examples/congoBongo.c | 51 | ||||
-rw-r--r-- | nl_examples/opamp.c | 21 |
2 files changed, 51 insertions, 21 deletions
diff --git a/nl_examples/congoBongo.c b/nl_examples/congoBongo.c index 9584de39b88..1a04c0a2ad3 100644 --- a/nl_examples/congoBongo.c +++ b/nl_examples/congoBongo.c @@ -49,9 +49,9 @@ NETLIST_START(dummy) // .END SOLVER(Solver, 24000) - PARAM(Solver.ACCURACY, 1e-8) + PARAM(Solver.ACCURACY, 1e-7) PARAM(Solver.NR_LOOPS, 90) - PARAM(Solver.SOR_FACTOR, 0.00001) + PARAM(Solver.SOR_FACTOR, 0.001) PARAM(Solver.GS_LOOPS, 1) //PARAM(Solver.GS_THRESHOLD, 99) PARAM(Solver.ITERATIVE, "SOR") @@ -334,7 +334,7 @@ NETLIST_START(CongoBongo_schematics) NET_C(C61.1, R94.2) NETLIST_END() -NETLIST_START(opamp) +NETLIST_START(opamp_mod) /* Opamp model from * @@ -374,13 +374,18 @@ NETLIST_START(opamp) NET_C(EBUF.ON, fVREF) /* The opamp model */ - VCCS(G1) + LVCCS(G1) PARAM(G1.RI, RES_K(1000)) - +#if 0 PARAM(G1.G, 0.0022) RES(RP1, 1e6) CAP(CP1, 0.0318e-6) - +#else + PARAM(G1.G, 0.0002) + PARAM(G1.CURLIM, 0.002) + RES(RP1, 9.5e6) + CAP(CP1, 0.0033e-6) +#endif VCVS(EBUF) PARAM(EBUF.RO, 50) PARAM(EBUF.G, 1) @@ -395,21 +400,43 @@ NETLIST_START(opamp) DIODE(DP,".model tt D(IS=1e-15 N=1)") DIODE(DN,".model tt D(IS=1e-15 N=1)") - +#if 1 NET_C(DP.K, fUH.Q) NET_C(fUL.Q, DN.A) NET_C(DP.A, DN.K, RP1.1) +#else + /* + * This doesn't add any performance by decreasing iteration loops. + * To the contrary, it significantly decreases iterations + */ + RES(RH1, 0.1) + RES(RL1, 0.1) + NET_C(DP.K, RH1.1) + NET_C(RH1.2, fUH.Q) + NET_C(fUL.Q, RL1.1) + NET_C(RL1.2, DN.A) + NET_C(DP.A, DN.K, RP1.1) +#endif NET_C(EBUF.IP, RP1.1) NETLIST_END() NETLIST_START(MB3614_DIP) - SUBMODEL(opamp, op1) - SUBMODEL(opamp, op2) - SUBMODEL(opamp, op3) - SUBMODEL(opamp, op4) - +#if 1 + SUBMODEL(opamp_mod, op1) + SUBMODEL(opamp_mod, op2) + SUBMODEL(opamp_mod, op3) + SUBMODEL(opamp_mod, op4) +#else + /* The opamp actually has an FPF of about 500k. This doesn't work here and causes oscillations. + * FPF here therefore about half the Solver clock. + */ + OPAMP(op1, ".model MB3614 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=11k SLEW=0.6M RI=1000k RO=50 DAB=0.002)") + OPAMP(op2, ".model MB3614 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=11k SLEW=0.6M RI=1000k RO=50 DAB=0.002)") + OPAMP(op3, ".model MB3614 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=11k SLEW=0.6M RI=1000k RO=50 DAB=0.002)") + OPAMP(op4, ".model MB3614 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=11k SLEW=0.6M RI=1000k RO=50 DAB=0.002)") +#endif ALIAS( 1, op1.OUT) ALIAS( 2, op1.MINUS) ALIAS( 3, op1.PLUS) diff --git a/nl_examples/opamp.c b/nl_examples/opamp.c index 01db8fb4383..ce347c21c64 100644 --- a/nl_examples/opamp.c +++ b/nl_examples/opamp.c @@ -11,10 +11,12 @@ NETLIST_START(main) /* Standard stuff */ CLOCK(clk, 1000) // 1000 Hz - SOLVER(Solver, 48000) - //PARAM(Solver.ACCURACY, 1e-3) + SOLVER(Solver, 480000) + PARAM(Solver.ACCURACY, 1e-10) + PARAM(Solver.NR_LOOPS, 30000 ) //PARAM(Solver.CONVERG, 1.0) - //PARAM(Solver.GS_LOOPS, 30) + PARAM(Solver.GS_LOOPS, 30) + PARAM(Solver.GS_THRESHOLD, 99) // Tie up +5 to opamps thought it's not currently needed // Stay compatible @@ -47,8 +49,8 @@ NETLIST_START(main) NET_C(RL.2, GND) NET_C(RL.1, op1.OUT) - //LOG(logX, op1.OUT) - //LOG(logY, clk) + LOG(logX, op1.OUT) + LOG(logY, clk) NETLIST_END() NETLIST_START(opamp) @@ -73,10 +75,11 @@ NETLIST_START(opamp) /* The opamp model */ - VCCS(G1) - PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000 - RES(RP1, 1000) - CAP(CP1, 1.59e-6) // <== change to 1.59e-3 for 10Khz bandwidth + LVCCS(G1) + PARAM(G1.G, 0.0021) + PARAM(G1.CURLIM, 0.002) + RES(RP1, 1e7) + CAP(CP1, 0.00333e-6) VCVS(EBUF) PARAM(EBUF.RO, 50) PARAM(EBUF.G, 1) |