LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i create a sequence with a loop running within the frame?

i've created a vi that will run with a certain frequency and then give me the mark average for my spectrum analyzer how i want it to run with another frequency and repeat the whole process again. I need help figuring out how to do that because i need to run it over and over again at different frequencies. Any help on how i can get that working would be greatly appreciated.
0 Kudos
Message 1 of 2
(2,380 Views)
If your existing VI has a frequency input and an average output, you just need to use that VI as a sub-VI. Your calling VI will pass a list of frequencies (one at a time) to the sub-VI and will get the averages out. The list of frequencies can be stored as an array, if you want the frequencies to be completely arbitrary, or can be generated by an algorithm if you want to step through a range of frequencies. Either way, you'll have your sub-VI inside a For loop in your calling VI.
To use the array method:
Create a numeric array control on the front panel of your calling VI.
Enter a list of frequencies into the array.
Save the array data as default (right-click on the array index and goto Data Operations >> Make Current Value Default).
Place a For loop on the diagram.
Insert your sub-VI into the For loop.
Wire from the array terminal (outside of the For loop) to the Frequency input of your sub-VI.
The For loop will default to auto-index the array to run every frequency in the array. You don't need to wire anything to the Count terminal of the For loop.
Create a numeric array indicator on your front panel.
On the diagram, wire the average output of your sub-VI to the indicator array (outside of your For loop).
The For loop will default to auto-index the averages to create an array.
To use the algorithm method:
Define your algorithm. You may want to do something like run 10 steps, increasing the frequency by 10kHz on each run.
On your calling VI diagram, have your sub-VI inside a For loop.
On the front panel, have numeric controls for the starting frequency, the number of steps, and the size of the step (in frequency).
On your diagram, wire the number of steps (outside the For loop) to the Count (N) terminal of the For loop.
Add a shift register to your For loop (right-click on either side of the For loop frame and select Add Shift Register).
Wire the starting frequency (outside of the For loop) to the input (left-hand terminal) shift register.
Inside the For loop, wire the input shift register to the frequency input of your sub-VI.
Add an Add function inside the For loop.
Wire the input shift register to one input of the Add.
Wire the step size (from outside the For loop) to the other input of the Add.
Wire the Add output to the output (right-hand terminal) shift register.
Create a numeric array indicator on your front panel.
On the diagram, wire the average output of your sub-VI to the indicator array (outside of your For loop).
The For loop will default to auto-index the averages to create an array.
Message 2 of 2
(2,380 Views)