HART Forums  |  Login  

The HART Communication Protocol is the leading communication technology for intelligent process measurement and control instrumentation and systems with more than 26 million devices installed worldwide.
Home > Documents & Services > Specifications & Documents


Writing a Field Device Configuration Utility Using the HART OPC Server

The principle objective of the HART OPC Server is to act as a transport mechanism for communicating with HART devices. The interface via the Server to the device is the same whether the device is connected directly to the PC or connected via some intermediate I/O system. While the intermediate I/O systems may vary, the interface to applications using the OPC server remains the same. Using the Server to access and configure your device provides significant benefits including:

The HART Server provides two basic interfaces: the OPC interface; and the HART pass-through interface:

The simplest development strategy for the configuration utility software uses both interfaces. The procedure for configuring a field device would be:

  1. Using the OPC interface, allow the user to browse through the connected field devices.

  2. When the user selects the field device to configure, the OPC interface provides the tag for that field device.

  3. Using the tag, a connection is made via the HART pass-through interface to the device.

  4. This connection allows device specific commands to be sent to the field device.

  5. Once configuration is complete, the connection is closed and the configuration utility can exit.

Proper use of the HART tag is required by most host systems including the HART OPC Server. In fact, the OPC Specifications use the tag to connect to and access field device data. Each element in the communication path contains a tag including the network, multiplexer and field device. Of course, HART Universal Commands require the tag to be supported in the field device. All networks must have a different tag. All multiplexers connected to single network must have unique tags and all devices connected to a single multiplexer must have a unique tag. However, two field devices connected to two different multiplexers may have the same tag. When the tags are concatenated together for the network, multiplexer and field device the unique communication path from the server to the field device is created.

Connecting to Your Field Device
Since the Server will usually be a fixed installation, connecting to your device is an important part of your configuration program. The server can support simultaneous access to a large number of devices:

The connection to your field device is established by allowing the user to browse through the networks, multiplexers and field devices. This browse function is part of the OPC Server. Diagram below shows a sample browse screen that the user may see. In this example there are two networks. On the first network there are three multiplexers. In addition, the second multiplexer has two sub-panels. Since your device's manufacturer ID, device type and device revision is known you can ask the Server to filter the instruments that are browsed. This will ensure the device selected is your device.

Access to the device is associated with the tag string for the device. This is the communication path to the field device. Each network, multiplexer and the device's tag is separated by a dot ( . ). For example, the tag for the Moore Products 340S in Figure 1 would be "Production Plant.UPPER TERRACE.PT943"

Your application does not need to decode this string. It merely uses this string to open the HART pass-through interface.

Opening the HART Pass-Through connection
Once the tag string has been obtained for your device, the HART pass-through connection can be initialized. Like OPC, the pass-through interface uses OLE or, more specifically, Microsoft's Distributed Component Object Model (DCOM). This allows simple access from anywhere on the plant's corporate network. The pass-through interface has several methods or subroutine calls defined that allow device specific commands to be sent from your application to your field device. A few of the methods are shown in the table below.

To open the pass-through connection, call the "ConnectByTag" method using the tag string returned from the OPC Server browse function. This returns the handle for the connection. All subsequent calls to the pass-through mechanism are made using this handle.

Method Parameters Description
ConnectByTag [in] BSTR szwAccess,
[in] BSTR szwTag,
[in] VARIANT_BOOL bExclusive
[out, retval] long *plHandle
Uses the dot separated tag as the path to the field device. A connection is opened to that device and a handle for the connection returned.
Disconnect [in] long lHandle Disconnects the client application from the field device.
Send [in] long lHandle,
[in] SAFEARRAY psaCommand
[out] SAFEARRAY *ppsaReply,
[out, retval] long *lStatus)
Sends a command to the field device. The client provides a byte array containing the command number, byte count, and data. The data in the slave device reply and the status are returned.

Sending Commands
Sending commands require only the command number, byte count, and the data field. An array containing these bytes is passed to the "Send" method. The Server will route the command to your device while adding the delimiter, address, and check bytes to form a proper HART message. In other words, the client application does not need to track device addresses or calculate message check bytes. When the slave device answers, Send returns the command, Byte count and data fields to the client. Send is synchronous and does not return until it has the slave response.

Additional methods are provided that allow asynchronous message transmission.

The pass-through interface has a higher priority in the Server than routine OPC-related scanning of the field devices. The command passed to Send is placed at the front of the message queue for the multiplexer connected to your field device. This allows diagnostic and configuration applications to have the best access and throughput via the Server.

Before exiting, your application must disconnect from the server thus freeing system resources.

Benefits of the HART Server
There are many benefits to using the HART OPC Server:

Perhaps most importantly, using the HART OPC Server is a low cost solution for developing a MS-Windows based configuration utility.