-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[help] Implementing a basic NPN BJT model #160
Comments
As a quick fix: use There was a warning message from @instantiateModel: Information message from getSortedAndSolvedAST for model CommonEmitter:
The following variables are iteration variables but have no start/init values defined.
If units are used in the model, start/init values with correct units should be defined
to avoid unit errors during compilation.
Involved variables:
X.Vbe
RC.n.v This means that the mentioned variables need to be explicitly declared with units, such as:
Unfortunately, RC.n.v from model library |
Thanks a lot. Your suggestion seems to work. But then another model using this errors with NaN value. Code:Amplifier1 = Model(
Vcc = ConstantVoltage | Map(V=22.0u"V"),
R1 = Resistor | Map(R=56e3u"Ω"),
R2 = Resistor | Map(R=8.2e3u"Ω"),
RC = Resistor | Map(R=6.8e3u"Ω"),
RE = Resistor | Map(R=1.5e3u"Ω"),
Ci = Capacitor | Map(C=10e-6u"F", v=Var(init=0.0u"V")),
Co = Capacitor | Map(C=10e-6u"F", v=Var(init=0.0u"V")),
CE = Capacitor | Map(C=20e-6u"F", v=Var(init=0.0u"V")),
Vi = SineVoltage | Map(V=8e-3u"V", f=1.5e3u"Hz"),
Vo = VoltageSensor,
X = BJT_NPN,
ground = Ground,
connect = :[
(Vcc.p , R1.p, RC.p)
(Vi.p, Ci.p)
(R1.n, R2.p, Ci.n, X.b)
(RC.n, Co.p, X.c)
(RE.p, CE.p, X.e)
(Vo.p, Co.n)
(ground.p, R2.n, RE.n, CE.n, Vcc.n, Vi.n, Vo.n)
]
)
amplifier1 = @instantiateModel(Amplifier1, unitless=true, log=true)
simulate!(amplifier1, Tsit5(), stopTime = 5e-3u"s", log=true) # runs fine up to 0.00668s Output:
How can I step-through-debug the model, or failing that find out the exact variable dump of the error state? |
While fiddling with Modia, I tried to implement a basic NPN BJT model referring to the MATLAB code from (https://gist.github.com/bencholmes/d3ce40d1e9450f692320f68fd0a239f7) like this
Using it like this:
gives the following message
Some help pointing in the right direction would be very helpful.
The text was updated successfully, but these errors were encountered: