Skip to main content
Version: 7.9

Creating Memory, Expression, and Query Tags

Memory Tags

Inductive University

Creating Memory Tags

Watch the video

Memory tags are simply values. You can use them as setpoints (that are not stored in the PLC) or just for storing extra information. The value is specified during configuration and is stored globally in the gateway when written.

To Create Memory Tags

  1. From Tag Browser, right-click on Tags or a folder of your choice and select New Tag > Memory Tag.

    " "

  2. In the Tag Editor, type a Name (for example, Memory Tag), initial Value, and Data Type.

    " "

  3. Click OK.

    You now have a memory tag that you can read from or write to. This is just like having a global variable for your project.

Creating Expression Tags

Inductive University

Creating Expression Tags

Watch the video

Expression Tags are driven by an expression. The expression syntax is the same as for property bindings and allows mathematical operations, references to other tags, logic operations, and more. Expression Tags cannot be written to.

With expression tags you can do a calculation based on certain values, other tags, or any one of the built in functions. In this way, you can do the calculation one time and view it on any window in your project.

To Create an Expression Tag

  1. In the Tag Browser, right-click on Tags or a folder of your choice and select New Tag > Expression Tag.

    " "

  2. In the Tag Editor, type FtoC Expression for Name and choose Float4 for Data Type.

  3. Click on the Expression tab on the left side of Tag Editor.

  4. Type in any expression using Ignition’s Expression Language. See Expression Functions in the Appendix for information on all expression operations and functions.

    Copy in the following expression:

    (5/9) * ({[~]Refrigeration/ambientTemp} - 32)

    " "

    If you want to use a different tag, just replace the {[~]Refrigeration/ambientTemp} tag path with any Tag of your choice. Note that instead of typing the referenced tag path (in this example Refrigeration/ambientTemp), you can use the Tag icon on the right side of the Tag Editor > Expression window to select the tag path.

    " "

  5. Click OK. You will see the value from your calculation on the Tag. Note that the Expression tags are evaluated at the rate the Scan Class is set to.

    " "

    With an expression tag, you can also choose to write the value back to another OPC item. In the Tag Editor > Expressions, simply click the check box next to Write value back to OPC item? and select the tag you want to write to. Every time the value is calculated, the value gets written to the selected tag.

Creating Query Tags

Inductive University

Creating Query Tags

Watch the video

Query Tags execute a SQL Query, whose result provides the value for the Tag. Like SQL binding in Vision, SQL Query Tags can reference other tags to build dynamic queries. Query Tags cannot be written to. The value of a SQL Query tag comes from the database through a SQL query.

To Create a SQL Query Tag

  1. In Tag Bowser, right-click on Tags or a folder of your choice and select New Tag > Query Tag.

    " "

  2. In the Tag Editor window, type Current Time for Name and choose DateTime for Data Type.

  3. Click on SQL Query tab on the left side of Tag Editor.

  4. Type in any SQL query you want.

note

The query must return a scalar result because the data type is not a dataset.

  1. In the drop-down list, select the database to run the query through, for example MySQL.

  2. Copy in the following query:

    SELECT CURRENT_TIMESTAMP

    " "

    Query Type

    In certain circumstances you may want to update the database instead of querying it for data. The query tag will accept an update query and update the target data source. The value attribute of the tag becomes the number of rows affected by the update query.

    The data source refers to the default data source of the tag provider as opposed to the default data source of the project.

    In the Gateway Configure Section, go to Tags > Realtime and edit the appropriate tag provider. Set the default database connection that this tag provider will use for its query tags.

  3. Click OK.

    You will see the value from your SQL query on the Current Time Tag.

    " "