Opened 6 years ago
Closed 6 years ago
#5736 closed discussion (invalid)
Expandable connector bus
| Reported by: | Owned by: | somebody | |
|---|---|---|---|
| Priority: | high | Milestone: | Future |
| Component: | *unknown* | Version: | |
| Keywords: | Cc: |
Description
hey everyone . I m student I am a beginner on modelica,this is my first post
I want to transform this model SystemArchitecture from Modelica by example
by Dr. Michael M. Tiller https://mbe.modelica.university/components/architectures/sensor_comparison_ad/ that includes a plant, controller, sensor and actuator
to other Architecture with expandable connector bus
Model SystemArchitecture without expandable connector :
model SystemArchitecture_0
"A system architecture built from subsystem interfaces"
model BasicPlant "Implementation of the basic plant model"
parameter Modelica.SIunits.Inertia J_a=0.1 "Moment of inertia";
parameter Modelica.SIunits.Inertia J_b=0.3 "Moment of inertia";
parameter Modelica.SIunits.RotationalSpringConstant c=100 "Spring constant";
parameter Modelica.SIunits.RotationalDampingConstant d_shaft=3
"Shaft damping constant";
parameter Modelica.SIunits.RotationalDampingConstant d_load=4
"Load damping constant";
Modelica.Mechanics.Rotational.Interfaces.Support housing
"Connection to mounting"
annotation (Placement(transformation(extent={{-110,-70},{-90,-50}})));
Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
"Input shaft for plant"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange_b
"Output shaft of plant"
annotation (Placement(transformation(extent={{90,-10},{110,10}})));
protected
Modelica.Mechanics.Rotational.Components.Fixed fixed
annotation (Placement(transformation(extent={{-10,-80},{10,-60}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=J_a)
annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia1(J=J_b)
annotation (Placement(transformation(extent={{20,-10},{40,10}})));
Modelica.Mechanics.Rotational.Components.SpringDamper springDamper(c=c, d=
d_shaft)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Mechanics.Rotational.Components.Damper damper(d=d_load)
annotation (Placement(transformation(extent={{20,-40},{40,-20}})));
equation
connect(springDamper.flange_a, inertia.flange_b) annotation (Line(
points={{-10,0},{-20,0}},
color={0,0,0},
smooth=Smooth.None));
connect(springDamper.flange_b, inertia1.flange_a) annotation (Line(
points={{10,0},{20,0}},
color={0,0,0},
smooth=Smooth.None));
connect(damper.flange_b, inertia1.flange_b) annotation (Line(
points={{40,-30},{50,-30},{50,0},{40,0}},
color={0,0,0},
smooth=Smooth.None));
connect(damper.flange_a, fixed.flange) annotation (Line(
points={{20,-30},{0,-30},{0,-70}},
color={0,0,0},
smooth=Smooth.None));
connect(inertia1.flange_b, flange_b) annotation (Line(
points={{40,0},{100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(inertia.flange_a, flange_a) annotation (Line(
points={{-40,0},{-100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(fixed.flange, housing) annotation (Line(
points={{0,-70},{0,-60},{-100,-60}},
color={0,0,0},
smooth=Smooth.None));
end BasicPlant;
model IdealSensor "Implementation of an ideal sensor"
Modelica.Mechanics.Rotational.Interfaces.Flange_a shaft
"Flange of shaft from which sensor information shall be measured"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
Modelica.Blocks.Interfaces.RealOutput w "Absolute angular velocity of flange"
annotation (Placement(transformation(extent={{100,-10},{120,10}})));
protected
Modelica.Mechanics.Rotational.Sensors.SpeedSensor idealSpeedSensor
"An ideal speed sensor" annotation (Placement(transformation(
extent={{-10,-10},{10,10}})));
equation
connect(idealSpeedSensor.flange, shaft) annotation (Line(
points={{-10,0},{-100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(idealSpeedSensor.w, w) annotation (Line(
points={{11,0},{110,0}},
color={0,0,127},
smooth=Smooth.None));
end IdealSensor;
model ProportionalController "Implementation of a proportional controller"
parameter Real k=20 "Controller gain";
Modelica.Blocks.Interfaces.RealInput setpoint "Desired system response"
annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=270, origin={0,120})));
Modelica.Blocks.Interfaces.RealInput measured "Actual system response"
annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=180, origin={100,0})));
Modelica.Blocks.Interfaces.RealOutput command "Command to send to actuator"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180, origin={-110,0})));
protected
Modelica.Blocks.Math.Gain gain(k=k)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180, origin={-50,0})));
Modelica.Blocks.Math.Feedback feedback
annotation (Placement(transformation(
extent={{10,-10},{-10,10}})));
equation
connect(feedback.y, gain.u) annotation (Line(
points={{-9,0},{2,0},{2,0},{-38,0}},
color={0,0,127}, smooth=Smooth.None));
connect(feedback.u1, setpoint) annotation (Line(
points={{8,0},{40,0},{40,60},{0,60},{0,120}},
color={0,0,127},
smooth=Smooth.None));
connect(gain.y, command) annotation (Line(
points={{-61,0},{-80.5,0},{-80.5,0},{-110,0}},
color={0,0,127},
smooth=Smooth.None));
connect(measured, feedback.u2) annotation (Line(
points={{100,0},{60,0},{60,-40},{0,-40},{0,-8}},
color={0,0,127}, smooth=Smooth.None));
end ProportionalController;
model IdealActuator "An implementation of an ideal actuator"
Modelica.Mechanics.Rotational.Interfaces.Flange_b shaft "Output shaft"
annotation (Placement(transformation(extent={{90,-10},{110,10}})));
Modelica.Mechanics.Rotational.Interfaces.Support housing
"Connection to housing"
annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
Modelica.Blocks.Interfaces.RealInput tau "Input torque command"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
protected
Modelica.Mechanics.Rotational.Sources.Torque torque(useSupport=true)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(torque.flange, shaft) annotation (Line(
points={{10,0},{100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(torque.support, housing) annotation (Line(
points={{0,-10},{0,-60},{100,-60}},
color={0,0,0},
smooth=Smooth.None));
connect(torque.tau, tau) annotation (Line(
points={{-12,0},{-120,0}},
color={0,0,127},
smooth=Smooth.None));
end IdealActuator;
replaceable BasicPlant plant
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-10,-50},{10,-30}})));
replaceable IdealActuator actuator
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-50,-50},{-30,-30}})));
replaceable IdealSensor sensor
annotation (choicesAllMatching=true,
Placement(transformation(extent={{30,-50},{50,-30}})));
replaceable ProportionalController controller
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Trapezoid setpoint(period=1.0)
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-60,30},{-40,50}})));
equation
connect(actuator.shaft, plant.flange_a) annotation (Line(
points={{-30,-40},{-10,-40}},
color={0,0,0},
smooth=Smooth.None));
connect(actuator.housing, plant.housing) annotation (Line(
points={{-30,-46},{-10,-46}},
color={0,0,0},
smooth=Smooth.None));
connect(plant.flange_b, sensor.shaft) annotation (Line(
points={{10,-40},{30,-40}},
color={0,0,0},
smooth=Smooth.None));
connect(controller.measured, sensor.w) annotation (Line(
points={{10,0},{70,0},{70,-40},{51,-40}},
color={0,0,127},
smooth=Smooth.None));
connect(controller.command, actuator.tau) annotation (Line(
points={{-11,0},{-70,0},{-70,-40},{-52,-40}},
color={0,0,127},
smooth=Smooth.None));
connect(setpoint.y, controller.setpoint) annotation (Line(
points={{-39,40},{0,40},{0,12}},
color={0,0,127},
smooth=Smooth.None));
end SystemArchitecture_0;
Model with expandable connector bus :
model SystemArchitecture_1
"A system architecture built from subsystem interfaces"
expandable connector Conn
extends Modelica.Icons.SignalBus;
end Conn;
model IdealSensor "Implementation of an ideal sensor"
Modelica.Mechanics.Rotational.Interfaces.Flange_a shaft
"Flange of shaft from which sensor information shall be measured"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
Conn bus annotation (Placement(transformation(extent={{100,-10},{120,10}})));
protected
Modelica.Mechanics.Rotational.Sensors.SpeedSensor idealSpeedSensor
"An ideal speed sensor" annotation (Placement(transformation(
extent={{-10,-10},{10,10}})));
equation
connect(idealSpeedSensor.flange, shaft) annotation (Line(
points={{-10,0},{-100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(idealSpeedSensor.w, bus.w) annotation (Line(points={{11,0},{110,0}},
color={0,0,127}), Text(
string="%second",
index=1,
extent={{6,3},{6,3}}));
end IdealSensor;
model BasicPlant "Implementation of the basic plant model"
parameter Modelica.SIunits.Inertia J_a=0.1 "Moment of inertia";
parameter Modelica.SIunits.Inertia J_b=0.3 "Moment of inertia";
parameter Modelica.SIunits.RotationalSpringConstant c=100 "Spring constant";
parameter Modelica.SIunits.RotationalDampingConstant d_shaft=3
"Shaft damping constant";
parameter Modelica.SIunits.RotationalDampingConstant d_load=4
"Load damping constant";
Modelica.Mechanics.Rotational.Interfaces.Support housing
"Connection to mounting"
annotation (Placement(transformation(extent={{-110,-70},{-90,-50}})));
Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
"Input shaft for plant"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange_b
"Output shaft of plant"
annotation (Placement(transformation(extent={{90,-10},{110,10}})));
protected
Modelica.Mechanics.Rotational.Components.Fixed fixed
annotation (Placement(transformation(extent={{-10,-80},{10,-60}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=J_a)
annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia1(J=J_b)
annotation (Placement(transformation(extent={{20,-10},{40,10}})));
Modelica.Mechanics.Rotational.Components.SpringDamper springDamper(c=c, d=
d_shaft)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Mechanics.Rotational.Components.Damper damper(d=d_load)
annotation (Placement(transformation(extent={{20,-40},{40,-20}})));
equation
connect(springDamper.flange_a, inertia.flange_b) annotation (Line(
points={{-10,0},{-20,0}},
color={0,0,0},
smooth=Smooth.None));
connect(springDamper.flange_b, inertia1.flange_a) annotation (Line(
points={{10,0},{20,0}},
color={0,0,0},
smooth=Smooth.None));
connect(damper.flange_b, inertia1.flange_b) annotation (Line(
points={{40,-30},{50,-30},{50,0},{40,0}},
color={0,0,0},
smooth=Smooth.None));
connect(damper.flange_a, fixed.flange) annotation (Line(
points={{20,-30},{0,-30},{0,-70}},
color={0,0,0},
smooth=Smooth.None));
connect(inertia1.flange_b, flange_b) annotation (Line(
points={{40,0},{100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(inertia.flange_a, flange_a) annotation (Line(
points={{-40,0},{-100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(fixed.flange, housing) annotation (Line(
points={{0,-70},{0,-60},{-100,-60}},
color={0,0,0},
smooth=Smooth.None));
end BasicPlant;
model IdealActuator "An implementation of an ideal actuator"
Modelica.Mechanics.Rotational.Interfaces.Flange_b shaft "Output shaft"
annotation (Placement(transformation(extent={{90,-10},{110,10}})));
Modelica.Mechanics.Rotational.Interfaces.Support housing
"Connection to housing"
annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
Conn bus
annotation (Placement(transformation(extent={{-120,-10},{-100,10}})));
protected
Modelica.Mechanics.Rotational.Sources.Torque torque(useSupport=true)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(torque.flange, shaft) annotation (Line(
points={{10,0},{100,0}},
color={0,0,0},
smooth=Smooth.None));
connect(torque.support, housing) annotation (Line(
points={{0,-10},{0,-60},{100,-60}},
color={0,0,0},
smooth=Smooth.None));
connect(bus.tau, torque.tau) annotation (Line(
points={{-110,0},{-12,0}},
color={255,204,51},
thickness=0.5), Text(
string="%first",
index=-1,
extent={{-6,3},{-6,3}}));
end IdealActuator;
model ProportionalController "Implementation of a proportional controller"
extends ControlSystem_WithExpandableBus;
parameter Real k=20 "Controller gain";
Modelica.Blocks.Interfaces.RealInput setpoint "Desired system response"
annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=270, origin={0,120})));
protected
Modelica.Blocks.Math.Gain gain(k=k)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180, origin={-50,0})));
Modelica.Blocks.Math.Feedback feedback
annotation (Placement(transformation(
extent={{10,-10},{-10,10}})));
equation
connect(feedback.y, gain.u) annotation (Line(
points={{-9,0},{2,0},{2,0},{-38,0}},
color={0,0,127}, smooth=Smooth.None));
connect(feedback.u1, setpoint) annotation (Line(
points={{8,0},{40,0},{40,60},{0,60},{0,120}},
color={0,0,127},
smooth=Smooth.None));
connect(gain.y, bus.tau) annotation (Line(points={{-61,0},{-90,0},{-90,-100},
{0,-100}}, color={0,0,127}), Text(
string="%second",
index=1,
extent={{6,3},{6,3}}));
connect(bus.w, feedback.u2) annotation (Line(
points={{0,-100},{0,-8}},
color={255,204,51},
thickness=0.5), Text(
string="%first",
index=-1,
extent={{-6,3},{-6,3}}));
end ProportionalController;
replaceable BasicPlant plant
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-10,-50},{10,-30}})));
replaceable IdealActuator actuator
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-50,-50},{-30,-30}})));
replaceable IdealSensor sensor
annotation (choicesAllMatching=true,
Placement(transformation(extent={{30,-50},{50,-30}})));
replaceable ProportionalController controller
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Trapezoid setpoint(period=1.0)
annotation (choicesAllMatching=true,
Placement(transformation(extent={{-60,30},{-40,50}})));
equation
connect(actuator.shaft, plant.flange_a) annotation (Line(
points={{-30,-40},{-10,-40}},
color={0,0,0},
smooth=Smooth.None));
connect(actuator.housing, plant.housing) annotation (Line(
points={{-30,-46},{-10,-46}},
color={0,0,0},
smooth=Smooth.None));
connect(plant.flange_b, sensor.shaft) annotation (Line(
points={{10,-40},{30,-40}},
color={0,0,0},
smooth=Smooth.None));
connect(setpoint.y, controller.setpoint) annotation (Line(
points={{-39,40},{0,40},{0,12}},
color={0,0,127},
smooth=Smooth.None));
connect(actuator.bus, controller.bus) annotation (Line(
points={{-51,-40},{-80,-40},{-80,-20},{0,-20},{0,-10}},
color={255,204,51},
thickness=0.5));
connect(sensor.bus, controller.bus) annotation (Line(
points={{51,-40},{82,-40},{82,-20},{0,-20},{0,-10}},
color={255,204,51},
thickness=0.5));
end SystemArchitecture_1;
I want the models to be equvalent
SystemArchitecture_1 = SystemArchitecture_0
can someone tell me if the models are equivalent ( i get the same simulation results ) ? or how can i improve the architecture with expandable connector bus so that both models stay equivalent
thank you

This tracker is for reporting bugs and other issues related to OpenModelica. If you have questions about modelling or how to use OpenModelica you should instead use for example the OpenModelica forum or StackOverflow, where you are far more likely to find someone who can answer your questions.