APIs, concepts, guides, and more
userlimit-feedrate.cs
/* 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);
// 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)
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
controller.UserLimitDisable(0);
controller.UserLimitCountSet(0);
Console.WriteLine("\nUser limit feed rate change complete.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void AbortMotionObject(RapidCodeMotion motionObject)
Aborts motion on the given RapidCodeMotion object (Axis or MultiAxis), waits for motion to stop,...
Definition _helpers.cs:186
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
static void PhantomAxisReset(Axis phantomAxis)
Configures a phantom axis on the controller.
Definition _helpers.cs:144
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
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:5862
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
void UserLimitDisable(int32_t number)
Disable the processing of a User Limit.
void UserLimitConditionSet(int32_t number, int32_t conditionNumber, RSIUserLimitLogic logic, uint64_t addressOfUInt32, uint32_t userLimitMask, uint32_t limitValueUInt32)
Set the conditions for a User Limit with a 32-bit integer trigger value.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void UserLimitOutputSet(int32_t number, uint32_t andMask, uint32_t orMask, uint64_t outputPtr, bool enabled)
Configure a User Limit Output block.
void UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
void Delete(void)
Delete the MotionController and all its objects.
void UserLimitCountSet(int32_t userLimitCount)
Set the number of processed UserLimits in the MotionController.
void InterruptEnableSet(bool enable)
Control interrupts for this class.
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.
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