flex_set_op_mode

NI-Motion Functions

flex_set_op_mode

Device Compatibility

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

Set Operation Mode

Usage

status = flex_set_op_mode(u8 boardID, u8 axisOrVectorSpace, u16 operationMode);

Purpose

Sets the operation mode for an axis or vector space.

Tip  Refer to the Remarks section for information about how the behavior of this function differs between controllers.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
axisOrVectorSpace u8 axis or vector space to control
operationMode u16 mode of operation

Parameter Discussion

axisOrVectorSpace is the axis or vector space to control. Valid values are NIMC_AXIS1 through NIMC_AXIS30 or NIMC_VECTOR_SPACE1 through NIMC_VECTOR_SPACE15. On motion controllers that support fewer than thirty axes, configuring non-existent axes or vector spaces returns error –70006 (NIMC_badResourceIDOrAxisError). Refer to Axes and Vector Spaces for axis and vector space resource IDs.

operationMode selects the type of position or velocity mode for an axis or vector space.

operationMode Constant operationMode Value
NIMC_ABSOLUTE_POSITION 0
NIMC_RELATIVE_POSITION 1
NIMC_VELOCITY 2
NIMC_RELATIVE_TO_CAPTURE 3
NIMC_MODULUS_POSITION 4
NIMC_ABSOLUTE_CONTOURING 5
NIMC_RELATIVE_CONTOURING 6

Using This Function

This function is used both during initialization and during normal motion control operation to configure the mode of operation for all trajectory commands to the axis or vector space specified.

Position modes are applied to all axes in a coordinate (vector) space. If you later want to operate an axis independently in a different mode from the other axes, call Set Operation Mode again on that axis.

Note  All axes in a vector space must have the same operation mode. If the operation modes are different on each axis when a Start Motion or Blend Motion function is executed, an error is generated.

The operation mode must be set or changed before any other trajectory parameters are loaded for the next move. The operation mode affects how the target position and velocity values are interpreted. Trajectory parameters loaded after a mode change are interpreted in the newly selected mode. Trajectory parameters loaded any time before a mode change do not reflect the new mode.

Note  Changing operation mode after the trajectory parameters are loaded can result in improper operation.

The five operation modes are described in the following sections:

NIMC_ABSOLUTE_POSITION

In absolute position mode, target positions are interpreted with respect to an origin, reference, or zero position. The origin is typically set at a home switch, end of travel limit switch, or encoder index position. An absolute position move uses the preprogrammed values of acceleration, deceleration, s-curve, and velocity to complete a trajectory profile with an ending position equal to the loaded absolute target position.

Caution  Any single move is limited to between –231 and 231–1 counts or steps. An error is generated if you exceed this limit by loading a target position too far from the current position.

The length of an absolute move depends upon the loaded position and the current position when the move is started. If the target position is the same as the current position, no move occurs.

NIMC_RELATIVE_POSITION

In relative position mode while motion is not in progress, loaded target positions are interpreted with respect to the current position at the time the value is loaded. A relative position move uses the preprogrammed values of acceleration, deceleration, s-curve and velocity to complete a trajectory profile with an ending position equal to the sum of the loaded relative target position and the starting position.

If a relative move is started while motion is in progress, the new target position is calculated with respect to the target position of the move already in progress (considered to be the new starting position), as if that move had already completed successfully. Motion continues to the new relative position, independent of the actual position location when the new move is started.

In relative mode, the new target position is calculated and double-buffered when you execute either the Load Target Position or Load Vector Space Position function. You must reload the relative target position each time before executing a Start Motion or Blend Motion function.

NIMC_VELOCITY

In velocity mode, the axis moves at the loaded velocity until you execute a Stop Motion function, a limit is encountered, or a new velocity is loaded and you execute a Start Motion function. Load target positions have no effect in velocity mode. The direction of motion is determined by the sign of the loaded velocity.

You can update velocity at any time to accomplish velocity profiling. Changes in velocity while motion is in progress uses the preprogrammed acceleration, deceleration, and s-curve values to control the change in velocity. You can reverse direction by changing the sign of the loaded velocity and executing a Start Motion function.

Note  Executing a Blend Motion function in velocity mode has no effect because the move in process never normally stops. You must always use the Start Motion function to update velocity in velocity mode.

NIMC_RELATIVE_TO_CAPTURE

The relative-to-capture position mode is very similar to absolute position mode, except that the zero position reference (origin) is the last captured position for the axis or axes. A relative-to-capture position move uses the preprogrammed values of acceleration, deceleration, s-curve and velocity to complete a trajectory profile with an ending position equal to the sum of the loaded target position and the last captured position.

In relative-to-capture mode, the new target position is calculated and double-buffered when you execute either the Load Target Position or Load Vector Space Position function. These functions use existing values in the position capture register(s). You must load the target position after the capture event has occurred and before executing the Start Motion or Blend Motion function.

This mode is typically used in registration applications. Refer to the Gearing section of the NI-Motion Help for information about using superimposed moves/registration applications. Also, refer to the Rotating Knife section of the NI-Motion Help for example code that includes superimposed moves.

NIMC_MODULUS_POSITION

In modulus position mode, the loaded target position is interpreted within the boundaries of a modulus range and the direction of motion is automatically chosen to generate the shortest trajectory to the target. To load the modulus range execute the Load Position Modulus function.

Modulus position mode is typically used with rotary axes or for other similarly repetitive motion applications.

Note  Multiple revolution moves cannot be accomplished by indicating target positions greater than the modulus value. All moves are resolved to one modulus range.

Example

A rotary tool changer has a modulus of 360°, such that 0°, 360°, 720°, and so on, are the same rotary position.

In modulus position mode, the present position and the specified target position are used to calculate the shortest trajectory to the target position. If the present position is 30° and the target position is 290°, there are two possible moves:

   290–30 = 260° in the clockwise direction, or
   290–360–30 = –100° in the counterclockwise direction.

Because 100° is the shortest trajectory, the tool changer moves counterclockwise to the target position of 290°.

NIMC_ABSOLUTE_CONTOURING and NIMC_RELATIVE_CONTOURING

The absolute and relative contouring modes allow you to provide the motion controller with a series of points to spline through. These modes allow you to specify arbitrary motion and velocity profiles. Velocity, acceleration, and deceleration are all determined implicitly by the contour points you provide.

Note  If you are running a contoured move with a stepper axis, it is possible that the contour velocity exceeds the maximum step rate of the controller. In this case, the controller kills the axis and sets the following error status to true. Refer to the Specifications section of your controller user manual for the maximum step rate of your controller.

To use contouring mode, you must also configure a buffer with the Configure Buffer function and fill the buffer with contouring data. Successive points in the buffer are fed to the motion controller automatically at the user-specified time interval in milliseconds. The motion controller then splines through the contour points. Refer to the Configure Buffer function for more information.

All contour moves are relative, meaning that the move starts from the current position of the axis or axes. In absolute contouring mode, positions are interpreted with respect to the starting position of the contouring move. In relative contouring mode, positions are interpreted with respect to the previous position in the contouring data array.

Remarks

This section includes information about how the behavior of this function differs among the controllers that support it.

NI 73xx Controller Considerations

The following list includes considerations you must make when you are using this function with a 73xx motion controller:

  • NI 7330 and NI 7390 controllers do not support absolute or relative contouring.
  • NI 73xx controllers do not support NIMC_VELOCITY for vector spaces.

NI SoftMotion Controller Considerations

The following includes considerations you must make when you are using this function with the NI SoftMotion Controller:

The NI SoftMotion Controller does not support the NIMC_MODULUS_POSITION option for operationMode.