LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong definition for local/global variables

Highlighted

My program is intended to acquire data in three modes: 1. Acquire only, 2. Acquire and save based on external trigger, and 3. Save data.  When you run it, it will not go to the intended screen (tab) right away, rather only after completing the first iteration. Also you can’t change any of the controls when the program is actually running.  I think this has to do with the way I defined my local/global variables, but I am not sure.  I can’t figure this one out…  Any advice would be greatly appreciated!

 

Also, is there an (easy!) way to modify this code such that it will run in an idle mode and will only execute each time you hit specific button?

 

Thanks for your help!

 

 

0 Kudos
Message 1 of 4
(494 Views)

Hi,

 

What you should always try to do is to seperate your UI loop from your Program loop.  It's called consumer and producer loop.

It means that you are sending commands (queue's) from the UI loop to the Program loop.

 

The reason for your time delay now is that when you're acquiring samples, it doesn't respond to your buttons any more.

 

I will try to rewrite your code now.

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's Smiley Wink
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 2 of 4
(491 Views)

Hereby some quick and dirty code of producer/consumer.  This should get you started.

 

The only thing to do now is to watch that your DAQ loop isn't locked in one state while waiting for data. 

Better is to start a task => go to idle => fetch aqcuired data => go to idle => fetch data => go to idle => ...  untill you finished measuring

 

Consumer_Producer.png

 

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's Smiley Wink
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 3 of 4
(488 Views)

@voice wrote:

My program is intended to acquire data in three modes: 1. Acquire only, 2. Acquire and save based on external trigger, and 3. Save data.  When you run it, it will not go to the intended screen (tab) right away, rather only after completing the first iteration. Also you can’t change any of the controls when the program is actually running.  I think this has to do with the way I defined my local/global variables, but I am not sure.  I can’t figure this one out…  Any advice would be greatly appreciated!

 

Also, is there an (easy!) way to modify this code such that it will run in an idle mode and will only execute each time you hit specific button?

 

Thanks for your help!

 


 

You have an infinite while loop in event case one.  You have a false constant wired to the stop terminal which means the loop never ends.  The only way to end the program is to hit the abort button.  Also, you have Lock Front Panel until event completes checked, which prevents any more events from registering for the front panel until the event completes.  This can block execution.

 

With event structures, you shouldn't have any while loops inside of an event case.  You really don't want any event case to take so long that the user feels the program has become stuck or unresponsive.  This means limiting the execution time of the code to less than a second, perhaps less than 1/2 a second.

 

As ABC said, if you do have long running code, then it is a good idea to pass that execution off to a parallel while loop with a producer/consumer architecture.

 

0 Kudos
Message 4 of 4
(472 Views)