For gearing, we use SetAxisGear to link the master and slave axes.

In Gear.cpp, add the following code:

KsCommandStatus AssignGearSlave(int Master, int Slave)
    RtPrintf("Link a slave to the master for gearing.\n\n");

    KsCommandStatus gear = WaitForCommand(5, FALSE, SetAxisGear(
        Master,   //The index of the master axis.
        Slave,    //The index of the slave axis.
        FALSE,    //Determine whether the gear state is preserved after the motor is disabled.
        GEAR_NUMERATOR / GEAR_DENOMINATOR,   //The gear ratio.
        //For example, if the ratio is 3:2, the slave moves three units and master moves two.
        mcSetValue,   /*Master Value Source. Value of the master velocity used.
                        Can be the target velocity or the actual velocity.*/
        MAXIMUM_ACCELERATION,   //Acceleration for gearing in.
        MAXIMUM_DECELERATION,   //Deceleration for gearing in.
        MAXIMUM_JERK,           //Jerk fo gearing in.
        mcAborting              //Define how to blend the velocity of two functions.
    if (gear.Error)
        RtPrintf("SetAxisCam failed: %d\n\n", gear.ErrorId);

    return gear;



Motion command: MoveAxisVelocity

Direction: negative