The RMP Motion Controller APIs

◆ InterruptWait()

RSIEventType InterruptWait ( int32_t  milliseconds)
inherited
Description:
InterruptWait suspends the current thread until an interrupt arrives from the controller. This is commonly used while waiting for specific interrupts such as Motion Done, velocity reached, or recorder done. Please see RSIEventType for options. You can specify an extact wait time or use RSIWait.
Parameters
millisecondsMilliseconds to wait -or- an RSIWait value to return immediately or wait forever.
Returns
(RSIEventType) Event which takes place or RSIEventTypeTIMEOUT event after time elapses.
Remarks
This function is also available in RapidSequencer.
Sample Code:
UserLimitCommandPositionDirectSet
// Constants
const int AXIS_COUNT = 1;
const int USER_LIMIT_FIRST = 0; // Specify which user limit to use.
const int USER_LIMIT_SECOND = 1;
const int USER_LIMIT_COUNT = 2;
const RSIUserLimitLogic LOGIC = RSIUserLimitLogic.RSIUserLimitLogicEQ; // Logic for input value comparison.
const RSIUserLimitTriggerType TRIGGER_TYPE = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION; // Choose the how the condition (s) should be evaluated.
const RSIAction ACTION = RSIAction.RSIActionTRIGGERED_MODIFY; // Choose the action you want to cause when the User Limit triggers.
const int DURATION = 0; // Enter the time delay before the action is executed after the User Limit has triggered.
const bool ONE_SHOT = true; // if true, User Limit will only trigger ONCE
// User Limit Interrupt constants
const int COMMAND_POSITION_INDEX = 0;
const int ACTUAL_POSITION_INDEX = 1;
const int TC_COMMAND_POSITION_INDEX = 2;
const int TC_ACTUAL_POSITION_INDEX = 3;
public void UserLimitCommandPositionDirectSet()
{
// Some Necessary Pre User Limit Configuration
controller.AxisCountSet(AXIS_COUNT);
controller.UserLimitCountSet(USER_LIMIT_COUNT); // Set the amount of UserLimits that you want to use.
axis = CreateAndReadyAxis(Constants.AXIS_NUMBER); // Initialize your axis object.
// set the triggered modify values to stop very quickly
axis.TriggeredModifyDecelerationSet(Constants.DECELERATION);
axis.TriggeredModifyJerkPercentSet(Constants.JERK_PERCENT);
// USER LIMIT CONDITION 0 (trigger on digital input)
controller.UserLimitConditionSet(USER_LIMIT_FIRST, 0, LOGIC, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeDIGITAL_INPUTS), 0x400000, 0x400000); // Set your User Limit Condition (1st step to setting up your user limit)
// controller.UserLimitOutputSet(USER_LIMIT_FIRST, RSIDataType.RSIDataTypeDOUBLE, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTC_ACTUAL_POSITION), controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER), true);
controller.UserLimitConfigSet(USER_LIMIT_FIRST, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION, ONE_SHOT); // Set your User Limit Configuration. (2nd step to setting up your user limit)
// CONDITION 0 (wait for first user limit to trigger)
controller.UserLimitConditionSet(USER_LIMIT_SECOND, 0, RSIUserLimitLogic.RSIUserLimitLogicEQ, controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSERLIMIT_STATUS, USER_LIMIT_FIRST), 1, 1);
// CONDITION 1 (AND wait for Axis command velcity = 0.0)
controller.UserLimitConditionSet(USER_LIMIT_SECOND, 1, RSIUserLimitLogic.RSIUserLimitLogicEQ, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_VELOCITY), 0.0);
// OUTPUT (copy value from UserBuffer to TC.CommandPosition when trigered)
//controller.UserLimitOutputSet(USER_LIMIT_SECOND, RSIDataType.RSIDataTypeDOUBLE, controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER), axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTC_COMMAND_POSITION), true);
controller.UserLimitConfigSet(USER_LIMIT_SECOND, RSIUserLimitTriggerType.RSIUserLimitTriggerTypeCONDITION_AND, RSIAction.RSIActionNONE, 0, 0, ONE_SHOT);
// get the Axis moving
axis.ClearFaults();
axis.AmpEnableSet(true);
axis.MoveVelocity(Constants.VELOCITY, Constants.ACCELERATION);
// configure and enable interrupts
ConfigureUserLimitInterrupts(USER_LIMIT_FIRST);
ConfigureUserLimitInterrupts(USER_LIMIT_SECOND);
controller.InterruptEnableSet(true);
// wait for (and print) interrupts
WaitForInterrupts();
}
public void ConfigureUserLimitInterrupts(int userLimitIndex)
{
controller.UserLimitInterruptUserDataAddressSet(userLimitIndex, COMMAND_POSITION_INDEX, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION));
controller.UserLimitInterruptUserDataAddressSet(userLimitIndex, ACTUAL_POSITION_INDEX, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeACTUAL_POSITION));
}
public void WaitForInterrupts()
{
bool done = false;
int timeout_millseconds = 10;
while (!done)
{
RSIEventType eventType = controller.InterruptWait(timeout_millseconds);
Console.WriteLine("IRQ: " + eventType.ToString() + " at sample " + controller.InterruptSampleTimeGet());
switch (eventType)
{
case RSIEventType.RSIEventTypeUSER_LIMIT:
Console.WriteLine("UserLimit " + controller.InterruptSourceNumberGet());
Console.WriteLine("CmdPos: " + controller.InterruptUserDataDoubleGet(COMMAND_POSITION_INDEX));
Console.WriteLine("ActPos: " + controller.InterruptUserDataDoubleGet(ACTUAL_POSITION_INDEX));
Console.WriteLine("TC.CmdPos: " + controller.InterruptUserDataDoubleGet(TC_COMMAND_POSITION_INDEX));
Console.WriteLine("TC.ActPos: " + controller.InterruptUserDataDoubleGet(TC_ACTUAL_POSITION_INDEX));
break;
case RSIEventType.RSIEventTypeTIMEOUT:
done = true;
break;
default:
break;
}
}
}
Note
InterruptWait will return logged Interrupts until there are none in the FIFO buffer. Then it begin waiting with a timeout for the next.
See also
RapidCodeMotion::InterruptEnableSet, MotionController::InterruptEnableSet, RapidCodeMotion::InterruptWake, MotionController::InterruptWake
Examples
ControllerInterrupts.cpp, Homing.cs, and UserLimit.cs.
RSI::RapidCode::MotionController::UserLimitCountSet
void UserLimitCountSet(int32_t userLimitCount)
Set the number of processed UserLimits in the MotionController.
RSI::RapidCode::RapidCodeInterrupt::InterruptSourceNumberGet
int32_t InterruptSourceNumberGet()
Get the number (or index) of the object (Axis, Motor, etc) that generated the interrupt.
RSI::RapidCode::RapidCodeInterrupt::InterruptUserDataDoubleGet
double InterruptUserDataDoubleGet(uint32_t userDataIndex)
Get the user data associated with the interrupt, as a 64-bit double.
RSI::RapidCode::MotionController::UserLimitInterruptUserDataAddressSet
void UserLimitInterruptUserDataAddressSet(int32_t number, uint32_t userDataIndex, uint64_t address)
Set the User Data address based on a User Limit trigger.
RSI::RapidCode::MotionController::AxisCountSet
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
RSI::RapidCode::RSIEventType
RSIEventType
Event Types or Status Bits.
Definition: rsienums.h:911
RSI::RapidCode::MotionController::InterruptEnableSet
void InterruptEnableSet(bool enable)
Control interrupts for this class.
RSI::RapidCode::RSIUserLimitLogic
RSIUserLimitLogic
Logic options for User Limits.
Definition: rsienums.h:635
RSI::RapidCode::MotionController::UserLimitConfigSet
void UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
RSI::RapidCode::MotionController::AddressGet
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
RSI::RapidCode::RapidCodeInterrupt::InterruptWait
RSIEventType InterruptWait(int32_t milliseconds)
Suspend the current thread until an interrupt arrives from the controller.
RSI::RapidCode::MotionController::UserLimitConditionSet
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.
RSI::RapidCode::RapidCodeInterrupt::InterruptSampleTimeGet
int32_t InterruptSampleTimeGet()
Get the sample timer value when the last interrupt was generated.
RSI::RapidCode::RSIUserLimitTriggerType
RSIUserLimitTriggerType
Trigger types for UserLimits.
Definition: rsienums.h:622
RSI::RapidCode::RSIControllerAddressType
RSIControllerAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition: rsienums.h:412
RSI::RapidCode::RSIAction
RSIAction
Action to perform on an Axis.
Definition: rsienums.h:1051
RSI::RapidCode::RSIAxisAddressType
RSIAxisAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition: rsienums.h:430