LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restart averaging function in FFT Mag-Phase vi

I am doing FFT on waveform data acquired from an accelerometer. Sampling rate is 50K. All 50K samples are sent for FFT in a single shot. The process is continuous (runs for 20 days non-stop).
I wish to control the "restart averaging" function such that averaging is re-started whenever:
1) The user hits the re-start button AND/OR
2) Averaging is done (as per user setting)

Thus suppose the setting is average 25 sets. I want the averaging to be re-started after 25 averages are done (irrespective of 'weighting mode') OR when the user hits the restart averaging button (irrespective of whether 25 were done).

I tried using a OR function but get the error that the "wire is member of a cycle".

Any help is highly apprec
iated. Thanks in advance!

- Gurdas
Systems Engineer
gurdas@qagetech.com
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 1 of 9
(4,526 Views)
The wire will become member of a cycle if you just connect the averaging done output boolean to the re-start input (or to an OR-gate connected to re-start). To fix your problem, create a shift register in your while-loop (right-click on the edge of the loop and select Add Shift Register), connect the averaging done output to the right terminal of the shift register, and the left terminal to your OR-gate. That way the averaging will automatically restarted the way you want.
Message 2 of 9
(4,526 Views)
Thanks Alain. I tried your suggestion and the results were exactly what I wanted!

I also need to understand how the "AI config + AI start + AI read" VIs acquire data when setup for multiple channels. Say I have 5 channels. I wish to sample at 60Ksamples/sec for all channels and want 20K samples for each channel. My questions:

1) Do I need to keep my buffer size as 20K or 5*20K=100K?

2) Does the vi acquire all 20K samples for each channel and then move to the next channel OR does it scan all channels (in the given order) 20K times i.e take one sample from a channel and then move to the next and so on?

Looking forward to your reply.

Gurdas Singh
Systems Engineer
gurdas@qagetech.com
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 3 of 9
(4,526 Views)
Answering your questions:
1) If you look at the DAQ example "Cont Acq&Graph (buffered).vi", you can see that to get a continuous acquisition running in a loop you need to set "number of scan to acquire" = 0 in the AI-Start and "number of scan to read" = 20000 (in your case) in the AI-Read.
I would recommend you to select a buffer size of, for example, 4 times your block size so you also need to define your buffer size = 80000 in the AI-Config. All these values are independant of you channel count.

2) It depends on the board you are using. If you are using an NI-4472 board, all the samples will be acquired "in parallel" for all channels, so a sample clock will trig the acquisitions on all 8 channels. If you are using an MIO-type board, the
sampling will be multiplexing so you'll acquire the samples one by one following your channel list ch.0 samp0, ch.1 samp0 ... ch.n samp0, ch.0 samp1, ch.1 samp1 ..., ch.0 samp19999 ... ch.n samp19999
0 Kudos
Message 4 of 9
(4,526 Views)
Ques. 2 answered satisfactorily.
Need more inputs on 1. Let me put forth what I need and you can suggest optimal settings.

I am using a 6023 with NI-DAQ 6.9.2 and LVPDS 6

My requirements are:
# Channels to acquire: 5
# Sampling rate per channel: 30Ksamples/sec
# Continuous sampling unless aborted by user
# Scans to read: 10K

To achieve the above, what should be my settings for:
# Buffer size [does it refer to size per channel or the cumulative size for all channels?]
# Scans to Acquire [what if I set it to -1?]
# Scan Rate [is this per channel? Can I set it to 2,00,000 in my case?]
# Scans to Read [does it refer to scans to read per channel or total scans to be read? Thus in my example when I set it at 10K, does it me
an I will be reading 10K samples of each channel or 2K (dividing 10K by 5 channels)?]

Best,
Gurdas
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 5 of 9
(4,526 Views)
hello,

I have a problem concerning the average restarting of the power spectrum computation. I am Labview beginner, sorry, if my question is maybe evident.

My VI opens a sound file and computes a power spectrum with the initialised parameters (FFT size,overlap). The Vi is launched when the user selects "power spectrum" on the face panel. I made it with an Event structure (is it the best solution ???)
It works well the first time, but if the user wants to launch another computation (2nd push on the power spectrum button), the computation is no more done.

I tried to choose other parameter for the input "restart avereaging", but it doesn't work as I would like. In fact, if "restart" button is "on", it seems there is a computation but no averaging, and if the button stays on "off", it doesn't work. 

Do you have an idea to help me ?
I attached the 2 Vi on this mail.

A second question : if I want to create an array (or a cluster, I don't know exactly what is the best solution) containing all the results of each averaged power spectrum, what kind of function do I have to use ? Then I would like to plot each averaged power spectrum on a graph.

Thanks for your advices.

Mathieu
Download All
0 Kudos
Message 6 of 9
(4,174 Views)

Hi Mathieu,

In the future I would recommend that you create a new thread for the community to better help you since this one was created back in 2003.

The first iteration of your loop does appear to function properly but the data in not valid after that point. You can use the highlight execution feature of LabVIEW to watch your program iterate. It does appear that the user can select to perform another analysis. The restart averaging does appear to be working also because when it is true only there is no averaging performed. You are iterating through the for loop and each iteration increases the offset that you use in your file read and it appears you are offsetting too far. As far as the data type, an array can only hold a single data type and a cluster can hold different data types. You can create an array of your clusters of data by connecting it to the right side of your for loop with auto-indexing enabled. Auto-indexing can be enabled/disabled on a tunnel by right-clicking the tunnel and making your selection.

I would also recommend you look at an example using the FFT Power Spectrum VI to see what to expect as a result. You can find a good example in the Example Finder by searching for spectrum and opening 'Power Spectrum Measurement.vi'. You can find the Example Finder by selecting Help>>Find Examples on the menu bar.

Steve B

0 Kudos
Message 7 of 9
(4,144 Views)
Hi Steve,
thanks for your help. Sorry if I didn't create a new thread for this subject.
I didn't know the highlight execution feature, I tried it and it is a very good system.
You are right : if "restart averaging" is true, there is no averaging, and if it is false, averaging is done. So, for my application, restart averaging needs to be false.
If I use the highlight execution feature, I can see that when the user clicks for the second time on the "power spectrum" button, then a new file is read, and the offset index is initialised again, and increases well (my wav data files have more than 480000 samples and I use 16384 points for the FFT with 50% overlap), so the loop is not iterating too far and works properly.

It seems that the problem comes from the Powerspectrum VI. During the 2nd turn (a 2nd wav file is opened), if restart averaging is set as False (correct for averaging), then the LED indicator (averaging done) is always True, and the numeric indicator (average completed) is not initialised again and the old value is always in memory, so in my case average completed is always 10.

In the "Power Spectrum Measurement.vi" example, the initialisation of the average number and of the LED works good. I don't understand why it doesn't work in my VI...

At the moment, I work with a Labview Version Evaluation in order to evaluate Labview for my company, so I can not open the Power Spectrum VI to modify it and maybe adapt it.
Do you have an idea in order to initialise the PowerSpectrum.VI without modify this VI ?

Concerning cluster array with auto indexing, I will try your method. So, if I compute 3 power spectum,  auto indexing should create a 3D cluster of array, is it true ? To plot the 3 curves corresponding to this 3D cluster array, I saw that Graph.vi accepts only 1D, 2D or waveform data. What is the method in order to plot 3D cluster ??

Thanks for your help and your advices.

Mathieu
0 Kudos
Message 8 of 9
(4,129 Views)
Hi Mathieu,

As Steve suggested, please create a new thread for any more questions you may have (even concerning this issue) so the forum community can better support you.  It really does make a difference!

What you need to do is reinitialize the averaging done by the FFT Power Spectrum VI between files.  To do this you must send a boolean True to the Restart Averaging input during the first iteration with the new data from the new file.

The example VI accomplishes this by latching a button press to send a boolean True during only one iteration of the while loop.  In your case, you will want to simply send a boolean True on the first iteration of your For Loop, and False on all subsequent iterations.

When you auto-index your cluster and run 3 iterations, you will output a 1D array (of length 3) of clusters.  Sometimes the best way to see something like this is to just try it out yourself!


I hope this helps! 
Brian A.
National Instruments
Applications Engineer
0 Kudos
Message 9 of 9
(4,113 Views)