LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create an array containing shared variable values

Hi
 
I am trying to programmatically create an array containing shared variable values and their names.  I can get the variable names by supplying the process name to the get shared variable list function.  How do I then read the value of all the shared variable items returned?
 
I have used a data socket open to open a connection to all variables when my program starts.  I then use datasocket read on the opened connections to write to an array.  This works fine until I try to write to one of the variables using a shared variable node.  The variables writes can take from 4secs to 2 mins.  When I remove the shared variable node again all is fine.  Also when I stop using the data sockets, all is fine.
 
Is there a conflict between shared variable nodes and data socket writes to the shared variables?
 
Can anyone help?  I cannot easily post example code because I am reading the variables from a Wago PFC (PLC) using OPC.
0 Kudos
Message 1 of 6
(3,587 Views)
Hi R-R,

I am not sure I follow, do you mean that if you use a shared variable node as well as writing via datasocket the variable node takes a long time to execute? When using a variable node does anything happen to the datasocket reads?

Regards

Jon B
Applications Engineer
NI UK & Ireland
0 Kudos
Message 2 of 6
(3,565 Views)
Hi
 
The shared variables being written into the array works really well on its own.  It also works well with read and writes to the PLC using front panel objects bound to the same shared variables. 
 
The problem occurs as soon as I put a shared variable write node within the main program loop where the data socket reads exist.  This causes the main loop to slow down and writes requested to the PLC via bound controls take ages and the whole thing grinds to a halt.  The reading of values doesn't appear to be affected as much.  When the main loop is stopped it takes a while to actually stop and the write requests suddenly start getting though to the PLC in quick succession.
 
It seems like the write requests are being queued but are being blocked by something.  I will try and post and stripped down version of my software so you see if I have done anything wrong.
 
Thanks
 
Mark.
 
0 Kudos
Message 3 of 6
(3,561 Views)

What happens if you select the shared variable write node and do a "Create sub-VI" and save?

THis has been reported to help with performance.

Yes post an example and share which version you are using.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 6
(3,554 Views)

Hi

Sorry I forgot to mention the LabVIEW version, its 8.20.  I have tried saving the shared variable node as a sub VI and it makes no difference.

Attached is a stripped down version of the software.  You will not be able to connect to the IO server because it requires some Wago hardware and software.  You may spot something I have done wrong with the I/O servers, variables or sub VI's.

The main program that runs is called 'HMI Engine' in the 'Framework' folder.  There may be some other things in the project that aren't used in this example.  I have removed all but the variable connection part of the code.

I hope someone can help!?

Thanks

Mark.

0 Kudos
Message 5 of 6
(3,542 Views)
Can anyone help me with the performance issue I have?
0 Kudos
Message 6 of 6
(3,513 Views)