nimcReadAllAxisData

NI-Motion Functions

nimcReadAllAxisData

Device Compatibility

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

Read All Axis Data

Usage

status = nimcReadAllAxisData(TnimcDeviceHandle deviceHandle, TnimcAxisHandle axisHandle, TnimcAxisData* data);

Purpose

Reads the position, velocity, following error, and encoder position of the selected axis.

Parameters

Name Type Description
deviceHandle TnimcDeviceHandle assigned by Measurement & Automation Explorer (MAX)
axisHandle TnimcAxisHandle axis to read
data TnimcAllAxisData* the data record containing axis execution information

Parameter Discussion

axisHandle is the axis to read with this function. Valid values are 1 through 30. On motion controllers that support fewer than thirty axes, reading non-existent axes returns error –70006 (NIMC_badResourceIDOrAxisError).

data is the data record containing axis execution information in the following structure:

struct {
   u32 size;
   f64 position;
   f64 velocity;
   f64 followingError;
   f64 encoderPosition;
} TnimcAllAxisData;

Using This Function

Use this function to read the position, velocity, following error, and encoder position of the selected axis.

Caution  If this function uses reflective memory, it should not be used for event checking. In this case, only use the information returned by this function for display purposes. Refer to Reflective Memory Functions for more information.

For open-loop stepper axes, this function returns position information in number of steps generated. For closed-loop stepper axes, it converts the primary feedback position from counts to steps and then returns the value in steps. Closed-loop stepper axes require you to correctly load values of steps per revolution and counts per revolution to function correctly.

Note  For closed-loop axes, this function always returns the position of the primary feedback resource. Refer to the Read Coordinate Position function for an easy way to read the positions of all axes in a coordinate in one call.

For axis velocity, this function returns filtered velocity in counts/s (for servo axes) or steps/s (for stepper axes). The sign of velocity indicates direction of motion.

For axis following error, this function returns the instantaneous difference between the commanded trajectory position and the actual feedback position in counts for servo systems and steps for stepper systems.

Encoder position data is in quadrature count value of the encoder mapped to the selected axis.

During axis setup, you can operate the closed-loop stepper axis in open-loop mode and use this function to directly measure the counts per revolution and steps per revolution for the axis. These values must be loaded in advance for subsequent closed-loop operation. Refer to the Load Counts/Steps per Revolution function for more information.

You also can use the encoderPosition element to return a finer reading of position in cases where the encoder resolution greatly exceeds the step resolution of the closed-loop stepper axis.

Note  Because of the way the controller updates information, the values returned are not guaranteed to all be sampled in the same time slice.

Example

To call this function on axis 2, use the following syntax:

TnimcAllAxisData data;
data.size = sizeof(TnimcAllAxisData);
nimcReadAllAxisData(boardID, 2, &data);

Note  You must specify the value for the size element of data before calling this function. If you do not properly set the size element, the function will return error –70023 (NIMC_parameterValueError).
Note  Refer to Function Execution Times for benchmark timing information about your controller.