From: Lukáš Jiřiště Date: Tue, 9 Dec 2025 12:34:51 +0000 (+0100) Subject: Add an EMF model I derived for a DC motor X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;p=emf.git Add an EMF model I derived for a DC motor --- 75dd035d40d562a19917043b610839d8933ab3e7 diff --git a/emf.mo b/emf.mo new file mode 100644 index 0000000..d2479ab --- /dev/null +++ b/emf.mo @@ -0,0 +1,52 @@ +package EMF + +model EMF + import Modelica.Units.SI; + parameter SI.ElectricalTorqueConstant k = 1; + + SI.Voltage v; + SI.Current i; + SI.Angle phi(start = 1); + SI.AngularVelocity omega; + SI.Torque tau; + + Modelica.Electrical.Analog.Interfaces.PositivePin p; + Modelica.Electrical.Analog.Interfaces.NegativePin n; + Modelica.Mechanics.Rotational.Interfaces.Flange_b flange; + +protected + parameter SI.ElectricalTorqueConstant k_mod = k * 2 / + Modelica.Constants.pi; + +equation + omega = der(phi); + tau = k_mod * abs(sin(phi)) * i; + v = k_mod * abs(sin(phi)) * omega; + + tau = flange.tau; + phi = flange.phi; + v = p.v - n.v; + 0 = p.i + n.i; + i = p.i; +end EMF; + +model DCMotor + import Elct = Modelica.Electrical.Analog.Basic; + + EMF emf; + Elct.Resistor resistor(R = 1); + Elct.Inductor inductor(L = 1); + Elct.Ground ground; + Modelica.Electrical.Analog.Sources.ConstantVoltage source(V = 1); + Modelica.Mechanics.Rotational.Components.Inertia inertia(J = 1); + +equation + connect(source.p, resistor.p); + connect(resistor.n, inductor.p); + connect(inductor.n, emf.p); + connect(emf.n, ground.p); + connect(source.n, ground.p); + connect(emf.flange, inertia.flange_a); +end DCMotor; + +end EMF;