LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass argument generated from the block to the same block (basically like recursive function in C).

Hi All,

 

I need to to pass argument to block which is generated by same block.

 

For your undestannding i am attached my vi code , there i have 3 blocks.

Block 1, Block 2, Block3.

 

The block 2 output is going to block 3 as an input , the block 3 generating some output that i need to pass again to blcok 3. (Basicaly like recursive function in C).

 

How to do this in labview. Kindly suggest me.

 

Your help will be greatly appreciable.

 

Regards

Punith

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

Assuming you're using LabVIEW >= 2009, just put the VI inside - you need to make sure that the VI is set to reentrant execution.

 

There are more details here: http://www.ni.com/white-paper/9387/en/


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 7
(2,634 Views)

Hi Sam,

 

Thanks for your reply but even i made recursive , how to connect argument to block 3.

 

Regards

Punith

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

What do you want to connect it to?  I don't see anything in this VI that needs recursion.  Do you just want to use the value on the next iteration of your loop?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(2,601 Views)

Where did you get the idea of using "blank" In-Place Element structures (for example, your Block 3, which seems to contain more of these curious things)?  As far as I know, they do nothing in LabVIEW (except cause confusion in people such as I).

 

You mention "recursive functions in c".  The key word is functions.  The analogous LabVIEW equivalent would be a reentrant VI.  If Block 3 were a VI, you could make it reentrant, so within Block 3 it could call itself.  However, there is no such VI, so there is no reentrancy.

 

I believe you have received the suggestion to spend the time to view (and follow along doing the examples) the LabVIEW Tutorials.  It doesn't seem like you have invested very much time in trying to learn LabVIEW.  True, you can, indeed, learn a lot by "doing experiments", but it really helps to have some idea of the basic fundamentals.

 

Based on your Recursive_Test VI, here are some suggestions:

  • Do not use empty In-Place Element structures.  These have a specific set of functions that you are not using.  Having them in your Block Diagram does nothing except take up space and cause confusion.
  • Learn about Case Statements.  There is never a need to bring one wire into the Case Statement twice (as you always do).
  • Create sub-VIs to do specific functions.  There is no benefit to having all of the code in a single VI, particularly where this results in a massive sprawl across multiple screens.
  • Try to keep your Block Diagram on a single reasonable-sized screen (almost all of mine fit on a single 1280 x 1024 screen, and I have some pretty massive programs).
  • Documentation is Good.  Self-documentation is also good.  You can achieve the latter by having meaningful names for Controls and Indicators, meaningful names (and identifiable icons) for sub-VIs, and, in a pinch, useful Free Labels).

Bob Schor

 

Message 5 of 7
(2,598 Views)

HI Bob,

 

Thanks for your suggestion , Can you suggest on fallowings.

 

1. If i dont use "In Place elament structure" how can i tell the compiler , what is  the flow of execution.(means order of execution).

 

2. Is it possibel to call sub vi from sub vi?.

 

3. if create subvi there are so many outputs , that i need to pass to my  main vi indicators.  How to do that.

 

4. i tested by making subvi and assinging "shared clone reentrant execution property", but it is not working.

 

Regards

Punith

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

@punee wrote:

1. If i dont use "In Place elament structure" how can i tell the compiler , what is  the flow of execution.(means order of execution).

2. Is it possibel to call sub vi from sub vi?.

3. if create subvi there are so many outputs , that i need to pass to my  main vi indicators.  How to do that.

4. i tested by making subvi and assinging "shared clone reentrant execution property", but it is not working.


  1. dataflow determines execution order. If you need more control, use a flat sequence structure.
  2. Yes, if the subVI is reentrant a subVI can call itself. Any subVI can call any other subVI, ad infinitum.
  3. Use a cluster as output.
  4. You need to define the meaning of "not working" (broken wire, wrong result, computer burst into flames, etc.).
0 Kudos
Message 7 of 7
(2,560 Views)