Blending for single-axis moves
Blending is to blend movements so the motion and paths can be linked smoothly without a velocity drop. For single-axis moves, only the velocity is blended because there is only one axis moving. The details can be found in Blend movements.
Code
In the blending sample, we blend two MoveAxisAbsolute. The first command's BufferMode is mcAborting
because the blending mode in the first doesn't affect anything. The second uses the blending mode, mcBlendingLow
that blends the lower velocity between the two moves.
In SingleAxisMotion.cpp
, add the following code:
Blending
VOID Blending(int Index, double Distance, double Target)
{
RtPrintf("Blend velocity.\n\n");
/*-----First motion command-----*/
//Start a relative move.
//The first command's BufferMode can be set to any buffer mode.
RtPrintf("Make a relative move.\n\n");
KsCommandStatus status = MoveAxisRelative(Index, Distance, MAXIMUM_VELOCITY,
MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK, mcAborting);
if (status.Error)
RtPrintf("MoveAxisRelative failed: %d\n", status.ErrorId);
Sleep(3000);
RtPrintf("End position:\n");
GetAnAxisPosition(Index);
/*-----Second motion command-----*/
//The blending mode decides how the previous and this command's velocity is blended.
RtPrintf("Make an absolute move.\n\n");
status = MoveAxisAbsolute(Index, Target, 2000, 20000, 20000, 2000000,
mcPositiveDirection, mcBlendingLow);
if (status.Error)
RtPrintf("MoveAxisAbsolute failed: %d\n", status.ErrorId);
Sleep(3000);
RtPrintf("End position:\n");
GetAnAxisPosition(Index);
}
Output:
First MoveAxisAbsolute Target: 2000
Second MoveAxisAbsolute Target: 4000
Blending
When the axis is close to the position 2000, it starts blending the velocity of the next command.
Blue trace: interpolation velocity
Green trace: interpolation position
Without blending
The velocity drops to zero after the axis reaches the position 2000.