nimcReadAxisData

NI-Motion Functions

nimcReadAxisData

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 Axis Data

Usage

status = nimcReadAxisData(TnimcDeviceHandle deviceHandle, TnimcAxisHandle axisHandle, TnimcAxisData attribute, TnimcData* data);

Purpose

Reads position, velocity, or following error information on an axis.

Parameters

Name Type Description
deviceHandle TnimcDeviceHandle assigned by Measurement & Automation Explorer (MAX)
axisHandle TnimcAxisHandle axis to read
attribute TnimcAxisData attribute to read
data TnimcData* the value for the attribute you are reading

Parameter Discussion

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

attribute is the attribute to read. The following are valid attributes:

  • TnimcAxisDataPosition
  • TnimcAxisDataVelocity
  • TnimcAxisDataFollowingError

data is the value for the attribute you are reading in the following structure:

struct{
   i32 longData;
   u8 boolData;
   f64 doubleData;
} TnimcData;

Based on the attribute, the correct member of TnimcData will be returned by the motion controller. The values of the other elements in the structure are undefined.

Read doubleData in the TnimcData structure to retrieve the axis position, velocity, or following error.

Using This Function

Use this function to read position, velocity, or following error information on an 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 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 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.

Note  Refer to Function Execution Times for benchmark timing information about your controller.