12-06-2012 11:16 PM
Hi,
I am having a problem with sharing data with functional globals between two parallel while loops:
The problem is sometimes the functional global seems to get "locked" and the output becomes constant zero. It also appears that every time I first open the VI, it works just fine. But from the second time execution, it begins to have the problem.
Solved! Go to Solution.
12-06-2012 11:58 PM
You need to intialize your FGV Stop VI BEFORE your lower loop begins. Although you are using a functional global variable, you still have a race condition. The FGV gets read in the lower loop before it has a chance to be intialized with a false in the upper loop. Functional global variables remember their data between runs of the VI. So it is still set to stop from the last time you ran the VI. The reason it works when your VI first opens is because the VI has not been in memory, so when it loads, it loads with the default value of False in the shift register.
12-07-2012 08:57 AM
Why not use user events to update the UI? It is a better approach than the FG and will avoid race conditions.
12-07-2012 09:51 AM
Thanks for the idea. Where can I find an example related to this problem? I found one here:
https://decibel.ni.com/content/docs/DOC-21277
Is it relavant?
12-07-2012 10:26 AM
Yes, that is one place. You can also look at the examples that ship with LabVIEW.