I am having trouble constraining translational motion using a prismatic joint in Modelica. My goal is to make a body stop after it has moved a certain distance (x meters). Ideally, I want the motion to stop suddenly, but it's also acceptable if it stops gradually.
Here's what I have tried so far:
I am using a BodyBox, a Prismatic joint, and a constant Force to drive the motion.
I have tried implementing a reverse force to stop the motion. While it stops, the body then moves in the reverse direction because the force is constant.
I have successfully implemented stopping the exertion of force after the body moves 1 meter, but since the force was already applied, it stops accelerating, but the velocity remains the same.
I am aware of using a damper, but I need the damper to only engage after the body has moved x meters. I don't want the damper to affect the system from the beginning.
Could someone provide a solution or guide me on how to implement this in Modelica? A graphical implementation would be very helpful. How can I gradually stop the motion without causing the body to move in the reverse direction or maintain its velocity?
Thank you!
above stops force exertion after 1m, below exerts force in reverse-direction after 1m
I think the "ElastoGap" model should do what you need: Modelica.Mechanics.Translational.Components.ElastoGap
.
An experiment using the ElastoGap to stop a mass from moving could look like this:
with the result being:
The ElastoGap is basically a spring-damper element which only gets active after a certain distance (s_rel0
) is reached. For more information on this model I would advice to check the documentation of the model itself or e.g. this example Modelica.Mechanics.Translational.Examples.ElastoGap
applying it in both directions
The code for replicating:
model StoppingMass
inner Modelica.Mechanics.MultiBody.World world annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Mechanics.MultiBody.Joints.Prismatic prismatic(useAxisFlange=true,
n={1,0,0},
s(start=0, fixed=true),
v(start=0, fixed=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}}, rotation=0)));
Modelica.Mechanics.MultiBody.Parts.Body body(r_CM={0,0,0}, m=1)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={50,0})));
Modelica.Mechanics.Translational.Components.ElastoGap elastoGap(
c=1e6,
d=100e3,
s_rel0=-1) annotation (Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=0,
origin={2,40})));
Modelica.Mechanics.Translational.Sources.ConstantForce constantForce(f_constant=10)
annotation (Placement(transformation(extent={{-10,64},{10,84}})));
equation
connect(body.frame_a, prismatic.frame_b)
annotation (Line(
points={{40,0},{10,0}},
color={95,95,95},
thickness=0.5));
connect(world.frame_b, prismatic.frame_a)
annotation (Line(
points={{-40,0},{-10,0}},
color={95,95,95},
thickness=0.5));
connect(prismatic.support, elastoGap.flange_b)
annotation (Line(points={{-4,6},{-4,20},{-12,20},{-12,40},{-8,40}}, color={0,127,0}));
connect(prismatic.axis, elastoGap.flange_a) annotation (Line(points={{8,6},{8,20},{16,20},{16,40},{12,40}}, color={0,127,0}));
connect(constantForce.flange, elastoGap.flange_a) annotation (Line(points={{10,74},{16,74},{16,40},{12,40}}, color={0,127,0}));
annotation (uses(Modelica(version="4.0.0")));
end StoppingMass;