mirror of
https://github.com/holub/mame
synced 2025-07-10 04:05:16 +03:00
NPN BJT now working
This commit is contained in:
parent
db714497ec
commit
3b82caf8ac
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -361,6 +361,7 @@ keymaps/km_se_OSX.map svneol=native#text/plain
|
||||
nl_examples/7400_astable.c svneol=native#text/plain
|
||||
nl_examples/bjt.c svneol=native#text/plain
|
||||
nl_examples/bjt_eb.c svneol=native#text/plain
|
||||
nl_examples/bjt_eb_pnp.c svneol=native#text/plain
|
||||
nl_examples/msx_mixer_stage.c svneol=native#text/plain
|
||||
nl_examples/ne555_astable.c svneol=native#text/plain
|
||||
nl_examples/opamp.c svneol=native#text/plain
|
||||
|
33
nl_examples/bjt_eb_pnp.c
Normal file
33
nl_examples/bjt_eb_pnp.c
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* bjt.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "netlist/devices/net_lib.h"
|
||||
|
||||
NETLIST_START(bjt)
|
||||
/* Standard stuff */
|
||||
|
||||
CLOCK(clk, 1000) // 1000 Hz
|
||||
SOLVER(Solver, 48000)
|
||||
ANALOG_INPUT(V5, 5)
|
||||
ANALOG_INPUT(V3, 3.5)
|
||||
|
||||
/* PNP - example */
|
||||
|
||||
QBJT_EB(Q1, "BC556B")
|
||||
RES(RB1, 1000)
|
||||
RES(RC1, 1000)
|
||||
|
||||
NET_C(RC1.1, GND)
|
||||
NET_C(RC1.2, Q1.C)
|
||||
NET_C(RB1.1, clk)
|
||||
NET_C(RB1.2, Q1.B)
|
||||
NET_C(Q1.E, V3)
|
||||
|
||||
LOG(logA, clk)
|
||||
LOG(logB, Q1.B)
|
||||
LOG(logC, Q1.C)
|
||||
|
||||
NETLIST_END()
|
@ -14,11 +14,11 @@
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
#define QBJT_SW(_name, _model) \
|
||||
NET_REGISTER_DEV(QBJT_switch, _name) \
|
||||
NET_REGISTER_DEV(QBJT_switch, _name) \
|
||||
NETDEV_PARAMI(_name, model, _model)
|
||||
|
||||
#define QBJT_EB(_name, _model) \
|
||||
NET_REGISTER_DEV(QBJT_EB, _name) \
|
||||
NET_REGISTER_DEV(QBJT_EB, _name) \
|
||||
NETDEV_PARAMI(_name, model, _model)
|
||||
|
||||
|
||||
@ -167,8 +167,10 @@ public:
|
||||
|
||||
NETLIB_UPDATE_TERMINALS()
|
||||
{
|
||||
m_gD_BE.update_diode(-m_D_EB.deltaV());
|
||||
m_gD_BC.update_diode(-m_D_CB.deltaV());
|
||||
double polarity = (qtype() == BJT_NPN ? 1.0 : -1.0);
|
||||
|
||||
m_gD_BE.update_diode(-m_D_EB.deltaV() * polarity);
|
||||
m_gD_BC.update_diode(-m_D_CB.deltaV() * polarity);
|
||||
|
||||
double gee = m_gD_BE.G();
|
||||
double gcc = m_gD_BC.G();
|
||||
@ -176,8 +178,8 @@ public:
|
||||
double gce = m_alpha_f * gee;
|
||||
double sIe = -m_gD_BE.I() + m_alpha_r * m_gD_BC.I();
|
||||
double sIc = m_alpha_f * m_gD_BE.I() - m_gD_BC.I();
|
||||
double Ie = sIe + gee * m_gD_BE.Vd() - gec * m_gD_BC.Vd();
|
||||
double Ic = sIc - gce * m_gD_BE.Vd() + gcc * m_gD_BC.Vd();
|
||||
double Ie = (sIe + gee * m_gD_BE.Vd() - gec * m_gD_BC.Vd()) * polarity;
|
||||
double Ic = (sIc - gce * m_gD_BE.Vd() + gcc * m_gD_BC.Vd()) * polarity;
|
||||
//double Ie = sIe + gee * -m_D_EB.deltaV() - gec * -m_D_CB.deltaV();
|
||||
//double Ic = sIc - gce * -m_D_EB.deltaV() + gcc * -m_D_CB.deltaV();
|
||||
//printf("EB %f sIe %f sIc %f\n", m_D_BE.deltaV(), sIe, sIc);
|
||||
|
Loading…
Reference in New Issue
Block a user