Output Commands

Output commands can be inserted in a path sequence to set the value of an output bit when the interpolating axes reach a particular point in the path. The shape of the path and the velocity profiles of the interpolating axes are not changed by the insertion of output commands. For example, smoothing will still be applied if an output command is inserted between two linear interpolations.

If an output command is inserted at a corner with smoothing, the output bit will be set after the smoothing is completed.

The maximum number of output commands that may be set before each non-output command (interpolation commands and sleep commands) is maxPathIntplLookaheadOutputPerSegment. Adding more output commands than this number before one non-output command will cause the excess output commands to be ignored.

Output Command Example

The following sample code executes a path containing an output command. The output 0.0 is set to 1 on the top edge of the square shaped path, when the axis 0 position is at 600. The same output is set to 0 when the axis 0 position is at 400.

//Create the path interpolation with look ahead buffer
wmxlib_AdvancedMotion->advMotion->CreatePathIntplLookaheadBuffer(0, 1000);

//Configure the path interpolation with look ahead channel
AdvMotion::PathIntplLookaheadConfiguration conf;

conf.axisCount = 2;
conf.axis[0] = 0;
conf.axis[1] = 1;
conf.compositeVel = 1000;
conf.compositeAcc = 2000;
conf.sampleDistance = 100;

wmxlib_AdvancedMotion->advMotion->SetPathIntplLookaheadConfiguration(0, &conf);

//Add the path interpolation with look ahead commands
AdvMotion::PathIntplLookaheadCommand path;

path.numPoints = 8;

path.point[0].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[0].data.linear.axisCount = 2;
path.point[0].data.linear.axis[0] = 0;
path.point[0].data.linear.axis[1] = 1;
path.point[0].data.linear.target[0] = 1000;
path.point[0].data.linear.target[1] = 0;
path.point[0].data.linear.smoothRadius = 300;

path.point[1].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[1].data.linear.axisCount = 2;
path.point[1].data.linear.axis[0] = 0;
path.point[1].data.linear.axis[1] = 1;
path.point[1].data.linear.target[0] = 1000;
path.point[1].data.linear.target[1] = 1000;
path.point[1].data.linear.smoothRadius = 300;

path.point[2].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[2].data.linear.axisCount = 2;
path.point[2].data.linear.axis[0] = 0;
path.point[2].data.linear.axis[1] = 1;
path.point[2].data.linear.target[0] = 600;
path.point[2].data.linear.target[1] = 1000;
path.point[2].data.linear.smoothRadius = 300;

path.point[3].type = AdvMotion::PathIntplLookaheadSegmentType::SetOutputBit;
path.point[3].data.setOutputBit.byteAddress = 0;
path.point[3].data.setOutputBit.bitAddress = 0;
path.point[3].data.setOutputBit.value = 1;
path.point[3].data.setOutputBit.type = AdvMotion::PathIntplOutputType::Immediate;
path.point[3].data.setOutputBit.source = AdvMotion::PathIntplOutputSource::IOOutput;

path.point[4].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[4].data.linear.axisCount = 2;
path.point[4].data.linear.axis[0] = 0;
path.point[4].data.linear.axis[1] = 1;
path.point[4].data.linear.target[0] = 400;
path.point[4].data.linear.target[1] = 1000;
path.point[4].data.linear.smoothRadius = 300;

path.point[5].type = AdvMotion::PathIntplLookaheadSegmentType::SetOutputBit;
path.point[5].data.setOutputBit.byteAddress = 0;
path.point[5].data.setOutputBit.bitAddress = 0;
path.point[5].data.setOutputBit.value = 0;
path.point[5].data.setOutputBit.type = AdvMotion::PathIntplOutputType::Immediate;
path.point[5].data.setOutputBit.source = AdvMotion::PathIntplOutputSource::IOOutput;

path.point[6].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[6].data.linear.axisCount = 2;
path.point[6].data.linear.axis[0] = 0;
path.point[6].data.linear.axis[1] = 1;
path.point[6].data.linear.target[0] = 0;
path.point[6].data.linear.target[1] = 1000;
path.point[6].data.linear.smoothRadius = 300;

path.point[7].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[7].data.linear.axisCount = 2;
path.point[7].data.linear.axis[0] = 0;
path.point[7].data.linear.axis[1] = 1;
path.point[7].data.linear.target[0] = 0;
path.point[7].data.linear.target[1] = 0;

wmxlib_AdvancedMotion->advMotion->AddPathIntplLookaheadCommand(0, &path);

//Execute path interpolation with look ahead
wmxlib_AdvancedMotion->advMotion->StartPathIntplLookahead(0);

//Wait for the path interpolation with look ahead to complete
AdvMotion::PathIntplLookaheadStatus pathStatus;
wmxlib_AdvancedMotion->advMotion->GetPathIntplLookaheadStatus(0, &pathStatus);
while(pathStatus.remainCommandCount > 0) {
    Sleep(10);
    wmxlib_AdvancedMotion->advMotion->GetPathIntplLookaheadStatus(0, &pathStatus);
}

//Move the axes to Idle state
wmxlib_AdvancedMotion->advMotion->StopPathIntplLookahead(0);

//Wait until the path interpolation with look ahead is in Stopped state
wmxlib_AdvancedMotion->advMotion->GetPathIntplLookaheadStatus(0, &pathStatus);
while(pathStatus.state != AdvMotion::PathIntplLookaheadState::Stopped) {
    Sleep(10);
    wmxlib_AdvancedMotion->advMotion->GetPathIntplLookaheadStatus(0, &pathStatus);
}

//Free the path interpolation with look ahead buffer (normally, the buffer should only be freed at the end of the application)
wmxlib_AdvancedMotion->advMotion->FreePathIntplLookaheadBuffer(0);

The following plots show the two-dimensional trajectory, the position and velocity of each axis, and the value of the I/O output 0.0 when the above sequence is executed from position (0, 0).

../_images/WMXDOC_FUNC_PLA_SEC1_image13.png

The I/O output 0.0 is set to 1 when moving along the top edge of the square shaped path. At the time that the axis 0 position is at 600, the I/O output is set to 1, and at the time that the axis 0 position is at 400, the I/O output is set to 0.