LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combining two VIs

I am fairly new to labview. Currently I have two separate VIs to acquire data using DAQmx. The first VI manually collects data while the second is automated. I want to be able to switch between these two VI's at the switch of a button. What I tried was creating a case structure where in one case the automated data taking code would be run and in the other case the data taking would be manual. However, while both of these VI's run just fine before changing the case, as soon as the case is changed everything freezes. Perhaps the first code in the first case isn't being terminated properly when the case is switched? Any suggestions as to how I could fix my problem are greatly appreciated. I will upload my VI with the case structure, but there will be missing subVIs. The subVIs should all have descriptions though. Thanks!

0 Kudos
Message 1 of 2
(1,793 Views)

A few problems.  One, you are using a stacked sequence structure.  You'd be a bit better off if it was a flat sequence structure.  There are a number of reasons why NI has now removed it from the palettes.  In reality, you problem don't need a sequence structure at all.

 

But the big problem is your VI is inside out.  You have a case structure on the outside and a while loop inside.  There is no changing of the switch because it is only read once when the VI begins.  You have to stop the VI and restart it for it to read the switch again.

 

The reason it locks up is if you hit the enable button, it is registered for an event structure in the one case, and it is set to lock the front panel until complete.  Well if you can't get to that case, you can't ever get to the event structure to handle that event!  Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help

An event structure should never be in a part of code where it can't regularly be accessed through normal program execution to handle events, especially not an event structure that locks the front panel.

 

Oh, and your code in that enable case is pure Rube Goldberg Code.  You use a boolean to drive a select case that either outputs a True or False,  exactly what you started with!  Just using the wire gives the same result!

 

Throw away your VI and start over.  Anything where the state of code is dependent on other things screams out for a State Machine architecture.

0 Kudos
Message 2 of 2
(1,770 Views)