LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

functinal global variable for producer - consumer architecture

Hi all,

 

I am using a Producer - consumer architecture for my data acquistion as in the belwo diagram.. at some time i am stuck insde the while loop continously acquiring data .. is there any way i use one stop button as a functional gloabl variable and stop inside (consumer while loop) as well as producer architecture....

 

Why i need this ?? so many design rules say that global variables are not a good idea...

 

Thanks in advance...

 

 

FGV

0 Kudos
Message 1 of 3
(2,215 Views)

Global variables are perfectly fine when used correctly. In fact using them to signal an application shutdown is probably fine. If your functional global only has a set and get, and doesn't perform any action, then a global is actually preferable.

 

If you care about the order in which your loops are shut down then you need something more complex.

 

That said I did write a micro nugget on doing just what you are asking.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 3
(2,213 Views)

FGVs will work fine for your application.  You can also wire your error cluster to your stop button.  Your producer loop should throw an error 1 when the stop button is pressed, which will in turn stop your consumer loop.  But you would need a slightly different design for this.  Your consumer loop is designed to not advance until the stop button is pressed.  Instead of using and enum, you can use your producer loop to control the trigger to take a measurement.  No need for the while loop in the consumer loop this way.  You could set up your consumer loop to take a number of measurements, and then quit or take measurements for a certain amount of time.  Either way, you can stop your while loop when it times out.

If you choose to stay with this design, a simple state machine archetecure might be better based on what I see.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 3 of 3
(2,195 Views)