MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

SCurveMotion.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
void SCurveMotionMain()
{
using namespace RSI::RapidCode;
// Constants
const int AXIS_NUMBER = 0; // Specify which axis/motor to control
const int RELATIVE_POSITION = 100; // Specify the position to travel to.
const int USER_UNITS = 1048576; // Specify your counts per unit / user units. (the motor used in this sample app has 1048576 encoder pulses per revolution)
const int VELOCITY = 10; // Specify your velocity. - units: Units/Sec (it will do "1048576 counts / 1 motor revolution" per second)
const int ACCELERATION = 10; // Specify your acceleration. - units: Units/Sec^2
const int DECELERATION = 10; // Specify your deceleration. - units: Units/Sec^2
const int JERK_PCT = 50; // Specify your jerk percent (0.0 to 100.0)
// Insert the path location of the RMP.rta (usually the RapidSetup folder)
char rmpPath[] = "C:\\RSI\\X.X.X\\";
// Initialize MotionController class.
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
Axis *axis = controller->AxisGet(AXIS_NUMBER); // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)
SampleAppsCPP::HelperFunctions::CheckErrors(axis); // [Helper Function] Check that the axis has been initialize correctly.
axis->UserUnitsSet(USER_UNITS); // Specify the counts per Unit.
axis->ErrorLimitTriggerValueSet(1); // Specify the position error limit trigger. (Learn more about this on our support page)
axis->PositionSet(0); // Make sure motor starts at position 0 everytime.
axis->Abort(); // If there is any motion happening, abort it.
axis->ClearFaults(); // Clear faults.>
axis->AmpEnableSet(true); // Enable the motor.
printf("SCurve Motion Example\n");
printf("SCurve Profile: In Motion...\n");
axis->MoveSCurve(RELATIVE_POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PCT); // Command SCurve Motion
axis->MotionDoneWait(); // Wait for motion to finish
printf("SCurve Profile: Completed\n");
axis->AmpEnableSet(false); // Disable the motor
}
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.
}