Normal stop

A normal stop is to decelerate an axis first and then stop it, so the axis won't be damaged during the stopping process.

Functions

HaltAxis: decelerates an axis until the velocity of the axis is zero. While the axis is decelerating, it is in the Discrete Motion state. When the axis' velocity is zero, the axis is in the StandStill state. You can send another motion function to move the axis when it is in StandStill.

WaitForCommand: waits for a command to be finished.

 

To test HaltAxis, use it with a continuous move command such as MoveAxisContinuousAbsolute or MoveAxisContinuousRelative. Because an axis needs some time to be stopped, we use WaitForCommand to give it a few seconds to finish its work.

Code

In SingleAxisMotion.cpp, add the following code:

Copy
HaltAxis
VOID Halt(int Index)
{
    //Give some time for the axis to be halted.
    KsCommandStatus status = WaitForCommand(5, FALSE, HaltAxis(Index, MAXIMUM_DECELERATION,
        MAXIMUM_JERK, mcAborting));
    if (status.Error)
        RtPrintf("HaltAxis failed: %d\n", status.ErrorId);

    RtPrintf("Halt Axis %d.\n\n", Index);
}

 

Output:

MoveAxisContinuousRelative Distance: 11000

For MoveAxisContinuousRelative, an axis continue to move after it travels the distance, so the end position won't be the same as the distance.