NexMotion  1.4.0
Open Robots & Machines [WIP]
Axis_Motion_Control

Axis Motion Control Functions. More...

Collaboration diagram for Axis_Motion_Control:

Functions

RTN_ERR FNTYPE NMC_AxisPtp (I32_T DevID, I32_T AxisIndex, F64_T TargetPos, _opt_null_ const F64_T *PMaxVel)
 Execute Point-To-Point Motion according with target position. More...
 
RTN_ERR FNTYPE NMC_AxisJog (I32_T DevID, I32_T AxisIndex, I32_T Dir, _opt_null_ const F64_T *PMaxVel)
 Execute Point-To-Point Motion according with target (or default) velocity. More...
 

Detailed Description

Axis Motion Control Functions.

Function Documentation

RTN_ERR FNTYPE NMC_AxisJog ( I32_T  DevID,
I32_T  AxisIndex,
I32_T  Dir,
_opt_null_ const F64_T PMaxVel 
)

Execute Point-To-Point Motion according with target (or default) velocity.

Parameters
DevIDDevice ID (DevID)
AxisIndexAxis Index
DirDirection. 1:Forward, -1:Reverse
PMaxVelInput target velocity with a pointer variable. Moreover, input 0 directly for no target velocity, and the driver will get the configuration in axis parameter AXP_VM as the target velocity.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:

  1. The function can be called for point-to-point motion if the axis is excitation.
  2. If the axis is homing, the function will return the error code.
  3. If the axis is in the axis state AXIS_STATE_STOPPING, AXIS_STATE_STOPPED or AXIS_STATE_ERROR, the function will return the error code. After NMC_AxisResetState() is called to reset the axis to normal excitation (AXIS_STATE_STAND_STILL), the function can be called for JOG motion successfully.
  4. After the function is called, the drive will increase/decrease the velocity to the target velocity in accordance with the configuration in the axis parameter AXP_ACC, and the axis state will transfer to AXIS_STATE_CONTINUOUS_MOTION.
  5. After the target velocity is input with the pointer variable PMaxVel, the axis parameter AXP_VM will be modified accordingly. The input target velocity can be 0.
  6. After the function is called and the target velocity is reached, the bit 8 of the axis status becomes to 0, and the motion is continued at the target velocity.
  7. If the axis is executing other motions, it will execute the corresponding behavior depended on the axis parameter AXP_BUFF_PARAM after the function is called.
  8. After the function is called, NMC_AxisHalt() can be called to stop the motion.

Examples:

RTN_ERR ret = 0;
F64_T maxVel = 100;
ret = NMC_AxisJog( 0, 0, -1, &maxVel ); // Set the axis move reversely. Modify the axis parameter AXP_VM to 100 as the target velocity for the velocity plan.

Reference:

  1. NMC_AxisSetParamI32(), NMC_AxisSetParamF64()
  2. NMC_AxisResetState()
  3. NMC_AxisGetStatus()
  4. NMC_AxisHalt()
RTN_ERR FNTYPE NMC_AxisPtp ( I32_T  DevID,
I32_T  AxisIndex,
F64_T  TargetPos,
_opt_null_ const F64_T PMaxVel 
)

Execute Point-To-Point Motion according with target position.

Parameters
DevIDDevice ID (DevID)
AxisIndexAxis index
TargetPosTaget Position (Unit: user unit). The value will be interpreted to absolute or relative distance based on the axis parameter 0x30 (absolute or relative programming).
PMaxVelInput the target velocity with a pointer variable. Moreover, input 0 directly for no target velocity, and the driver can plan the motion based on the velocity configuratio of the axis parameter AXP_VM.
Returns
Return an error code.
If the function is called successfully, the return value is ERR_NEXMOTION_SUCCESS (0). Otherwise, the return value is an error code. All error codes are defined in the header file, NexMotionError.h.

Usage:

  1. The function can be called for point-to-point motion if the axis is excitation.
  2. If the axis is homing, the function will return the error code.
  3. If the axis is in the axis state AXIS_STATE_STOPPING, AXIS_STATE_STOPPED or AXIS_STATE_ERROR, the function will return the error code. After NMC_AxisResetState() is called to reset the axis to normal excitation (AXIS_STATE_STAND_STILL), the function can be called for point-to-point motion successfully.
  4. If the axis is executing other motions, it will execute the corresponding behavior depended on the axis parameter AXP_BUFF_PARAM after the function is called.
  5. The function can be called to enable the point-to-point motion. After the motion completely, the axis will move to the input target position. If the axis parameter 0x30 (Absolute or relative programming) is set to 1, the target position and the relative distance from the current position shall be input in the function. If the relative distance is set to 0, the target position will be set as an absolute position.
  6. If the axis is excuting the point-to-point motion, the axis state will transfer to AXIS_STATE_DISCRETE_MOTION. After the axis moves to the target position and there is no successive motion, the bit 9 of axis status will become to 1, and the axis will transfer to the normal excitation (AXIS_STATE_STAND_STILL).
  7. The drive will plan the velocity curve depended on the axis parameters, AXP_PROF_TYPE, AXP_ACC, AXP_DEC and AXP_JERK.
  8. The maximum velocity can be input with the pointer variable, PMaxVel. Then the corresponding axis parameter AXP_VM will be modified to the input value, and the velocity plan will be performed accordingly.
  9. If the pointer variable, PMaxVel, is set to 0, the drive will perform the velocity plan based on the axis parameter AXP_VM as the target velocity.
  10. If the axis state is AXIS_STATE_STAND_STILL, the function will enable the point-to-point motion immediately after called whether the content of axis parameter AXP_BUFF_PARAM.
  11. After the function is called and if the axis state is AXIS_STATE_WAIT_SYNC and the axis parameter AXP_BUFF_PARAM is aborting, the motions stored in the motion queue will be removed. Then the point-to-point motion will be stored into the motion queue and wait for trigger signal.
  12. If the axis has not reach the target position during the point-to-point motion, NMC_AxisHalt() can be called to stop the motion.

Examples:

RTN_ERR ret = 0;
ret = NMC_AxisPtp( 0, 0, 100, 0 ) // Plan the motion based on the velocity configuration of the axis parameter AXP_VM

Reference:

  1. NMC_AxisSetParamI32(), NMC_AxisSetParamF64()
  2. NMC_AxisResetState()
  3. NMC_AxisGetStatus()
  4. NMC_AxisHalt()