flex_sub_vars

NI-Motion Functions

flex_sub_vars

Device Compatibility

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

Subtract Variables

Usage

status = flex_sub_vars(u8 boardID, u8 variable1, u8 variable2, u8 returnVector);

Purpose

Subtracts the value of second variable from the value of the first variable and returns the result.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
variable1 u8 first operand
variable2 u8 second operand
returnVector u8 destination for the result

Parameter Discussion

variable1 is the variable holding the first operand. Valid inputs are variables (0x01 through 0x78) and indirect variables (0x81 through 0xF8).

variable2 is the variable holding the second operand. Valid inputs are variables (0x01 through 0x78) and indirect variables (0x81 through 0xF8).

returnVector indicates the destination for the return data generated by this function. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and return no data (0). Refer to Input and Return Vectors for more detailed information.

Using This Function

This function subtracts the value of second variable from the value of the first variable and returns the result to the destination specified by the returnVector.

V1 – V2 = Result

where:
V1 is the value at variable1.
V2 is the value at variable2.
Result is stored in the location pointed to by returnVector.

The result can be returned to a new variable or one of the two input variables, returned to the host computer, or thrown away. In all cases the condition codes are set according to the resulting value. This value is compared with 0, and the appropriate condition code is set: GREATER THAN, LESS THAN, or EQUAL to zero.

This function is often used to compare two values prior to executing a conditional jump with the Jump on Event function. In this case, the result is typically thrown away by setting returnVector = 0.