LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass parameters to a subVI and run it in background

Hi, I have a simple wish: Under LabVIEW 8.2 (Windows), I wish to pass some parameters to a SubVI, and then the SubVI should run in background, that is: continue without halting the main VI.

 

If I just call the VI, the main VI is halted, and if I call by VI reference, I cannot pass parameters to the SubVI.

What is the best solution to this ?

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 1 of 10
(4,896 Views)

You could pass parameters to the subvi using an Action Engine.  See here

 

 http://forums.ni.com/ni/board/message?board.id=170&thread.id=240328&view=by_date_ascending&page=1

 

 

PS Sorry for the weird spacing, dont know what is causing that 

Message Edited by jmcbee on 10-07-2008 01:43 PM
Message Edited by jmcbee on 10-07-2008 01:43 PM
Message 2 of 10
(4,888 Views)

Jan Nielsen wrote:

... and if I call by VI reference, I cannot pass parameters to the SubVI.

What is the best solution to this ?


Please clarify.

 

A Call by Reference allows you to pass values to the VI. See here.

 

 

I'll assume you meant to write that the VI hangs until the sub-VI call completes.

 

I that case you can use an Invoke node >>> Run (set Wait until Done input to false) VI AFTER you have used invoke node >>> ctrl Val.Set to specify your parameters.

 

Ben

 

PS JM, Kudos to you for citing my Nugget. Smiley Wink

Message Edited by Ben on 10-07-2008 02:45 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 10
(4,884 Views)

Hi Jan,

 

If I understand your situation correctly, what you want to do is run the vi dynamically. A search of the forum will show lots a examples I am sure as well as if you search for "dynamic" in the LV examples. But one possible method I show in the attached image. You first set a front panel control value by name, then run the vi, show the window (in my case set the transparency of the window) and then close the reference. Something similar should work for you hopefully. Hope this helps.

 

cheers,

 

--Russ

 

 

Message Edited by Russ Evans on 10-07-2008 02:49 PM
Message 4 of 10
(4,879 Views)

Thanks Russ, I have tried the method you describe, however I get this error when trying to run the VI:

Error 1000 -   Possible reason(s): LabVIEW:  The VI is not in a state compatible with this operation.

Method Name: Run VI  VI Path: C:\LabVIEW-programmer\DB Monitering\Double_Shell_Call.vi

 

Do you have any hints what is wrong ?

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 5 of 10
(4,848 Views)

Jan Nielsen wrote:

...

Error 1000 -   Possible reason(s): LabVIEW:  The VI is not in a state compatible with this operation.

...

 

Do you have any hints what is wrong ?


I believe that error will be returned if the target VI is reserved to run due to it being in the hiarchy of an already running VI.

 

Ben

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

In addition to Ben's point, I think you also need to have it closed in your development enviornment.

 

To find some examples in the forum and on DevZone, try 'Launcher' as keyword. 

 

Felix 

0 Kudos
Message 7 of 10
(4,807 Views)

Thanks a lot everyone, now it is almost working.

 

I have one last question. I am calling a SubVI that does a task, then waits 10 secs., then does another task - using Russ' dynamic method as above, with an Invoke Node. But I am not opening the Front Panel of the SubVI since I don't need this.

 

Now, if I have a Close Reference last - as in Russ' example - the last task is never run. So I think, the Close Reference makes the thread "disappear".

If instead I wire a True constant to the Auto Dispose Ref in the Run VI Invoke Node, the task is run.

Will this be OK or will I have the references "hanging" ?

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 8 of 10
(4,777 Views)

Auto Dispose Ref = TRUE means that LabView determines if the ref is not needed any more. You will go fine with that.

 

Auto Dispose Ref = FALSE means, that you tell LabVIEW when to dispose the reference using the Close.vi. That's why your module never run. A common use case for that is to launch a VI and pass the reference to the vi (now holding the reference to itself). When the VI is don, it closes the reference of itself to unload.

 

Felix 

0 Kudos
Message 9 of 10
(4,769 Views)

Thanks everyone, all is OK now.

 

BR, Jan

Jan Nielsen
Freelance system analyst and LabVIEW programmer
0 Kudos
Message 10 of 10
(4,734 Views)