Skip to content

Commit 5cb0ed0

Browse files
authored
Merge pull request #1067 from cesarBLG/controller-delays
Traction and dynamic brake retardation
2 parents f2bc634 + b471b7c commit 5cb0ed0

File tree

14 files changed

+636
-477
lines changed

14 files changed

+636
-477
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ locomotive (regardless of transmission type) are as follows:
425425
single: MaxPower
426426
single: MaxForce
427427
single: MaxContinuousForce
428+
single: ORTSTractiveForceIsPowerLimited
428429

429430
``ORTSDieselEngineMaxPower`` ==> sets the maximum power output at the
430431
shaft of the diesel engine (or prime mover).
@@ -438,6 +439,9 @@ wheels when starting.
438439
continuously supply to the wheels without exceeding the design specifications.
439440
Typically this is linked to a particular speed (see next parameter).
440441

442+
``ORTSTractiveForceIsPowerLimited`` ==> determines if tractive force curves
443+
shall be limited to the available output power from the diesel engine.
444+
441445
.. index::
442446
single: ORTSSpeedOfMaxContinuousForce
443447
single: MaxVelocity
@@ -1141,6 +1145,67 @@ with the ``ORTSTractionMotorType ( AC ) `` parameter, to be inserted in the Engi
11411145
section of the ENG file. The use of this motor will have an impact on wheel slip,
11421146
because the wheel speed never exceeds the frequency of the rotating magnetic field.
11431147
1148+
Traction force retardation
1149+
''''''''''''''''''''''''''
1150+
1151+
.. index::
1152+
single: ORTSTractiveForceRampUpRate
1153+
single: ORTSTractiveForceRampDownRate
1154+
single: ORTSTractiveForceRampDownToZeroRate
1155+
single: ORTSTractivePowerRampUpRate
1156+
single: ORTSTractivePowerRampDownRate
1157+
single: ORTSTractivePowerRampDownToZeroRate
1158+
single: ORTSDynamicBrakeForceRampUpRate
1159+
single: ORTSDynamicBrakeForceRampDownRate
1160+
single: ORTSDynamicBrakeForceRampDownToZeroRate
1161+
single: ORTSDynamicBrakePowerRampUpRate
1162+
single: ORTSDynamicBrakePowerRampDownRate
1163+
single: ORTSDynamicBrakePowerRampDownToZeroRate
1164+
single: ORTSDelayTimeBeforeUpdating
1165+
1166+
When the driver sets full throttle, the control electronics may not apply the full
1167+
tractive force instantly, but it will instead linearly apply force until reaching
1168+
the target demand. This can be tuned both for traction and dynamic braking by inserting
1169+
``ORTSTractiveForceRampUpRate``, ``ORTSTractiveForceRampDownRate``,
1170+
``ORTSTractiveForceRampDownToZeroRate``, ``ORTSDynamicBrakeForceRampUpRate``,
1171+
``ORTSDynamicBrakeForceRampDownRate`` and ``ORTSDynamicBrakeForceRampDownToZeroRate``
1172+
in the .eng file. The value of each parameter determines the force increase/decrease
1173+
rate. To include ramp up/down times also for power, use the equivalent
1174+
``ORTSTractivePowerRampUpRate``, ``ORTSTractivePowerRampDownRate``,
1175+
``ORTSTractivePowerRampDownToZeroRate``, ``ORTSDynamicBrakePowerRampUpRate``,
1176+
``ORTSDynamicBrakePowerRampDownRate`` and ``ORTSDynamicBrakePowerRampDownToZeroRate``
1177+
parameters.
1178+
1179+
Example::
1180+
1181+
Engine (
1182+
ORTSTractiveForceRampUpRate ( 50kN/s )
1183+
ORTSTractiveForceRampDownRate ( 50kN/s )
1184+
ORTSTractiveForceRampDownToZeroRate ( 100kN/s )
1185+
ORTSDynamicBrakePowerRampUpRate ( 1000kW/s )
1186+
ORTSDynamicBrakeForceRampDownRate ( 50kN/s )
1187+
)
1188+
1189+
Another possibility to avoid sudden variations in tractive force while the driver
1190+
is moving the throttle, is to only update the throttle/brake demand when the lever
1191+
has not been moved for a defined amount of time. This can be implemented using the
1192+
``ORTSDelayTimeBeforeUpdating``, which has to be inserted for the desired
1193+
controller in the ``EngineControllers`` block.
1194+
1195+
Example::
1196+
1197+
Engine (
1198+
EngineControllers (
1199+
Throttle ( 0 1 0.1 0
1200+
NumNotches ( 0 )
1201+
ORTSDelayTimeBeforeUpdating ( 0.5s )
1202+
)
1203+
Brake_Dynamic ( 0 1 0.1 0
1204+
NumNotches ( 0 )
1205+
ORTSDelayTimeBeforeUpdating ( 1s )
1206+
)
1207+
)
1208+
)
11441209

11451210
Steam Locomotives
11461211
-----------------

Source/Orts.Parsers.Msts/STFReader.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ public double ReadDouble(double? defaultValue)
647647
/// </summary>
648648
// Additional entries because MSTS has multiple default units, e.g. some speeds in metres/sec and others in miles/hr
649649
[Flags]
650-
public enum UNITS
650+
public enum UNITS : ulong
651651
{
652652
/// <summary>No unit parsing is done on the {constant_item} - which is obviously fastest
653653
/// </summary>
@@ -821,6 +821,16 @@ public enum UNITS
821821
/// </summary>
822822
Energy = 1 << 29,
823823

824+
/// <summary>Valid Units: n/s, kn/s, lbf/s
825+
/// <para>Scaled to newtons per second.</para>
826+
/// </summary>
827+
ForceRate = 1 << 30,
828+
829+
/// <summary>Valid Units: w/s, kw/s, hp/s
830+
/// <para>Scaled to watts per second.</para>
831+
/// </summary>
832+
PowerRate = 1ul << 31,
833+
824834
// "Any" is used where units cannot easily be specified, such as generic routines for interpolating continuous data from point values.
825835
// or interpreting locomotive cab attributes from the ORTSExtendedCVF experimental mechanism.
826836
// "Any" should not be used where the dimensions of a unit are predictable.
@@ -1170,6 +1180,23 @@ internal double ParseUnitSuffix(ref string constant, UNITS validUnits)
11701180
case "wh": return 3.6e3f;
11711181
case "kwh": return 3.6e6f;
11721182
}
1183+
if ((validUnits & UNITS.ForceRate) > 0)
1184+
switch (suffix)
1185+
{
1186+
case "": return 1.0;
1187+
case "n/s": return 1;
1188+
case "kn/s": return 1e3;
1189+
case "lbf/s": return 4.44822162;
1190+
case "lb/s": return 4.44822162;
1191+
}
1192+
if ((validUnits & UNITS.PowerRate) > 0)
1193+
switch (suffix)
1194+
{
1195+
case "": return 1.0;
1196+
case "w/s": return 1;
1197+
case "kw/s": return 1e3;
1198+
case "hp/s": return 745.699872;
1199+
}
11731200
STFException.TraceWarning(this, "Found a suffix '" + suffix + "' which could not be parsed as a " + validUnits.ToString() + " unit");
11741201
return 1;
11751202
}

Source/Orts.Simulation/Simulation/RollingStocks/MSTSControlTrailerCar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public override string GetStatus()
263263
/// <summary>
264264
/// This function updates periodically the locomotive's motive force.
265265
/// </summary>
266-
protected override void UpdateTractiveForce(float elapsedClockSeconds, float t, float AbsSpeedMpS, float AbsWheelSpeedMpS)
266+
protected override void UpdateTractiveForce(float elapsedClockSeconds)
267267
{
268268
}
269269

0 commit comments

Comments
 (0)