Limit a variable in Modelica

485 Views Asked by At

I'm trying to model a simple actuator. When I use the following line of code to define the limits of the extended and retracted length of the actuator, the results is such that the s_rel is limited but the free flange is moving indefinitely:

s_rel=smooth(0, if strokeUpperLimit then l_cyl else if strokeLowerLimit then l_cyl + l_rod else flange_a.s - flange_b.s);

What is the best way to put limits to a continuous variable ?

1

There are 1 best solutions below

0
On

I don't know if this is the best way, but the Modelica standard library includes a limiter:

Modelica.Blocks.Nonlinear.Limiter