LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send data to network shared variable

I am connecting to my hardware via network and using modbus to read the data. I have a series of channel addresses (not consequtive) in an array which I then loop through, read the modbus registers and format the data. This data is stored in a further array (A) . I have a listing of the shared variables also in an array (B) and want to write the corresponding value of A into variable B. This is my problem, try as I might, I cannot get the writing of data to work. 

 

vtiu_0-1678180822930.png

vtiu_1-1678180950383.png

 

The orange line is the connection to the data array (A). For test purposes, there are 3 shared variable with the names "1", "2" and "3". When I get the write to work I will supply a listing of the shared variables in an array.

 

Labview 2019, 32 Bit with DSC module.

 

The error says that a connection on open variable is missing or wrong.

 

I would appreciate any help. Many thanks.

 

Mark

0 Kudos
Message 1 of 5
(852 Views)

Hi vtiu,

 


@vtiu wrote:

vtiu_0-1678180822930.png

The error says that a connection on open variable is missing or wrong.


I see two problems:

  1. Why don't you wire the SV reference directly to the OpenSharedVariable function? Why do you need the URL string in between?
  2. You forgot to wire the reference output of the Open function to the Write function…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(846 Views)

It will not accept the SV reference to the OpenSharedVariable function. The data line shows Network Variable (BV Tag) and the input is a refnum.

 

"You forgot to wire the reference output of the Open function to the Write function…" - corrected, thanks.

0 Kudos
Message 3 of 5
(836 Views)

After making these changes, the VI will run but the shared variables are not updated.

 

vtiu_0-1678191983759.png

And I have this error:

vtiu_1-1678192049105.png

 

0 Kudos
Message 4 of 5
(814 Views)

After sleeping on the problem, I have found the error and solution. The problem was the variable Refnum. A small demo VI is below. The Shared Variables MUST be created first.

 

vtiu_0-1678262947801.png

Right click on the network variable (on the right) and changing to programmatic access gave me the correct Refnum string. This I copied to the left side and wired to the write function. This demo runs too fast to be able to see the data change!

 

In my original VI I then created an array with the Refnums and wired it to the Write function WITH autoindexing. The data array I also set to autoindexing. This runs fine in about 250 ms for the whole VI - fast enough for me. The end result is below.

 

vtiu_1-1678263468987.png

 

0 Kudos
Message 5 of 5
(772 Views)