LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spawn dynamic number of reentrant clones (PtByPt vi)

Solved!
Go to solution

Hello,

 

I remember a few years ago I have seen an example for what I try to do now, but I just cannot find it. I have some idea which way to go, but I would ask first the advanced coders here.

 

Scenario: i need to monitor some bit flags from a TCP/IP stream, and a useful VI is the "Boolean Crossing PtByPt.vi" for this. However, I have many channels which I need to monitor for "rising edge" independently. If I had just a very few channels, I could go in the following not too elegant static way (see below, the Case structure needs to be setup manually for all elements).

 

I know the proper solution involves some dynamic VI call technique, but I would like to ask your opinion how to do it properly, and efficiently? Thanks very much!

 

Example_VI_BDdvcsd.png

 

 

0 Kudos
Message 1 of 10
(3,933 Views)
Solution
Accepted by topic author Blokk

Have you seen this page here? http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/asynchronous_vi_calls/

 

Specifically, read the last two bullet points - if you open a single reference and then it will run the VI as reentrant. If you open the reference multiple times, it's preallocated so each call (reference) should retain it's own memory space.

 

For an example - look at the second diagram at this link: http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/acbr_call_and_collect/


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 10
(3,916 Views)

Do you think this way is OK?

 

Test_dynamic_call_reentrant_VI.png

 

 

0 Kudos
Message 3 of 10
(3,897 Views)

That should work, but I don't see the advantage of the asynchronous call for this purpose.

The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.

 

Message 4 of 10
(3,889 Views)

Thanks, you are right, more simple!

 

Test_dynamic_call_reentrant_VI_version2.png

0 Kudos
Message 5 of 10
(3,881 Views)

@dan_u wrote:

That should work, but I don't see the advantage of the asynchronous call for this purpose.

The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.

 


Oh yes, I sometimes forget that you can do synchronous calls - I tend to use asynchronous more commonly (for launching multiple instances of a UI VI) so I didn't think about it.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 10
(3,876 Views)
Solution
Accepted by topic author Blokk

Talking about simple, a simple "Greater?" primitive with the old array as comparison will result in the same thing. No need for a for loop or multiple instances of subVIs.

RisingEdge-Array.png

Message 7 of 10
(3,875 Views)

@Sam_Sharp wrote:

@dan_u wrote:

That should work, but I don't see the advantage of the asynchronous call for this purpose.

The VI you're calling returns immediately. You need several instances, but synchronous call will be simpler and does the same thing for your use case.

 


Oh yes, I sometimes forget that you can do synchronous calls - I tend to use asynchronous more commonly (for launching multiple instances of a UI VI) so I didn't think about it.


Yes, the async call is convenient for "handlers" or UI VIs that keep running for a while. I'm not sure how much overhead it would cause for a simple case like this where synchronous call seems the ideal solution.

 

0 Kudos
Message 8 of 10
(3,871 Views)

Haha, well, I could call my solution a kind of "advanced Rube Goldberg"? Smiley Very Happy

But for sure it was good to learn/clarify the usage method of this kind of dynamic call. For the actual code, your simple "Greater?" function with a shift register (or feedback node) is just superior 😄

0 Kudos
Message 9 of 10
(3,866 Views)

Smiley Very Happy

 

0 Kudos
Message 10 of 10
(3,859 Views)