LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Averaging - help!

Hi tbob,

So I got it to average multiple channels, which is great. The problem is... I'm sure I am doing it in a very unoptimized way. I've included a picture of the VI that I am using to do it...

Basically I repeated your program for each index in the array. So for channel 1 was index 1, channel 2 index 2, etc. As you can see I need a separate queue and and loop to average each channel. With 4 channels means a total of 5 loops! I'm sure there is an easier way that I am missing.

Thanks for you help,

Stephen L




Message Edited by Stephen L on 03-19-2008 06:39 PM
0 Kudos
Message 11 of 14
(1,431 Views)

You should not need separate queues.  I need to know what the output of Tin Scan is.  An array of 4 elements, one element for each channel?  Is it an array of many elements?  Several for channel 1, several for channel 2, etc...?

You can make the queue data type an array of DBL.  When dequeueing, separate the array into 4 separate arrays.  Use 4 shift registers to hold the separate arrays.  Or you can make a 2D array where there are 4 rows, one for each channel, and many columns for the data for each channel.  When the number of columns equal 10, separate into 4 arrays and take an average of each one.

I'm sorry I don't have time to write a VI because I have too much of a work load right now.  Perhaps someone else would volunteer to step in and write some sample code.  Please state what is the output of Tin Scan subvi.

- tbob

Inventor of the WORM Global
0 Kudos
Message 12 of 14
(1,419 Views)

I have  a vi that is used to display data from 9 netscanner modules. This vi was available at the Netscanner website, but it is only for 1 module. I have had to expand the vi to collect from 9 modules. Each of these modules has in it a case structure and case 4 has a while loop.

 

So my question is this, would it be best to place this ArrayAvg.vi inside each of the individual while loops or do you think it would work better if I somehow figured out how to place it outside of the case structure.?? I am VERY new to Labview and would greatly appreciate any help you can give.

0 Kudos
Message 13 of 14
(1,241 Views)

What is the output of  the while loop in case 4?  Is it an array, and the other cases output a single value?  This makes a difference.  If case 4 outputs an array, and the average must be taken for each element in the array, then you can put ArrayAvg.vi in a For Loop after the case structure, and wire the array from case 4 to the for loop with indexing enabled.  For the other cases, you would have to put a Build Array function so that the case always puts out an array, even if it is an array on one element.  The For loop will only execute one time in this case, and it would execute several times for Case 4.  I hope this is clear.

- tbob

Inventor of the WORM Global
0 Kudos
Message 14 of 14
(1,224 Views)