Tutorial 3-6: Interpolation

Interpolation functions coordinate the motion of two or more axes to execute one motion.

The most common type of interpolation is linear interpolation, which will coordinate the motion of axes to move in a completely straight line in 2D space, 3D space, or even higher dimensions if rotary axes or multiple sets of axes are included.

Other types of interpolations include circular interpolation, which will coordinate the motion of two or three axes to trace a circle or an arc in 2D or 3D space, helical interpolation, which will coordinate the motion of three axes to trace a helix, and path interpolation, which will coordinate up to six axes in a more complex path consisting of linear and circular segments.

Also see Interpolation, Path Interpolation, and Path Interpolation with Look Ahead for more detailed discussions of interpolations.

The following code executes a linear interpolation and a circular interpolation in 2D space.

Motion::LinearIntplCommand lin;
Motion::LengthAndEndCircularIntplCommand cir;

//Set linear interpolation parameters
lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;
lin.target[0] = 10000;
lin.target[1] = 10000;
lin.profile.type = ProfileType::Trapezoidal;
lin.profile.velocity = 10000;
lin.profile.acc = 10000;
lin.profile.dec = 10000;

//Set circular interpolation parameters
cir.axis[0] = 0;
cir.axis[1] = 1;
cir.arcLengthDegree = 180;
cir.clockwise = 0;
cir.endPos[0] = 0;
cir.endPos[1] = 0;
cir.profile.type = ProfileType::Trapezoidal;
cir.profile.velocity = 10000;
cir.profile.acc = 10000;
cir.profile.dec = 10000;

//Execute linear interpolation motion
err = wmxlib_cm.motion->StartLinearIntplPos(&lin);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to execute linear interpolation. Error=%d (%s)\n", err, errString);
    goto exit;
}

//Block execution until motion is finished
err = wmxlib_cm.motion->Wait(0);

//Execute circular interpolation motion
err = wmxlib_cm.motion->StartCircularIntplPos(&cir);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to execute circular interpolation. Error=%d (%s)\n", err, errString);
    goto exit;
}

The 2D position plot and the velocity plots of the axes during this motion are shown below.

../_images/WMXDOC_TUTORIAL_SEC3_image5.png