The following functions can be used to command and move an axis. The following axis shows how to do a single axis movement. For this example to work, you need to add an axis to your axis configuration and switch the control to BB. It is recommended to do this using IndraWorks.
We begin the example by checking if the axis is available and what type of axis we want to move. Only virtual and real axis can be commanded.
The following lines perform a check to make sure that we can move the axis and that there are no configuration errors.
We are now ready to start the axis movement. Please note that all axis command functions have asynchronous behavior. This means that when the MLPI function returns, the command has not been finished yet. It might even not have been started yet. The function tells the axis to abort the current command and start with the new movement as soon as possible (e.g. next motion cycle). After setting the new command, the MLPI function returns immediately. It returns an error code if the new command has not been accepted by the axis. If the motion command has been accepted, the axis will start to execute your command. For example, moving to a given absolute position if you have commanded it using mlpiMotionMoveAbsolute. Other than the return code, the movement function also returns a so called 'Motion-Handle' (MLPIMOTIONHANDLE) as a output argument. You can use this output handle at any time with the function mlpiMotionGetStatus to check the current state of the axis movement. This way, you can check if the axis has already finished the movement (e.g. reached the target position) or an error has occurred.
In the example below, the helper function utilMotionWait is used to poll if the axis has finished the given motion command. It blocks the current thread until the command has been finished by the axis. It is also possible to give a timeout to the function. Have a look at the source code of utilMotionWait to see an example of how mlpiMotionGetStatus can be used.
MLPIRESULT mlpiMotionGetStatus | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
const MLPIMOTIONHANDLE | motionHandle, | ||
MlpiMotionStatus * | status | ||
) |
This function reads the status of a motion command.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[in] | motionHandle | Handle of the motion command where the status should be requested. |
[out] | status | Pointer to data where status will be stored. |
MLPIRESULT mlpiMotionPower | ( | const MLPIHANDLE | connection, |
const MlpiMotionPower * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands power to the drive. This is only necessary for a real axis. Virtual axis can be moved without giving power to the axis.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionStop | ( | const MLPIHANDLE | connection, |
const MlpiMotionStop * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a stop of motion to the drive.
TRUE
you have to call it again with FALSE
to get axis from state 'Stopping' to state 'Standstill' command and to make the axis accept new commands. [in] | connection | Handle for multiple connections. |
[in] | paramSet | Reference to the axis that should be stopped. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionHome | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands to home an axis. Only axes with incremental encoders can be homed. If the axis has an absolute encoder, the command "set absolute measurement" must be used.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionSetAbsoluteMeasurement | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis | ||
) |
This function commands to "set absolute measurement" of an axis. Only axis with absolute encoders can be used with this function.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
MLPIRESULT mlpiMotionChangeFlexProfileSet | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
const MlpiMotionFlexProfileStep * | paramSet, | ||
const ULONG | numElements, | ||
const DOUBLE | masterVel, | ||
const MlpiProfileSetSelection | set | ||
) |
This function writes all parameters necessary to configure a flex profile.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[in] | paramSet | Pointer to array of structures containing the parameters for the flex profile. |
[in] | numElements | Number of structures passed. |
[in] | masterVel | Master velocity for given flex profiles. |
[in] | set | Set where flex profile should be stored. |
MLPIRESULT mlpiMotionMoveVelocity | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveVelocity * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a velocity movement. Once the commanded velocity had been reached, the axis will continue to run with this velocity until another command is issued.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMoveContinuousAbsolute | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveContinuousAbsolute * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a movement to a position where a commanded velocity is reached. Once this position is reached, the axis will continue to run with the commanded velocity until another command is issued.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMoveContinuousRelative | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveContinuousRelative * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a movement of a specified relative distance ending with the specified velocity. Once this distance is reached, the axis will continue to run with the commanded velocity until another command is issued.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMoveAbsolute | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveAbsolute * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an absolute movement. This means that the axis will move to a given target position.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMoveAdditive | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveAdditive * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an additive movement. The additive position is added to the target position and is used as new target. It can be used to add a relative position to the already commanded movement.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMoveRelative | ( | const MLPIHANDLE | connection, |
const MlpiMotionMoveRelative * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a relative movement. The relative position is added to the current position and is used as new target. The difference between this and an additive movement is that the position offset is added to the current position, not the target position. So a movement command which is currently running will be interrupted and only the position offset is added to the current position.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionTorqueControl | ( | const MLPIHANDLE | connection, |
const MlpiMotionTorqueControl * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands a move torque.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionOpenCyclicPositionChannel | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
The following functions all deal with motion that is commanded by sending cyclic data. This is used to be able to generate your own profiles. This is contrary to all other motion commands where the profiles are generated by the control. In order to be able to write cyclic data, a "channel" must be opened first. Once opened, cyclic data should be written every motion cycle. No explicit error will occur if no cyclic data is written. In this case, the last known cyclic data will be send again. But keep in mind, that the movement on the drive might be jittered or even result in errors in the drive. To correctly synchronize your cyclic write access to the drive you might want to have a look at the function mlpiTaskWaitForEvent
. The cyclic command mode can be canceled using any other single or synchronous motion command. Prior to opening a cyclic channel, you should initialize the first channel value by using the corresponding write command (e.g. mlpiMotionWriteCyclicPosition).
This function opens a cyclic channel for cyclic position commands.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionOpenCyclicVelocityChannel | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function opens a cyclic channel for cyclic velocity commands.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionOpenCyclicAnalogChannel | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function opens a cyclic channel for cyclic analogue commands.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionOpenCyclicTorqueChannel | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function opens a cyclic channel for cyclic torque commands.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionWriteCyclicPosition | ( | const MLPIHANDLE | connection, |
const MlpiMotionCyclic * | paramSet, | ||
const ULONG | numElements = 1 |
||
) |
This function commands a cyclic position. It is possible to give an array to paramSet and to set the position of several axes using one call only.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[in] | numElements | Number of given positions in paramSet. |
MLPIRESULT mlpiMotionWriteCyclicVelocity | ( | const MLPIHANDLE | connection, |
const MlpiMotionCyclic * | paramSet, | ||
const ULONG | numElements = 1 |
||
) |
This function commands a cyclic velocity. It is possible to give an array to paramSet and to set the velocity of several axes with only one call in this way.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[in] | numElements | Number of given velocities in paramSet. |
MLPIRESULT mlpiMotionWriteCyclicAnalog | ( | const MLPIHANDLE | connection, |
const MlpiMotionCyclic * | paramSet, | ||
const ULONG | numElements = 1 |
||
) |
This function commands a cyclic analog value. It is possible to give an array to paramSet and to set the velocity of several axes using only one call in this way.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[in] | numElements | Number of given analog values in paramSet. |
MLPIRESULT mlpiMotionWriteCyclicTorque | ( | const MLPIHANDLE | connection, |
const MlpiMotionCyclic * | paramSet, | ||
const ULONG | numElements = 1 |
||
) |
This function commands a cyclic torque value. It is possible to give an array to paramSet and to set the torque of several axes with only one call in this way.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[in] | numElements | Number of given torque values in paramSet. |
MLPIRESULT mlpiMotionControlOn | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function switches the axis to controlled motion.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionControlOff | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function switches the axis away from controlled motion.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionAddAxisToGroup | ( | const MLPIHANDLE | connection, |
const MlpiMotionAdminAxisGroup * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function adds an axis to a group.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing the information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionRemAxisFromGroup | ( | const MLPIHANDLE | connection, |
const MlpiMotionAdminAxisGroup * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function removes an axis from a group.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing the information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionGearIn | ( | const MLPIHANDLE | connection, |
const MlpiMotionGearIn * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands velocity synchronization to the master.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionGearInPos | ( | const MLPIHANDLE | connection, |
const MlpiMotionGearInPos * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands position synchronization to the master.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionCamIn | ( | const MLPIHANDLE | connection, |
const MlpiMotionCamIn * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to synchronize to the master by using a cam table.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionMotionProfile | ( | const MLPIHANDLE | connection, |
const MlpiMotionMotionProfile * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to synchronize to the master by using a motion profile. The command can only be used on IndraDrives with interpolation in the drive.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionFlexProfile | ( | const MLPIHANDLE | connection, |
const MlpiMotionFlexProfile * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to synchronize to the master by using a flex profile. The command can only be used on IndraDrives with interpolation in the control or with Sercos drives.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionSynchronOut | ( | const MLPIHANDLE | connection, |
const MlpiAxisRef | axis, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to become unsynchronized. The axis will continue to run with the velocity at the time the command was issued. Can be called after GearIn, GearInPos MotionProfile, FlexProfile and CamIn.
[in] | connection | Handle for multiple connections. |
[in] | axis | Reference to the axis. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionPhasing | ( | const MLPIHANDLE | connection, |
const MlpiMotionPhasing * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to perform a master phase offset when the drive is synchronized to the master. The command can also be executed when unsynchronized, but it will only take effect when the axis is synchronized.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |
MLPIRESULT mlpiMotionPhasingSlave | ( | const MLPIHANDLE | connection, |
const MlpiMotionPhasing * | paramSet, | ||
MLPIMOTIONHANDLE * | motionHandle | ||
) |
This function commands an axis to perform a slave phase offset when the drive is synchronized to the master. The command can also be executed when unsynchronized, but it will only take effect when synchronizing the axis.
[in] | connection | Handle for multiple connections. |
[in] | paramSet | Structure containing all information necessary for the command. |
[out] | motionHandle | Pointer to value where motion handle will be stored. |