summaryrefslogtreecommitdiffstatshomepage
path: root/nl_examples
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-04-06 14:11:06 +0200
committer couriersud <couriersud@gmx.org>2019-04-07 19:09:48 +0200
commit58e6383ada73e3d9bb2330248c77d99f4063896d (patch)
tree69ea6066ac01e90cffba02ebf7e3775dfeaaaf87 /nl_examples
parent140dc2237eed85e3451ab95a4bcdae84ee8600c5 (diff)
netlist: MB3614 again, function controlled VARCLOCK and other
improvements. - fix MB3614 parameter - Added VARCLOCK which derives step size from function - optimized function handling in CS and VS - fixed a bug in ppreprocessor - add trunc to pfunction - added opamp_amplification_curve to derive characteristic amplification curve
Diffstat (limited to 'nl_examples')
-rw-r--r--nl_examples/cmos_inverter_clk.cpp2
-rw-r--r--nl_examples/congo_bongo.c6
-rw-r--r--nl_examples/opamp_amplification_curve.cpp72
3 files changed, 76 insertions, 4 deletions
diff --git a/nl_examples/cmos_inverter_clk.cpp b/nl_examples/cmos_inverter_clk.cpp
index 95dba92bb79..8b70c46e715 100644
--- a/nl_examples/cmos_inverter_clk.cpp
+++ b/nl_examples/cmos_inverter_clk.cpp
@@ -32,7 +32,7 @@ NETLIST_START(cmos_inverter_clk)
//CLOCK(V, 500000)
#else
VS(V, 5)
- PARAM(V.FUNC, "T 5e6 *")
+ PARAM(V.FUNC, "T * 5e6")
#endif
MOSFET(P, "PMOS(VTO=-0.5 GAMMA=0.5 TOX=20n)")
diff --git a/nl_examples/congo_bongo.c b/nl_examples/congo_bongo.c
index c31258b0bb2..3ad52e7dced 100644
--- a/nl_examples/congo_bongo.c
+++ b/nl_examples/congo_bongo.c
@@ -111,11 +111,11 @@ NETLIST_START(dummy)
NET_C(RX1.2, XU16.7)
#endif
- /* The opamp actually has an FPF of about 200k. This doesn't work here and causes oscillations.
+ /* The opamp actually has an FPF of about 1000k. This doesn't work here and causes oscillations.
* FPF here therefore about half the Solver clock.
*/
- PARAM(XU16.B.MODEL, "MB3614(TYPE=3 UGF=22k)")
- PARAM(XU17.C.MODEL, "MB3614(TYPE=3 UGF=22k)")
+ PARAM(XU16.B.MODEL, "MB3614(TYPE=3)")
+ PARAM(XU17.C.MODEL, "MB3614(TYPE=3 UGF=44k)")
#if 0
PARAM(XU17.A.MODEL, "MB3614(TYPE=1)")
PARAM(XU17.B.MODEL, "MB3614(TYPE=1)")
diff --git a/nl_examples/opamp_amplification_curve.cpp b/nl_examples/opamp_amplification_curve.cpp
new file mode 100644
index 00000000000..73cb7273d9b
--- /dev/null
+++ b/nl_examples/opamp_amplification_curve.cpp
@@ -0,0 +1,72 @@
+// license:GPL-2.0+
+// copyright-holders:Couriersud
+/*
+ * Script to analyze opamp amplification as a function of frequency.
+ *
+ * ./nltool -t 0.5 -f nl_examples/opamp_amplification_curve.cpp
+ *
+ * t=0.0: 10 Hz
+ * t=0.1: 100 Hz
+ * t=0.2: 1000 Hz
+ * t=0.3: 10000 Hz
+ * t=0.4: 100000 Hz
+ * ....
+ *
+ * ./plot_nl.sh --log Y Z
+ */
+
+
+#include "netlist/devices/net_lib.h"
+
+#define OPAMP_TEST "MB3614(FPF=10 UGF=1000k)"
+
+NETLIST_START(main)
+
+ /* Standard stuff */
+
+ //VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
+ //CLOCK(clk, 1000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-7)
+ PARAM(Solver.NR_LOOPS, 300)
+ PARAM(Solver.DYNAMIC_TS, 1)
+ PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-7)
+
+ VS(vs, 0)
+ PARAM(vs.FUNC, "0.001 * sin(6.28 * pow(10, 1 + 10*T) * T)")
+ //PARAM(vs.FUNC, "0.001 * sin(6.28 * pow(10, trunc((1 + T * 4)*2)/2) * T)")
+ //PARAM(vs.FUNC, "1.001 * sin(6.28 * 100 * T)")
+ PARAM(vs.R, 0.001)
+ ALIAS(clk, vs.1)
+ NET_C(vs.2, GND)
+ ANALOG_INPUT(V12, 12)
+ ANALOG_INPUT(VM12, -12)
+
+ OPAMP(op,OPAMP_TEST)
+
+ NET_C(op.GND, VM12)
+ NET_C(op.VCC, V12)
+
+ /* Opamp B wired as inverting amplifier connected to output of first opamp */
+
+ RES(R1, 0.1)
+ RES(R2, 10000)
+
+ NET_C(op.PLUS, GND)
+ NET_C(op.MINUS, R2.2)
+ NET_C(op.MINUS, R1.2)
+
+ NET_C(clk, R1.1)
+ NET_C(op.OUT, R2.1)
+
+ RES(RL, 2000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, op.OUT)
+
+ AFUNC(f, 1, "A0 * 1000")
+ NET_C(f.A0, op.OUT)
+#if 1
+ LOG(log_Y, R1.1)
+ LOG(log_Z, f)
+#endif
+NETLIST_END()