LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enum to control VI's

I have 4 small but different VI programs on the same BLOCK diagram. Is it possible to control from the ENUM in the PANEL to execute only ONE VI? Or If I press the ON button the VI's will run one after another. I just want to run one vi at any one time.
0 Kudos
Message 1 of 13
(3,715 Views)

Create a case structure and wire the enum into its selector terminal.
That's it, now you can use the enum values as different cases. If you right click and add a case, you will get another one of the values. Simply place a loop around the case and place each subVI into the appropriate frame.


___________________
Try to take over the world!
0 Kudos
Message 2 of 13
(3,713 Views)
If I have four VI's then should I have four loops? Or is it one loop for all the four vi's? Should I use FOR LOOP or WHILE LOOP? Can you give me a simple example? It would be much apperciated.
0 Kudos
Message 3 of 13
(3,706 Views)
You use one whiile loop. (You don't know at the start how many iterations should run. Only if you know that, a FOR loop is suitable).
 
An example would be the "New event handler". Search for it in the example browser. What is your LabVIEW version.
0 Kudos
Message 4 of 13
(3,705 Views)
My labview version is 6.0 (or 6i).
0 Kudos
Message 5 of 13
(3,696 Views)
I have not been able to locate the  example "new event handler". However I have done something. I hope that it is correct.  I believe that the  only the selected sub VI will run. The other VI's will not run. Is it right?
0 Kudos
Message 6 of 13
(3,687 Views)
Oops! I forgot the VI. Here it is!
0 Kudos
Message 7 of 13
(3,685 Views)

Look at this:

The shift register keeps the value from the last iteration. In each iteration the value of the enum is compared to the last value, and when it changes, the True case executes. The same can be done by using the small OpenG VI shown here (along with its code). Because that VI was made reentrant, you can place it on any wire you like and it will tell you if the value of the wire changed since the last time it was read.

As a suggestion, you may wish to avoid using the green edge for the case structure. That is usually used for error handling and can be confusing.


___________________
Try to take over the world!
0 Kudos
Message 8 of 13
(3,678 Views)

"As a suggestion, you may wish to avoid using the green edge for the case structure. That is usually used for error handling and can be confusing."

But the green edge is a case. I cannot delete the case. The program will mess up.

With this LV, can I choose which sub VI to run. I want to execute only "UP" for example and none of the others. Can that be done?

0 Kudos
Message 9 of 13
(3,674 Views)

I didn't say delete the case. I said you may not want to use a green edge for the case because, because that's usually used for error handling and can be confusing. The green edge appears if you wire an error cluster into the selector. You can change it by using the paint tool on the edge.


With this LV, can I choose which sub VI to run. I want to execute only "UP" for example and none of the others. Can that be done?

Didn't you test it?
In your VI, if you choose a value for the enum, only one of the subVIs will execute (and the VI will stop).
In my VI, every time you change the value of the enum , the appropriate subVI will be run (just once, or in your case, just 100 times). The only difference between our VIs is that mine runs constantly. That's the while loop we talked about.

So the answer to your question is yes, it can be done, and you seem to already know how to do it.


___________________
Try to take over the world!
0 Kudos
Message 10 of 13
(3,674 Views)