Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Calculated Variables

  • Last UpdatedFeb 20, 2025
  • 3 minute read

A calculated variable allows you to do the following:

  • Generate a tag value at runtime that is the result of a Cicode expression.

  • Call an internal Cicode function as a variable tag.

Calculated variables are evaluated on the I/O server only when a subscription to the calculated variable exists.

The following data types are supported for calculated variables:

  • Int

  • Long

  • Real

  • Digital

  • String

To configure a calculated variable, you use a variable tag that addresses an I/O device with its protocol set to "CICODE". If the variable tag address is a valid Cicode expression, the Cicode I/O device will calculate the result of the expression and present it as the tag value.

Note:
• The same Cicode function can generate different results depending on whether or not the Cicode function was called from a process, an event, or if it was called from a Cicode I/O device.
• When used as an address of a calculated variable, if there is at least one argument in #BAD then a function will return #BAD even if it executed properly.

If the expression in the Address field reads from or writes to another tag in the system, the calculated variable is added towards the point count.

Example 1

The Plant SCADA Example Project includes a number of tags that support the Steel Mill page. These tags include two tags that identify the length and width of the coil that is currently loaded on the uncoiling station.

Tag Name

I/O Device

Address

Data Type

Units

Entry_CoilLength

SteelMillDisk

R10

REAL

meters

Entry_CoilWidth

SteelMillDisk

R13

REAL

millimeters

Using a calculated variable, you could determine how many square meters of steel will be produced by the coil that is currently uncoiling. To do this, you could create the following calculated variable on an I/O device called "CicodeIODevice".

Tag Name

I/O Device

Address

Data Type

Units

Entry_CoilArea

CicodeIODevice

Entry_CoilLength * (Entry_CoilWidth)/1000

REAL

m2

You could then use the value generated by this tag at runtime to estimate the production potential of the current coil.

Example 2

Using a calculated variable, you can call a Cicode function for diagnostics and determine the state of an I/O device.

Tag Name

I/O Device

Address

Data Type

IOServer_Mixer_PM800_State

CicodeIODevice

IODeviceInfo("IOServer_Mixer_PM800", 10)

STRING

In the example above, a CICODE function has been used in a calculated variable to determine the state of the specified mixer (for example, online or offline).

Note: Cicode functions used for calculated variables need to be non-blocking functions.

Example 3

Using a calculated variable, you can trigger an alarm when an I/O device goes offline. In this case, you will need to:

  • create a variable tag with a calculated variable to determine the state of an I/O device

  • create an advanced alarm with an expression that will trigger an alarm when the expression evaluates to TRUE.

Tag Name

I/O Device

Address

Data Type

IOServer_Mixer_PM800_State

Mixer

IODeviceInfo("IOServer_Mixer_PM800", 10)

STRING

Alarm Tag

I/O Device

Expression

IOServer_Mixer_PM800_Offline

Mixer

(StrToInt(IOServer_Mixer_PM800_State) = 16)

OR

(StrToInt(IOServer_Mixer_PM800_State) = 32)

In the example above, the variable tag calculates the state of the mixer. The alarm will be triggered if the tag is calculated to be 16 (offline) or 32 (disabled).

Example 4

Using a calculated variable, you can perform mathematical calculations. In this example, the variable tag calculates the quotient of two integers and in the event of the divisor being 0 returns an error code.

Tag Name

I/O Device

Address

Data Type

Divide_Tag_Value

CicodeIODevice

Divide(4,9)

REAL

REAL FUNCTION Divide( INT iDividend, INT iDivisor)

REAL iResult;

INT iError;

Errset(1);

iResult = iDividend / iDivisor

iError = isError();

Errset(0);

RETURN iResult;

END

See Also

Add a Calculated Variable

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in