APIs, concepts, guides, and more
axis-config-phantom-axis.cs
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Config Phantom Axis");
// get rmp objects
using MotionController controller = MotionController.Get();
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 axisNumber = controller.AxisCountGet() - 1; // last axis [zero-based]
Axis axis = controller.AxisGet(axisNumber);
// 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: {axisNumber}");
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
}
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
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:5870
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
int32_t AxisCountGet()
Get the number of axes processing.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the 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