LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to average several Hispectrums

Hi all...
I am acquiring scalar data  from a voltmeter and power supply and i m converting each of them to an array which is fed by register shift so that i can draw a xy graph with history. For example, i have 400 hundreds iteration which  gives me 400 x and 400 y values.
x1 vs y1 gives me a point and i draw , x2 vs y2.. so have 400 data point in my graph. Lets say that this is first spectrum. I want to repeat same spectrum but now  x1 and y1 for second spectrum v are slightlz different than that of first one. So i want to average x1 value of first spectrum and x1 value of second spectrum giving another x1 value of averaged spectrum
 I want to do this for all x and y values so that after everz spectrum i can have averaged one.  I m a bit confused. can u help me?
0 Kudos
Message 1 of 12
(3,361 Views)
I made my question more clear with attached vi.  It imitates what i want to do. there s a sweeping machine which sweeps my current values between 2 defined values. for each of current value i gain a y value from multimeter. So i start sweeping current from 0 ,+4,-4 and 0 again with equan increments.  When I reach 0 the collected data called spectrum1. Iteration goes on and i have spectrum 2 like first one, but the problem is that y values are different than that of first one.
i want to plot averaged spectrum every time when i get new a spectrum.
what would be the best way?thanks
0 Kudos
Message 2 of 12
(3,356 Views)
i forgot to attach.
here it is
0 Kudos
Message 3 of 12
(3,348 Views)
What you could do is use a sub-VI with some uninitialized shift registers to store a running sum of arrays and the current number of arrays.  Every time you put a new array set following a sweep into the input of the sub-VI, it would add it to the sum array shift register, increment the count by 1, divide the sum by the count, and output the average.
 
I also created a Enum to provide 2 actions.  The default is the averaging action.  There is also an initialize action which should be run first before the data collection starts, or whenever the averaging needs to be reset.
 
I could only save it as far back as LV 8.0

Message Edited by Ravens Fan on 04-10-2007 09:59 PM

Download All
0 Kudos
Message 4 of 12
(3,340 Views)
thanks for ur answer. Unfortunately,I m using 7.0 so i can not open them. Could you please provide as pictures?
0 Kudos
Message 5 of 12
(3,331 Views)
That I can do.
 
Attached are 2 .png's.  One is the average case, the other is the initialize case.
0 Kudos
Message 6 of 12
(3,320 Views)
I can not insert those sub-vi  into mine because of the loop . the vi that you supplied keeps going due to the its loop structure... i m confused
0 Kudos
Message 7 of 12
(3,317 Views)
I apologize.  I forgot to set the constant going into the stop button of the loop to be true.  I want the loop to run only once each time the VI is called.  Since the VI remains in memory, the uninitialized shift registers hold the data for the next time the VI gets called.
 
Please forgive me.Smiley Sad
 
This arrangment only allows for averaging after an entire sweep is made and is added then averaged.  I was thinking about another variation where it shows the averaging everytime a single element gets updated.  So some parts of the array may consist of 5 samples, others may consist of 4.  I am attaching that variation with screenshots.
 
Here the elements are added in one at a time.  The count value is now turned into a count array and maintained through a USR.  That way the VI knows how many values are present for each element of the array.  As a result, a new input is needed for index so that it knows which element of the array the new value gets put into.  In the initialize screen, I use the index input so that an entire array is initialized at once to the full size of the array.  So if you know you have 100 elements, wire a 100 into the subVI when you wire in the Initialize enum.  From there on out, wire the average enum, the value to put in, and the index where that value goes.
 
The routine basically uses that index to pick the current value of the array, add the new value to that number, and replace that element with the new sum.  Same goes for the count array, but it just increments the value of that particular element by 1.
Download All
Message 8 of 12
(3,305 Views)

thanks Ravens!

I have still further question regarding that vi. Seemingly, index will control the adding proceess, like into which element of the array new input gets as u said. Lets assume that I m sweeping the current between +- 3 with 1 amp increment  lets say N times that i dont set before measurement.

so i ll get  following for each iteration of my main loop that controls the data acqyisation.

i (iteration)        Current value             corresponding multimeter value(y)           array of x                array of y

     0                         0                                              y0                                            [0]                               [y0]

     1                         1                                               y1                                           [1,0]                            [y1,y0]

     2                         2                                               y2                                           [2,1,0]                         [y2,y1,y0]

     :                          :                                                 :                                                :                                   :

12(new sweep)      0                                                y12                                [0,-1,-2...0...2..0]                [y12,y11.....y0]

13                           1                                                y13                                [1,0,-1,2..0...2..0]                [y13,y12,y11...y0]

:                               :                                                   :                                               :                                          :

now what i dont understand is that how to command vi so that it will add y13 with y0 ,y14 with y1 and so on giving averaged array with each corresponding element. My iteration keeps going continously till I see that averaged spectrum seems ok. So i can not set at the beginning how many iteartion will be performed. Besides, I might change the sweeping rate and the limits are not fixed that might be changed for each measurement. Regarding those conditions how i can set the index number performing the average process above? Please help me:)

 

0 Kudos
Message 9 of 12
(3,294 Views)
And when the number of sweepings increases than it ll be more comlicated than i have the set the index number for lets say 7th average. Then the first elemtn of averaged array elements will be summation of (y0+y13+y26+y39...)/7
it s hardddd..
0 Kudos
Message 10 of 12
(3,291 Views)