Communication by OPC DA interface

The principle of the data transfer over the OPC DA:
The OPC server is required. You can get the OPC server from companies that produce the software. Such company is often the manufacturer of PLC devices. The OPC server is the Windows OS application that runs either as a stand-alone program or it can be for example a DLL library. The OPC server , for example, can communicate with PLC devices via the computer's serial port and at the same time it can offer data (that are get from the PLC device) over the OPC interface to other Windows OS applications. In this case the PROMOTIC application is the other application.
In the PROMOTIC application that wants to get (set) the data from the PLC device, it is necessary to create the PmaOpcDaClient object. In this object the OPC server is selected (if the OPC is correctly installed, then it appears in the menu). It is necessary to insert required number of PmaOpcDaClientGroup objects into the PmaOpcDaClient object. These objects represent groups of the data that we want to transfer. They must be configured correspondingly. You can enter there if the data group has to be read or written automatically. If you don't want to read-write data automatically, then it can be solved in the script by the PmaOpcDaClientGroup.Read-PmaOpcDaClientGroup.Write method.

Further it is necessary to define, which data are needed to be transferred. There are two ways of doing this:
1) Data extension: A very convinient way of defining the data we want to communicate with is to use Data extension It is defined in data item of the PmaData object and for OPC the ExtOpcDa is used.
2) Data definition direct in the PmaOpcDaClientGroup object: On the "Data" tab can be defined variables, which are configured similarly to for example in the PmaData object. But for each item it is necessary to set moreover two fields required for the OPC communication. The fields are the ItemId and AccesPath items. These two fields represent the address of the variable in the OPC server. If the OPC server supports the OPC version 2, then the selection of the fields should be functional at the enter points directly from the OPC server (use the button with three dots). If it is not true, then it is necessary to enter the data manually.
The access to the data items in the PmaOpcDaClientGroup object is the same as in the PmaData object, i.e. for example by the PmaOpcDaClientGroup.Item method. This property accesses one variable as the PmVar object from which the standard data (especially the value of the variable by the Value property) can be found but the PmVar object has two more properties specific only for the OPC in the PmaOpcDaClientGroup object. It goes about the PmVar.Quality property, by means of which it is possible to find out the validity of the received value, and the ExtOpcDa.TimeStamp property, by means of which it is possible to find out the timestamp of the last value.

OPC DA Basic terms:
CACHE: the auxiliary memory of the OPC server where the server stores data on an ongoing basis that are get from other data sources (e.g. from the PLC device, DEVICE - see further). If the OPC client needs to get data, then they needn't to be get slowly from the PLC device but it can read them quickly from this memory in the OPC server.
DEVICE: the source of the data, from which the OPC server gets data. An access to these data is usually slower by an exponent than from the CACHE.
Asynchronous transmission: The way of the data transfer between the client and the server. The client sends a request (writing, reading) to the OPC server and it DOESN'T WAIT for the end of processing the request. The request is processed by the OPC server during the certain time and the result is sent to the client. The client can perform other operations between sending the request and the result. This way of the data transfer is suitable for prolonged operations, for example reading or writing data from the DEVICE.
Synchronous transmission: The way of the data transfer between the client and the server. The client sends a request (writing, reading) to the OPC server and it WAITS for the end of processing the request. This way of the data transfer is suitable for very fast operations, for example reading or writing from the CACHE if the OPC server is on the same computer as the client.

Instructions for simple check of the OPC communication:
1. Create an empty project (or use an existing one) and create the PmaOpcDaClient object in it. Enter the OPC server which you want to connect to in the "OPC server - CLSID/ProgID" configurator (the server can be selected by the button on the right). If the required server is not offered, then it means that this server isn't correctly installed on Your computer.
2. Create new PmaOpcDaClientGroup subobject in the PmaOpcDaClient object.
3. Check in the PmaOpcDaClientGroup object that the Active after start and Refresh from server at server change configurators are ticked.
4. Create one variable on the "PmaOpcDaClientGroup > Data" tab: press the "" button. The window for configuration of new variable opens. Set the required data type.
5. Fill in the required OPC address of the variable in the "ItemId" configurator. This configurator can be filled in by the button on the right - then the OPC server is started and it'll offer variables that can be transferred, to you by itself (only the OPC server with the interface OPCv2.0 and newers allow it - older OPC servers don't allow it).
6. Some types of addressing require entering another "ItemId" configurator except the "AccessPath" configurator (the same method from the previous step is valid for entering). But for most OPC servers you can leave this configurator empty.
7. Leave entering the variable and start the application (runtime).
8. For testing you needn't create any panels, everything can be found out in the INFO system. Open the INFO system window, switch to the "PmaRoot" item and there switch into the PmaOpcDaClientGroup object that you've created.
You can see the current value and the status of variables on the "Vars" tab.
You can see the statistic of the OPC transfer of this object on the "Object" tab.
9. If the data transfer is not functional, then look into the "Errors" tab in the INFO system.

Pm8.00.04: Improved access to OPC-DA servers on another computer: now it is not necessary to install remote OPC server on the computer with the PROMOTIC application. See Configuration of the DCOM interface for OPC-DA server.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.