InTouch SCADA Logging Tag Values with InTouch

While tag values can be logged for reporting and historical purposes by using Wonderware Historian, the same results can achieved through using InTouch functionality. Historian provides an easy way to import InTouch tags for recording historical data to an SQL Server database, but this ease of use comes at a price through the licensing. With a bit of scripting InTouch can provide the same historical logging results without the need for Historian, plus the flexibility of using different data sources through ODBC.

Prerequisites:

  1. InTouch version 7.1 or higher. For this example version 10.0 will be used.
  2. An ODBC data source. SQL Server 2005 will be used for this example.
  1. Create an ODBC Data source

    In order for InTouch to record tag information, a data source must be created to store the data. This is done through the use of an ODBC connection, which is setup through the Windows ODBC data source administrator tool. See the article Creating an ODBC data source for information on creating an ODBC data connection. For this example set the data source name (DSN) to “InTouchDB”.
  2. Add a New Database Table to SQL server

    To store the InTouch Tag data, a database table will need to be created with the SQL Server Management Studio Tool. For this example I will be using a database called “InTouch” and a table called “tblTagValues”.

    The tag values table will have the following columns:


    Column Name

    Data Type

    Tag1

    varchar(50)

    Tag2

    real

    Tag3

    real

    Tag4

    real

    Tag5

    int


    For further information on creating a database table within SQL server, see the article Using SQL to create a Database Table.
  3. Create a Bind List within InTouch

    Open InTouch Window Maker for the InTouch application you wish to log tag data for, and find the Tools view which is located towards the bottom left hand side. Within Tools find the “SQL Access Manager” node and expand it to display the “Bind List” and “Table Template” child nodes.

    3.1. Double click on the “Bind List” node to create a new bind list. If this is the first time you have created a new bind list you will be asked to create a new SQL Access Manager definition (.DEF) data file. Click Yes on this to create the definition file.

    3.2. You will now be able to create a new Bind List, click the “New” button on the “Select a Bind List” Window. The Bind List Configuration window will open.



    3.3. Within the Bind List Configuration window enter a Bind List Name. Here the bind list name has been called “blTagValues”.

    3.4. Specify a Tag name to use as the source of tag data.

    3.5. Specify a database table column name for which to record tag data. These column names relate to the database table created in section 2.

    3.6. Once the tag name and column name have been specified, add this item to the bind list by clicking on the “Add Item” button.



    3.7. Add bind list items for each of the table columns specified in section 2 and then click on the “OK” to save the bind list.

  4. Logging tag values with a Data Change event.

    For the purpose of this example tag value data will be logged every minute using some InTouch scripting and a Data Change event.

    4.1. Within InTouch Window Maker, find the scripts view. Within the scripts view find the “Data Change” tree node and then right click on it to open the options popup menu. From this popup menu left click on the “New” option to create a new data change event. The data change scripts window will open.

    4.2. Within the data change scripts window, enter a tag name into the “Tag Name” field. For this example the tag name “$Minute” will be used, which will trigger the data change script every minute.

    4.3. Add the following InTouch Script:

    {Connect to SQL server}
    {Parameters: ConnetionID; DSN Name}
    SQLConnect( ConnectionID, "DSN=InTouchDB");

    {Record the tag data to the Tag Values database table}
    {Parameters: ConnectionID; TableName; BindListName.}
    SQLInsert( ConnectionID, "tblTagValues", "blTagValues" );

    {Disconnect the open SQL Server database connection}
    {Parameters: ConnectionID}
    SQLDisconnect( ConnectionID );

    4.4. Click the “OK” button to save the data change script.

  5. Run the InTouch application. A new record should be inserted into the “tblTagValues” table every minute.

Note: If SQL errors occur they will be logged within the System Management Console or the WWLogger application (InTouch 7.1). Use this information to diagnose scripting and configuration issues.







Return to all articles