Considerations when Using Read Functions

NI-Motion Functions

Considerations when Using Read Functions

Read functions return data from the NI motion controller. There are two types of Read functions. The first takes a return vector and returns the data to a general-purpose variable in onboard memory, or the Return Data Buffer (RDB). This type of function is typically used in conjunction with onboard programming. The second type returns the data by reference into a variable in the application. The functions that return data by reference have a suffix _rtn. This is the more commonly used type of function. Refer to Input and Return Vectors for more information about return vectors.

Example

The return vector version of the Read Position function has the following function prototype:

status = flex_read_pos (boardID, axis, returnVector)

When you use this function, the data retrieved by the controller is placed into the general-purpose variable indicated by the returnVector parameter. If the returnVector is 0xFF (for Visual Basic users, &HFF), the return data is placed in the Return Data Buffer (RDB) for later retrieval.

The _rtn version of the Read Position function has the following function prototype:

status = flex_read_pos_rtn (boardID, axis, position)

where boardID and axis are inputs and position is an output. When you use this function, the NI-Motion software places the data retrieved from the controller into the position variable that you referenced when calling the function. For C/C++ users, position is a pointer to an i32. For Visual Basic users, position is of type long and the pass-by-reference behavior is made clear to the compiler by the function prototype in the Flexmotn.bas header file.