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 producer of the PLC device. The OPC server is the OS Windows application that runs either as a stand-alone program or it can be for example a Dll library. The OPC server can, for example, communicate with the PLC device 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 OS Windows 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, it is necessary to create the PmOpcClient 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 PmOpcClientData objects into the PmOpcClient 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 PmOpcClientData.Read-PmOpcClientData.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 PmData
object and for OPC the ExtOpcClient
2) Data definition direct in PmOpcClientData object:
In the Data
page can be defined variables, which are configured similarly as for example for the PmData
object. But for each item it is necessary to set moreover two fields required for the OPC communication. The fields are the ItemID
items. These two fields represent the address of the variable on the OPC server. If the OPC server supports the OPC version 2, then the buttons (with 3 dots) for the selection of the fields should be functional at the enter points directly from the OPC server. If it is not true, then it is necessary to enter the data manually.
The access to the data items in the PmOpcClientData object is the same as in the PmData object, i.e. for example over the PmOpcClientData.Item property. This property accesses one variable as the Var object from which the standard data (especially the value of the variable by the Value property) can be found but the Var object has two more properties specific only for the OPC in the PmOpcClientData object. It goes about the Var.Quality property, by means of which it is possible to find out the validity of the received value, and the ExtOpcClient.TimeStamp property, by means of which it is possible to find out the timestamp of the last value.
OPC DA Basic terms
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 on the OPC server.
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
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 writing or reading data from the DEVICE
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 writing or reading from the CACHE
if the OPC server is on the same computer as the client.
Instruction for simple check of the OPC communication:
1. Create an empty project (or use an existing one) and create the PmOpcClient
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.
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 "PmRoot" item and there switch into the PmOpcClientData
object that you've created. You can see the current value and the status of variables on the Vars
page. You can see the statistic of the OPC transfer of this object on the Object
9. If the data transfer doesn't work, then look in the Errors
item of the INFO system.