Knot83
Knot83

Reputation: 63

Spice3 NMOS Model interface with standard Modelica models

I'm experiencing an issue in Open Modelica when trying to use NMOS model of the library Spice3 coupled with a standard Modelica voltage source model. With reference to the example of a simple half-bridge configuration with an RL load, I've simulated the following cases:

a) using a Spice3 pulse voltage source(Modelica.Electrical.Spice3.Sources.V_pulse) on the gate of low-side NMOS(Modelica.Electrical.Spice3.Semiconductors.M_NMOS) -> Everything Spice models

b) using a Modelica pulse source (Modelica.Blocks.Sources.Pulse) and a signal-controlled voltage source(Modelica.Electrical.Analog.Sources.SignalVoltage) on the gate of low-side NMOS (Modelica.Electrical.Spice3.Semiconductors.M_NMOS) -> Mix of Spice models and Modelica models.

In case a) the simulation is working properly and results expected (current thought the inductive load and "inside" the low and high side NMOS models, as drain/source/body current values). Instead in case b), the simulation has convergence issues. Moreover, it seems that partial results of load current are expected, but looking inside both NMOS models, the drain/source/body current values are not expected.

Could anyone please help me to fix the issue in "Test_NMOS_nok" schematic? Does anyone know if there are compatibility issues between Spice3 models and Modelica models?

Link Model case a) : https://drive.google.com/file/d/1CkaMiwzZ_Q1jOfuYO0k4-JqKoZi0f8pt/view?usp=sharing

Link Model case b): https://drive.google.com/file/d/1iT8ssJwAzViCcXwuda4R_cNzbKLgSlwN/view?usp=sharing

Thanks in advance!

Upvotes: 3

Views: 175

Answers (1)

Markus A.
Markus A.

Reputation: 7500

Summarizing the comments of the original question:

  • There is no compatibility issue between MSL and SPICE3.
  • The problem is specific to the model, i.e. the SPICE3 model used, in combination an ideal rectangular voltage as excitation.

Below, find the code from the question's Google drive links, just in case they don't work at some point in the future. All of the example are created by Know83.

a) Original working model:

model Test_NMOS_ok
  Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {0, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Sources.V_constant v_constant(V = 13.5)  annotation(
    Placement(visible = true, transformation(origin = {-80, 56}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Spice3.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {0, -62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.Ground ground annotation(
    Placement(visible = true, transformation(origin = {-80, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.R_Resistor r_Resistor(R = 2.4)  annotation(
    Placement(visible = true, transformation(origin = {62, 52}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  parameter Modelica.Electrical.Spice3.Semiconductors.ModelcardMOS mos_model( CBD = 1e-12, CBS = 1e-12,KP = 20, LAMBDA = 0.001, NSUB = 1e15, VTO = 2.48) annotation(
    Placement(visible = true, transformation(origin = {-38, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.L_Inductor l_Inductor(IC = 0, L = 1.4e-03)  annotation(
    Placement(visible = true, transformation(origin = {62, 26}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos1(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {1, 42}, extent = {{-9, -10}, {9, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Sources.V_constant v_constant1(V = 0)  annotation(
    Placement(visible = true, transformation(origin = {-32, 26}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Spice3.Sources.V_pulse v_pulse(PER = 1e-03, PW = 0.5e-03, TD = 1e-03, TF = 50e-09, TR = 50e-09, V1 = 0, V2 = 5) annotation(
    Placement(visible = true, transformation(origin = {-34, -22}, extent = {{10, -10}, {-10, 10}}, rotation = 90)));
equation
  connect(m_nmos.B, m_nmos.S) annotation(
    Line(points = {{10, -10}, {16, -10}, {16, -20}, {0, -20}}, color = {0, 0, 255}));
  connect(ground1.p, m_nmos.S) annotation(
    Line(points = {{0, -52}, {0, -20}}, color = {0, 0, 255}));
  connect(v_constant.n, ground.p) annotation(
    Line(points = {{-80, 46}, {-80, 40}}, color = {0, 0, 255}));
  connect(r_Resistor.p, v_constant.p) annotation(
    Line(points = {{62, 62}, {62, 72}, {-80, 72}, {-80, 66}}, color = {0, 0, 255}));
  connect(r_Resistor.n, l_Inductor.p) annotation(
    Line(points = {{62, 42}, {62, 36}}, color = {0, 0, 255}));
  connect(l_Inductor.n, m_nmos.D) annotation(
    Line(points = {{62, 16}, {62, 7}, {0, 7}, {0, 0}}, color = {0, 0, 255}));
  connect(m_nmos1.S, m_nmos.D) annotation(
    Line(points = {{1, 32}, {1, 15}, {0, 15}, {0, 0}}, color = {0, 0, 255}));
  connect(m_nmos1.D, v_constant.p) annotation(
    Line(points = {{1, 52}, {1, 72}, {-80, 72}, {-80, 66}}, color = {0, 0, 255}));
  connect(m_nmos1.B, m_nmos1.S) annotation(
    Line(points = {{10, 42}, {10, 32}, {1, 32}}, color = {0, 0, 255}));
  connect(v_constant1.p, m_nmos1.G) annotation(
    Line(points = {{-32, 36}, {-32, 42}, {-8, 42}}, color = {0, 0, 255}));
  connect(v_constant1.n, m_nmos1.S) annotation(
    Line(points = {{-32, 16}, {0, 16}, {0, 22}, {2, 22}, {2, 32}}, color = {0, 0, 255}));
  connect(v_pulse.n, ground1.p) annotation(
    Line(points = {{-34, -32}, {-34, -52}, {0, -52}}, color = {0, 0, 255}));
  connect(v_pulse.p, m_nmos.G) annotation(
    Line(points = {{-34, -12}, {-10, -12}, {-10, -10}}, color = {0, 0, 255}));
  annotation(
    uses(Modelica(version = "3.2.3")));
end Test_NMOS_ok;

b) Original not working model:

model Test_NMOS_nok
  Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {0, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Sources.V_constant v_constant(V = 13.5)  annotation(
    Placement(visible = true, transformation(origin = {-80, 56}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Spice3.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {0, -62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.Ground ground annotation(
    Placement(visible = true, transformation(origin = {-80, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.R_Resistor r_Resistor(R = 2.4)  annotation(
    Placement(visible = true, transformation(origin = {62, 52}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  parameter Modelica.Electrical.Spice3.Semiconductors.ModelcardMOS mos_model( CBD = 1e-12, CBS = 1e-12,KP = 20, LAMBDA = 0.001, NSUB = 1e15, VTO = 2.48) annotation(
    Placement(visible = true, transformation(origin = {-38, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Basic.L_Inductor l_Inductor(IC = 0, L = 1.4e-03)  annotation(
    Placement(visible = true, transformation(origin = {62, 26}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos1(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {1, 42}, extent = {{-9, -10}, {9, 10}}, rotation = 0)));
  Modelica.Electrical.Spice3.Sources.V_constant v_constant1(V = 0)  annotation(
    Placement(visible = true, transformation(origin = {-32, 26}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Blocks.Sources.Pulse pulse(amplitude = 5, offset = 0, period = 1e-03, startTime = 1e-03, width = 50) annotation(
    Placement(visible = true, transformation(origin = {-78, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage annotation(
    Placement(visible = true, transformation(origin = {-38, -24}, extent = {{-14, 14}, {14, -14}}, rotation = -90)));
equation
  connect(m_nmos.B, m_nmos.S) annotation(
    Line(points = {{10, -10}, {16, -10}, {16, -20}, {0, -20}}, color = {0, 0, 255}));
  connect(ground1.p, m_nmos.S) annotation(
    Line(points = {{0, -52}, {0, -20}}, color = {0, 0, 255}));
  connect(v_constant.n, ground.p) annotation(
    Line(points = {{-80, 46}, {-80, 40}}, color = {0, 0, 255}));
  connect(r_Resistor.p, v_constant.p) annotation(
    Line(points = {{62, 62}, {62, 72}, {-80, 72}, {-80, 66}}, color = {0, 0, 255}));
  connect(r_Resistor.n, l_Inductor.p) annotation(
    Line(points = {{62, 42}, {62, 36}}, color = {0, 0, 255}));
  connect(l_Inductor.n, m_nmos.D) annotation(
    Line(points = {{62, 16}, {62, 7}, {0, 7}, {0, 0}}, color = {0, 0, 255}));
  connect(m_nmos1.S, m_nmos.D) annotation(
    Line(points = {{1, 32}, {1, 15}, {0, 15}, {0, 0}}, color = {0, 0, 255}));
  connect(m_nmos1.D, v_constant.p) annotation(
    Line(points = {{1, 52}, {1, 72}, {-80, 72}, {-80, 66}}, color = {0, 0, 255}));
  connect(m_nmos1.B, m_nmos1.S) annotation(
    Line(points = {{10, 42}, {10, 32}, {1, 32}}, color = {0, 0, 255}));
  connect(v_constant1.p, m_nmos1.G) annotation(
    Line(points = {{-32, 36}, {-32, 42}, {-8, 42}}, color = {0, 0, 255}));
  connect(v_constant1.n, m_nmos1.S) annotation(
    Line(points = {{-32, 16}, {0, 16}, {0, 22}, {2, 22}, {2, 32}}, color = {0, 0, 255}));
  connect(signalVoltage.v, pulse.y) annotation(
    Line(points = {{-55, -24}, {-66, -24}}, color = {0, 0, 127}));
  connect(signalVoltage.p, m_nmos.G) annotation(
    Line(points = {{-38, -10}, {-10, -10}}, color = {0, 0, 255}));
  connect(signalVoltage.n, ground1.p) annotation(
    Line(points = {{-38, -38}, {-38, -52}, {0, -52}}, color = {0, 0, 255}));
  annotation(
    uses(Modelica(version = "3.2.3")),
    Diagram);
end Test_NMOS_nok;

c) Model fixed with a slew rate limiter:

model Test_NMOS_nok_corrected_with_slew_reate   Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {0, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Spice3.Sources.V_constant v_constant(V = 13.5)  annotation(
    Placement(visible = true, transformation(origin = {-176, 56}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));   Modelica.Electrical.Spice3.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {0, -62}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Spice3.Basic.Ground ground annotation(
    Placement(visible = true, transformation(origin = {-176, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Spice3.Basic.R_Resistor r_Resistor(R = 2.4)  annotation(
    Placement(visible = true, transformation(origin = {62, 52}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));   parameter Modelica.Electrical.Spice3.Semiconductors.ModelcardMOS mos_model( CBD
= 1e-12, CBS = 1e-12,KP = 20, LAMBDA = 0.001, NSUB = 1e15, VTO = 2.48) annotation(
    Placement(visible = true, transformation(origin = {46, -72}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Spice3.Basic.L_Inductor l_Inductor(IC = 0, L =
1.4e-03)  annotation(
    Placement(visible = true, transformation(origin = {62, 26}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));   Modelica.Electrical.Spice3.Semiconductors.M_NMOS m_nmos1(modelcard = mos_model) annotation(
    Placement(visible = true, transformation(origin = {1, 42}, extent = {{-9, -10}, {9, 10}}, rotation = 0)));   Modelica.Blocks.Sources.Pulse pulse(amplitude = 5, offset = 0, period
= 1e-03, startTime = 1e-03, width = 50) annotation(
    Placement(visible = true, transformation(origin = {-182, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage annotation(
    Placement(visible = true, transformation(origin = {-38, -24}, extent = {{-14, 14}, {14, -14}}, rotation = -90)));   Modelica.Blocks.Nonlinear.SlewRateLimiter slewRateLimiter(Rising = 5 / 1e-6, Td = 1e-07) annotation(
    Placement(visible = true, transformation(origin = {-128, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));   Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1 annotation(
    Placement(visible = true, transformation(origin = {-70, 28}, extent = {{10, -10}, {-10, 10}}, rotation = 90)));   Modelica.Blocks.Sources.Constant const(k = 0) annotation(
    Placement(visible = true, transformation(origin = {-122, 28}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation   connect(m_nmos.B, m_nmos.S) annotation(
    Line(points = {{10, -10}, {16, -10}, {16, -20}, {0, -20}}, color = {0, 0, 255}));   connect(ground1.p, m_nmos.S) annotation(
    Line(points = {{0, -52}, {0, -20}}, color = {0, 0, 255}));   connect(v_constant.n, ground.p) annotation(
    Line(points = {{-176, 46}, {-176, 40}}, color = {0, 0, 255}));   connect(r_Resistor.p, v_constant.p) annotation(
    Line(points = {{62, 62}, {62, 72}, {-176, 72}, {-176, 66}}, color = {0, 0, 255}));   connect(r_Resistor.n, l_Inductor.p) annotation(
    Line(points = {{62, 42}, {62, 36}}, color = {0, 0, 255}));   connect(l_Inductor.n, m_nmos.D) annotation(
    Line(points = {{62, 16}, {62, 7}, {0, 7}, {0, 0}}, color = {0, 0, 255}));   connect(m_nmos1.S, m_nmos.D) annotation(
    Line(points = {{1, 32}, {1, 15}, {0, 15}, {0, 0}}, color = {0, 0, 255}));   connect(m_nmos1.D, v_constant.p) annotation(
    Line(points = {{1, 52}, {1, 72}, {-176, 72}, {-176, 66}}, color = {0, 0, 255}));   connect(m_nmos1.B, m_nmos1.S) annotation(
    Line(points = {{10, 42}, {10, 32}, {1, 32}}, color = {0, 0, 255}));   connect(signalVoltage.p, m_nmos.G) annotation(
    Line(points = {{-38, -10}, {-10, -10}}, color = {0, 0, 255}));   connect(signalVoltage.n, ground1.p) annotation(
    Line(points = {{-38, -38}, {-38, -52}, {0, -52}}, color = {0, 0, 255}));   connect(pulse.y, slewRateLimiter.u) annotation(
    Line(points = {{-170, -24}, {-140, -24}}, color = {0, 0, 127}));   connect(slewRateLimiter.y, signalVoltage.v) annotation(
    Line(points = {{-116, -24}, {-54, -24}}, color = {0, 0, 127}));   connect(const.y, signalVoltage1.v) annotation(
    Line(points = {{-111, 28}, {-83, 28}}, color = {0, 0, 127}));   connect(signalVoltage1.p, m_nmos1.G) annotation(
    Line(points = {{-70, 38}, {-70, 42}, {-8, 42}}, color = {0, 0, 255}));   connect(signalVoltage1.n, m_nmos1.S) annotation(
    Line(points = {{-70, 18}, {0, 18}, {0, 32}, {2, 32}}, color = {0, 0, 255}));   annotation(
    uses(Modelica(version = "3.2.3")),   Diagram(coordinateSystem(extent = {{-200, -100}, {100, 100}})),   Icon(coordinateSystem(extent = {{-200, -100}, {100, 100}})),   version
= ""); end Test_NMOS_nok_corrected_with_slew_reate;

Upvotes: 3

Related Questions