LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using global variable

Solved!
Go to solution

Hi,

 

I have always learned that using global variables in software engineering is not the right method. So I am going to do a task where I need to communicate between different VIs. So can you please help me by telling me what is the alternate method to communicate between VIs if using global variables is wrong. Thanking You.

 

Govind Sankar Nair

Student Master of Science

University of Applied Sciences Darmstadt

 

0 Kudos
Message 1 of 17
(3,926 Views)
Solution
Accepted by topic author govindsankar

Notifier, queues, channels, events, ...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 17
(3,908 Views)

I need to share data between VIs. So using notifier, queues, channels etc, I can do that? Please kindly do reply. Thanking You.

0 Kudos
Message 3 of 17
(3,900 Views)
Solution
Accepted by topic author govindsankar

@govindsankar
Yes. Data can be passed from two different VI's using either notifier, queues, channels etc while still following LV dataflow. You can search for examples to see how those method works.

0 Kudos
Message 4 of 17
(3,893 Views)

Thank You very much for your kind reply, I will do as you have explained.

0 Kudos
Message 5 of 17
(3,885 Views)

the main problem are race conditions for the read-write-access.

you have also the option of wrapping the global access with a semaphore

or use a data value reference (DVR).

 

in most cases a queue / channel is the way to go for communicating between loops as the others have suggested.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 6 of 17
(3,880 Views)

@GerdW wrote:

Notifier, queues, channels, events, ...


Assuming Govind isn't asking about how to get data from 1 VI to Another in the normal circumstance, in which case direct wiring through the connector pane is the answer. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 17
(3,864 Views)

@govindsankar wrote:  I have always learned that using global variables in software engineering is not the right method.

There is a time and place...Are Global Variables Truly Evil?

 

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 17
(3,862 Views)

No, I am talking about different VIs in a project, one VI acquiring the data and another VI needs to work on it. So the first VI should have data in some kind of memory for the second VI to access. This is where my doubt is, I am currently going through queues to find out how this can be done. If anyone has any access to any material that will help me in doing the same, it would be very helpful. Thanking You. 

0 Kudos
Message 9 of 17
(3,849 Views)

@govindsankar wrote:

No, I am talking about different VIs in a project, one VI acquiring the data and another VI needs to work on it. So the first VI should have data in some kind of memory for the second VI to access. This is where my doubt is, I am currently going through queues to find out how this can be done. If anyone has any access to any material that will help me in doing the same, it would be very helpful. Thanking You. 


Yes, depending on how fast collecting and analysing data is, you can either use the easy Connector pane out from data gathering, to Connector pane in of the analysing VI, i.e. normal dataflow.

The 2nd most common option is to look at the "Queue based Producer/Consumer" example and send all data collected to a queue, and have an analysis queue.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 17
(3,836 Views)