LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control a SubVI with Main VI using event Structure

Solved!
Go to solution

Hello All,

 

I am trying to pass values from Main Vi to the Sub VI..

However my subvi runs with an Event structure. (Value change). 

So when i run my main VI and i press the highlight  (yellow bulb), the sub vi does not execute..

I am sure.. i m missing something very basic.

 

Both my Main and SubVI operate with an event structure.

Please see my attached files.

 

 

Download All
0 Kudos
Message 1 of 19
(6,476 Views)

Remove the event structure and local variable, and "calculate" button in the subVI , they are not needed.

 

When the main VI calls the subVI, the subVI executes and returns the result. The subVI does not even need to be open.

 

You should also place a while loop around the event structure in the main VI. (don't use the continuous run button!)

Message 2 of 19
(6,471 Views)

Thank you for your advice.

Yes, i understand, that by removing my event structure in my Subvi, i can easily use my main VI to call the SubVI using the event structure in main VI as shown by you.

 

However, is there a possibility that i can call my SubVI (with event structure) from mainVI(with event structure, without opening the subVI.).

 

As shown in the previous attachment, i am trying to fire the event(in both VI's) using the same "calculate" button.

0 Kudos
Message 3 of 19
(6,452 Views)
Solution
Accepted by Rambo333

Each event structure listend to a different calculate button: the one on the respective fromt panel. (Even if they have the same label, they are completely seperate!)

Events are primarily for user iteractions, they will not fire if a terminal is written programmatically. If the front panel of the subVI is closed, you cannot press the button on it.

 

Can you explain the purpose of your exercise? You seem to tangle yourself up in some basic misconceptions about dataflow and events.

0 Kudos
Message 4 of 19
(6,446 Views)

Try taking a look at Ton's Nugget on Dynamic Event Registration found here.

 

 

I have images in my image gallery showing examples of how I have used this to keep my code clean and modular.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 19
(6,442 Views)

The idea behind was for a test purpose.
I have to have 5 indivisual test programs created for users.I also want to have 1 program to include all the 5 indivisual programs.
So I created 1 program and included all the 5 indivisual programs as SubVI's fired using the same indivisual event structure variable.
Please see an example attached for 2 indivisual programs.. 

Download All
0 Kudos
Message 6 of 19
(6,437 Views)

Rambo333 wrote:

I have to have 5 indivisual test programs created for users.I also want to have 1 program to include all the 5 indivisual programs. 


We need a few more sentences on how this all should work. Earlier, you said that the subVI does not need to show the panel.

 

What is the purpose of the outer while loop in the main program.

0 Kudos
Message 7 of 19
(6,433 Views)

As shown in my previous attachment...

 

I have 2 SubVI's , both of them if run indivisually using an event structure and works fine. Both of them have events fired on Boolean "Value change". 

 

I then created a Main VI and included 2 SubVI's.

 

My main VI now has 2 event structures, both supposed to run indivisually on their respective events being fired.

My aim is to have the same Boolean (of the indivisual SubVi's) to fire the events in he main VI.

 

Earlier, you said that the subVI does not need to show the panel.

I want to run everything from the Main VI, so i dont want to show the user, that the SubVI even exist. Please see my attach example, of what i do not want to do.

The program using "SubVI node setup". Using this technique, I can get results.

 

What is the purpose of the outer while loop in the main program.

The purpose was to keep running the program until the user hits stop.

No particular significance to it.

 

 

Download All
0 Kudos
Message 8 of 19
(6,428 Views)

Ton's nugget will show you how to fire events in the sub-VI for objects on the FP of the caller as illustrated below.

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 19
(6,424 Views)

@Rambo333 wrote:

What is the purpose of the outer while loop in the main program.

The purpose was to keep running the program until the user hits stop.


Since the inner loops never stop, the outer loop never does anything useful.

 


@Rambo333 wrote:

 

My main VI now has 2 event structures, both supposed to run indivisually on their respective events being fired.

My aim is to have the same Boolean (of the indivisual SubVi's) to fire the events in he main VI.

 

Earlier, you said that the subVI does not need to show the panel.

I want to run everything from the Main VI, so i dont want to show the user, that the SubVI even exist. Please see my attach example, of what i do not want to do.



This is way too convoluted and useless for my taste. So the Main VI fires the subVI, which should (without showing its panel!) fire the event in the main VI? Are you serious? Since the main VI controls the subVI, it should know what's coming. Also, since the subVI now never completes, it will stall the main VI forever inside each event case.

 

Can you describe an exact use case where all this would make sense? Why would mainVI and subVIs battle each other in an endless (event)firefight?

0 Kudos
Message 10 of 19
(6,422 Views)