LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run a VI as subVi and alos with a Asynchronous Call

Hi ,

I want to run a VI as a SubVI using Asynchronus Call and then the same VI as a Asynchronus Call.

Is it possible?

0 Kudos
Message 1 of 7
(2,456 Views)

Hi himanshu,

 


@himanshu25 wrote:

I want to run a VI as a SubVI using Asynchronus Call and then the same VI as a Asynchronus Call. Is it possible?


How do you run "as a subVI using AsyncCall"?

 

You cannot run the very same instance of a VI as "ordinary" subVI and also using ASyncCall. When you want to start several instances of a VI then you should use VI templates or reentrant VIs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,446 Views)

@himanshu25 wrote:

I want to run a VI as a SubVI using Asynchronus Call and then the same VI as a Asynchronus Call.


Is that a typo (besides the obvious typo)?

 

You want to run it as "Asynchronus Call and then the same VI as a Asynchronus Call".

 

So you simply want to call it asynchronous twice? The VI should be reentrant, and you should open an clone (0x80 or 0x100 IIRC, but read the help on Open VI Reference)...

 

I personally avoid all kinds of dynamic calling If I can (and I usually succeed)... You only need dynamic calling if the (maximum) number of instances at run time is unknown. Or if the exact instance can change (plug-ins). There are some corner cases where it can be practical to dynamically call VIs. All other cases it can be avoided, making life easier (IMHO)...

0 Kudos
Message 3 of 7
(2,434 Views)

Hi,

I have a VI that i want to run in a for loop twice using Asynchronous call. The first iteration runs the VI as a normal VI (x100 and x0) and the next iteration it runs in backgound (x100.and x40) 

I refered this exmaple. " Asynchronous Call and Collect (Using Option 0x40).vi"

Sorry for asking stupid questions but i am new to LabVIEW.

0 Kudos
Message 4 of 7
(2,424 Views)

@himanshu25 wrote:

Sorry for asking stupid questions but i am new to LabVIEW.


It's not stupid at all...

 

Where do you fail? Simply opening the reference in the for loop, with different options the second time should work.

 

If you post what you have (or an trimmed down version) we can give more detailed advice.

 

If you only want to call the VI twice, I'd say you can ditch the for loop. Simply put the VI on the diagram for the first (normal call), then do the async call after that. Even the 2nd call could be replaced by a normal call, depending on the circumstances.

0 Kudos
Message 5 of 7
(2,421 Views)

Somethings to consider:

  • Are the two instances of the single VI supposed to be run at the same time?  In that case, you'll need to make the VI reentrant, as you need two "instances" of it in memory in order to keep track of who is doing what and when.
  • If they are not supposed to be run simultaneously, then you need to be sure Instance #1 exits before starting Instance #2.  Do you have a way of doing this?
  • Have you thought of simplifying your situation by simply calling the same VI the same way twice?  If you use Call and Collect for #1, you can (in principle) tell when it exits (if you are calling them strictly sequentially) and know if you can Call and Collect again for the second instance.
  • Have you thought about using something like a Master/Slave Pattern to simply call your VI directly, without Start Asynchronous Call?  If it is a Slave, it can run independently (and asynchronously) with the main routine.

Bob Schor

0 Kudos
Message 6 of 7
(2,379 Views)

I am using JKI SM (mainVI and subVI ) and calling the sub VI Asynchronously. My aim is to run two tasks in paralllel. I have not used the Master Slave approch but will try it. 

Thanks for your suggestion.

0 Kudos
Message 7 of 7
(2,351 Views)