We are moving to our new home. Several online services will be unavailable from
Saturday, December 16th to Sunday, December 17th.   |   More information

Inductive Automation
News Room

News / December 01, 2010

How To Store History On a Condition

Learn how to store tag history only when a condition is met. Many end-users only want to store history when machines are on. That way they are not logging non-crucial data to a SQL database. By doing so it will cut down on the size of the database and allow the user to see when the machine was on or off. The condition can be more than just a machine state; it can be based on any tag or custom calculation.

1) First, we need to set up a simulator driver so there are values to log. Open the Ignition Gateway and log into the Configure section. The default username is admin and the default password is password.

2) Navigate to the OPC-UA > Devices section and click on the Add a Device link.

3) Expand the Simulators folder and select the Generic driver. Press the Next button.

4) Name the device GenSim and press the Save button. This will take you back to the Devices page and your GenSim device will say "connected."

5) Now open your project in the designer.

6) In the SQLTags Browser pane of the designer, right-click Tags and select New Tag > DB Tag... Name this tag Trigger and press the OK button.

7) Next, we need to create a new scan class. Click on the Edit Scan Classes... icon in the SQLTags Browser pane.

8) Click the green + icon and select the New Scan Class that is created.

9) Change the Scan Class Name to Driven History, change the Mode to Driven, and change the Slow rate (ms) to 0.

10) For the Driving Tag property, click the Insert Tag icon and navigate to Tags > Trigger. Press OK.

11) Set the Operator field to Equal and the Value to 1.0. Press OK.

12) Now click on the Browse OPC Servers icon in the SQLTags Browser pane.

13) Expand the Ignition OPC-UA Server and navigate to Devices > GenSim > Sine. Select the SINE1 tag and drag it into the Tags section of the browser. Close the OPC browser.

14) In the SQLTags Browser, right click on the SINE1 tag and click Edit Tag(s)...

15) Under the History properties section, set Store History to Yes, and select your History provider and the Driven History Scan class. Press the OK button. You can see that the tag is now recording history by the orange scroll icon next to the tag name.

16) To test the driven scan class, create a window and drag an Easy Chart into the rod container. Set the Chart Mode component property to Realtime and drag the SINE1 tag onto the chart.

17) The data will not be logged until the value goes to 1. So, to start logging, turn the gateway traffic to Read/Write, and click the Toggle Value Editability icon in the SQLTags browser. Set the Trigger DB tag to 1.