How to Connect to OPC Server

I’ve created the COM or ActiveX framework to connect and access the data from the OPC server. It can be used in conjunction with other programming platform that uses COM or ActiveX framework such as Visual Basic or .NET framework.

It is compiled in the form of DLL and requires COM registration, just as other COM DLL or EXE file.

Below is the short description of how to use the component in Visual Basic 6:

opc01

The above code snippet is the core steps to get the OPC data access to get going and running. First, the oOPC object is created using the standard CreateObject statement.

The next step is to perform connection to the OPC server, which can be located on different machine. The client should supplies the required parameters as follows: The IP Address (sIPAddress), Computer Name of the destination OPC server (sComp), the user and password that has the priviledge to access the destination server (sUser and sPassword) and the OPC server ActiveX or COM object name (sOPCName).

The OPC server name depends on the OPC vendor that creates the OPC server and should be obtained from their documentation files. For example, ABB OPC server is ABB.AfwOpcDaSurrogate.1.

The last step is to get the tag value of interest. Required parameters are array of tag id to be retrieved (aTagCode), and array values to be filled by the OPC object, which are array of tag values (rtnValue), array of tag quality (rtnQuality) and tag timestamp (rtnTS).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: