Using Cicode Expressions
- Last UpdatedJul 18, 2023
- 3 minute read
Cicode expressions are the basic elements of the Cicode language. An expression can be a constant, the value of a variable tag, or the result of a complex equation. You can use expressions to display and log data for monitoring and analysis, and to trigger various elements in your system, such as alarms, events, reports, and data logging.
You can enter a Cicode expression in any Plant SCADA editor form or graphic object that contains an expression property. Unlike a command, an expression does not execute a specific task - it is evaluated. The evaluation process returns a value that you can use to display information on the screen (for example, as a bar graph) or to make decisions. The following expression returns a result of 12:
-
Numeric expression: 8 + 4
In the above example, the value of the expression is a constant (12) because the elements of the expression are constants (8 and 4).
Displaying Data Using Expressions
In the following example, the value of the expression is the value of the variable B1_TIC_101_PV. As its value changes, the value of the expression also changes. You can use this expression to display a number on a graphics page.
-
Numeric expression: B1_TIC_101_PV
As the expression changes, the number also changes.
Expressions can also include mathematical calculations. For example, you can add two variables together and display the combined total:
-
Numeric expression: B1_TIC_101_PV + B1_TIC_102_PV
In this case, the value of the expression is the combined total. As the value of one variable (or both variables) changes, the value of the expression changes.
Decision-Making
Some expressions return only one of two logical values, either TRUE(1) or FALSE(0). You can use these expressions to make decisions, and to perform one of two actions, depending on whether the return value is TRUE or FALSE. For example, you can configure a text object with appearance as follows:
-
On text when: B1_PUMP_102_CMD
-
ON text: Pump Running
-
OFF text: "Pump Stopped"
In this example, if B1_PUMP_102_CMD is a digital tag (variable), it can only exist in one of two states (0 or 1). When your system is running and the value of B1_PUMP_102_CMD changes to 1, the expression returns TRUE and the message "Pump Running" is displayed. When the value changes to 0, the expression returns FALSE and the message "Pump Stopped" is displayed.
Logging Expression Data
You can log the value of an expression to a file for trending, by defining it as a trend tag:
|
Trend Tag Name |
B1_TIC |
|
Expression |
B1_TIC_101_PV + B1_TIC_102_PV |
|
File Name |
[log]:B1_TIC |
When the system is running, the value of the expression B1_TIC_101_PV + B1_TIC_102_PV is logged to the file [log]:B1_TIC.
Triggering Events Using Expressions
Logical expressions - those that return either TRUE (1) or FALSE (0) -can be used as triggers.
For example, you might need to log the expression in the above example only when an associated pump is running.
|
Trend Tag Name |
B1_TIC |
|
Expression |
B1_TIC_101_PV + B1_TIC_102_PV |
|
File Name |
[log]:B1_TIC |
|
Trigger |
B1_PUMP_101_CMD |
In this example, the trigger is the expression B1_PUMP_101_CMD (a digital variable tag). If the pump is ON, the result of the trigger is TRUE, and the value of the expression (B1_TIC_101_PV + B1_TIC_102_PV) is logged. If the pump is OFF, the result is FALSE, and logging ceases.