homingSlave

homingSlave uses a servo drive's homing features to home an axis. To use homingSlave, you must select a homing mode provided by your servo drive first, and then you can configure the homing parameters.

Process of using homingSlave

The following process shows how homingSlave is done:

SetAxisParameter (select a homing mode provided by a servo drive) -> HomeAxis (select homingSlave and home an axis)

The parameters used in SetAxisParameter are in the McAxisParameter type.

Functions

SetAxisParameter: writes a value of a vendor-specific parameter. The parameters are defined in McAxisParameter.

HomeAxis: commands the axis to perform the "search home" sequence.

Code

We divide the homingSlave code into steps to explain. In the last part, we combine all the code for you to see the completed one.

In Homing.cpp, add the following code:

  1. Use SetAxisParameter to select mcSlaveHomingmode and a homing mode provided by a servo drive. You need to check the values of the homing modes in your drive manual. We use WaitForCommand to give it some time to finish.
  2. Copy
    VOID HomingSlave(int Index)
    {
        RtPrintf("Home an axis using homingSlave.\n\n");
        
        KsCommandStatus status = WaitForCommand(5, FALSE, SetAxisParameter(Index, mcSlaveHomingMode,
            35, mcImmediately));
        if (status.Error)
            RtPrintf("SetAxisParameter failed: %d\n", status.ErrorId);
  3. Use HomeAxis to home your axis. We use WaitForCommand to give it some time to finish.
  4. Copy
        KsCommandStatus home = WaitForCommand(30, TRUE, HomeAxis(Index, 0, HOMING_HIGH_VELOCITY,
            HOMING_LOW_VELOCITY, HOMING_ACCELERATION, HOMING_DECELERATION, MAXIMUM_JERK,
            HOMING_DIRECTION, homingSlave));
        
        if (home.Error)
            RtPrintf("homingSlave failed: %d\n", home.ErrorId);
        
        else if (home.Done)
            RtPrintf("homingSlave is completed.\n\n");
    }

Complete code

The complete code should be as follows:

Copy
homingSlave
VOID HomingSlave(int Index)
{
    RtPrintf("Home an axis using homingSlave.\n\n");
    
    KsCommandStatus status = WaitForCommand(5, FALSE, SetAxisParameter(Index, mcSlaveHomingMode,
        35, mcImmediately));
    if (status.Error)
        RtPrintf("SetAxisParameter failed: %d\n", status.ErrorId);
    
    KsCommandStatus home = WaitForCommand(30, TRUE, HomeAxis(Index, 0, HOMING_HIGH_VELOCITY,
        HOMING_LOW_VELOCITY, HOMING_ACCELERATION, HOMING_DECELERATION, MAXIMUM_JERK,
        HOMING_DIRECTION, homingSlave));
    
    if (home.Error)
        RtPrintf("homingSlave failed: %d\n", home.ErrorId);
    
    else if (home.Done)
        RtPrintf("homingSlave is completed.\n\n");
}

 

Output: