MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

CustomEtherCATHome.cpp
#include "rsi.h" // Import our RapidCode Library.
using namespace RSI::RapidCode;
// user defined options
const int AXIS_NUMBER = 1; // which axis?
const int NETWORK_INPUT_INDEX = 22; // which network PDO input?
const int HOME_BIT_INDEX = 0; // home input is which bit index? (0-based)
const int VELOCITY = 80000;
const int ACCELERATION = 600000;
const int DECELERATION = 600000;
void PrintRapidCodeErrors(RapidCodeObject *rsiClass)
{
RsiError *err;
bool hasErrors = false;
while (rsiClass->ErrorLogCountGet() > 0)
{
err = rsiClass->ErrorLogGet();
printf("%s\n", err->text);
hasErrors = true;
}
if (hasErrors)
exit(1);
}
void customEtherCATHomeMain()
{
uint64 networkAddress;
char* inputName;
// create MotionController class
PrintRapidCodeErrors(controller);
// create Axis class
Axis *axis = controller->AxisGet(AXIS_NUMBER);
PrintRapidCodeErrors(axis);
try
{
axis->Abort();
axis->ClearFaults();
axis->AmpEnableSet(true);
{
printf("Error, should be in IDLE state.\n");
exit(1);
}
inputName = controller->NetworkInputNameGet(NETWORK_INPUT_INDEX);
printf("Input name is %s \n", inputName);
networkAddress = controller->NetworkInputAddressGet(NETWORK_INPUT_INDEX);
axis->HomeLimitCustomConfigSet(networkAddress, HOME_BIT_INDEX);
axis->HomeVelocitySet(VELOCITY);
axis->HomeSlowVelocitySet(VELOCITY);
axis->HomeAccelerationSet(ACCELERATION);
axis->HomeDecelerationSet(ACCELERATION);
axis->HomeOffsetSet(0.0);
axis->Home();
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.
}