Astha
Astha

Reputation: 11

Issue with Adding a Temperature Sensor to DCPM Motor Model in OpenModelica

I am a beginner to OpenModelica, and I'm trying to build a model of a DC Permanent Magnet (DCPM) motor to measure its temperature using a temperature sensor. My model is based entirely on the DCPM components from DCMachines.

I am trying to add a temperature sensor to a DC Permanent Magnet (DCPM) motor model in OpenModelica. The model already includes components like a speed sensor, inertia, PI controller, and others. However, I encounter an incompatible component error when attempting to integrate the temperature sensor with the motor.

I attempted to add the temperature sensor directly to the DCPM motor model using the available components in OpenModelica. I expected the sensor to connect to the thermal port of the motor, allowing it to measure the motor's temperature correctly. However, I received an error indicating that the components were incompatible.

Model Overview:

Connections:

Snapshots: model issue with model

Model Code:

model modelmotor
    Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation(
    Placement(transformation(origin = {360, 42}, extent = {{-14, -14}, {14, 14}})));
    Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_PermanentMagnet motor(useSupport =
    false, useThermalPort = true, VaNominal = 24, Ra = 0.5, La = 0.01) annotation(
    Placement(transformation(origin = {128, 40}, extent = {{-10, -10}, {10, 10}})));
    Modelica.Blocks.Continuous.PI PI(T = 0.05, x(start = 0.0, fixed = true), k = 1.5, initType =
    Modelica.Blocks.Types.Init.InitialOutput) annotation(
    Placement(transformation(origin = {54, 40}, extent = {{-10, -10}, {10, 10}})));
    Modelica.Blocks.Math.Feedback feedback1 annotation(
    Placement(transformation(origin = {-20, 40}, extent = {{-10, -10}, {10, 10}})));
    Modelica.Blocks.Sources.Step step(height = 24, startTime = 1, offset = 0) annotation(
    Placement(transformation(origin = {-84, 42}, extent = {{-10, -10}, {10, 10}})));
    Modelica.Mechanics.Rotational.Components.Inertia inertia(J = 10) annotation(
    Placement(transformation(origin = {211, 41}, extent = {{-13, -13}, {13, 13}})));
    Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V = 24) annotation(
    Placement(transformation(origin = {94, 72}, extent = {{-10, -10}, {10, 10}})));
    Modelica.Mechanics.Rotational.Sources.Torque torque annotation(
    Placement(transformation(origin = {95, -21}, extent = {{-11, -11}, {11, 11}})));
  equation
    connect(feedback1.y, PI.u) annotation(
    Line(points = {{-11, 40}, {42, 40}}, color = {0, 0, 127}));
    connect(step.y, feedback1.u1) annotation(
    Line(points = {{-72, 42}, {-28, 42}, {-28, 40}}, color = {0, 0, 127}));
    connect(inertia.flange_b, speedSensor.flange) annotation(
    Line(points = {{224, 41}, {224, 42}, {346, 42}}));
    connect(speedSensor.w, feedback1.u2) annotation(
    Line(points = {{376, 42}, {394, 42}, {394, -72}, {-20, -72}, {-20, 32}}, color = {0, 0,127}));
    connect(constantVoltage.p, motor.pin_ap) annotation(
    Line(points = {{84, 72}, {62, 72}, {62, 90}, {134, 90}, {134, 50}}, color = {0, 0, 255}));
    connect(PI.y, torque.tau) annotation(
    Line(points = {{66, 40}, {66, 39}, {82, 39}, {82, -21}}, color = {0, 0, 127}));
    connect(torque.flange, motor.flange) annotation(
    Line(points = {{106, -21}, {106, 0.5}, {138, 0.5}, {138, 40}}));
    connect(constantVoltage.n, motor.pin_an) annotation(
    Line(points = {{104, 72}, {122, 72}, {122, 50}}, color = {0, 0, 255}));
    connect(inertia.flange_a, motor.flange) annotation(
    Line(points = {{198, 41}, {198, 40}, {138, 40}}));
    annotation(
    Diagram(coordinateSystem(extent = {{-200, -100}, {400, 100}})),
    Icon(coordinateSystem(extent = {{-200, -100}, {400, 100}})),
    version = "",
    uses(Modelica(version = "4.0.0")));
    end modelmotor;

Request: Can anyone help identify the issue and guide me on how to add a temperature sensor to measure the motor's temperature?

Thank you!

Upvotes: 1

Views: 95

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 12517

There are a number of modeling issues here:

  1. Electrical circuits should be grounded.
  2. If you add a thermal port you need an adapter to use with Modelica.Thermal.HeatTransfer and you need to connect it to heat capacitor or similarly.
  3. Something with parameters, that might be for EE SE.

Below you find a package with the model that at least translates in Dymola, but then fails due to the parametrization issue. (And obviously connecting all of the thermal part to the same same heat capacitor is a bit of over-simplification.)

package Test
  model modelmotor
    Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation (
        Placement(transformation(origin={360,42}, extent={{-14,-14},{14,14}})));
    Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_PermanentMagnet
      motor(
      useSupport=false,
      useThermalPort=true,
      VaNominal=24,
      Ra=0.5,
      La=0.01) annotation (Placement(transformation(origin={128,40}, extent={{-10,
              -10},{10,10}})));
    Modelica.Blocks.Continuous.PI PI(
      T=0.05,
      x(start=0.0, fixed=true),
      k=1.5,
      initType=Modelica.Blocks.Types.Init.InitialOutput) annotation (Placement(
          transformation(origin={54,40}, extent={{-10,-10},{10,10}})));
    Modelica.Blocks.Math.Feedback feedback1 annotation (Placement(transformation(
            origin={-20,40}, extent={{-10,-10},{10,10}})));
    Modelica.Blocks.Sources.Step step(
      height=24,
      startTime=1,
      offset=0) annotation (Placement(transformation(origin={-84,42}, extent={{-10,
              -10},{10,10}})));
    Modelica.Mechanics.Rotational.Components.Inertia inertia(J=10) annotation (
        Placement(transformation(origin={211,41}, extent={{-13,-13},{13,13}})));
    Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=24)
      annotation (Placement(transformation(origin={94,72}, extent={{-10,-10},{10,10}})));
    Modelica.Mechanics.Rotational.Sources.Torque torque annotation (Placement(
          transformation(origin={95,-21}, extent={{-11,-11},{11,11}})));
    Modelica.Electrical.Analog.Basic.Ground ground
      annotation (Placement(transformation(extent={{234,-38},{254,-18}})));
    ThermalAdapter thermalPart
      annotation (Placement(transformation(extent={{164,-48},{184,-28}})));
    Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=100)
      annotation (Placement(transformation(extent={{288,-12},{308,8}})));
  equation 
    connect(feedback1.y, PI.u)
      annotation (Line(points={{-11,40},{42,40}}, color={0,0,127}));
    connect(step.y, feedback1.u1)
      annotation (Line(points={{-73,42},{-28,42},{-28,40}}, color={0,0,127}));
    connect(inertia.flange_b, speedSensor.flange)
      annotation (Line(points={{224,41},{224,42},{346,42}}));
    connect(speedSensor.w, feedback1.u2) annotation (Line(points={{375.4,42},{394,
            42},{394,-72},{-20,-72},{-20,32}}, color={0,0,127}));
    connect(constantVoltage.p, motor.pin_ap) annotation (Line(points={{84,72},{62,
            72},{62,90},{134,90},{134,50}}, color={0,0,255}));
    connect(PI.y, torque.tau) annotation (Line(points={{65,40},{65,39},{81.8,39},{
            81.8,-21}}, color={0,0,127}));
    connect(torque.flange, motor.flange)
      annotation (Line(points={{106,-21},{106,0.5},{138,0.5},{138,40}}));
    connect(constantVoltage.n, motor.pin_an)
      annotation (Line(points={{104,72},{122,72},{122,50}}, color={0,0,255}));
    connect(inertia.flange_a, motor.flange)
      annotation (Line(points={{198,41},{198,40},{138,40}}));
    connect(motor.pin_ap, ground.p) annotation (Line(points={{134,50},{134,56},{148,
            56},{148,-12},{244,-12},{244,-18}}, color={0,0,255}));
    connect(motor.thermalPort, thermalPart.thermalPort1) annotation (Line(points={
            {128,30},{128,-37.6},{164,-37.6}}, color={191,0,0}));
    connect(thermalPart.armature_port, heatCapacitor.port) annotation (Line(
          points={{183.8,-28},{228,-28},{228,-44},{298,-44},{298,-12}}, color={191,
            0,0}));
    connect(thermalPart.core_port, heatCapacitor.port) annotation (Line(points={{184,
            -32},{228,-32},{228,-44},{298,-44},{298,-12}}, color={191,0,0}));
    connect(thermalPart.strayLoad_port, heatCapacitor.port) annotation (Line(
          points={{184,-36},{228,-36},{228,-44},{298,-44},{298,-12}}, color={191,0,
            0}));
    connect(thermalPart.friction_port, heatCapacitor.port) annotation (Line(
          points={{184,-40},{228,-40},{228,-44},{298,-44},{298,-12}}, color={191,0,
            0}));
    connect(thermalPart.brush_port, heatCapacitor.port) annotation (Line(points={{
            184.2,-44},{298,-44},{298,-12}}, color={191,0,0}));
    connect(thermalPart.brush_port1, heatCapacitor.port)
      annotation (Line(points={{184,-48},{298,-48},{298,-12}}, color={191,0,0}));
    annotation (
      Diagram(coordinateSystem(extent={{-200,-100},{400,100}})),
      Icon(coordinateSystem(extent={{-200,-100},{400,100}})));
  end modelmotor;

  model ThermalAdapter
    Modelica.Electrical.Machines.Interfaces.DCMachines.ThermalPortDCPM
      thermalPort1
      annotation (Placement(transformation(extent={{-110,-6},{-90,14}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a armature_port
      annotation (Placement(transformation(extent={{88,90},{108,110}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a core_port
      annotation (Placement(transformation(extent={{90,50},{110,70}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a strayLoad_port
      annotation (Placement(transformation(extent={{90,10},{110,30}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a friction_port
      annotation (Placement(transformation(extent={{90,-30},{110,-10}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a brush_port
      annotation (Placement(transformation(extent={{92,-70},{112,-50}})));
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a brush_port1
      annotation (Placement(transformation(extent={{90,-110},{110,-90}})));
  equation 
    connect(armature_port, thermalPort1.heatPortArmature) annotation (Line(
          points={{98,100},{98,74},{86,74},{86,6},{-84,6},{-84,4},{-100,4}},
          color={191,0,0}));
    connect(thermalPort1.heatPortCore, core_port) annotation (Line(points={{-100,
            4},{-86,4},{-86,60},{100,60}}, color={191,0,0}));
    connect(strayLoad_port, thermalPort1.heatPortStrayLoad)
      annotation (Line(points={{100,20},{100,4},{-100,4}}, color={191,0,0}));
    connect(friction_port, thermalPort1.heatPortFriction) annotation (Line(
          points={{100,-20},{100,2},{-88,2},{-88,4},{-100,4}}, color={191,0,0}));
    connect(brush_port, thermalPort1.heatPortBrush) annotation (Line(points={{102,
            -60},{102,-34},{-86,-34},{-86,4},{-100,4}}, color={191,0,0}));
    connect(brush_port1, thermalPort1.heatPortPermanentMagnet) annotation (Line(
          points={{100,-100},{100,-74},{86,-74},{86,0},{-84,0},{-84,2},{-101,2}},
          color={191,0,0}));
    annotation();
  end ThermalAdapter;
  annotation (uses(Modelica(version="4.0.0")));
end Test;

Upvotes: 1

Related Questions