APIs, concepts, guides, and more

◆ UserLimitConditionSet() [2/2]

void UserLimitConditionSet ( int32_t number,
int32_t conditionNumber,
RSIUserLimitLogic logic,
uint64_t addressOfUInt32,
uint32_t userLimitMask,
uint32_t limitValueUInt32 )
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
*addressOfUInt32Use any address in the controller (see sample code).
userLimitMaskA 32-bit AND mask, the limit ANDs the value stored in address with this mask.
limitValueUInt3232-bit value to be compared with the value stored in address after it is ANDed with the mask.

Part of the User Limit method group.

Sample Code:
IO: User Limits
/* This sample demonstrates how to configure a user limit triggered by a single digital input.
When the input matches the specified value, the configured output is activated.
Uses simulated IO with user buffer memory for demonstration purposes.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 User Limit: Digital Input One Condition");
// get rmp objects
MotionController controller = MotionController.Get();
try
{
Helpers.CheckErrors(controller);
// configure user limits
controller.UserLimitCountSet(1); // set the amount of user limits to use
controller.InterruptEnableSet(true); // enable user limit interrupts
// create simulated io using user buffer memory
ulong userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0);
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, bitNumber: 0);
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, bitNumber: 1);
Helpers.CheckErrors(output0);
// configure user limit condition
controller.UserLimitConditionSet(
number: 0,
conditionNumber: 0,
logic: RSIUserLimitLogic.RSIUserLimitLogicEQ,
addressOfUInt32: input0.AddressGet(),
userLimitMask: (uint)input0.MaskGet(),
limitValueUInt32: (uint)input0.MaskGet());
// configure user limit settings
controller.UserLimitConfigSet(
number: 0,
triggerType: RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION,
action: RSIAction.RSIActionNONE,
actionAxis: 0,
duration: 0);
// configure user limit output
controller.UserLimitOutputSet(
number: 0,
andMask: (uint)output0.MaskGet(),
orMask: (uint)output0.MaskGet(),
outputPtr: output0.AddressGet(),
enabled: true);
Console.WriteLine("Waiting for input trigger...");
// verify output is initially off
if (output0.Get())
throw new Exception("ERROR: Output should not be triggered yet");
// set input high (bit 0) - condition met
controller.MemorySet(input0.AddressGet(), 0b0001); // bit 0 is high
// wait for user limit interrupt to confirm trigger
if (controller.InterruptWait(1000) != RSIEventType.RSIEventTypeUSER_LIMIT)
throw new Exception("ERROR: User limit did not trigger when input was high");
// verify output was activated
if (!output0.Get())
throw new Exception("ERROR: Output should be high after user limit triggered");
Console.WriteLine("✓ User limit triggered successfully - input high, output activated");
// cleanup
output0.Set(false);
controller.UserLimitDisable(0);
controller.UserLimitCountSet(0);
Console.WriteLine("\nUser limit digital input one condition complete.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
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
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
uint64_t AddressGet()
Get the Host Address for the I/O point.
void Set(bool state)
Set the state of a Digital Output.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
static IOPoint * CreateDigitalOutput(Axis *axis, RSIMotorDedicatedOut motorDedicatedOutNumber)
Create a Digital Output from an Axis' Dedicated Output bits.
bool Get()
Get the state of Digital Input or Output.
int32_t MaskGet()
Get the bit mask for the I/O point.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
Definition rsi.h:11550
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Definition rsienums.h:405
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
RSIUserLimitLogic
Logic options for User Limits.
Definition rsienums.h:646
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1115
RSIUserLimitTriggerType
Trigger types for UserLimits.
Definition rsienums.h:633
Note
Logic evaluates as follows: VALUE_AT_ADDRESS RSIUserLimitLogic LIMIT_VALUE' E.g. A limit with logic RSIUserLimitLogic.RSIUserLimitLogicGT Would be true when 'VALUE_AT_ADDRESS > LIMIT_VALUE'.
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