04-04-2018 10:36 AM
We are now planning to move an application that uses ProfiNet communications to OPC standard and I'm trying to gather all relevant sources of informations on that.
Specifically, I noted at the bottom of this help page the note (highlight is mine):
You also can share live data from an industrial network by connecting to OPC systems using network variables or the DataSocket Library.
For the life of me I wasn't able to find any documentation about using network variables to connect to an OPC server: can somebody help me? Also, I seem to understand that Datasocket is somewhat out of date and network variables are more efficient in modern network environment: am I wrong?
04-05-2018 02:54 AM - edited 04-05-2018 02:57 AM
If you need "classic" OPC there are samples like a client in samples\datasocket\OpcClient\
If it's OPC UA I believe that you need something like https://open62541.org/ (haven't tried it yet)
04-05-2018 07:44 AM - edited 04-05-2018 07:46 AM
Thanks CVI_User, I already planned to go the DataSocket way. I will start some tests within a few weeks from now. I was just puzzled by that note about network variables: since DS technology is quite neglected, or at least documentation on it is poor and fragmented, I was wondering whether network variables can be better at this.
Are you actively using DS as a OPC client? Does it work well? Is it robust?
04-05-2018 08:44 AM
Hi
I recommend you to use the network variable engine (NVE) instead of DataSocket as an OPC DA server. It is well supported, and we have used it successfully as OPC DA server for years. The NI Distributed System Manager is a good tool to watch and change your variables as you go.
04-05-2018 09:06 AM
Hello Gaus, thanks for the info. I need to communicate with a Siemens S7 PLC via OPC: can network variables be used for that? Can you give me some advice?
I haven't the PLC ready at the moment but I will have it shortly and would like to be able to test it rapidly.
04-06-2018 02:05 AM
Hi,
I'm not familiar with the PLC, but the NVE will not pull the values from the PLC to the NVE (OPC Server).
You have to create an application that does the following:
1) Create required NVE tags (OPC tags). This can also been done manually using NI Distributes System Manager.
2) Reads values from PLC and place the values in the OPC server (and vice versa).
Any OPC client can then read/write data to your OPC server, but your application has to read/write the values to the PLC. There is many OPC servers for PLC that you can buy, but it is more fun to do it yourself:)
04-06-2018 03:33 AM
Hello Roberto,
I've been using DataSocket to implement an OPC client when I need to communicate with Siemens S7 OPC DA interface for years.
I can say that this approach works (I developed applications from CVI 6 to CVI 2015).
I use NVE to develop a custom OPC DA Server, but I never tried to use them to implement an OPC DA Client (as you need).
I don't know if it's possible and/or somehow supported by NI.
As far as I know NI has a module for LabVIEW (DSC module, if my meory is good) which contains a lot of OPC client drivers to communicate with third party OPC DA Server. I perfetly know that this is not a real and effective option for CVI.
OPC UA is a completely different matter. I opened a topic some years ago and as far as I know the best option is open62541 library.
Unfortunately the integration is not painless and the library is under development.
From my side, I proposed fixed on the github page and I suggest NI to actively help developing that library (but I'm not sure NI is really interested in it - and in CVI anymore ).
I hope that the above thoughts and experiences can help you.
04-16-2018 01:26 PM - edited 04-16-2018 01:28 PM
I worked with Siemens OPC Server.
The name is "SIMATIC NET OPC Scout" the price is around 300€
The reference is 6GK1704-0HB14-0AA0 (probably is obsolete)
Functions for work with datasocket is:
http://zone.ni.com/reference/en-XX/help/370051AC-01/toolslib/cvidatasocket_library_function_tree/
Example code:
void OPCCallback (DSHandle localDSHandle, int event, void *pUserData); //header Callback
int status;
short valueOPC;
DSHandle OpcHandle;
char addressOPC[256]="opc://localhost/.."; // Please, see the next picture the correct url
status = DS_OpenEx (addressOPC, DSConst_ReadWriteAutoUpdate, OPCCallback, NULL, DSConst_EventModel, 2.0, &OpcHandle);
DS_GetDataValue (OpcHandle, CAVT_BOOL, &valueOPC, sizeof(valueOPC), 0, 0);
void OPCCallback (DSHandle localDSHandle, int event, void *pUserData)
{
HRESULT hr = S_OK;
int index=-1,i=0;
switch (event)
{
case DS_EVENT_DATAUPDATED:
if(localDSHandle==OpcHandle)
hr = DS_GetDataValue (OpcHandle, CAVT_BOOL, &valueOPC, sizeof(valueOPC), NULL, NULL);
break;
/*
case DS_EVENT_STATUSUPDATED:
DS_GetStatus (localDSHandle, &Gstatus);
hr = DS_GetLastMessage (localDSHandle, message, 1000);
break; */
}
return;
}
04-17-2018 01:21 AM
Hello Jose,
thanks for the info, but unfortunately my customer wants the PLC to be a client and my program to operate as a server.
I contacted with NI support and unfortunately they can give little or no up-to-date info on whether it is actually possible to use network variables engine as a OPC server and how, so I'm now going a different path.