MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

CustomHome.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
// user defined options
const int AXIS_NUMBER = 0;
const int CAPTURE_SOURCE = RSIMotorDedicatedInHOME;
const int HOME_LIMIT_NETWORK_INDEX = 99; //You may want to discover this rather than hard code it.
const int HOME_LIMIT_SIG_BIT = 0;
/* Motion Parameters */
const int VELOCITY = 5000;
const int ACCELERATION = 80000;
const int DECELERATION = 80000;
const int POSITION = 0;
void customHomeMain()
{
// Initialize MotionController class.
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
// initialize Axis class
Axis *axis = controller->AxisGet(AXIS_NUMBER);
SampleAppsCPP::HelperFunctions::CheckErrors(axis);
uint64 homeLimitAddress = controller->NetworkInputAddressGet(HOME_LIMIT_NETWORK_INDEX);
axis->HomeLimitCustomConfigSet(homeLimitAddress, HOME_LIMIT_SIG_BIT);
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
// Ready Axis
axis->Abort();
axis->ClearFaults();
axis->AmpEnableSet(true);
printf("Looking for Home...\n\n");
// commanding a velocity move. This program assumes that the Custom Home will trigger at some point.
axis->MoveVelocity(VELOCITY, ACCELERATION);
// wait (sleep) until motion done interrupt occurs
if ((controller->NetworkInputValueGet(HOME_LIMIT_NETWORK_INDEX) & HOME_LIMIT_SIG_BIT) > 0) //On Home Limit
{
axis->HomeStateSet(true);
}
else
{
//Evaluate why we aren't on custom home.
}
// setup Home Action (the home action will not trigger)
axis->ClearFaults();
axis->AmpEnableSet(false);
}
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.
}