APIs, concepts, guides, and more
axis-config-phantom-axis.cs
Note
See Axis: Configuration 📜 for a detailed explanation of this sample code.
Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Config: Phantom Axis");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// get defaults
int DEFAULT_AXIS_COUNT = controller.AxisCountGet();
Console.WriteLine($"Initial Axis Count: {controller.AxisCountGet()}\n");
// add phantom axis
controller.AxisCountSet(controller.AxisCountGet() + 1);
// get phantom axis
int axisIndex = controller.AxisCountGet() - 1; // last axis [zero-based]
Axis axis = controller.AxisGet(axisIndex);
Helpers.CheckErrors(axis);
// disable all limits (not used for phantom axes)
axis.ErrorLimitActionSet(RSIAction.RSIActionNONE);
axis.HardwareNegLimitActionSet(RSIAction.RSIActionNONE);
axis.HardwarePosLimitActionSet(RSIAction.RSIActionNONE);
axis.HomeActionSet(RSIAction.RSIActionNONE);
axis.SoftwareNegLimitActionSet(RSIAction.RSIActionNONE);
axis.SoftwarePosLimitActionSet(RSIAction.RSIActionNONE);
double POSITION_TOLERANCE_MAX = Double.MaxValue / 10.0; // reduce from max slightly, so XML to string serialization and deserialization works without throwing System.OverflowException
axis.PositionToleranceCoarseSet(POSITION_TOLERANCE_MAX); // set Settling Coarse Position Tolerance to max value
axis.PositionToleranceFineSet(POSITION_TOLERANCE_MAX); // set Settling Fine Position Tolerance to max value (so Phantom axis will get immediate MotionDone when target is reached)
axis.MotorTypeSet(RSIMotorType.RSIMotorTypePHANTOM); // set the MotorType to phantom
Console.WriteLine($"After adding phantom axis..");
Console.WriteLine($"Axis count: {controller.AxisCountGet()}");
Console.WriteLine($"Phantom Axis index: {axisIndex}");
Console.WriteLine($"Motor type: {axis.MotorTypeGet()}");
Console.WriteLine($"Error limit action: {axis.ErrorLimitActionGet()}");
Console.WriteLine($"Hardware negative limit action: {axis.HardwareNegLimitActionGet()}");
Console.WriteLine($"Hardware positive limit action: {axis.HardwarePosLimitActionGet()}");
Console.WriteLine($"Home action: {axis.HomeActionGet()}");
Console.WriteLine($"Software negative limit action: {axis.SoftwareNegLimitActionGet()}");
Console.WriteLine($"Software positive limit action: {axis.SoftwarePosLimitActionGet()}");
Console.WriteLine($"Position tolerance coarse: {axis.PositionToleranceCoarseGet()}");
Console.WriteLine($"Position tolerance fine: {axis.PositionToleranceFineGet()}");
// restore defaults
controller.AxisCountSet(DEFAULT_AXIS_COUNT);
Console.WriteLine($"\nRestored Axis count: {controller.AxisCountGet()}");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
void HardwareNegLimitActionSet(RSIAction action)
Set the action that will occur when the Hardware Negative Limit Event triggers.
void HardwarePosLimitActionSet(RSIAction action)
Set the action that will occur when the Hardware Positive Limit Event triggers.
void PositionToleranceCoarseSet(double tolerance)
Set the Coarse Position Tolerance for Axis settling.
void SoftwareNegLimitActionSet(RSIAction action)
Set the action that will occur when the Software Negative Limit Event triggers.
void HomeActionSet(RSIAction action)
Set the action that will occur when the Home Event triggers.
void PositionToleranceFineSet(double tolerance)
Set the Fine Position Tolerance for Axis settling.
void ErrorLimitActionSet(RSIAction action)
Set the action that will occur when the Error Limit Event triggers.
void MotorTypeSet(RSIMotorType type)
Set the motor type.
void SoftwarePosLimitActionSet(RSIAction action)
Set the action that will occur when the Software Positive Limit Event triggers.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1115
RSIMotorType
Motor Type.
Definition rsienums.h:1311
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21