Absolute move

The way Absolute moves an axis is "position." You decide the position your axis moves to. The starting point is the axis' current position, and the end point is the target position. The target position is counted from the origin in the specified coordinate system.

Functions

MoveAxisAbsolute: moves an axis to an absolute position.

MoveAxisContinuousAbsolute: moves an axis to an absolute position. After that, the axis keeps moving using the EndVelocity.

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.

MoveAxisAbsolute

MoveAxisAbsolute moves an axis from the starting point to end point. The axis stops after it reaches the end point.

Starting point: this is where your axis is now. It is zero.

End point: the target position your axis will move to. It is 10000.

Notice the following parameters:

Code

In SingleAxisMotion.cpp, add the following code:

Copy

MoveAxisAbsolute

VOID MoveAbsolute(int Index, double Target)
{
    RtPrintf("Make an absolute move.\n\n");

    //Start an absolute move.
    KsCommandStatus status = WaitForCommand(30, TRUE, MoveAxisAbsolute(Index, Target, MAXIMUM_VELOCITY, 
        MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK, mcPositiveDirection, mcAborting));
    if (status.Error)
        RtPrintf("MoveAxisAbsolute failed: %d\n", status.ErrorId);

    //Wait a few cycles to get the correct end positions.
    Sleep(5);

    RtPrintf("End position:\n");
    GetAnAxisPosition(Index);
}

MoveAxisContinuousAbsolute

MoveAxisContinuousAbsolute is the function making a continuous absolute move, for which an axis continues to travel using the end velocity after it reaches the target position. Since MoveAxisContinuousAbsolute keeps moving an axis, you need to use HaltAxis or StopAxis to stop its move. For more information about how to stop an axis, see Stop a movement.

Notice the following parameters:

Code

In SingleAxisMotion.cpp, add the following code. Notice that we don't use WaitForCommand for MoveAxisContinuousAbsolute. If you use it, MoveAxisContinuousAbsolute will act like MoveAxisAbsolute because the axis won't keep moving after it reaches the target. To stop a continuous move, we use HaltAxis, which is written in another function. See Stop a movement > Normal stop.

Copy

MoveAxisContinuousAbsolute

VOID MoveContinuousAbsolute(int Index, double Target)
{
    RtPrintf("Make a continuous absolute move.\n\n");

    //Start a continuous absolute move.
    KsCommandStatus status = MoveAxisContinuousAbsolute(Index, Target, MAXIMUM_VELOCITY, END_VELOCITY, 
        MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK, mcPositiveDirection, mcAborting);
    if (status.Error)
        RtPrintf("MoveContinuousAbsolute failed: %d\n", status.ErrorId);

    Sleep(6000);

    RtPrintf("End position:\n");
    GetAnAxisPosition(Index);
}

 

Output:

MoveAxisAbsolute Target: 10000

MoveAxisContinuousAbsolute Target: 12000

We reset the starting position to zero after MoveAxisAbsolute is completed. For MoveAxisContinuousAbsolute, an axis continues to move after it reaches the target, so the end position is not the same as the target.