APIs, concepts, guides, and more
axis-homing-akd-drive.cs
/* This sample application demonstrates drive-based homing with a Kollmorgen AKD drive using the RapidCode .NET API.
AKD Drive-based ASCII homing uses preloaded methods available on the drive.
This allows for homing to be performed entirely in the drive without network latencies producing more accurate results.
Drive homing is the recommended homing strategy since it avoids network latencies by having the drive execute the homing routine.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Homing: AKD Drive");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// check is network is started
if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL)
{
Console.WriteLine("Network not started. Please start it before running this app.");
return;
}
// get axis
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
// check Axis type
if (axis.NetworkNode.TypeGet() != RSINodeType.RSINodeTypeKOLLMORGEN_AKD)
{
Console.WriteLine("Wrong Axis type. This sample requires an AKD Axis.");
return;
}
// 1. get the drive ready
axis.OperationModeSet(RSIOperationMode.RSIOperationModeHOMING_MODE); // set mode to homing mode
axis.NetworkNode.AKDASCIICommand("DRV.OPMODE 2"); // set drive operation mode (0=current, 1=velocity, 2=position)
axis.NetworkNode.AKDASCIICommand("HOME.AUTOMOVE 0"); // 0=disabled, 1=homing starts when drive enabled
// Make sure you know your motor's position, velocity, and acceleration units before you send any values
// 2. set limit switches
axis.NetworkNode.AKDASCIICommand("DIN5.MODE 18"); // set digital input modes - DI5 is now positive limit switch
axis.NetworkNode.AKDASCIICommand("DIN5.INV 1"); // set polarity - DI5 is now active when low
axis.NetworkNode.AKDASCIICommand("DIN6.MODE 19"); // set digital input modes - DI6 is now negative limit switch
axis.NetworkNode.AKDASCIICommand("DIN6.INV 1"); // set polarity - DI6 is now active when low
// 3. configure drive homing parameters
axis.NetworkNode.AKDASCIICommand("HOME.MODE 1"); // select homing method (MODE1 = find limit input)
axis.NetworkNode.AKDASCIICommand("HOME.V 20"); // set homing velocity
axis.NetworkNode.AKDASCIICommand("HOME.ACC 200"); // set homing acceleration
axis.NetworkNode.AKDASCIICommand("HOME.DEC 200"); // set homing deceleration
axis.NetworkNode.AKDASCIICommand("HOME.DIR 0"); // set homing direction (0=negative, 1=positive)
axis.NetworkNode.AKDASCIICommand("HOME.P 0"); // set home position
axis.NetworkNode.AKDASCIICommand("HOME.DIST 0"); // set homing distance
axis.NetworkNode.AKDASCIICommand("HOME.MAXDIST 0"); // set max homing distance
axis.NetworkNode.AKDASCIICommand("HOME.IPEAK"); // set peak current
// 4. get the axis ready
axis.ErrorLimitActionSet(RSIAction.RSIActionNONE); // set action to none so we don't get position error while drive is in control
axis.Abort(); // disable axis
axis.ClearFaults(); // clear any faults
axis.AmpEnableSet(true); // enable the axis
System.Threading.Thread.Sleep(100); // allow time for amp enable
// 5. start homing
axis.NetworkNode.AKDASCIICommand("HOME.MOVE"); // start homing procedure (active in opmode 2 only)
Console.WriteLine("HOME.MOVE command sent");
// 6. check is homing done
UInt16 statusWord;
int isHomed = 0;
int axisIdx = axis.NumberGet();
while (isHomed != 1) // when isHomed = 1, homing has finished
{
statusWord = axis.NetworkNode.StatusWordGet(axisIdx);
isHomed = statusWord >> 12; // get 12th bit only - tells us homing is done when it goes high
}
Console.WriteLine("Axis homed");
// 7. cleanup
axis.OriginPositionSet(0.0); // set origin to 0 (needed for repeated use)
axis.Abort(); // disable the axis
axis.OperationModeSet(RSIOperationMode.RSIOperationModeINTERPOLATED_POSITION_MODE); // restore mode of operation
axis.ErrorLimitActionSet(RSIAction.RSIActionABORT); // restore position error action
}
// 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 OriginPositionSet(double position)
Set the origin position.
void OperationModeSet(RSIOperationMode mode)
Set the axis operation mode.
NetworkNode * NetworkNode
Gets the associated NetworkNode object.
Definition rsi.h:5900
void ErrorLimitActionSet(RSIAction action)
Set the action that will occur when the Error 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.
RSINetworkState NetworkStateGet()
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
char * AKDASCIICommand(const char *const command)
Send a Kollmorgen AKD ASCII command (NodeType must equal KOLLMORGEN_AKD)
uint16_t StatusWordGet(int32_t axisIndex)
Get the DS402 status word.
RSINodeType TypeGet()
Get the node type, as determined by the Vendor ID and Product Code.
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void Abort()
Abort an axis.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
int32_t NumberGet()
Get the axis number.
RSINetworkState
State of network.
Definition rsienums.h:568
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1115
RSINodeType
Valid Node types.
Definition rsienums.h:677
RSIOperationMode
DS402 modes of operation.
Definition rsienums.h:1331