LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running while or for loop three times and taking the average simultaneously

Hi There,

 

I have a VI that running an  electromganet using a DAQ device (not shown in the attahced but the simulator is shown). The measurement data (voltage vs field) are not taken by DAQ and instead the voltage istaken by keithley and the field is taken by a gaussmeter (both are represented in the attached by two random number generators). Although everthing is fine with this code, the noise is somehow high and therefore I have to take average of two or three loops.

 

Basically what I want is to make the VI in the middle of the sequence strucutre run three times and then taken the average which should be shown in another XY graph and be written to an excel file. Any help in doing that will be really appreciated.

 

Hadiq 

Islam means peace
0 Kudos
Message 1 of 7
(2,568 Views)

This might do what you want.  Signal In goes into Signal Out, with the previous value and the one before that "memorized" on the shift register.  Simply adding these three together and dividing by 3 gives you a running average of the current point and the previous two points.

0 Kudos
Message 2 of 7
(2,537 Views)

All you need is mean ptbypt with a sample lenght of 3.

 

(However, a lot of your code makes very little sense or is meaningless. Why are you autoindexing over empty arrays in a while loop???)

0 Kudos
Message 3 of 7
(2,530 Views)

Thank you Bob and Altenbach for providing me with how to do the mean average. Most importantly, however,  is how to run the loop three times, indexing data and then taking the average.

Islam means peace
0 Kudos
Message 4 of 7
(2,507 Views)

I got an idea to run three cascaded loops by putting the while loop inside a for loop and then set (N) the count of terminals to 3. Although the VI gets complicated but it works. Now, can help me in sorting the average of the three loops and how two write them to an excel file. There is an error coming to me each time about dublicating the measurement file.

Islam means peace
0 Kudos
Message 5 of 7
(2,495 Views)

Hi Bob,

 

Do I need two of them for the data coming from keithley and the data coming from the gaussmeter.

Islam means peace
0 Kudos
Message 6 of 7
(2,494 Views)

If your data are coming in at the same rate and within the same loop, you can simply make a taller While loop, have Keithley In and Gaussometer In, a separate set of shift registers for each, and Keithley Out/K Avg Out and Gaussometer Out/G Avg Out outputs.

 

BS

0 Kudos
Message 7 of 7
(2,488 Views)