LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to handle nested sweeps?

Below I explain my problem, and a solution. So my questions are how do I best implement this solution, is this solution really a bad idea, and is there a better solution?

Scenario: Four independent variables, say frequency, amplitude, phase, and bias. Each one sets a piece of test equipment. I want to sweep all of these independent variables over a range and measure the response of a DUT to all combinations of settings in the four dimensional volume defined by the ranges of the four independent variables.

Standard Solution: Four nested loops, one loop for each variable. I don't really like this solution because the complexity of the problem is embedded in the code. It is difficult to troubleshoot and not easily adapted to other numbers of independent variables.

A more object oriented approach: Each combination of the independent variables is an object. These objects can be combined into a list object. Conceivably I could create a list of all combinations of the independent variables, then go through the list writing the values to my test instruments. The list could be really big, not a good thing, and there would be lots of redundant writes to my instruments (this could be dealt with if it mattered). But it does remove the complexity from the program to the class constructor.

My preferred solution: Generate the independent data objects one by one. Have a function that creates one independent variable vector. Use this four times, once each for frequency, amplitude, phase, and bias. Feed these to a vi that indexes thought the four arrays and sequentially returns the points in the four dimensional independent variable space (each vector is an axis of this space)(this then is the class constructor). Write these values to the instruments. (use logic to avoid redundant writes if necessary). This moves the complexity to the vi that generates the independent variable vectors, and to the vi that indexes thought the independent variable space. And these are very reusable, and can be easily extended to any number of variables. If this solution is reasonable is it already coded somewhere? If not coded are there functions in Labview that already implement some of this, such as a function that will generated the sweep vectors, or that will generate all of the multidimensional indices?

Thanks
David Grucza, CLD
0 Kudos
Message 1 of 5
(2,971 Views)
Not too sure if this will help as I don't know exactly how you intend to do your 'sweep', but attached is a vi from a program i'm developing which uses 15 variables and all combinations of all variables are output into the DUT. This sub-vi stores the initial, final, step size and current value for each variable and will generate the next iteration when instructed to.
Hopefully this will solve the problems of complexity and redundant instrument writes.

Andy
0 Kudos
Message 2 of 5
(2,971 Views)
Thanks. I believe I see what you are doing. I do have another soultion that generates all possible combinations of indices into the swept parameter vectors that uses a mixed base adder. This can either generate indices one at a time, or a list of all combinations that can be placed before the loop. If you are interested I'll post the code next week when it is completed.
David Grucza, CLD
0 Kudos
Message 3 of 5
(2,971 Views)
Yes, I'd be interested to see an alternative solution, especially as I have no idea what a mixed base adder is!

Andy
0 Kudos
Message 4 of 5
(2,971 Views)
I thought that I should post this even though it isn't complete. It will generate all combinations of indices into any number of vectors of differing lengths. The idea is to place the code that uses the indices inside of the while loop in the top level program. I have a control in the top level program in which you enter the vector dimensions. In an application this would be coded. The flagged version of the index vector allows disabling of redundent uses of the indices. With slight modification you can use this to generate a two dimensional array that contains all combinations of indices, though for much more than a few vectors this could take up a good bit of memory. My purpose here is to replace a neste
d loop approach to nested parameter sweeps with a single while loop. This will make it easy to change the number of nested parameters, especially if using an Object Oriented design. I have the design mostly finished, but I'm not sure when I'll have time to finish it. I'll post it here when done, but I've just started a summer grad class, so this might be a while. Anyway, feedback is appreciated. I'll incorporate suggestions that will improve the implementation. For instance, I thought of bundling an array of logic values with the index array rather than using a -1 flag in the array itself. In OOD the implementation doesn't really matter, especially because the index generator would be a class method, and likely a private method at that.
David Grucza, CLD
0 Kudos
Message 5 of 5
(2,971 Views)