APIs, concepts, guides, and more
userlimit-feedrate.cs
Note
See IO: User Limits 📜 for a detailed explanation of this sample code.
Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
/* This sample demonstrates how to configure a user limit to change the feed rate when the axis reaches a specified position.
The user limit triggers when the command position exceeds the trigger value.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 User Limit: Feed Rate Change at Position");
// set sample config params
const int CONDITION = 0;
const double POSITION_TRIGGER_VALUE = 5.0;
const double DEFAULT_FEED_RATE = 1.0;
const double DESIRED_FEED_RATE = 2.0;
const int DURATION = 0;
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// configure user limits
controller.UserLimitCountSet(1);
controller.InterruptEnableSet(true);
// get axis
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(axis);
Helpers.PhantomAxisReset(axis);
// set initial feed rate
axis.FeedRateSet(DEFAULT_FEED_RATE);
Console.WriteLine($"Initial Feed Rate: {axis.FeedRateGet()}");
// configure user limit condition (trigger when position > POSITION_TRIGGER_VALUE)
controller.UserLimitConditionSet(
number: 0,
conditionNumber: CONDITION,
logic: RSIUserLimitLogic.RSIUserLimitLogicGT,
addressOfDouble: axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION),
limitValueDouble: POSITION_TRIGGER_VALUE);
// configure user limit settings
controller.UserLimitConfigSet(
number: 0,
triggerType: RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION,
action: RSIAction.RSIActionNONE,
actionAxis: axis.NumberGet(),
duration: DURATION);
// configure user limit output to change feed rate
controller.UserLimitOutputSet(
number: 0,
limitValueDouble: DESIRED_FEED_RATE,
outputPtr: axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTARGET_FEEDRATE),
enabled: true);
Console.WriteLine($"Moving to position {POSITION_TRIGGER_VALUE + 1}...");
Console.WriteLine($"Feed rate will change to {DESIRED_FEED_RATE} when position > {POSITION_TRIGGER_VALUE}");
// start motion past the trigger position
axis.AmpEnableSet(true);
axis.MoveSCurve(POSITION_TRIGGER_VALUE + 1);
// verify feed rate changed
double finalFeedRate = axis.FeedRateGet();
Console.WriteLine($"Final Feed Rate: {finalFeedRate}");
if (finalFeedRate == DESIRED_FEED_RATE)
Console.WriteLine("✓ User limit triggered - feed rate changed successfully");
else
Console.WriteLine($"✗ Feed rate did not change (expected: {DESIRED_FEED_RATE}, actual: {finalFeedRate})");
// cleanup
Helpers.AbortMotionObject(axis);
controller.UserLimitDisable(0);
controller.UserLimitCountSet(0);
Console.WriteLine("\nUser limit feed rate change complete.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
Definition _constants.cs:3
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:11
uint64_t AddressGet(RSIAxisAddressType addressType)
Get the an address for some location on the Axis.
void MoveSCurve(double position, double vel, double accel, double decel, double jerkPct)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
int32_t MotionDoneWait()
Waits for a move to complete.
double FeedRateGet()
Get the axis feed rate.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
void FeedRateSet(double rate)
Set the feed rate for an Axis.
int32_t NumberGet()
Get the axis number.
RSIUserLimitLogic
Logic options for User Limits.
Definition rsienums.h:646
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1115
RSIAxisAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:434
RSIUserLimitTriggerType
Trigger types for UserLimits.
Definition rsienums.h:633
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21