Set a control mode

To set a control mode, we use the SetAxisControlMode function.

Keep in mind these things:

Code

In AxisConfiguration.cpp, add the following code:

Copy
VOID SetControlMode(int Index)
{
    RtPrintf("Set a control mode.\n");

    string controlMode[10] = { "modeManual", "modeDirectPos", "modeDirectVel",
    "modeDirectTor", "modePidVel", "modePidTor", "modeMasterIntPos",
    "modeMasterIntVel", "modeMasterIntTor", "modeSlaveInt" };

    //Set the mode depending on your access mode and needs.
    McControlMode Mode = modeMasterIntPos;
    KsCommandStatus status = WaitForCommand(5, TRUE, SetAxisControlMode(Index, Mode));
    if (status.Error)
        RtPrintf("SetAxisControlMode failed: %d\n", status.ErrorId);

    else if (status.Done)
    {
        for (int i = 0; i < 10; i++)
        {
            if (Mode == i)
            {
                RtPrintf("The current control mode: %s\n\n", controlMode[i].c_str());
                break;
            }
        }
    }

    RtPrintf("\n");
}