MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

Home.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
const int AXIS_NUMBER = 0;
const int VELOCITY = 8000;
const int ACCELERATION = 6000;
const int DECELERATION = 6000;
//Only used if you set max Travel distances for Various homing stages.
const int MAX_TRAVEL_TO_SWITCH = 10000;
const int MAX_TRAVEL_TO_EDGE = 100;
const int MAX_TRAVEL_TO_INDEX = 2000;
//If you wish to create a log file. Set this to 1. This is completely optional.
const int LOG_HOMING = 0;
Axis *axis;
void homeMain()
{
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
// Once Per Application Initialization
//MotionController *controller = MotionController::CreateFromSoftware(/*rmpPath*/);
// -or- Not both.
axis = controller->AxisGet(AXIS_NUMBER);
SampleAppsCPP::HelperFunctions::CheckErrors(axis);
// These is unlikely to change. If it will not. Put it in Initialization above.
axis->HomeOffsetSet(0.0);
axis->HomeVelocitySet(VELOCITY);
axis->HomeSlowVelocitySet(VELOCITY / 10); // Used for final move to index, if selected method does so.
axis->HomeAccelerationSet(ACCELERATION);
axis->HomeDecelerationSet(ACCELERATION);
// Optional Configuration for Max Travel.
axis->HomeTravelDistanceSet(RSIHomeStageSTAGE_ONE, MAX_TRAVEL_TO_SWITCH);
axis->HomeTravelDistanceSet(RSIHomeStageSTAGE_TWO, MAX_TRAVEL_TO_EDGE);
axis->HomeTravelDistanceSet(RSIHomeStageSTAGE_THREE, MAX_TRAVEL_TO_INDEX);
// May or may not be constantly enabled.
// Ready axis->
axis->ClearFaults();
axis->AmpEnableSet(true);
// Log Homing if you set it to true above.
if (LOG_HOMING)
{
axis->TraceFileSet("RapidCodeHomeTrace.txt"); // Change the file name to whatever you want.
axis->Trace(true);
}
// Begin Homing.
axis->Home();
// Close Out Logging.
if (LOG_HOMING)
{
axis->Trace(false);
axis->TraceFileClose();
}
if (axis->HomeStateGet() == true)
{
printf("Homing successful\n");
}
axis->ClearFaults();
}
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.
}