MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

ControllerInterrupts.cpp

Controller Interrupts sample application.

Precondition
This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
Warning
This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires.
#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
long interruptType;
// Initialize Controller, enable interrupts
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
controller->InterruptEnableSet(true);
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
while (controller->OS->KeyGet(RSIWaitPOLL) < 0)
{
// add code here to generate interrupts (move axes, etc.)
// wait for an interrupt
interruptType = controller->InterruptWait(TIMEOUT);
if (interruptType != 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.
}