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:
If the axis position would increase beyond Single Turn Encoder Count, the position loops back to 0. This includes both the Command Position and Feedback Position.
If the axis position would decrease beyond 0, the position loops back to Single Turn Encoder Count
If the Single Turn Reduce To Half Turn parameter is set to TRUE, the travel direction of absolute position commands between 0 and Single Turn Encoder Count will be adjusted so that the travel distance is equal to or less than half of the Single Turn Encoder Count.
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.
