MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

DedicatedIO.cpp

Dedicated IO sample application.

This application demonstrates how to access Dedicated IO. See the Dedicated I/O topic page for additional information.

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 DedicatedIOMain()
{
// Constants
const int AXIS_NUMBER = 0; // Specify the axis that will be used.
printf("Dedicated Inputs:");
char rmpPath[] = "C:\\RSI\\X.X.X\\"; // Insert the path location of the RMP.rta (usually the RapidSetup folder)
// Initialize MotionController class.
MotionController *controller = MotionController::CreateFromSoftware(/*rmpPath*/); // NOTICE: Uncomment "rmpPath" if project directory is different than rapid setup directory.
SampleAppsCPP::HelperFunctions::CheckErrors(controller); // [Helper Function] Check that the axis has been initialize correctly.
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
Axis *axis = controller->AxisGet(AXIS_NUMBER); // initialize Axis class
SampleAppsCPP::HelperFunctions::CheckErrors(axis); // [Helper Function] Check that the axis has been initialize correctly.
printf("Axis %i:\n", AXIS_NUMBER);
// Retrieve dedicated inputs with generic and specific function.
printf("RSIMotorDedicatedInLIMIT_HW_NEG: %i and %i\n",
axis->NegativeLimitGet());
printf("RSIMotorDedicatedInLIMIT_HW_POS: %i and %i\n",
axis->PositiveLimitGet());
printf("RSIMotorDedicatedInHOME: %i and %i\n",
axis->HomeSwitchGet());
printf("RSIMotorDedicatedInAMP_FAULT: %i and %i\n",
axis->AmpFaultGet());
printf("RSIMotorDedicatedInAMP_ACTIVE: %i and %i\n",
axis->AmpEnableGet());
}
catch (RsiError const& err)
{
printf("%s\n", err.text); // If there are any exceptions/issues this will be printed out.
}
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.
}