LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket problems with OPC

Hello,

I'm connecting to an OPC-server with datasockets and have a problem when I have more than ~6 open connections.

I use the Datasocket open-, read/write- and close VIs with LabView 7.0.
With 6 open connections everything is ok, but when I add a couple more then the whole program freezes randomly (LabView needs to be killed with taskmanager).
It is not a problem with a _particular_ OPC-connection, lets say that I have connections to OPC data A,B,C,D,E,F (that's 6 connections) it works. Then I add connections to G and H -> it freezes on some runs.
If I then delete (lets say) B and C and have: A,D,E,F,G,H -> it works fine again.

So the program I'm running is of the following sort:

A flat sequence with three frames. In the first frame I open the connections with the DataSocket Open VIs. Error ins and outs are serially connected, so the Open VIs don't execute in parallel. This should be ok? With ~6 opens here the program runs great, but with ~7-8 opens it freezes randomly. I have tried timeouts in the range of 500ms to 40s. When a DataSocket VI freezes (execution highlighted to see where everything goes wrong) there is no timeout. Everything just freezes.

The second frame has a while loop and inside that loop there is code that modifies/reads the contents of the corresponding OPC data connections.

In the last frame I close all the connections with DataSocket close VIs.


Is this a problem with LabView 7.0 DataSocket VIs or is there something wrong with my datasocket usage..
I would require only about 15 open connections, what would be the best choice to subscribe and publish OPC data?

Should I open and close the connections inside the loop on EVERY loop iteration? (which doesn't sound that wise) That way I would not have many connections open at the same time.

And what happens if I DON'T use the DataSocket Open/Close VIs, instead I use the write/read VI straight away (you can specify the URL directly to the read/write VIs and it works, atleast it gives/writes data). Does the write/read VIs automatically close the connection when finished?


Well, any comments or experience with similar problems would be nice.

-Olli
0 Kudos
Message 1 of 3
(2,939 Views)
The maximum number of connections is theoretically 1000 (What Is the Maximum Number Of DataSocket Connections I Can Make To One DataSocket Server?), so it's not simply a problem with the number of connections. That many connections is probably just overloading your system. What are the specs of the computer you are using?

What mode are you running these connections in? You could try running them in AutoUpdateMode (Difference between DataSocket AutoUpdate Mode and Non-AutoUpdate Mode) to improve performance.

As far as the programming structure goes, have you had a look at "Multiple OPC Items Monitor.vi" in the NI Example Finder? You may be able to make some optimizations based on its structure.

Are you familiar with LabVIEW DSC (Datalogging & Supervisory Control)? The Tag Engine used by DSC can greatly optimize communication with OPC servers. See this thread for more information.
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,915 Views)
hi

have you tried to emulate your OPC-Server with some DSTP - Items? By doing so you may be able to find an error inside your App, you just need to change some URLs. I can't imagine a OPC - Server which is unable to serve more than 6 items at the same time, as long as the machine has enough RAM and CPU and there's no problem with the hardware attached to the server.

for the programming its the best to use DataSocket Open/Close Functions before and after the while-loop and DataSocket Read/Write Functions inside the loop. Pass the Connection ID to the Functions, when passing the URL the connection is established and closed at each call inside the loop.


By the way: what kind of OPC-Server do you use? can you post some code?

best regards
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 3
(2,909 Views)