From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Recursive Vi's

Solved!
Go to solution

Hello,

 

I am trying to program a variable sweep for an instrument.

 

There are 20 variables, A,B,C, ... 

Each one has a parameter range Low, High, Step. 

 

Each one can be called in a hierarchy:

 

Loop A:

           Loop B:

                       Loop C:

                                   Measurement

 

Or

 

Loop C:

           Loop A:

                       Loop B:

                                   Measurement

 

Now I have 20 variables, if I were to code out each possibility that's 20!

My current idea is to : 

read from a text for the looping sequence,

create a queue of vi references,

call the first vi from the queue, and pass rest of the queue sequence

then the first and each subsequent vi will call take out the first element of the queue and call it, until there is no more to call. 

 

Is there any idea on to program this? Maybe there is better way to do this?

0 Kudos
Message 1 of 27
(4,794 Views)

Hi Threshold,

 

I don't think it's a good idea to place 20! VI references in a queue…

 

Do you really need to iterate over all "variables" (aka parameters) for so many variables? Ever heard of DoE?

(Do you really need to evaluate and analyze those 20! test results?

Best regards,
GerdW


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

Time to look into OO! Especially the Composite pattern.

 

That would allow you to program (or read from file) any combination of (recursive) functions you want.

Class Hierarchy.pngClass Hierarchy Diagram.png

0 Kudos
Message 3 of 27
(4,720 Views)

Since I really enjoy Recursion, I was drawn to this Post, but (other that knowing one could generate all the Permutations (not Combinations, that's a trivial problem) of 20 things taken 20 at a time, but Recursion wasn't mentioned!  Oh, well.

 

Bob Schor

 

P.S. -- How many Combinations are there of 20 things taken 20 at a time?  The answer, of course, is one.

0 Kudos
Message 4 of 27
(4,682 Views)

Some wise person once said:

"To understand recursion, you must first understand recursion."

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 27
(4,674 Views)

I am not sure where you got the combination idea, as I was talking about a permutation of loops.

Here is what I got so far:

 

Main VIMain VISub VI "A,B,C"Sub VI "A,B,C"

 

 

 

 

 

 

 

 

User can type in any sequence he wants of A,B,C multiple times and in any order repeating or not.

I am crashing my lab view 2018. I am not sure whats going wrong for each VI. At least I am doing something right.

 

Capture.PNG

 

Crash.PNG

 

0 Kudos
Message 6 of 27
(4,668 Views)

Hi Threshold,

 

User can type in any sequence he wants of A,B,C multiple times and in any order repeating or not.

Why don't you just use a loop executing those "A", "B", and "C" cases one after the other?

No need for any recursion/combination/VI references/global variables/VI server calls/rest of all that overhead here!

 

To get the idea:

check.png

When you want to manipulate the call order in the process you could use a queue to store those ABC values…

Best regards,
GerdW


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

@GerdW wrote:

Hi Threshold,

 

User can type in any sequence he wants of A,B,C multiple times and in any order repeating or not.

Why don't you just use a loop executing those "A", "B", and "C" cases one after the other?

No need for any recursion/combination/VI references/global variables/VI server calls/rest of all that overhead here!

 

To get the idea:

check.png

When you want to manipulate the call order in the process you could use a queue to store those ABC values…


I think he needs ramping on multiple variables. So:

A=1, B=1, A=1, B=2, A=1, B=3, A=1, B=4, A=1, B=5, A=1, B=6,

A=2, B=1, A=2, B=2, A=2, B=3, A=2, B=4, A=2, B=5, A=2, B=6,

A=3, B=1, A=3, B=2, A=3, B=3, A=3, B=4, A=3, B=5, A=3, B=6.

 

This could of be implemented with a string sequence that is executed, especially if the sequence commands are Turing complete.

 

If you want to give the composite pattern a go, let me know. A proof of principle would be a 15 min. time investment from my part, so I'll only commit to it if you thing it's useful.

0 Kudos
Message 8 of 27
(4,647 Views)

I have 3 recursive VI's, LoopA, LoopB, LoopC.

User types in the order that each Vi should be called in.

"ABCCBA"

 

In turn the main vi will call LoopA and pass down "BCCBA"

LoopA will call LoopB and passdown "CCBA"

LoopB will call LoopC and passdown "CBA"

LoopC will call LoopC and passdown "BA"

LoopC will call LoopB and passdown "B"

LoopB ends recursion as the queue is empty

 

 

MainVIMainVILoopA, LoopB, LoopCLoopA, LoopB, LoopC

I have created a project but it seems the moment a call by reference is made the system gives an error.

Then lab-view crashes.

 

I am attaching the whole project.

 

Any ideas on how to make this work?

 

 

 

0 Kudos
Message 9 of 27
(4,651 Views)

Are A, B, and C all re-entrant, shared clones?  If not, they need to be.

 

You also need to use an "Open VI reference" function each time (not just once at the start to populate your global!) you want to start a re-entrant VI, and be sure to use the 0x40 option.

0 Kudos
Message 10 of 27
(4,623 Views)