The RMP Motion Controller APIs

◆ UserLimitConditionSet() [1/2]

void UserLimitConditionSet ( int32_t number,
int32_t conditionNumber,
RSIUserLimitLogic logic,
uint64_t addressOfDouble,
double limitValueDouble )
Description:
UserLimitConditionSet set one of the conditions for a User Limit.
Parameters
numberThe index of the UserLimit. Starts from 0 and goes to (UserLimitCountGet - 1).
conditionNumberThis should be 0 or 1, User Limits only support two conditions.
logicUse RSIUserLimitLogic
*addressOfDoubleUse any address in the controller (see sample code).
limitValueDouble64-bit double value to be compared with the value stored at the address specified.
Remarks
This function is also available in RapidSequencer.

Part of the User Limit method group.

Sample Code:
User Limits
// Constants
const int INPUT_INDEX = 0; // This is the index of the digital input you will use to trigger the user limit.
const int OUTPUT_INDEX = 1; // This is the index of the digital output that will go active when the user limit triggers.
controller.AxisCountSet(1); // The number of user limits must not be greater than the number of axis and must be set before the number of user limits
controller.UserLimitCountSet(1); // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
controller.InterruptEnableSet(true); // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)
UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabing an memory address to store a simulated IO point.
//Instead of using physical IO we will use simulated IO using a memory address as simulated IO. See the IO sample apps to see how to use a physical IO instead.
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX); // Create a simulated IOpoint using userBuffer memory.
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
//-------- PARAMETERS FOR UserLimitConditionSet --------
int userLimitNumber = 0; // Specify which user limit to use.
int condition = 0; // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
RSIUserLimitLogic logic = RSIUserLimitLogic.RSIUserLimitLogicEQ; // Logic for input value comparison.
UInt64 inputAddress = input0.AddressGet(); // Use IOPoint or manually set using controller.NetworkInputAddressGet(INPUT_INDEX); for Beckhoff 10 was the index of 1st input. (To check your IO indexes go to RapidSetup -.
uint test = (uint)input0.MaskGet();
uint inputMask = (uint)input0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
uint limtValue = (uint)input0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
// [1] Configure the input's trigger condition.
controller.UserLimitConditionSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use
condition, // (Condition Number) - Specify how many inputs you want to compare.
logic, // (Comparison Logic) - Specify the how the input value(s) will be compared
inputAddress, // (Input Address) - Specify the address of the input that will be compared.
inputMask, // (Input Mask) - Specify the bits in an address which need to be used when comparing inputs.
limtValue); // (Limit Value) - Specify the value to be compared with.
//-------- PARAMETERS FOR UserLimitConfigSet --------
RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION;
RSIAction action = RSIAction.RSIActionNONE;
int axisNumber = 0;
int duration = 0;
// [2] Configure and Enable the user limit.
controller.UserLimitConfigSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use.
triggerType, // (Trigger Type) - Specify how your condition should be evalutated.
action, // (User Limit Action) - Specify the action you want to cause on the axis when the user limit triggers.
axisNumber, // (Current Axis) - Specify the axis that the action (defined above) will occur on.
duration); // (Output Timer) - Specify the time delay before the action is executed after the User Limit has triggered.
//-------- PARAMETERS FOR UserLimitOutputSet --------
uint andMask = (uint)output0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
uint orMask = (uint)output0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
UInt64 outputAddress = output0.AddressGet(); //Alternatively set manually using: controller.NetworkOutputAddressGet(OUTPUT_INDEX);
bool enableOutput = true;
// [3] Configure what the output will be. (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
controller.UserLimitOutputSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use.
andMask, // (Logic AND Mask) - Specify the value that the digital output will be AND-ed with.
orMask, // (Logic OR Mask) - Specify the value that the digital output will be OR-ed with.
outputAddress, // (Output Address) - Specify the digital output address.
enableOutput); // (Enable Output Set) - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.
while (controller.InterruptWait(250) != RSIEventType.RSIEventTypeUSER_LIMIT) // Loop will execute every 250 ms
{
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
controller.MemorySet(input0.AddressGet(), 1);
}
Assert.True(output0.Get(), "We expect the output to be triggered");
controller.UserLimitDisable(userLimitNumber); // Disable User Limit.
output0.Set(false); // Disable User Limit.
Note
Be sure to user the correct overload of UserLimitConditionSet depending on if you have a 64-bit double or 32-bit integer trigger value.
See also
UserLimitConfigSet , UserLimitOutputSet