mpiAxisCommandPositionSet

Declaration

long mpiAxisCommandPositionSet(MPIAxis  axis,
                               double   command) 

Required Header: axis.h

Description

mpiAxisCommandPositionSet sets the value of the command position of an Axis (axis) from command. The motor will servo directly to the new command position the next servo sample after the new command position is set. This change in position will not be gradual or controlled, as it is in an mpiMotionStart(...). Use mpiMotionStart(...) for controlled, gradual motion.

mpiAxisCommandPositionSet writes to the controller's axis origin position to adjust the command position. Because the origin is an offset from the controller's command and actual positions, the mpiAxisCommandPositionSet will not cause a change to the position error. Thus, if the motor is enabled, it will not jump when mpiAxisCommandPositionSet is called.

mpiAxisCommandPositionSet should not be called when the axis is in a STOPPING, STOPPED, or MOVING state. If called while in these states, mpiAxisCommandPostionSet will not set the command position and return a MPIAxisMessageCOMMAND_NOT_SET error which is necessary to protect the application from conflicting with the controller's trajectory generation.

axis a handle to an Axis object.
command value to which the Actual command position will be set
Return Values
MPIMessageOK
MPIMessageARG_INVALID
MPIAxisMessageCOMMAND_NOT_SET

Remarks

Setting the Axis Actual Position causes the axis to jump if the ampEnable is enabled. See the discussion of the Axis Origin before using the mpiAxisActualPositionSet(...) and mpiAxisCommandPositionSet(...) methods.

Sample Code

Zero the command and actual postions.

returnValue =
	mpiAxisCommandPositionSet(axis, 0.0);

if (returnValue == MPIMessageOK) {
	returnValue =
		mpiAxisActualPositionSet(axis, 0.0);
}

See Also

MPIMotorDisableAction | AxisActualPositionSet | AxisCommandPositionSet | Controller Positions