OPC Tools and Techniques

OPC Development

OPC Platforms

Access Mechanisms

OPC Development

Debugging with OPC Sniffer

OPC Sniffer is a free download which all OPC developers will want to have in their toolbox, though most will use it rarely. Sniffer is a troubleshooting tool which monitors and logs all client/server traffic on the standard OPC Data Access interfaces. All calls are logged to file, as well as being optionally displayed in a console window; logging options are controlled via a textual configuration file.

Usage is straightforward: the client program connects directly to Sniffer rather than the 'true' server, at which point Sniffer uses a dialog box to prompt for the real OPC server. From that point on, operation is almost completely transparent, except that all OPC traffic is logged for later analysis.

As far as we know, MatrikonOPC Sniffer is the only freely available OPC debugging tool which provides reporting at the raw message level. It will therefore prove uniquely valuable in some scenarios, such as when client and server rely on subtly different interpretations of the OPC specification.

Other excellent OPC diagnostic tools are listed on our Free Stuff page.

OPC Client Programming with Java

This content is now found on our dedicated Java page.

OPC Programming with Perl

Martin Tomes of Eurotherm has put together a Perl module for use with the OPC Data Access Automation interfaces. The objective is to simplify client development, particularly for the production of test scripts; Perl gurus will know that this is one of the language's great strengths.

The module is available from the CPAN archive, the main distribution point for anything associated with Perl. For your convenience, we've extracted the primary reference documentation - the CPAN download also includes a number of sample scripts. The module was last updated, to version 1.01, in July 2004.

Requirements:

  • The Perl module and example scripts were tested using ActivePerl 5.8.0 build 806 from ActiveState. ActiveState Perl must be installed on your system.
  • An implementation of the OPC Automation interfaces is needed. As supplied, the example scripts make use of the OPC DA Auto wrapper from OPC Foundation. A freely available automation DLL is listed on our Free Utilities page.

OPC Programming with Python

OpenOPC for Python

OpenOPC is a free, open source toolkit that arguably makes OPC DA client programming easier than ever. Here is an example of a minimal working program: -

import OpenOPC
opc = OpenOPC.client()
opc.connect('Matrikon.OPC.Simulation')
print opc['Square Waves.Real8']
opc.close()

The functional programming style allows statements to be chained in an elegant, readable manner. This single line of code, for example...

opc.read(opc.list('Square Waves.*'))

will read the values of all items matching the wildcard pattern.

Standard Python constructs are used wherever possible. For example, the read() function returns a tuple consisting of the value, quality and timestamp: -

opc.read('Random.Int4')
(19169, 'Good', '06/24/07 15:56:11')

value, quality, time = opc.read('Random.Int4')

Alternatively, the short form of the function supplies only the value, which will be set to None in the event of any problem: -

>>> value = opc['Random.Int4']

As a bonus, OpenOPC includes a gateway service allowing remote, and even cross-platform (Linux, Mac) operation. The gateway makes use of Pyro (Python Remote Objects).

OpenOPC also includes a very easy to use command line client, allowing quick OPC operations from the Windows Command Prompt, e.g.: -

C:\> opc -r Random.String Random.Int4 Random.Real8
Random.String  Your       Good  06/25/07 23:46:33
Random.Int4    19169      Good  06/25/07 23:46:33
Random.Real8   8009.5730  Good  06/25/07 23:46:33

Read 3 of 3 items (0.02 seconds)

OpenOPC uses the DA Automation interfaces. It will work with Automation wrapper DLLs from a range of vendors, and ships with the Graybox wrapper.

If you know Python already, you're sure to love OpenOPC. If not, it may even convert you to the language.

Note: a very good, self-contained, Python distribution for Windows is available from ActiveState.

PyOPC

PyOPC is an Open Source framework for rapidly creating XML-DA clients and servers using Python. See our XML-DA page for more information.

Simplified OPC access from Visual Basic and scripting environments

VB Sample Code

Perhaps the best source of Visual Basic sample code is Takebishi's page at http://www.faweb.net/us/opc/sample_index.html.

This code relies on there being an installed OPC Data Access Automation server capability. A freely available automation DLL is listed on our Free Utilities page.

ActiveX Controls for OPC Data Binding

Our Components page includes a number of ActiveX control products aimed specifically at Visual Basic developers.

Some of these provide simpler alternatives to the OPC Data Access Automation DLL. Others go further, e.g. by allowing code-free binding of OPC items to any properties of any controls on a Visual Basic form.

QuickOPC

QuickOPC comes from OPC Labs. This product was formerly known as EasyOPC.

QuickOPC presents an interface consisting of just four properties and three methods. Creation and lifetime of server and group objects is managed behind the scenes using an "advanced algorithm". This means that client code is entirely stateless, and therefore less likely to contain errors.

QuickOPC clients may be written in any language or environment supporting Windows Scripting or Automation, including VBScript and ASP (for which the stateless nature of client code makes it especially suitable). QuickOPC is also available for Windows CE and Pocket PC.

A trial version may be downloaded. This allows complete solutions to be developed, with runtimes being time-limited until the product is registered.

QuickOPC is also marketed by Software Toolbox, using the product name OPC Web Client.

Custom OPC Servers with No Programming Needed

These products allow custom serial and/or TCP/IP protocols to be supported in a Data Access server with no need for programming skills:

MatrikonOPC Redundancy Broker

Like MatrikonOPC Sniffer, MatrikonOPC Redundancy Broker (ORB), also acts as an intermediary between client and server. The purpose of the ORB (also a free download), is to automatically redirect OPC traffic to a standby server in the event of a failure. Redundancy can be easily retrofitted into existing OPC systems, regardless of the server vendor.

OPC Platforms

Embedded OPC

OPC Unified Architecture (UA) was designed from the outset to be embeddable.

Windows CE allows for embedded COM-based OPC, from version 3.0 onwards.

In addition, Wind River Systems' Wind River OPC supports embedded OPC without Windows. Wind River OPC uses Wind River's own DCOM implementation and runs on their market-leading VxWorks real-time operating system.

OPC on Linux/UNIX

OPC Unified Architecture (UA) was designed from the outset to be cross-platform, and Linux solutions are available from a number of vendors.

Another option for non-Microsoft platforms is to use OPC XML-DA, which is not reliant on Microsoft COM. Linux support for XML-DA is provided, e.g., by Softing's OPC Toolbox for Linux.

OpenOPC for Python also offers a Linux client capability.

OPC for Symbian OS

Wapice reportedly offers an OPC Client for the Symbian platform. This software allows mobile phones to operate as OPC clients, and is compatible with certain Nokia Communicator models.

Access Mechanisms

OPC into Microsoft Office

OPC data can be brought into Microsoft Office applications using Office's built-in VBA language to drive an OPC Automation server.

Likewise, some of the other tools and techniques available to Visual Basic programmers may equally be used by Office developers.

However, OPC Office Link from Rensen Information Services simplifies this to a single copy/paste operation. It also offers a number of other powerful features such as OPC writes using a single VBA function call, and OPC data sampling directly into Access database tables. A time-limited evaluation copy may be freely downloaded.

Matrikon Analytic's Excel Reporter enables reporting on DA and HDA data via Excel.

WinTECH's OPCxchg utility allows easy linking of Excel to OPC items via DDE. No coding is necessary, and a demo download is available.

Resolvica's OPCEx Excel Add-In allows users to browse, read and write data items, and makes creation of Excel charts straightforward by allowing sequences of values to be inserted into consecutive cells. Reports may be sent via email, published as web pages, or printed. A free trial download is available.