APIs, concepts, guides, and more
userlimit-digital-input-two-condition.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 triggered by two digital inputs.
Uses AND logic - both inputs must be high for the output to activate.
The RMP controller's User Limits compare two different input bits to specific values (high=1 or low=0).
When both conditions match (using AND logic), the specified output bit is activated (turns high).
In this example:
- Two conditions are configured via UserLimitConditionSet() to monitor two separate inputs
- Both inputs must turn high (1) to trigger the user limit
- When triggered, UserLimitOutputSet() activates the output to high (1)
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 User Limit: Digital Input Two Condition");
// get rmp objects
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 input1 = IOPoint.CreateDigitalInput(controller, userBufferAddress, bitNumber: 1);
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, bitNumber: 2);
Helpers.CheckErrors(input0);
Helpers.CheckErrors(input1);
Helpers.CheckErrors(output0);
// configure first input condition (condition 0)
controller.UserLimitConditionSet(
number: 0,
conditionNumber: 0,
logic: RSIUserLimitLogic.RSIUserLimitLogicEQ,
addressOfUInt32: input0.AddressGet(),
userLimitMask: (uint)input0.MaskGet(),
limitValueUInt32: (uint)input0.MaskGet());
// configure second input condition (condition 1)
controller.UserLimitConditionSet(
number: 0,
conditionNumber: 1,
logic: RSIUserLimitLogic.RSIUserLimitLogicEQ,
addressOfUInt32: input1.AddressGet(),
userLimitMask: (uint)input1.MaskGet(),
limitValueUInt32: (uint)input1.MaskGet());
// configure user limit settings (AND logic for both conditions)
controller.UserLimitConfigSet(
number: 0,
triggerType: RSIUserLimitTriggerType.RSIUserLimitTriggerTypeCONDITION_AND,
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 both inputs to trigger...");
// verify output is initially off
if (output0.Get())
throw new Exception("ERROR: Output should not be triggered yet");
// set first input high (bit 0 only) - AND condition not met
controller.MemorySet(input0.AddressGet(), 0b0001); // only bit 0 is high
if (output0.Get())
throw new Exception("ERROR: Output should not trigger with only one input");
// set BOTH inputs high (bits 0 and 1) - AND condition met
controller.MemorySet(input1.AddressGet(), 0b0011); // both bit 0 AND bit 1 are 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 both inputs were 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 - both inputs high, output activated");
// cleanup
controller.UserLimitDisable(0);
output0.Set(false);
Console.WriteLine("\nUser limit digital input two condition complete.");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
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
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
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
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21