Tutorial 4-4: Single turn

Some axes, such as rotary axes, may not have a linear range of movement, but rather can rotate in either direction indefinitely. The position command of such axes may become excessively large after rotating in one direction for an extended period. These axes should be configured as Single Turn Mode axes so that the position command wraps around to stay within a particular range of positions.

Configuring an axis as a Single Turn Mode axis will have the following effects:

The following code sets an axis to single turn mode, and executes some position commands.

Motion::PosCommand pos;

//Set single turn mode
err = wmxlib_cm.config->SetSingleTurn(0, true, 5000);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to set single turn. Error=%d (%s)\n", err, errString);
    goto exit;
}

//Move the axis by 10000 in the positive direction
pos.axis = 0;
pos.profile.type = ProfileType::Trapezoidal;
pos.profile.velocity = 10000;
pos.profile.acc = 10000;
pos.profile.dec = 10000;
pos.target = 10000;
err = wmxlib_cm.motion->StartMov(&pos);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to execute motion. Error=%d (%s)\n", err, errString);
    goto exit;
}

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

//Move the axis to position 4000
pos.axis = 0;
pos.profile.type = ProfileType::Trapezoidal;
pos.profile.velocity = 10000;
pos.profile.acc = 10000;
pos.profile.dec = 10000;
pos.target = 4000;
err = wmxlib_cm.motion->StartPos(&pos);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to execute motion. Error=%d (%s)\n", err, errString);
    goto exit;
}

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

The position and velocity plots of the axis during this motion are shown below.

../_images/WMXDOC_TUTORIAL_SEC4_image0.png