LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering event in subvi from main vi

Solved!
Go to solution

Trying to trigger events from a main vi.

 

I have created a sample vi as a basic unit from a much larger program.

 

The top level vi calls a subvi that contains an event structure.  The subvi runs continously and will exit when the program is stopped by the user.

The top level has controls which are passed to a global, and the global is read in the subvi, which should trigger an event.  (it doesn't)

 

The subvi has to be able to run as either a subvi or a top level.

 

 

For context:

  The project this comes from is a test system.  The subvi prepresents the main control panel for the test system.  We wish to automate the test system and so are using the main control panel as a subvi so we can automate a number of individual test.  (Frequency response, gain linearity, etc.) 

 

 

See below for an additional attachment that contains the global variable and project file (can only attach 3 files at a time)

The global is just a stop button and a cluster that contains 3 boolean values.

 

 

It doesn't work, I was hoping somebody could explain how to do this without making many changes to the existing subvi.  If necessary a case statement could be added that is only active when the program is functioning as a subvi, which would contain the code to trigger the events so the event case can handle it.

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 1 of 8
(5,960 Views)

attachment with the global variable and project file

 

Download all files then open the project

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
Download All
0 Kudos
Message 2 of 8
(5,959 Views)

First things first.

 

Using 'Global' to communicate between VIs is not the best option.

 

However you can get you system to work by adapting your sub-vi according to this:

19547i343D6687127CFB2D

 

In your MainVI you should just place the Sub-vi. Don't us FP.Open, since that won't start the subVI.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 8
(5,948 Views)

I have modified your main and subvi to give you better architecture.  Instead of using globals, it is better to pass references to the subvi so that they can share the data space with the main vi.  Clicking on any referenced control on the main can cause an action in the subvi.  Also, instead of writing the value to a local or global in the subvi, you must write to the Value(signaling) property node in order to trigger an event.  In your main, you called the subvi dynamically, and then you called it implicitly.  Not desirable.  I changed your code to call it one, implicitly.  Study the modified vi's against your original ones.  You will see how references and Value(signaling) work.  Also, timing is important in that the timeout case in the event structure must be less than or equal to the Wait(ms) time in the lower loop.  If not, the lower loop will queue up events faster than the event structure can handle them and you will have problems.

 

You can delete your globals vi.  It isn't needed anymore.

- tbob

Inventor of the WORM Global
Download All
Message 4 of 8
(5,929 Views)
Solution
Accepted by topic author eximo

I'm looking over the code now, I'll update the kudos if this works

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 5 of 8
(5,928 Views)

This works perfectly, give this man some kudos.

 

I just hope I can integrate this into my main.

 

Works as standalone, works as a subvi.  PERFECT!

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 6 of 8
(5,915 Views)

Hi everybody,

i´ve a similar Problem. I want to do it the other way round. I want to Trigger an Event in my main.vi from a boolean action in my subvi.

The Subvi is called dynamically with the Call by Reference Node. When i press a Latch in my subvi i want to Trigger an Event in my main vi. Can i use this as an Example and just " turn it around" ?!

 is it a Problem when my Subvi gets called dynamically in an Event in the Mainvi?

0 Kudos
Message 7 of 8
(4,187 Views)

Hey Kai,

This post is from 7 years ago so I would recommend creating a new thread with your question to get more visibility! This should help your question get answered faster.

 

Adena L.
Technical Support Engineer
National Instruments
0 Kudos
Message 8 of 8
(4,173 Views)