03-04-2019 01:37 PM
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?
Solved! Go to Solution.
03-04-2019 02:23 PM
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?
03-05-2019 05:46 AM - edited 03-05-2019 06:05 AM
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.
03-06-2019 05:05 PM
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.
03-06-2019 06:11 PM
Some wise person once said:
"To understand recursion, you must first understand recursion."
03-06-2019 07:16 PM - edited 03-06-2019 07:17 PM
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 VI
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.
03-07-2019 01:04 AM - edited 03-07-2019 01:08 AM
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:
When you want to manipulate the call order in the process you could use a queue to store those ABC values…
03-07-2019 02:45 AM
@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:
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.
03-13-2019 06:03 PM
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
MainVI
LoopA, 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?
03-13-2019 06:51 PM
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.