TorqueStep

model TorqueStep "Constant torque, not dependent on speed"
    extends Modelica.Mechanics.Rotational.Interfaces.PartialTorque;

    parameter Modelica.SIunits.Torque stepTorque(start = 1) "Height of torque step (if negative, torque is acting as load)";
    parameter Modelica.SIunits.Torque offsetTorque(start = 0) "Offset of torque";
    parameter Modelica.SIunits.Time startTime = 0 "Torque = offset for time < startTime";
    Modelica.SIunits.Torque tau "Accelerating torque acting at flange (= -flange.tau)";
equation
    tau = offsetTorque + (if time < startTime then 0 else stepTorque);
    tau = -flange.tau;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-75, 0}, 
                        {75, 0}},
                    color = {192, 192, 192}), 
                Line(
                    points = {
                        {-75, -30}, 
                        {0, -30}, 
                        {0, 45}, 
                        {65, 45}},
                    color = {0, 0, 127}), 
                Text(
                    extent = {
                        {0, -40}, 
                        {100, -10}},
                    lineColor = {128, 128, 128},
                    textString = "time")}),
        Documentation(info = "<html>\n<p>\nModel of a torque step at time startTime.\nPositive torque accelerates in positive direction of <code>flange</code> rotation.\n</p>\n</html>"));
end TorqueStep;