Inch
Inch moves an axis at the specified velocity, just like Jog, but it has a specified distance. After the axis travels the distance, it stops.
Functions
InchAxis: moves an axis at a specified velocity with a maximum distance. The axis stops after it travels the distance.
WaitForCommand: waits for a command to be finished.
GetAnAxisPosition: displays the end position of an axis. For further details, see Get and set values.
InchAxis
InchAxis makes an Inch move. Its direction is controlled by the Direction parameter. It can be mcPositiveDirection
or mcNegativeDirection
. See the McDirection type.
Code
In SingleAxisMotion.cpp
, add the following code:
InchAxis
VOID Inch(int Index, double Distance)
{
RtPrintf("Make an inch move.\n\n");
//Start an inch move.
KsCommandStatus status = WaitForCommand(30, TRUE, InchAxis(Index, Distance, MAXIMUM_VELOCITY,
MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK, mcPositiveDirection));
if (status.Error)
RtPrintf("InchAxis failed: %d\n", status.ErrorId);
//Wait a few cycles to get the correct end positions.
Sleep(5);
RtPrintf("End position:\n");
GetAnAxisPosition(Index);
}
Output:
Distance: 8000