Since the Expression Builder relies on specific data values input by users, the manner in which the data is presented is crucial. This is why it is important for you to know the proper syntax of your expressions. One of the most common errors in building expressions is that the expression has been entered incorrectly. Throughout this chapter, the correct syntax for specific entries is described with specific examples.
Expressions require the following syntax:
value value operator value
where value is a constant or a data source and operator is a mathematical, relational, or Boolean symbol.
The operators in expressions are symbols that not only let you connect data values together but also determine how the values work together to convert the data source. The following types of operators are permitted in your expressions:
To access these operators, click the Mathematical Functions button on the Expression Builder dialog box and select them from the expanded operator keypad. You can also add numerals to your expressions by clicking the appropriate numeral in the Numeric area.
In addition to these operators, the Expression Builder allows you to select a set of functions. These functions are not shown on the expanded operator keypad and must be entered manually. The following table summarizes the available functions and their syntax. All trigonometric functions require values entered in radians.
|
ABS |
Absolute value of number. |
ABS (number) |
|
ACOS |
Arccosine of number. |
ACOS (number) |
|
ASIN |
Arcsine of number. |
ASIN (number) |
|
ATAN |
Arctangent of number. |
ATAN (number) |
|
COS |
Cosine of number. |
COS (number) |
|
EXP |
Anti-log of number. |
EXP (number) |
|
INT |
Integer value of number. |
INT (number) |
|
LOG |
Natural log of number. |
LOG (number) |
|
LOG10 |
Base 10 log of number. |
LOG10 (number) |
|
SIN |
Sine of number. |
SIN (number) |
|
SQRT |
Square root of the number. |
SQRT (number) |
|
TAN |
Tangent of number. |
TAN (number) |
The operators and their associated syntax are described in the following sections with examples of each.
Mathematical operators let you add, subtract, multiply, and divide two or more values. Using these operators, you can create a mathematical expression. You can also change the operator's order of precedence in the mathematical expression by using parentheses.
Mathematical expressions are evaluated by determining the data value on each side of the mathematical operator and then performing the mathematical operation. For example, consider the following expression:
5+DVSYS.AI1.F_CV
When this expression is evaluated, the current value of the tag AI1 is determined and then it is added to 5. If the value is 50, for example, the expression evaluates to 55.
Because of the way the expressions are evaluated, the values on both sides of an operator must both be either a numeric value or a string, but not one of each. You cannot, for example, add the descriptive string "Pump1 for Main Water Supply" to the data source DVSYS.AI1.F_CV. However, you can add that same string to the data source DVSYS.AI1.A_DESC.
The syntax for each mathematical operator in provided in the following table:
Consider the following expressions:
|
5+DVSYS.AI1.F_CV |
The current value of AI1 plus 5. If AI5 is 100, the expression evaluates to 105. |
|
"5"+DVSYS.AI1.A_CV |
The current value of AI1 and the string "5" concatenated together. If AI1 is 100, the expression evaluates to 1005. |
|
DVSYS.AI5.F_CV*OPC1.N35 |
The product of the tag AI1 and the I/O address N35. If the tag's value is 100, and the I/O point's value is 50, the expression evaluates to 5000. |
|
Alarms.Rect1.Width/Alarms.Rect1.Height |
The quotient of Rect1's width divided by its height. If both properties are equal, the expression evaluates to 1. |
|
Alarms.Pump5.HorizontalFillPercentage + DVSYS.AI1.F_CV |
The value of Pump5's HorizontalFillPercentage property plus the current value of the tag AI1. If the HorizontalFillPercentage property's value is 50 and AI1's value is 100, the expression evaluates to 150. |
|
Alarms.Prompt.Caption+"Enter tagname" |
The value of Prompt's Caption property and the string "Enter tagname" concatenated together. If the Caption property value is null, then the string evaluates to "Enter tagname". |
Relational operators let you compare two values to determine how they relate to each other.
Relational operators are commonly used in boolean conditions to determine if part or all of an expression is true or false. An example:
DVSYS.AI1.F_CV = 50
When this expression is evaluated, the value of the left side of the operator is compared to the right side. If the two values match, the condition is true. Otherwise, it is false.
You can compare any data value to any other data value. For example, consider the following boolean conditions:
|
3>1 |
TRUE |
|
5 = "Enter tagname" |
FALSE |
|
DVSYS.AI1.F_CV = 100 |
TRUE, if the current value of AI1 is 100. |
|
DVSYS.AI1.F_CV >= OPC1.N35 |
TRUE, if the current value of AI1 is greater than OPC1.N35. |
|
Alarms.Rect1.Width = Alarms.Rect1.Height |
TRUE, if Rect1 is a square. |
|
Alarms.Prompt.Caption ="Enter tagname" |
TRUE, if the value of Prompt's Caption property is "Enter tagname". |
The AND operator is used when both parts of the expression must be true. For example, suppose that in a factory, several ingredients need to be mixed together for up to 5 minutes while the mixture is being heated to 200 degrees. When both of these conditions (5 minutes and 200 degrees) are true, you want to create an expression to display the following text:
Mixing...
To accomplish these tasks, a rectangle object, MixTime, has been set up as a progress bar to show the time elapsed as a percentage. A text object, Temperature, has also been animated to show the current temperature.
Next, a text object needs to be created for the Mixing message. This object needs its Visible property animated with the following expression:
Mixing.MixTime.VerticalFillPercentage < 100 AND Mixing.Temperature.AnimatedCaption.InputValue < 200
This expression is true only when the mixing time is less than 5 minutes and the temperature is less than 200 degrees. When either condition is no longer true, the mixer stops and the message is no longer visible.
Now suppose you want to display instructions to the operator about the next stage of the process when mixing stops. To do this, you can create another text object and animate its Visible property with the following expression:
Mixing.MixTime.VerticalFillPercentage >= 100 OR Mixing.Temperature.AnimatedCaption.InputValue >= 200
Unlike AND or OR, the NOT operator does not connect two boolean conditions. Instead, it inverts the value of a condition. For example, if the following condition is true:
Alarms.Tank3.HorizontalFillPercentage>80
then the following condition is false:
NOT Alarms.Tank3.HorizontalFillPercentage>80
When evaluating an expression, DeltaV Operate defines an order of precedence for each operator. The order of precedence determines which operators (and the values on each side of the operator) are evaluated first. The following table lists each operator from highest to lowest precedence.
You can change the order of precedence by enclosing an expression in parentheses. Parentheses are regarded with the highest priority; thus all expressions within the parentheses are evaluated first. Operators with the same precedence are evaluated in the order they appear from left to right.