LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conflict when using a SubVI twice in a VI

Solved!
Go to solution
Highlighted

Hi,

I'm trying to understand how a subVI works in this case:

I create a subVI, like in the picture below. Where the "Numeric" control replace 1st value in the "Array" control, and move the result to "Array 2" indicator.

meihk_0-1597336393391.png

Then I create a VI, attach the subVI above:

meihk_1-1597336598825.png

What I want is, every 2 seconds, the array's 1st value is replaced by a number that I enter (numeric).

The problem is, while running this VI, only the second block works.

Is there any way that I can make 2 blocks work at the same time?

 

The .vi files are attached below.

 

 

Download All
0 Kudos
Message 1 of 6
(267 Views)
Highlighted

Your VI is not reentrant, meaning that the "first call?" only executes once globally. Whatever instance executes first gets it. The other doesn't.

 

Possible solutions:

  1. Make the subVI reentrant.
  2. Leave it at non-reentrant but create a control for the init boolean and wire a i=0 to each instance.
  3. Initialize the shift regsiters on the main diagram with your default 5 element array and remove the first call primitive in the subVI.
  4. ...

 

In general, you might also want to initialize your shift registers. In fact you could make the subVI reentrant and have a feedback node inside the subVI, dramatically cleaning up your main diagram.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 6
(253 Views)
Highlighted
Solution
Accepted by topic author meihk

@altenbach wrote:

In fact you could make the subVI reentrant and have a feedback node inside the subVI, dramatically cleaning up your main diagram.


Here's how that could look like:

 

altenbach_0-1597339985091.png

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 6
(234 Views)
Highlighted

@altenbach wrote:

@altenbach wrote:

In fact you could make the subVI reentrant and have a feedback node inside the subVI, dramatically cleaning up your main diagram.


Here's how that could look like:


Or just use the Data Queue PtByPt.vi.  No development required.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 4 of 6
(220 Views)
Highlighted

@crossrulz wrote:
Or just use the Data Queue PtByPt.vi.  No development required.

Yes, I intentional did not mention that in order to keep it simple. 😉 (I actually looked up the help on the ptbypt queue before posting).

 

(Also note that it is NOT the same because it fills the queue from the "other side")

 

Substituting basically a "one liner" subVI with something hidden deep in the palettes and having much more functionality (9 terminals!!) Would just complicate things to any newbie.

 

It's more about learning and understanding the basics of subVIs, "first call?", reentrancy, feedback nodes, etc. than to find a turnkey solution for exactly one specific problem. Maybe I misunderstood the purpose. :).

 

Data queue is strictly for DBLs (or CDBs for the other version) and this will not work, or work well, for most datatypes (integers, strings, etc.). Maybe somebody will make a VIM out of it eventually ...;)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 6
(208 Views)
Highlighted

That works. Thank you so much!!

 

0 Kudos
Message 6 of 6
(199 Views)