mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
Adjusted LM3900 model, fixed clipping in zaccaria.
This commit is contained in:
parent
a4f59176e4
commit
bd365f5eab
103
nl_examples/LM3900_test.cpp
Normal file
103
nl_examples/LM3900_test.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* Script to analyze opamp amplification as a function of frequency.
|
||||
*
|
||||
* ./nltool -t 0.5 -f nl_examples/LM9000_test.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 --db Y Z
|
||||
*/
|
||||
|
||||
|
||||
#include "netlist/devices/net_lib.h"
|
||||
|
||||
NETLIST_START(main)
|
||||
|
||||
/* Standard stuff */
|
||||
|
||||
//VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
|
||||
//CLOCK(clk, 1000)
|
||||
SOLVER(Solver, 48000)
|
||||
PARAM(Solver.ACCURACY, 1e-10)
|
||||
PARAM(Solver.NR_LOOPS, 300)
|
||||
PARAM(Solver.DYNAMIC_TS, 1)
|
||||
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-7)
|
||||
|
||||
VS(vs, 0)
|
||||
/*
|
||||
* 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, 50)
|
||||
ALIAS(clk, vs.1)
|
||||
NET_C(vs.2, GND)
|
||||
ANALOG_INPUT(V9, 9)
|
||||
ANALOG_INPUT(V12, 12)
|
||||
ANALOG_INPUT(VM12, -12)
|
||||
|
||||
//OPAMP(op, OPAMP_TEST)
|
||||
LM3900(op)
|
||||
|
||||
NET_C(op.GND, VM12)
|
||||
NET_C(op.VCC, V12)
|
||||
|
||||
/* Opamp B wired as inverting amplifier connected to output of first opamp */
|
||||
|
||||
RES(R1, 50)
|
||||
RES(RP, 500000) // Set to R2 * 2 if VPlus == VCC (see datasheet)
|
||||
RES(R2, 500000)
|
||||
|
||||
NET_C(op.PLUS, RP.1)
|
||||
|
||||
//NET_C(RP.2, V9)
|
||||
NET_C(RP.2, GND)
|
||||
//NET_C(RP.2, V12)
|
||||
|
||||
NET_C(op.MINUS, R2.2)
|
||||
NET_C(op.MINUS, R1.2)
|
||||
|
||||
CAP(C, 0.1e-6)
|
||||
|
||||
NET_C(clk, C.1)
|
||||
NET_C(C.2, R1.1)
|
||||
NET_C(op.OUT, R2.1)
|
||||
|
||||
CAP(CL, 1.0e-6)
|
||||
RES(RL, 2000)
|
||||
NET_C(RL.2, GND)
|
||||
NET_C(RL.1, CL.2)
|
||||
NET_C(CL.1, op.OUT)
|
||||
|
||||
AFUNC(f, 1, "A0 * 1000")
|
||||
NET_C(f.A0, RL.1)
|
||||
#if 1
|
||||
LOG(log_Y, R1.1)
|
||||
LOG(log_Z, f)
|
||||
#endif
|
||||
NETLIST_END()
|
@ -290,18 +290,19 @@ NETLIST_END()
|
||||
static NETLIST_START(LM3900)
|
||||
OPAMP(A, "LM3900")
|
||||
|
||||
DIODE(D1, "D")
|
||||
DIODE(D2, "D")
|
||||
DIODE(D1, "D(IS=1e-14 N=1)")
|
||||
CCCS(CS1) // Current Mirror
|
||||
|
||||
ALIAS(VCC, A.VCC)
|
||||
ALIAS(GND, A.GND)
|
||||
ALIAS(MINUS, A.MINUS)
|
||||
ALIAS(PLUS, A.PLUS)
|
||||
ALIAS(MINUS, A.MINUS)
|
||||
ALIAS(OUT, A.OUT)
|
||||
|
||||
NET_C(D1.A, A.PLUS)
|
||||
NET_C(D2.A, A.MINUS)
|
||||
NET_C(D1.K, D2.K, A.MINUS)
|
||||
NET_C(A.PLUS, CS1.IP)
|
||||
NET_C(D1.A, CS1.IN)
|
||||
NET_C(CS1.OP, A.MINUS)
|
||||
NET_C(CS1.ON, A.GND, D1.K)
|
||||
|
||||
NETLIST_END()
|
||||
#endif
|
||||
@ -320,7 +321,7 @@ NETLIST_START(OPAMP_lib)
|
||||
NET_MODEL("UA741 OPAMP(TYPE=3 VLH=1.0 VLL=1.0 FPF=5 UGF=1000k SLEW=0.5M RI=2000k RO=75 DAB=0.0017)")
|
||||
NET_MODEL("LM747 OPAMP(TYPE=3 VLH=1.0 VLL=1.0 FPF=5 UGF=1000k SLEW=0.5M RI=2000k RO=50 DAB=0.0017)")
|
||||
NET_MODEL("LM747A OPAMP(TYPE=3 VLH=2.0 VLL=2.0 FPF=5 UGF=1000k SLEW=0.7M RI=6000k RO=50 DAB=0.0015)")
|
||||
NET_MODEL("LM3900 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=2k UGF=4M SLEW=0.5M RI=1M RO=2k DAB=0.0015)")
|
||||
NET_MODEL("LM3900 OPAMP(TYPE=3 VLH=1.0 VLL=0.03 FPF=2k UGF=4M SLEW=0.5M RI=10M RO=2k DAB=0.0015)")
|
||||
|
||||
#if USE_LM3900_MODEL == 1
|
||||
NET_MODEL("LM3900_NPN1 NPN(IS=1E-14 BF=150 TF=1E-9 CJC=1E-12 CJE=1E-12 VAF=150 RB=100 RE=5 IKF=0.002)")
|
||||
|
@ -282,13 +282,13 @@ NETLIST_START(zac1b11142)
|
||||
//SOLVER(Solver, 48000)
|
||||
SOLVER(Solver, 48000)
|
||||
//PARAM(Solver.ACCURACY, 1e-10)
|
||||
PARAM(Solver.ACCURACY, 1e-7)
|
||||
PARAM(Solver.NR_LOOPS, 300)
|
||||
PARAM(Solver.ACCURACY, 1e-6)
|
||||
PARAM(Solver.NR_LOOPS, 3000)
|
||||
PARAM(Solver.METHOD, "MAT_CR")
|
||||
PARAM(Solver.PARALLEL, 0)
|
||||
PARAM(Solver.PARALLEL, 2)
|
||||
PARAM(Solver.DYNAMIC_TS, 0)
|
||||
PARAM(Solver.DYNAMIC_LTE, 5e-4)
|
||||
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 20e-6)
|
||||
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-7)
|
||||
|
||||
LOCAL_SOURCE(zac1b11142_schematics)
|
||||
|
||||
@ -336,4 +336,15 @@ NETLIST_START(zac1b11142)
|
||||
|
||||
INCLUDE(zac1b11142_schematics)
|
||||
|
||||
RES(R1, RES_K(100))
|
||||
RES(R3, RES_K(10))
|
||||
CAP(C7, CAP_U(0.1))
|
||||
|
||||
NET_C(P1.2, R3.1)
|
||||
NET_C(R3.2, C7.1)
|
||||
NET_C(C7.2, R1.1) // Connect to Pin 2 - also other sounds are mixed in here <- sound out
|
||||
NET_C(R1.2, GND) // Actually connected to ~6V from pin 3 of TDA1510
|
||||
|
||||
// FIXME: connect other sounds to netlist as well for proper mixing
|
||||
// FIXME: make P1 controllable by mame ui (see pong for an example)
|
||||
NETLIST_END()
|
||||
|
@ -428,7 +428,7 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config)
|
||||
m_pia_1i->writepa_handler().set(m_speech, FUNC(tms5220_device::data_w));
|
||||
m_pia_1i->writepb_handler().set(FUNC(zac1b11142_audio_device::pia_1i_portb_w));
|
||||
|
||||
MC1408(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 0.40, AUTO_ALLOC_INPUT, 0); // mc1408.1f
|
||||
MC1408(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 0.30, AUTO_ALLOC_INPUT, 0); // mc1408.1f
|
||||
voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
|
||||
vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT);
|
||||
vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT);
|
||||
@ -438,7 +438,7 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config)
|
||||
TMS5200(config, m_speech, 649200); // ROMCLK pin measured at 162.3Khz, OSC is exactly *4 of that)
|
||||
m_speech->irq_cb().set(m_pia_1i, FUNC(pia6821_device::cb1_w));
|
||||
m_speech->ready_cb().set(m_pia_1i, FUNC(pia6821_device::ca2_w));
|
||||
m_speech->add_route(ALL_OUTPUTS, *this, 0.80, AUTO_ALLOC_INPUT, 0);
|
||||
m_speech->add_route(ALL_OUTPUTS, *this, 0.60, AUTO_ALLOC_INPUT, 0);
|
||||
|
||||
netlist_mame_sound_device &sound_nl(NETLIST_SOUND(config, "sound_nl", 48000));
|
||||
sound_nl.set_constructor(netlist_zac1b11142);
|
||||
@ -460,7 +460,7 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config)
|
||||
NETLIST_STREAM_INPUT(config, "sound_nl:cin4", 4, "R_AY4H_B.R");
|
||||
NETLIST_STREAM_INPUT(config, "sound_nl:cin5", 5, "R_AY4H_C.R");
|
||||
|
||||
NETLIST_STREAM_OUTPUT(config, "sound_nl:cout0", 0, "P1.2").set_mult_offset(3000.0 * 10.0, 0.0); // FIXME: no clue what numbers to use here
|
||||
NETLIST_STREAM_OUTPUT(config, "sound_nl:cout0", 0, "C7.2").set_mult_offset(3000.0 * 10.0, 0.0); // FIXME: no clue what numbers to use here
|
||||
}
|
||||
|
||||
ioport_constructor zac1b11142_audio_device::device_input_ports() const
|
||||
|
Loading…
Reference in New Issue
Block a user