Instructions

UM-0085-B09 DT80 Range User Manual Page 72
RG
Data Types
Integers and Floating Point
DT80 channels can return either a 32-bit signed integer or a 32-bit floating point value. Digital and counter channels
return an integer value; most other channel types return floating point values.
The Type column in the above table indicates the data type that results from applying the specified operator. Operators
marked F always result in a floating point value, operators marked I result in an integer, and operators marked * result in
a floating point value if either of their operands is a floating point value. Note that a numeric constant is considered to be
an integer unless it has a decimal point or exponent.
Note however that channel variables can only hold floating point values. Thus if an expression result is assigned to a
channel variable then it will always be converted to a floating point value. This is not the case for a CALC channel,
which can return either an integer or a floating point value.
Error Values
If an operand has an error value (e.g. overrange) then the result of any operator will also be an error value. For example,
CALC=&1V/1000
will return a value of OverRange if the original
1V measurement that is being referenced was overrange.
Operator Precedence
Each operator is assigned a precedence level, as follows:
Precedence Level
Operators
1 (highest)
- (negative)
2
^
3
*, /, %
4
+, - (subtract)
5
<, <=, =, !=, >=, >
6
AND, OR, XOR, NOT
7 (lowest)
?:
When an expression contains more than one operator then the operator with the highest precedence is evaluated first. If
the operators have equal precedence then they are grouped left to right with the exception of
?:, which is grouped
right to left. Parentheses may be used to create sub-expressions and thereby alter the order of evaluation.
Examples
Equal precedence operators are grouped left to right:
3CV=7-2+3 '= (7-2)+3 = 8
...except for ?:, which are grouped right to left:
3CV=1?0:2?3:4 '= 1?0:(2?3:4) = 0
Changing evaluation order using parentheses:
4CV=1.5+2*3^2 '4CV = 19.5
4CV=(1.5+2)*3^2 '4CV = 31.5
4CV=((1.5+2)*3)^2 '4CV = 110.25
Negative and subtract operators are different:
2CV=-5^2 'negative: 2CV = 25
2CV=0-5^2 'subtract: 2CV = -25
Logical Expressions
The selection operator (?:) is the easiest way to select either one value or another based on a conditional. For example,
the following will set a channel to 999 if it is outside the range 0..100:
2CV=((2CV<0)OR(2CV>100))?999:2CV
To select between three or more alternatives you can nest the selection operators. For example, to return -999 for under
range and 999 for over range you could use:
2CV=(2CV<0)?-999:((2CV>100)?999:2CV)
Combining Methods
The different scaling and calculation methods can be used together. The following comprehensive examples are the best
way to demonstrate.