The RMP Motion Controller APIs
ControllerInterrupts.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
void controllerInterruptsMain()
{
const int TIMEOUT = (5000); //ms
RSIEventType interruptType;
// Initialize Controller, enable interrupts
controller->InterruptEnableSet(true);
try
{
HelperFunctions::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.
}
RSI::RapidCode::RapidCodeInterrupt::InterruptSourceNumberGet
int32_t InterruptSourceNumberGet()
Get the number (or index) of the object (Axis, Motor, etc) that generated the interrupt.
RSI::RapidCode::MotionController::OS
RapidCodeOS * OS
Provides access to operating system (Windows) features.
Definition: rsi.h:3569
RSI::RapidCode::RapidCodeInterrupt::InterruptNameGet
const char *const InterruptNameGet()
Get the text name of an interrupt type.
RSI::RapidCode::RsiError
The RsiError object contains information about any RapidCode API object's error/exception.
Definition: rsi.h:90
RSI::RapidCode::MotionController::Delete
void Delete(void)
Delete the MotionController and all its objects.
RSI::RapidCode::RapidCodeOS::KeyGet
int32_t KeyGet(int32_t milliseconds)
Wait for a key to be pressed and return its value.
RSI::RapidCode::RSIEventType
RSIEventType
Event Types or Status Bits.
Definition: rsienums.h:871
RSI::RapidCode::MotionController::CreateFromSoftware
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
RSI::RapidCode::MotionController::InterruptEnableSet
void InterruptEnableSet(bool enable)
Control interrupts for this class.
RSI::RapidCode
RSI::RapidCode::RSIEventType::RSIEventTypeINVALID
@ RSIEventTypeINVALID
RSI::RapidCode::RapidCodeInterrupt::InterruptWait
RSIEventType InterruptWait(int32_t milliseconds)
Suspend the current thread until an interrupt arrives from the controller.
RSI::RapidCode::RapidCodeInterrupt::InterruptSampleTimeGet
int32_t InterruptSampleTimeGet()
Get the sample timer value when the last interrupt was generated.
RSI::RapidCode::MotionController
The MotionController object represents the RMP INtime soft motion controller.
Definition: rsi.h:743
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
HelperFunctions.StartTheNetwork
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Definition: HelperFunctions.cs:109