08-24-2010 04:13 PM
Hi,
I am trying to create an infinite nest For loop in TestStand and kinda stuggling to figure out how to do it.
If you see the attached screenshot, the program will run each index of array, For Loop 1. There is another For Loop, For Loop 2, with Start/Stop/Step inside the For Loop 1. Run Step element is the index of nest loop, for example, Array Index 2 will start at 5, go to index 1 and run the loop (start from 0 to 10 with step of 2 and here at each step it will go back to Array Index 0 and run. When finished index 0, will back to index 1, and go though the loop. The same routine goes for Index 2, at each step will jump to index 0 or whatever it's set to).
In LabVIEW, I can just set it to re-entrant VI and feed in the Run Step index but how can I do this in TestStand?
I really appreciate the help in advance.
Best regards.
Solved! Go to Solution.
08-25-2010 10:25 AM
I'm not following exactly what you are saying, perhaps a screen shot of the code or pseudo-code describing the algorithm would help. That said, TestStand supports recursion so you can create a sequence and call it and it can call itself if that is what you need to duplicate what you are doing in LabVIEW (i.e. if that is why your vi needs to be reentrant).
Hope this helps,
-Doug
08-25-2010 11:03 AM - edited 08-25-2010 11:06 AM
Hello Doug,
Thanks for the reply. I'm attaching 2 VIs that will demonstrate what I'm trying to do. Appreciate your help. Sub-Nest Loop.vi is the re-entrant VI. Inside the while loop, Sub-Nest Loop.vi needs to run the selected element at each step. Thanks.
08-26-2010 09:35 AM
Your Sub-NestLoop 2.vi is recursive (i.e. it calls itself). I haven't looked at your code that carefully, but you should be able to write something equivalent in TestStand if you'd like. Though whether that makes sense or not depends on what the purpose of these VIs are. It might make more sense to just leave it as VIs and call the VIs from TestStand.
That said, if you want to make something equivalent in a TestStand sequence, just think of TestStand sequences as similar to VIs. The parameters to the sequence are like the inputs and outputs of the VI. All TestStand sequences are effectively reentrant in that they support being called recursively and from multiple threads in parallel.
If I have misunderstood your question please trying explaining in more detail what you are asking.
Hope this helps,
-Doug
09-01-2010 11:29 AM
Thanks for the reply Doug.
So I have the sequence (with steps that read from some variable) and wants to call itself from its own sequence but with different values in the variable (when called sequence is executed, the data passed into this sequence should not overwrite caller sequence), how can I implement something like this? Is there a way to check where the sequence was called from? or maybe some sort of input buffer that I can write/pass input data into the sequence? Maybe I should change the way of how it's written/designed...
Thanks!
09-02-2010 09:35 AM
@tlee16 wrote:
Thanks for the reply Doug.
So I have the sequence (with steps that read from some variable) and wants to call itself from its own sequence but with different values in the variable (when called sequence is executed, the data passed into this sequence should not overwrite caller sequence), how can I implement something like this? Is there a way to check where the sequence was called from? or maybe some sort of input buffer that I can write/pass input data into the sequence? Maybe I should change the way of how it's written/designed...
Thanks!
You should use "by value" parameters for your variables. To create such parameters, insert variables into the Parameters group of the variables view window. By default, they are "pass by reference", to change them to be passed by value, right-click on the parameter variable and uncheck the "Pass by Reference" menu item. Variables that are passed by value are passed as copies of the original, thus any changes to them in the sequence do NOT affect the original versions in the calling sequence. However, if you want to be able to pass data back out of the sequence they you will need at least some of your parameters to be "pass by reference" so that changes to the parameter in the subsequence can be returned back to the calling sequence.
Hope this helps,
-Doug