LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use global variable to transfer user parameter in some Vi

Hello,

I have troubles when I use a global variable to transfer the parameter to a first Vi (user interface) to a second vi (acquisition interface).

In the first Vi, the user paramater is wrote to my global variable.
In the second Vi, the acquisition parameter is read to my global variable.

This 2 Vis are include to a master Vi who synchronized by the error bus.

The problem :
For the first use, the user parameter is transfer to the global variable but the acquisition vi read the old parameter. In the second use, acquisition vi read the first use parameter.

After I use the IN/OUT parameter subvi and i have too this problem.

Thanks for help.

VIEW THE PROBLEM : (I use event structure
)
0 Kudos
Message 1 of 3
(2,817 Views)
Labview uses the dataflow to chain the execution. That is, as soon as one item of data is ready is is presented to the next stage.
Global (or local) variables do not easily fit in there. A variable is always present and ready to give away it's data. It does not matter that you write to it in one vi. Another vi, that is running concurrently is not aware that the content may have changed.
Especially if you reference variables outside of loops, the value is taken just once and never updated. Be aware! If in doubt, use the tracing facilty (the light bulb) to follow the data flow.
Gabi
7.1 -- 2013
CLA
Message 2 of 3
(2,817 Views)
Gabriela is right about there being the possibility of a race condition when global variables are used. I avoid the use of globals until it is absolutely necessary.

I took a look at your code. Because there is an error cluster to control when parts of thecode execute and there are no loops or VIs running in parallel, you could just pass the info in the global variable with a wire from one subVI to another.
0 Kudos
Message 3 of 3
(2,817 Views)