summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2016-12-24 01:01:17 +0100
committer couriersud <couriersud@arcor.de>2016-12-24 01:01:17 +0100
commit522362e2d26654b9736ea311ce91edf1e133f964 (patch)
tree19d7f7bda8c7567a85f2bb47fcc12259030366b0
parent3506240e198084966715e1dcbe3e74d9a6e100e4 (diff)
Add some files to nl_examples. (nw)
-rw-r--r--nl_examples/diode.c31
-rw-r--r--nl_examples/norton_opamp.c127
-rw-r--r--nl_examples/rc.c31
-rw-r--r--nl_examples/rl.c32
4 files changed, 221 insertions, 0 deletions
diff --git a/nl_examples/diode.c b/nl_examples/diode.c
new file mode 100644
index 00000000000..9a2196c6f24
--- /dev/null
+++ b/nl_examples/diode.c
@@ -0,0 +1,31 @@
+/*
+ * diode.c
+ *
+ */
+
+
+#include "netlist/devices/net_lib.h"
+
+NETLIST_START(diode)
+ /* Standard stuff */
+
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48)
+ ANALOG_INPUT(V5, 5)
+
+ //DIODE(D, "1N914")
+ DIODE(D, "D(IS=1e-15)")
+
+ RES(R, RES_K(10))
+ RES(R1, RES_K(10))
+
+ NET_C(clk, D.K)
+ NET_C(D.A, R.1)
+ NET_C(R.2, V5)
+ NET_C(R1.2, GND)
+ NET_C(R.1, R1.1)
+
+ LOG(logB, clk)
+ LOG(logC, D.A)
+
+NETLIST_END()
diff --git a/nl_examples/norton_opamp.c b/nl_examples/norton_opamp.c
new file mode 100644
index 00000000000..b5d8665fcc7
--- /dev/null
+++ b/nl_examples/norton_opamp.c
@@ -0,0 +1,127 @@
+/*
+ * opamp.c
+ *
+ */
+
+
+#include "netlist/devices/net_lib.h"
+
+NETLIST_START(main)
+
+ /* Standard stuff */
+
+ CLOCK(clk, 10000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ ANALOG_INPUT(V5, 5)
+ PARAM(Solver.ACCURACY, 1e-6)
+ PARAM(Solver.DYNAMIC_TS, 0)
+ PARAM(Solver.SOR_FACTOR, 1.0)
+ //PARAM(Solver.CONVERG, 1.0)
+ PARAM(Solver.GS_LOOPS, 5)
+ PARAM(Solver.GS_THRESHOLD, 5)
+
+ SUBMODEL(op1, opamp_fast)
+ /* Wired as non - inverting amplifier like in LM3900 datasheet */
+
+ RES(R1, 25000)
+ RES(R2, 100000)
+ RES(R3, 200000)
+ CAP(C1, CAP_U(0.05))
+
+ NET_C(clk, C1.1)
+ NET_C(C1.2, R1.1)
+
+ NET_C(op1.VM, GND)
+ NET_C(op1.VP, V5 )
+ NET_C(op1.PLUS, R1.2, R3.1)
+ NET_C(R3.2, V5)
+ //NET_C(R3.2, GND)
+ NET_C(op1.MINUS, R2.2)
+ NET_C(op1.OUT, R2.1)
+
+ RES(RL, 10000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, op1.OUT)
+
+ LOG(logX, op1.OUT)
+ LOG(logY, clk)
+NETLIST_END()
+
+NETLIST_START(opamp)
+
+ /* Opamp model from
+ *
+ * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
+ *
+ * Bandwidth 10Mhz
+ *
+ */
+
+ /* Terminal definitions for calling netlists */
+
+ ALIAS(PLUS, G1.IP) // Positive input
+ ALIAS(MINUS, G2.IN) // Negative input
+ ALIAS(OUT, EBUF.OP) // Opamp output ...
+ ALIAS(VM, EBUF.ON) // V- terminal
+ ALIAS(VP, DUMMY.I) // V+ terminal
+
+ DUMMY_INPUT(DUMMY)
+
+ /* The opamp model */
+
+ CCCS(G1)
+ CCCS(G2)
+ //PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000
+ PARAM(G1.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
+ PARAM(G2.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
+ RES(RP1, 1000)
+ CAP(CP1, 1.59e-6) // <== change to 1.59e-3 for 10Khz bandwidth
+ VCVS(EBUF)
+ PARAM(EBUF.RO, 50)
+ PARAM(EBUF.G, 1)
+
+// NET_C(EBUF.ON, GND)
+
+ NET_C(G1.ON, GND)
+ NET_C(G2.ON, GND)
+ NET_C(RP1.2, GND)
+ NET_C(CP1.2, GND)
+ NET_C(EBUF.IN, GND)
+
+ NET_C(G1.IN, G2.IP, GND)
+
+ NET_C(RP1.1, G1.OP)
+ NET_C(RP1.1, G2.OP)
+ NET_C(CP1.1, RP1.1)
+ NET_C(EBUF.IP, RP1.1)
+
+NETLIST_END()
+
+NETLIST_START(opamp_fast)
+
+ /*
+ * Fast norton opamp model without bandwidth
+ */
+
+ /* Terminal definitions for calling netlists */
+
+ ALIAS(PLUS, R1.1) // Positive input
+ ALIAS(MINUS, R2.1) // Negative input
+ ALIAS(OUT, G1.OP) // Opamp output ...
+ ALIAS(VM, G1.ON) // V- terminal
+ ALIAS(VP, DUMMY.I) // V+ terminal
+
+ DUMMY_INPUT(DUMMY)
+
+ /* The opamp model */
+
+ RES(R1, 1)
+ RES(R2, 1)
+ NET_C(R1.1, G1.IP)
+ NET_C(R2.1, G1.IN)
+ NET_C(R1.2, R2.2, G1.ON)
+ VCVS(G1)
+ PARAM(G1.G, 1000000)
+ PARAM(G1.RO, RES_K(8))
+
+NETLIST_END()
diff --git a/nl_examples/rc.c b/nl_examples/rc.c
new file mode 100644
index 00000000000..1850da313da
--- /dev/null
+++ b/nl_examples/rc.c
@@ -0,0 +1,31 @@
+/*
+ * cdelay.c
+ *
+ */
+
+#include "netlist/devices/net_lib.h"
+
+NETLIST_START(rc)
+
+ /*
+ * delay circuit
+ *
+ */
+
+ /* Standard stuff */
+
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ CLOCK(clk, 20000)
+
+ CAP(C1, 0.022e-6)
+ RES(R1, 10000)
+ RES(R2, 20000)
+
+ NET_C(clk, R2.1)
+ NET_C(R2.2, R1.1, C1.1)
+ NET_C(C1.2, R1.2, GND)
+
+ LOG(tt, C1.1)
+
+NETLIST_END()
diff --git a/nl_examples/rl.c b/nl_examples/rl.c
new file mode 100644
index 00000000000..3b5056b259c
--- /dev/null
+++ b/nl_examples/rl.c
@@ -0,0 +1,32 @@
+/*
+ * lr.c
+ *
+ */
+
+#include "netlist/devices/net_lib.h"
+
+NETLIST_START(lr)
+
+ /*
+ * delay circuit
+ *
+ */
+
+ /* Standard stuff */
+
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ CLOCK(clk, 50)
+ PARAM(Solver.ITERATIVE, "MAT_CR")
+
+ IND(L1, 10)
+ RES(R1, 10000)
+
+ NET_C(clk, L1.1)
+ NET_C(L1.2, R1.1)
+ NET_C(R1.2, GND)
+
+ //LOG(log_1, R1.1)
+ //LOG(log_2, clk)
+
+NETLIST_END()