You are here: Core Reference > Coding > Logic > Add Direct and Internal Variables to a Sequential Function Chart

Add Direct and Internal Variables to a Sequential Function Chart

You need to add variables to your Sequential Function Charts. There are 3 types of variable:

In this section, we explain how to add a direct variable and an internal variable:

  1. Display the SFC in Design mode (see Display a Sequential Function Chart).
  2. Either:
    1. Right-click in a row on the Direct tab or the Internal tab (as appropriate) to display a context sensitive menu.
    2. Select the Add option to display the Add Direct Variable window or the Add Internal Variable window.

    Or:

    1. In the Database Bar, select the database item that has the direct variable that you want to add to the SFC. Keep the left-hand mouse button pressed.
    2. Drag the database item onto the SFC. Release the left-hand mouse button to display the Add Direct Variable window.
  3. Use the Add Direct Variable window or Add Internal Variable window to define the settings for the new variable. The windows contain a selection of these settings (the settings vary according to whether the variable is direct or internal):
    • Name—Enter the name for the variable. This name will be used to refer to the variable within the program. A name is entered automatically when you drag a variable onto the Sequential Function Chart, but you can change it as required.
    • Tag Type—Choose the type of variable tag. This can be:
      • Read/Write (%M)—The Sequential Function Chart can both read the value and overwrite it with a new value.
      • Read Only (%I)—The Sequential Function Chart can only read the value and cannot change it.
      • Write Only (%Q)—The Sequential Function Chart cannot read the variable but can write a new value to it.
    • Tag—This is the name of the OPC property that represents the variable that you want to add to the Sequential Function Chart.

      ATTENTION: If a database item's name includes parentheses ( ), you should ensure that each opening parenthesis is paired with a closing parenthesis. If this is not the case, any Logic programs that reference the database item will not compile successfully. For example, a point named "Analog Point (4" or "Analog Point (4))" will generate a compile error message. Multiple sets of parentheses will compile successfully, including nested parentheses. For example, a Logic program can refer to a point named "Analog Point (4)" or "Analog Point (4(x))". For more information, see Limitation for Database Item Names Referenced in Logic Programs in the ClearSCADA Guide to Logic.

    • Type—Choose the type of value. The value type needs to be appropriate to the value that is represented by the selected tag (see Built-In Data Types).
    • Insert—Choose the type of variable tag that you are adding to the Sequential Function Chart. Choose the required type of variable from the combo-box (see Sequential Function Chart Components).
    • Retained—The Retained feature is designed to be used with internal variables. When selected, it allows the internal variable to be stored and transferred to other servers (in a multi-server setup).

      For more information on the Retain feature, see Using the RETAIN Keyword in an ST Program.

    • No Cache—Use the No Cache check box to determine whether the program uses the latest value or the initial value for a variable on each execution. If you check the No Cache check box, the program will use the latest value for the variable rather than the default value. If you clear the No Cache check box, the program will use the default value for the variable on each execution.

      The No Cache feature is especially useful with variables that are used as counts. For more information on the No Cache feature, please refer to Using VAR NOCACHE to Prevent Cached Values Being Used in an ST Program.

  4. Select the OK button to confirm the selections and close the Add Direct Variable or Add Internal Variable window.
    The new variable is added to the SFC—it is listed on the Direct or Internal tab (as appropriate).

You can now reference the direct or internal variable in the conditions for the transitions and in the ST code for any actions.


ClearSCADA 2015 R2