Additive move

The way Additive moves an axis is "distance." Just like Relative, you decide the distance your axis moves. The difference is that Additive adds a distance after the axis reaches a position or travels a distance commanded by the previous function. Additive can be used independently or with Absolute or Relative.

Function

MoveAxisAdditive: moves an axis a specified distance from the last commanded position.

WaitForCommand: waits for a command to be finished.

GetAnAxisPosition: displays the set and actual positions of an axis. For further details, see Get and set values.

MoveAxisAdditive

MoveAxisAdditive moves an axis from the last commanded position. The axis stops after it travels the specified distance.

Starting point: this is where your axis starts traveling. It is zero.

Relative distance: the relative distance your axis travels. It is 10000.

Absolute position: the target position your axis reaches. It is 10000, which is the position MoveAxisAdditive starts to move.

Additive distance: the additional distance the axis will move after it reaches a position or travels a distance commanded by the previous motion command. It is 4000.

Code

In SingleAxisMotion.cpp, add the following code. Notice that we didn't use SetAxisPositionOffset to set a starting position, because we want to add a distance from the last commanded position. If you set a starting position, MoveAxisAdditive will act like MoveAxisRelative.

Copy

MoveAxisAdditive

VOID MoveAdditive(int Index, double Distance)
{
    RtPrintf("Make an additional move.\n\n");

    //Start an additive move.
    KsCommandStatus status = WaitForCommand(30, FALSE, MoveAxisAdditive(Index, Distance,
        MAXIMUM_VELOCITY, MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK, mcAborting));
    if (status.Error)
        RtPrintf("MoveAxisAdditive failed: %d\n", status.ErrorId);

    //Wait a few cycles to get the correct end positions.
    Sleep(5);
    RtPrintf("End position:\n");
    GetAnAxisPosition(Index);
}

 

Output:

The output shows the use of MoveAxisRelative and MoveAxisAdditive.

MoveAxisRelative Distance: 9000

MoveAxisAdditive Distance: -7000

If you use MoveAxisAdditive independently, the position will be -7000.