LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to OPC via network variables

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?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 1 of 9
(3,603 Views)

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)

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 2 of 9
(3,522 Views)

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?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 9
(3,512 Views)

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.

0 Kudos
Message 4 of 9
(3,506 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 9
(3,503 Views)

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:)

 

 

 

 

0 Kudos
Message 6 of 9
(3,492 Views)

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 Smiley Sad).

 

I hope that the above thoughts and experiences can help you.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 7 of 9
(3,484 Views)

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

 

 image.jpg

 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;

}

0 Kudos
Message 8 of 9
(3,410 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 9 of 9
(3,396 Views)