6.2.Quick Start

Here's how to configure the OPC DataHub to write data to a database of your choice. We use a data point from the DataSim program in this example but you can just as easily use your own data point.

Open the ODBC Data Logging window

  1. In the OPC DataHub Properties window, select Data Logging .
  2. In the Configure Database (ODBC) Data Logging section click the Configure button.
    This opens the ODBC Data Logging window, shown below.

Connect to the Database

  1. Select the 1. DSN tab. A DSN is a Data Source Name. Windows uses this name to identify the database you want to connect to.
  2. From the drop-down box, select a DSN. If you do not have any DSNs, or you wish to create a new DSN, you can do this by opening the DSN Administrator. Please refer to Seting up a DSN for more details.
  3. Enter the appropriate user name and password (if required), and click the Connect button. A "Connected to ..." message should appear in the message box. If you get an error message in the box, consult your system administrator.

Configure a Table

  1. Select the 2. Table tab.
  2. Start the DataSim program if it isn't already running, and ensure that it is connected to the DataHub.
  3. In the Table name field type: datasimtest.
  4. Click the Add Column button, type: POINTID in the pop-up dialog, and then click OK.
  5. Click under the POINTID label in the Item row.
  6. Select <key> from the drop-down list. Notice after you make your selection that the word counter gets entered automatically for the Data Type.
  7. Click the Add Column button and enter the name PTNAME.
  8. In the point-picker list on the right, expand the DataSim data domain and select the point named Sine.
  9. In the PTNAME column, click in the Item row and select <point>. The full name of the point, DataSim:Sine, should appear.
    for Property in that column select name.
    for Data Type select varchar (or the equivalent).
    for Data Size the system might have entered a value for you. If not, type in a value like 64 and click Enter.
  10. Click the Add Column button again and add the column name PTVALUE. Then make these entries:
    for Item select <point>. (The point name, DataSim:Sine, should appear.)
    for Property select value.
    for Data Type select number (or the equivalent).
    for Data Size, depending on your database, you might not be able to enter anything. If you are able to make an entry, you can type in a number of bytes and click Enter.
    The entry fields should now look similar to this:
  11. Click the Create Table button. If successful, you have now created a new table in the database specified by your DSN. You can open your database program and view it to verify. If you get an error message, check your entries above carefully to ensure they are compatible with your database. For example, some databases will not allow spaces or special characters in table and column names.
    Once the table is created, you cannot add any more columns. However, you can delete the table using the Delete Table button. This will delete the table from the database, but all of your entries will remain in the entry fields. You can then add more columns if you wish, and recreate the table. You can easily rename, insert, or delete a column by right-clicking on the column name for a pop-up menu. For more information about creating and modifying tables, please refer to Section6.4, “Configuring a Database Table”.
  12. When you have the table the way you want it, go down to the Configured Actions box and click the Create button.
    A new configured action should appear in the list. For more information about configured actions, please refer to Section6.8, “Configured Actions”
    Next, to get the DataHub to write the data, you need to assign a trigger.

Assign a Trigger

For this example, we will trigger the action whenever the DataSim:Square point changes value.

  1. Select the 3. Trigger tab.
  2. From the point selector, expand the DataSim data domain and select the point Square.
  3. Click the + button to the right of the Point Name field. The point name DataSim:Square should fill in for you.

    You can choose any point for the trigger, including the point that gets written, such as DataSim:Sine in our example. For more information about triggers, please refer to Section6.6, “Assigning a Trigger”.

  4. In the Configured Actions box, make sure that the configured action you just created is highlighted. If not, click on it to highlight it. Then click the Modify button.
    Your configured action should now display the DataSim:Square point as your Trigger.
  5. Click the Apply button to activate the configured action.
  6. Open the Script Log to check for error messages and ensure that your data is being written successfully. Each write action to the database gets logged here. You can also verify the writes by querying the database itself.

You have just configured an action that logs the name and value of the Sine point in the DataSim data domain whenever the value of the Square point changes. Now you can create tables to log your own data, with triggers based on points or timers.

The remaining sections in this chapter explain the interface in more detail, and introduce the option of setting specific conditions for logging, if desired.