Top  | Previous | Next

How do I log history for a tag?

Ignition has several different ways for you to store tag history: SQLTags Historian, and Transaction Groups. Both have their benefits and their drawbacks, so knowing how you are going to want to access and use your tag history data in the future comes into play when selecting one option over the other. Each of these features have their own sizable sections in the user manual dedicated to explaining the ins and outs of how they function and you are encouraged to read these sections in their entirety.

 

Before You Can Store History

You need a device connected to Ignition and tags in the designer: How to I get data from my PLC?
You need a database connection: How do I connect to a database?
You need a SQLTags Historian provider configured in the gateway: Configuring SQLTags Historian

 

SQLTags Historian

Overview

The following section provides detailed information on this SQLTags Historian properties: History Properties
For an overview of how the SQLTags Historian works read the following: How SQLTags Historian Works

 

Items to Make Note Of

History is configured on a tag by tag basis.
Once configured, tag data is managed for you.
Tag history settings can be set/manipulated in a CSV tag export as well as in the designer.
There is a history provider created for each of the configured database connections. Take care to note the tags being stored and their respective providers.

 

How to Turn on History for a Tag

1.In the Ignition designer, locate the desired tag in the SQLTags browser.
2.Edit the tag by right clicking and selecting "Edit Tag" or merely double click on the tag.
3.Select the history option, and then select "yes" to enable history.
4.Fill in the appropriate settings for the history properties. Refer to this section for property explanation and help: History Properties
5.Finally click ok and history will start being stored for your tag to the history provider you selected.

 

Where Your Data is Stored

Your tag data is stored in the database connection associated with the selected history provider. Ignition creates and manages several tables within the database that the historian uses to not only store your data but also make it easily available within your Ignition projects. Data is partitioned out over multiple tables, spanning set time periods as specified in the configuration section of the history provider. This partitioning of the data allows for faster querying and data lookup from within your projects.

 

Accessing your stored data

You can access your stored historical data from within your projects in several ways:

The Easy Chart component allows for drag-and-drop functionality with historian enabled tags within the Ignition designer. Select any number of tags from the SQLTags browser and merely drag them onto an Easy Chart component you have placed on a window. Historical data for the selected tags will immediately begin to be displayed on the chart.
The data property of a table component can make use of the Tag History binding option. Here you can select from a list of available historical tags, specify a start and end date, and change the different modes for how your data should be returned. Using this option will display your history data for selected tags in a the table component that you can place on any of your project windows. Start and end dates can be bound to properties allowing the table data to be dynamic in regards to what time slice of data to be displayed. More information on the Tag History binding can be found here: SQLTags Historian Binding
Much of the power of Ignition is harnessed through event scripting and there are several built in scripting functions that allow you to query the Historian to get information about stored tag data. system.tag.queryTagHistory and system.tag.queryTagDensity are the scripting functions made available to you for access to your history data through scripting.

 

Pros of Using SQLTags Historian

Ease of setup
Drag and drop trending
Ignition managed historical database tables
Optional data compression

 

When SQLTags Historian may not be Ideal

You want to maintain a custom database schema for your historical data
Access to history data via custom/specialized SQL queries either through Ignition or third party software
Data needs to be stored on a complex trigger condition

 

 

Transaction Groups

Overview

An introduction to transaction groups and how they execute: Introduction and Execution Cycle
The different types of Transaction Groups: Standard Group, Block Group, Historical Group, Stored Procedure Group
Transaction Group Item types: Overview, OPC Item, Expression Item, SQLTag Reference
Other important aspects of a Transaction Group: Action Settings, Trigger and Handshake Settings, Advanced Settings

 

Items to Make Note Of

Different types of groups have different features. Make sure you are using the type that best fits your needs
OPC Items of a group are subscribed at the execution rate of the group, SQLTag references are subscribed at their own scan class rate
You specify the table to which the data gets written. If the table you specify doesn't exist and the auto-create feature is enabled, Ignition will attempt to create the table for you.
You can create your tables beforehand and then select them in the table selector dropdown.
In non-block groups, each tag will be stored to a column.
Order of Item execution: tag values updated -> triggered expression items executed in top-to-bottom order -> tag items written to db/opc

 

Setting up a Basic Historical Group

A historical group is the simplest of the Transaction Group types. Its function is to write opc tag, expression item, and SQLTag values to the database. You still have the option to run the group on a trigger and change some of the advanced settings, but the direction of the group is strictly opc -> db.

 

1.In the Ignition designer click on the "Transaction Group" item in the Project Browser to change your workspace view to the Transaction Group edit view.
2.Right click the Transaction Group item in the project browser then select New Transaction Group -> New Historical Group
3.Navigate to the OPC Browser in the Ignition designer. If it is not visible you can open it by clicking on the View menu option then going to Panels -> OPC Browser.
4.Browse through your devices and locate the tags you wish to store history for and then drag them into the "Basic OPC/Group Items" area of the designer.
5.Read through the following sections and the configure your group to your needs: Action Settings, Trigger and Handshake Settings, Advanced Settings
6.Once you have your group settings configured make sure to edit the Target Name option for each tag so that it represents the column of the database table in which you wish to store the tag values.
7.Click Enable and then save your project.
8.Your group should now be running and data should be populating your database. If your group failed to start check the events tab of the group and double click any error messages that may have been reported to see why the group has failed.

 

Where is Your Data Stored

Your tag data is written using the database connection specified to the database table that was configured in the group. You can verify that your data is being stored by using the Database Query browser tool available in the designer. This tool allows you to run SQL queries against the selected database connection. You can open it any time in the designer by selecting it from the Tools menu.

 

Accessing your stored data

Like SQLTags historian you have several ways to access your stored data within your Ignition projects.

Once again, the Easy Chart allows you to display your stored data as a trend. There are no drag-and-drop capabilities when you are not using SQLTags Historian, but the Easy Chart does allow you to set up what are known as Database Pens rather easily. Merely double clicking on an Easy Chart that resides on a window in the designer will bring up the Easy Chart Customizer. Clicking on the plus icon of the Database Pens section brings up the Edit Pen window that allows you to specify where the data for your pen resides. You merely have to give the pen a name, select the database connection, database table, and column where the data is stored.
Table components allow you display data brought back from a SQL query and the data property has two bindings that allow you to bring back data from your database. The SQL Query Binding and DB Browse Binding allow you to write and build queries to run against your database.
Several scripting functions allow you to run SQL queries against the database: system.db.runPrepQuery, system.db.runPrepUpdate are a couple of these functions that will return a dataset containing the results of your query.