APIs, concepts, guides, and more
axis-status.cs
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Status");
// get rmp objects
using MotionController controller = MotionController.Get();
try
{
Helpers.CheckErrors(controller);
Axis axis = controller.AxisGet(Constants.AXIS_INDEX);
// get axis state
RSIState state = axis.StateGet();
Console.WriteLine("Axis state: " + state);
switch (state)
{
case RSIState.RSIStateIDLE:
case RSIState.RSIStateMOVING:
break;
case RSIState.RSIStateERROR:
case RSIState.RSIStateSTOPPING_ERROR:
case RSIState.RSIStateSTOPPED:
case RSIState.RSIStateSTOPPING:
RSISource source = axis.SourceGet(); // SourceGet returns the RSISource enum name of the first status bit that is active. (Ex: RSISourceAMP_FAULT)
string sourceName = axis.SourceNameGet(source); // SourceNameGet returns the first status bit which is set on an Axis or MultiAxis.
Console.WriteLine("Axis source error: " + sourceName);
break;
}
// get axis status bits (works for all RSIEventTypes)
bool isAmpFaultActive = axis.StatusBitGet(RSIEventType.RSIEventTypeAMP_FAULT);
bool isPosErrLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_ERROR);
bool isHWNegLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_NEG);
bool isHWPosLimActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_POS);
Console.WriteLine($"Amp Fault Active: {isAmpFaultActive}");
Console.WriteLine($"Position Error Limit Active: {isPosErrLimActive}");
Console.WriteLine($"Hardware Negative Limit Active: {isHWNegLimActive}");
Console.WriteLine($"Hardware Positive Limit Active: {isHWPosLimActive}");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
const int AXIS_INDEX
Default: 0.
Definition _constants.cs:12
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
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.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
const char *const SourceNameGet(RSISource source)
Get the name (string) of the source of an error for an Axis or MultiAxis.
bool StatusBitGet(RSIEventType bitMask)
Return the state of a status bit.
RSIState StateGet()
Get the Axis or MultiAxis state.
RSISource SourceGet()
Get the source of an error state for an Axis or MultiAxis.
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
RSISource
Possible sources that have caused an Error state.
Definition rsienums.h:1014