flex_set_stepper_loop_mode

NI-Motion Functions

flex_set_stepper_loop_mode

Device Compatibility

Device Compatibility
7330
Y
7340
Y
7344
Y
7350
Y
7390
Y
NI SoftMotion Controller for CANopen—Xenus
N
NI SoftMotion Controller for CANopen—Accelnet
N

Set Stepper Loop Mode

Usage

status = flex_set_stepper_loop_mode(u8 boardID, u8 axis, u16 loopMode);

Purpose

Sets a stepper axis to operate in either open-loop, closed-loop, or P-Command mode.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer
axis u8 axis to control
loopMode u16 mode of the stepper axis

Parameter Discussion

axis is the axis to control. Valid values are NIMC_AXIS1 through NIMC_AXIS30. On motion controllers that support fewer than thirty axes, configuring non-existent axes returns error –70006 (NIMC_badResourceIDOrAxisError). Refer to Axes for axis resource IDs.

loopMode sets the mode for the stepper axis.
   0 = open-loop (default)
   1 = closed-loop
   2 = P-Command

Using This Function

You can operate stepper axes in both open and closed-loop modes. In open-loop mode, the stepper axis controls the trajectory profile and generates steps but has no feedback from the motor or actuator to determine if the profile is followed correctly.

In closed-loop mode, the feedback position is constantly compared to the number of steps generated to see if the stepper motor is moving correctly. When the trajectory profile is complete, missing steps (if any) are made up with a pull-in move. If, at any time during the move, the difference between the instantaneous commanded position and the feedback position exceeds the programmed following error limit, the axis is killed and motion stops.

You use P-Command mode for systems in which a servo drive receives step/dir (CW/CCW) from the motion controller. The drive closes the PID loop, and the motion controller generates the trajectory. Similar to closed-loop mode, in P-Command mode, the axis is killed when the programmed following error limit is exceeded.

Caution  For proper closed-loop and P-Command operation, the correct values for steps/rev and counts/rev must be loaded with the Load Counts/Steps per Revolution function. Incorrect counts to steps ratio can result in failure to reach the desired target position and erroneous closed-loop stepper operation.

To operate in closed-loop or P-Command mode, a stepper axis must have a primary feedback resource, such as an encoder, mapped to it prior to enabling the axis. Refer to the Configure Axis Resources function for more information about feedback resources. You can operate an axis with a primary feedback resource in open-loop, closed-loop, or P-Command mode and you can switch the mode at any time. You can still read the position of the mapped feedback resource even when the axis is in open-loop mode.