Tutorial 3-5: Overriding motion
Many motion commands can be overridden by motion commands of the same type before the motion command completes. When an override command is executed, the axis will move to the new target position using the new profile parameters. At the time that the override is executed, the velocity of the axis is preserved and the axis will not suddenly stop or change to another velocity.
Also see Overview for a more detailed discussion of override commands.
The following code executes a motion command, waits for 2 seconds, and then overrides the motion command with another motion command with a higher velocity and a different target position.
Motion::PosCommand pos;
//Set position command parameters
pos.axis = 0;
pos.profile.type = ProfileType::Trapezoidal;
pos.profile.velocity = 10000;
pos.profile.acc = 10000;
pos.profile.dec = 10000;
//Execute motion to position 40000
pos.target = 40000;
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;
}
Sleep(2000); //Wait for 2 seconds
//Set override position command parameters
pos.profile.type = ProfileType::Trapezoidal;
pos.profile.velocity = 20000;
pos.profile.acc = 10000;
pos.profile.dec = 10000;
//Execute motion to position 70000
pos.target = 70000;
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;
}
The position and velocity plots of the axis during this motion are shown below.
