summaryrefslogtreecommitdiffstats
path: root/nl_examples
diff options
context:
space:
mode:
authorGravatarGravatar couriersud <couriersud@gmx.org>2019-04-10 20:58:11 +0200
committerGravatarGravatar couriersud <couriersud@gmx.org>2019-04-12 00:44:21 +0200
commita4f59176e4801ea002c0cf50f30f2b2b93ab28c9 (patch) (github)
tree0e624ab623cfcbeafcf825c03fe912445f312008 /nl_examples
parent065f52438fc55bcbeea1d28d4601c43939d1af07 (diff)
downloadmame-a4f59176e4801ea002c0cf50f30f2b2b93ab28c9.tar.bz2
mame-a4f59176e4801ea002c0cf50f30f2b2b93ab28c9.zip
netlist: Add more SPICE elements to the conversion code.
Diffstat (limited to 'nl_examples')
-rw-r--r--nl_examples/opamp_amplification_curve.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/nl_examples/opamp_amplification_curve.cpp b/nl_examples/opamp_amplification_curve.cpp
index 73cb7273d9b..e1665244b0e 100644
--- a/nl_examples/opamp_amplification_curve.cpp
+++ b/nl_examples/opamp_amplification_curve.cpp
@@ -18,7 +18,7 @@
#include "netlist/devices/net_lib.h"
-#define OPAMP_TEST "MB3614(FPF=10 UGF=1000k)"
+#define OPAMP_TEST "MB3614(DAB=0.0015)"
NETLIST_START(main)
@@ -33,26 +33,48 @@ NETLIST_START(main)
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)")
+ /*
+ * Having f(t)=sin(g(t)*t) the derivative becomes
+ *
+ * f'(t) = d/dt(g(t)*t) * cos(g(t)*t)
+ *
+ * w(t) = d/dt(g(t)*t) = 2*pi*freq(t) is the angular frequency at time t
+ *
+ * choosing freq(t) = pow(10, a+b*t) and integrating we get
+ *
+ * g(t)*t = 2 * pi /(b*ln(10)) * (pow(10, a+b*t)-pow(10,a))
+ */
+
+ PARAM(vs.FUNC, "0.001 * sin(0.2728752708 * (pow(10, 1 + 10*T) - 10))")
+
+ /*
+ * Stepwise ... same as above
+ */
+ //PARAM(vs.FUNC, "0.001 * sin(6.28 * pow(10, trunc((1 + T * 10)*10)/10) * T)")
+
+ /*
+ * Fixed Frequency:
+ * 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)
+ 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)
+ RES(R1, 100)
+ RES(RP, 100)
+ RES(R2, 10000000)
- NET_C(op.PLUS, GND)
+ NET_C(op.PLUS, RP.1)
+ NET_C(RP.2, GND)
NET_C(op.MINUS, R2.2)
NET_C(op.MINUS, R1.2)