Connect to an OPC DA Server

This example is designed to guide you through connecting to an OPC DA Server using an OPC DA Datasource as the client.

Before beginning, here are some prerequisites and considerations to be taken into account.

  • In this example, we use a simulation OPC DA server from Matrikon to demonstrate how to connect to an OPC DA server. This can be downloaded for free from their website.

  • Datasource objects are created underneath Folder objects in the I/O Model. The Folder object needs to be linked to an "owner" Node. Please read the instructions on creating and linking a Folder to a Node before creating the OPC DA Datasource.

  • Accessing data sources is an administrative task so you must be logged into the System Config App as an administrator.

  1. Navigate to a Folder in the I/O Model.

  2. Right-click the Folder object to display the context menu and select Admin  New to open the Create Object dialog.

    io model create new
  3. In the Create Object dialog, open the External Interfaces section in the left-hand panel and select "Datasource DA".

  4. Enter an Object Name for the Datasource.

    io model create datasource da
  5. Move on to the OPC DA compound page and enter the Prog ID of the Server. This can be checked in the Matrikon simulation server config files but is usually Matrikon.OPC.Simulation.1.

    io model create datasource da opcdaprop
  6. More configuration options for the OPC DA Datasource are available but for this example, we will use the default configuration. Click Create to create the object in the I/O Model. It should connect and show 2 green lights.

    io model datasource da prebrowse
  7. In the I/O Model, right-click on the newly created OPC DA Datasource object and select Admin  Browse Once from the context menu to browse the datasource.

    io model datasource browse once

    Alternatively, select the Datasource object in the I/O Model and expand the Object Lens on the right-hand side of the compilation. Select the OPC DA property compound. In the OPC Client Options, expand the Browse Control property compound and set the Browse Options property to "Browse Once" then click Apply.

    io model browse opcda datasource
  8. Expand the OPC Datasource namespace and select one of the example tags. Check that the values are updating in the Object Lens.

    io model datasource da afterbrowse

When a ProgID property for an OPC Classic (COM) server is changed, the Datasource object needs to be disabled and re-enabled for this change to be recognized.