Data Operations

NI-Motion Functions

Data Operations

Data Operation functions include the available math functions on general-purpose variables. Variables can be loaded, added, multiplied, ANDed, and so on before being used as data in a motion control function.

General-purpose variables are 32 bits long and can be used either signed (i32) or unsigned (u32). All Data Operation functions operate on 32-bit values and return 32-bit values. You must be careful to avoid overflow and underflow conditions. For example, multiplying two 32-bit variables and returning the result to a 32-bit variable might overflow and wrap around.

Smaller sized data is right aligned within a 32-bit variable. Bitwise logical functions always assume this alignment and return similarly aligned results.

Many NI-Motion functions can take input data from a general-purpose variable by pointing to the variable with the input vector parameter. Similarly, all read functions can return data to a general-purpose variable by using the return vector parameter, refer to Input and Return Vectors.

All data operation functions set condition codes (less than, equal to or greater than zero) depending on the result of the operation. Your program can test these conditions with the Jump on Event function. Executing a data operations functions with a return vector of zero (0) tells the program to set the condition code and then throw the resulting data away. In this way, you can use all the data operations functions as tests for conditional branching.

You can use indirect variables as variable inputs or return vectors with all data operation functions.

Add Variables

Subtract Variables

Multiply Variables

Divide Variables

AND Variables

OR Variables

Exclusive OR Variables

Invert Variable

Logical Shift Variable

Load Constant to Variable

Read Variable