APIs, concepts, guides, and more
ControllerInterrupts.cpp
Attention
See the following Concept pages for a detailed explanation of this sample: Settling.
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.
#include "rsi.h" // Import our RapidCode Library.
#include "SampleAppsHelper.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode; // Import the RapidCode namespace
void controllerInterruptsMain()
{
const int TIMEOUT = (5000); //ms
RSIEventType interruptType;
// Initialize Controller, enable interrupts
controller->InterruptEnableSet(true);
try
{
SampleAppsHelper::StartTheNetwork(controller); // [Helper Function] Initialize the network.
while (controller->OS->KeyGet((int32_t)RSIWait::RSIWaitPOLL) < 0)
{
// add code here to generate interrupts (move axes, etc.)
// wait for an interrupt
interruptType = controller->InterruptWait(TIMEOUT);
if (interruptType != RSIEventType::RSIEventTypeTIMEOUT)
{
printf("IRQ %ld\n", interruptType);
printf("%s\n", controller->InterruptNameGet());
printf("InterruptSourceNumber = %ld\n", controller->InterruptSourceNumberGet());
printf("InterruptSampleTimer = %ld\n", controller->InterruptSampleTimeGet());
printf("\n");
}
else
{
printf("Timeout waiting for interrupts...\n");
}
}
}
catch (RsiError const& err)
{
printf("\n%s\n", err.text);
}
controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
system("pause"); // Allow time to read Console.
}
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
Definition rsi.h:111
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
@ RSIWaitPOLL
return immediately, use polling
Definition rsienums.h:1030
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void StartTheNetwork(MotionController *controller)
Starts the network communication for the given MotionController.