Modelica spring-pendulum - modelica

I want to model a simple "spring-pendulum" in modelica:
model Pendulum
parameter Boolean animation=true "= true, if animation shall be enabled";
inner Modelica.Mechanics.MultiBody.World world(axisLength=0.6)
Modelica.Mechanics.MultiBody.Parts.Body body1(
m=1,
animation=animation,
I_11=1,
I_22=1,
I_33=1,
r_CM={0,0,0},
cylinderDiameter=0.05,
sphereDiameter=0.2)
Modelica.Mechanics.MultiBody.Forces.Spring spring1(
coilWidth=0.01,
numberOfWindings=5,
c=20,
s_unstretched=0.2) ;
Modelica.Mechanics.MultiBody.Joints.Revolute revolute(phi(fixed=true), w(
fixed=true));
equation
connect(world.frame_b, revolute.frame_a)
connect(spring1.frame_a, revolute.frame_a)
connect(spring1.frame_b, body1.frame_a)
connect(revolute.frame_b, body1.frame_a
end Pendulum;
Trying to simulate the simulation fail - no error message.
Do i need a revolulte for a spring-pendulum? Thank you very much for your help!

Not exactly sure of what you're trying to model. If you make a drawing of your system you'll see that it won't represent what you're trying to model (I think).
Here's a pendulum with a spring:
model pendulum2
inner Modelica.Mechanics.MultiBody.World world annotation(Placement(visible = true, transformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute annotation(Placement(visible = true, transformation(origin = {-41.539, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Prismatic prismatic(s.start = .5) annotation(Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.Body body annotation(Placement(visible = true, transformation(origin = {25, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Forces.Spring spring(c = 100, s_unstretched = .5) annotation(Placement(visible = true, transformation(origin = {-10, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(spring.frame_b, prismatic.frame_b) annotation(Line(visible = true, origin = {0, 10}, points = {{0, 10}, {0, -10}}));
connect(spring.frame_a, prismatic.frame_a) annotation(Line(visible = true, origin = {-20, 10}, points = {{0, 10}, {0, -10}}));
connect(prismatic.frame_b, body.frame_a) annotation(Line(visible = true, origin = {7.5, 0}, points = {{-7.5, -0}, {7.5, 0}}));
connect(revolute.frame_b, prismatic.frame_a) annotation(Line(visible = true, origin = {-25.77, 0}, points = {{-5.77, 0}, {5.77, 0}}));
connect(world.frame_b, revolute.frame_a) annotation(Line(visible = true, origin = {-60.77, 0}, points = {{-9.23, 0}, {9.23, 0}}));
annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end pendulum2;

Related

Modelica v4.0.0 Visualizers are Broken

I have recently migrated to modelica version 4.0.0, am am having some problems, it turns out that some visualizer settings for the SignalArrow and sensors, such as the absoluteSensor had their diameter settings removed,
Changes in Modelica Version 4
Namely:
WorldForce The parameters diameter and N_to_m have been removed.
AbsoluteSensor The parameter arrowDiameter has been removed.
RelativeSensor The parameter arrowDiameter has been removed.
Distance The parameter arrowDiameter has been removed.
And many other things. This is somewhat frustrating, however I managed to find these missing settings have been moved into the world class,
However these changes do not affect the diameter sizes of these arrows from sensors and visualizers.
For example, in this image, the yellow and pink arrows should be 5mm (the same diameter of the black coordinate arrows), and not whatever modelica has calculated them to be.
I have attempted removing all visualizers and reinserting them, disabling then renabling them and everything else I can think of. Their diameters are being calculated from something somewhere. I however cannot seem to find it.
How can this be fixed or is this just broken in 4.0.0?
Added Code
v 3.2.3
model asdfa
inner Modelica.Mechanics.MultiBody.World world(label2 = "z", label1 = "x", n = {0, 0, -1}) annotation(Placement(visible = true, transformation(origin = {-110, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0, 1, 0}) annotation(Placement(visible = true, transformation(origin = {-50, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation1(r = {0, -1, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {10, 72.396}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.PointMass pointMass1(m = 1) annotation(Placement(visible = true, transformation(origin = {52.304, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Visualizers.SignalArrow signalArrow1(diameter = 0.008) annotation(Placement(visible = true, transformation(origin = {85, 55}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation2(r = {1, 0, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {17.792, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Sensors.AbsoluteSensor absoluteSensor1(get_r = true, resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.world, arrowDiameter = 0.008, arrowColor = {255, 0, 255}) annotation(Placement(visible = true, transformation(origin = {45, -21.932}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(revolute1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-80, 30}, points = {{20, 0}, {-20, -0}}));
connect(revolute1.frame_b, fixedTranslation2.frame_a) annotation(Line(visible = true, origin = {-16.104, 30}, points = {{-23.896, 0}, {23.896, 0}}));
connect(fixedTranslation1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-27.5, 51.198}, points = {{27.5, 21.198}, {22.5, 21.198}, {22.5, -21.198}, {-72.5, -21.198}}));
connect(absoluteSensor1.r, signalArrow1.r_head) annotation(Line(visible = true, origin = {60, -16.449}, points = {{-25, -16.483}, {-25, -21.483}, {25, -21.483}, {25, 59.449}}));
connect(fixedTranslation1.frame_b, signalArrow1.frame_a) annotation(Line(visible = true, origin = {36.25, 63.698}, points = {{-16.25, 8.698}, {-11.25, 8.698}, {-11.25, -8.698}, {38.75, -8.698}}));
connect(fixedTranslation2.frame_b, pointMass1.frame_a) annotation(Line(visible = true, origin = {40.048, 30}, points = {{-12.256, 0}, {12.256, 0}}));
connect(absoluteSensor1.frame_a, pointMass1.frame_a) annotation(Line(visible = true, origin = {39.922, -5.546}, points = {{-4.922, -16.386}, {-9.922, -16.386}, {-9.922, -1.386}, {12.383, -1.386}, {12.383, 35.546}}));
annotation(Diagram(coordinateSystem(extent = {{-150, -90}, {150, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5}), graphics = {Rectangle(visible = true, lineColor = {0, 114, 195}, fillColor = {255, 255, 255}, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(visible = true, textColor = {64, 64, 64}, extent = {{-150, 110}, {150, 150}}, textString = "%name")}));
end asdfa;
Migrated to v4.0.0
model asdfa
inner Modelica.Mechanics.MultiBody.World world(label2 = "z", label1 = "x", n = {0, 0, -1}, defaultArrowDiameter = 0.008) annotation(Placement(visible = true, transformation(origin = {-110, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0, 1, 0}) annotation(Placement(visible = true, transformation(origin = {-50, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation1(r = {0, -1, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {10, 72.396}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.PointMass pointMass1(m = 1) annotation(Placement(visible = true, transformation(origin = {52.304, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Visualizers.SignalArrow signalArrow1 annotation(Placement(visible = true, transformation(origin = {85, 55}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
/*diameter = 0.008*/
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation2(r = {1, 0, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {17.792, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Sensors.AbsoluteSensor absoluteSensor1(get_r = true, resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.world, /*arrowDiameter = 0.008,*/ arrowColor = {255, 0, 255}) annotation(Placement(visible = true, transformation(origin = {45, -21.932}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(revolute1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-80, 30}, points = {{20, 0}, {-20, -0}}));
connect(revolute1.frame_b, fixedTranslation2.frame_a) annotation(Line(visible = true, origin = {-16.104, 30}, points = {{-23.896, 0}, {23.896, 0}}));
connect(fixedTranslation1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-27.5, 51.198}, points = {{27.5, 21.198}, {22.5, 21.198}, {22.5, -21.198}, {-72.5, -21.198}}));
connect(absoluteSensor1.r, signalArrow1.r_head) annotation(Line(visible = true, origin = {60, -16.449}, points = {{-25, -16.483}, {-25, -21.483}, {25, -21.483}, {25, 59.449}}));
connect(fixedTranslation1.frame_b, signalArrow1.frame_a) annotation(Line(visible = true, origin = {36.25, 63.698}, points = {{-16.25, 8.698}, {-11.25, 8.698}, {-11.25, -8.698}, {38.75, -8.698}}));
connect(fixedTranslation2.frame_b, pointMass1.frame_a) annotation(Line(visible = true, origin = {40.048, 30}, points = {{-12.256, 0}, {12.256, 0}}));
connect(absoluteSensor1.frame_a, pointMass1.frame_a) annotation(Line(visible = true, origin = {39.922, -5.546}, points = {{-4.922, -16.386}, {-9.922, -16.386}, {-9.922, -1.386}, {12.383, -1.386}, {12.383, 35.546}}));
annotation(Diagram(coordinateSystem(extent = {{-150, -90}, {150, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5}), graphics = {Rectangle(visible = true, lineColor = {0, 114, 195}, fillColor = {255, 255, 255}, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(visible = true, textColor = {64, 64, 64}, extent = {{-150, 110}, {150, 150}}, textString = "%name")}));
end asdfa;

OpenModelica: Input in second level for FMU export

I have a model, create an FMU out of it, and want to import it in to python.
Having inputs on the first canvas works, and transferring them to the blocks which are used works, too.
Because of the architecture of the python code, i need to have the prefix for the inputs as for the rest of the block.
I made a minimal example:
package testi
model source
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage annotation(
Placement(visible = true, transformation(origin = {0, 36}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground annotation(
Placement(visible = true, transformation(origin = {48, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput u annotation(
Placement(visible = true, transformation(origin = {0, 108}, extent = {{-20, -20}, {20, 20}}, rotation = -90), iconTransformation(origin = {0, 108}, extent = {{-20, -20}, {20, 20}}, rotation = -90)));
equation
connect(signalVoltage.n, ground.p) annotation(
Line(points = {{10, 36}, {48, 36}, {48, 32}}, color = {0, 0, 255}));
connect(signalVoltage.p, pin) annotation(
Line(points = {{-10, 36}, {-20, 36}, {-20, 0}, {100, 0}, {100, 0}}, color = {0, 0, 255}));
connect(signalVoltage.v, u) annotation(
Line(points = {{0, 48}, {0, 48}, {0, 108}, {0, 108}}, color = {0, 0, 127}));
end source;
model base
testi.source source1 annotation(
Placement(visible = true, transformation(origin = {-42, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
testi.measurement measurement1 annotation(
Placement(visible = true, transformation(origin = {44, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(source1.pin, measurement1.pin) annotation(
Line(points = {{-32, 40}, {34, 40}}, color = {0, 0, 255}));
end base;
model measurement
Modelica.Electrical.Analog.Basic.Resistor resistor annotation(
Placement(visible = true, transformation(origin = {-24, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground annotation(
Placement(visible = true, transformation(origin = {30, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(pin, resistor.p) annotation(
Line(points = {{-100, 0}, {-34, 0}}, color = {0, 0, 255}));
connect(resistor.n, ground.p) annotation(
Line(points = {{-14, 0}, {30, 0}, {30, -18}, {30, -18}}, color = {0, 0, 255}));
end measurement;
annotation(
uses(Modelica(version = "3.2.3")));
end testi;
Trying to create the FMU causes the error: Undetermined equation system: 23 equations, 24 variables, although i would provide the input "source.u" via python. If I create an additional Input directly in the base model and connect it to the input of the source, it works, but then i do not have the same prefix "source.u" in my python code, which i would really like to have.
Does anyone know a way to solve this problem?
Define a second input u inside model base and connect it to the input of source.u so you only have inputs on the top level of the FMU.
Now the FMU will happily compile and you should be able to change source.u from outside.
model base
Modelica.Blocks.Interfaces.RealInput u;
testi.source source1;
testi.measurement measurement1;
equation
connect(source1.pin, measurement1.pin);
connect(u, source1.u);
end base;

Modelica Coding Standards / Modelica When Statement

Greeting Everyone,
Happy New Year 2020
I am using Openmodelica 1.14 release version on 64 bit windows 7 system.
I am facing some trouble with ‘when’ statement in OMSimulator. While searching for solution, I came across a closed ticket #2664 in Openmodelica. I can still see the reported issue in the current release version of Openmodelica.
I am including the relevant files of ticket # 2664.
model SimpleTest "just a simple model - Compilation etc."
Modelica.Blocks.Interfaces.IntegerInput u annotation(Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.IntegerOutput y annotation(Placement(visible = true, transformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
when change(u) then
y := y + 2;
end when;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(origin = {-6.15, 2.93}, fillColor = {0, 133, 199}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-77.89, 83.75}, {88.14, -92.53}})}));
end SimpleTest;
Is SimpleTest.mo as per Modelica standards?
While compilation of SimpleTest.mo , it throws a Translation Warning
Assuming fixed start value for the following 1 variables:
y:DISCRETE(flow=false fixed = false ) SimpleTest type: Integer
How to avoid this error?
It is just a warning. When you define a discrete variable like this such that it depends on it's previous value in a when condition, it has to have a fixed start value. Just providing a start value kind of is a guess value for the compiler, when you fix it you tell the compiler that it has to use this value for the initialization.
If you don't provide a start value it is set to zero, if you don't fix it, the compiler fixes it automatically (resulting in the warning).
Simple example:
Integer y(start=0, fixed=true);
Applied on your model:
model SimpleTest "just a simple model - Compilation etc."
Modelica.Blocks.Interfaces.IntegerInput u annotation(Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.IntegerOutput y(start=0, fixed=true) annotation(Placement(visible = true, transformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
when change(u) then
y := y + 2;
end when;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(origin = {-6.15, 2.93}, fillColor = {0, 133, 199}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-77.89, 83.75}, {88.14, -92.53}})}));
end SimpleTest;

Modelica.Blocks.Tables.CombiTable1Ds

I want to connect the output of a Combitable to the signal current source as shown in the code below, but it is not possible because the output of table is an array but the input of current source is a scalar.
model TableTest
Modelica.Blocks.Tables.CombiTable1Ds combiTable1Ds1(table = [0, 0; 1, 1; 2, 4; 4, 16]) annotation(
Placement(visible = true, transformation(origin = {-4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Constant const(k = -5) annotation(
Placement(visible = true, transformation(origin = {-46, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent1 annotation(
Placement(visible = true, transformation(origin = {48, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
equation
connect(const.y, combiTable1Ds1.u) annotation(
Line(points = {{-35, 0}, {-17, 0}}, color = {0, 0, 127}));
annotation(
uses(Modelica(version = "3.2.3")));end TableTest;
In your case, the CombiTable1Ds only has one output in its vector. Simply connect it to the current source with:
connect(combiTable1Ds1.y[1], signalCurrent1.u);
If you use Dymola, when you draw a connection select y[1] instead of the default y[:]
Best regards
Rene Just Nielsen

How to connect from an output block to an input block in openmodelica?

I have an openmodelica interface.
block InputInterfaceBlock
CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("/pathToSocket/rpcSocket");
Modelica.Blocks.Interfaces.RealOutput y annotation(
Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
while true loop
y := CPSModel.Functions.readFromSocket(con);
print("Message from server : " + String(y) + "\n");
end while;
annotation(
__OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Input\nInterface", fontName = "DejaVu Sans Mono Bold")}));
annotation(
Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end InputInterfaceBlock;
I have an interface block (InputInterfaceBlock) which reads from a socket which is defined in the path. I want this interface block to connect to another block (OutputInterfaceBlock).
block OutputInterfaceBlock
CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("pathToModel/rpcSocket");
Modelica.Blocks.Interfaces.RealInput y annotation(
Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
print("Trying to send : " + String(y) + "\n");
CPSModel.Functions.writeToSocket(con, y);
print("Message send to server." + "\n");
annotation(
__OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Output\nInterface", fontName = "DejaVu Sans Mono")}));
annotation(
Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end OutputInterfaceBlock;
My model is as follows.
model MechatronicSystem
CPSModel.Models.InputInterfaceBlock Input annotation(
Placement(visible = true, transformation(origin = {-90, 8}, extent = {{-28, -28}, {28, 28}}, rotation = 0)));
CPSModel.Models.OutputInterfaceBlock Output annotation(
Placement(visible = true, transformation(origin = {72, 12}, extent = {{28, 28}, {-28, -28}}, rotation = 0)));
equation
connect(Input.y, Output.y) annotation(
Line(points = {{-60, 8}, {44, 8}, {44, 12}, {42, 12}}, color = {0, 0, 127}));
annotation(
uses(Modelica(version = "3.2.2")));
end MechatronicSystem;
I can receive the data in the InputInterfaceBlock from the socket to the model, but when I try to send that data to OutputInterfaceBlock. It is not getting received in the OutputInterfaceBlock.
How can I fix it ?
You are using a while true loop in InputInterfaceBlock, but the different algorithms in Modelica are not co-routines but normal algorithms.
You could replace that with when sample(0.1,0.1) then ... end when; or similarly, which will run the code every 0.1s seconds.
The while-loop causes the model should be stuck in InputInterfaceBlock and OutputInterfaceBlock not be called.