09-27-2010 11:05 AM
I'm using the peak search VI to trend amplitudes from a power spectrum. The peak search VI is not outputing the correct amplitudes. They are off by a little bit everytime. I have looked at the output arrays from the power spectrum, and I have verified the peak search is getting good input data but outputting something unexpected. I have the peak search set for: 1) Single Max Peak, Threshold=0, Start=57.8Hz, Stop=59Hz and 2) Single Max Peak, Threshold=0, Start=61 Hz, Stop=62.2Hz. Neither one is displaying the correct value. I will post my code, but the file I'm opening is a .dat so I can't post that.
Solved! Go to Solution.
09-27-2010 11:14 AM
Change the extension from a .DAT to a .TXT then I will have a look at it.
09-27-2010 11:17 AM
Here is the .dat file that my Viewer opens. Change the extension to .dat
09-27-2010 11:23 AM
You may want to change my y-cursor display to display for sig figs.
09-28-2010 08:04 AM
Does anyone see an obvious problem with my code? I just don't see the value it outputs in the array coming from the Spectrum VI, so needless to say I'm confused. But it must be something simple that I'm overlooking!!
09-29-2010 01:23 PM
The spectrum peak search VI is doing a curve fit to identify peaks. The peak search algorithm is described in the help:
The SVFA Spectrum Peak Search VI finds all the peaks within the spectrum and performs amplitude/frequency or amplitude/order estimation on each individual peak. The VI operates on magnitude and power spectra.
Usually, the spectrum is computed based on a windowed input signal. The closed form of any cosine window, such as Hanning, Hamming, Blackman-Harris, and so on, is known. The presence of three dominant bins indicates a local maximum on the power spectrum. Therefore, when the SVFA Spectrum Peak Search VI locates three dominant bins, a curve fitting algorithm maps the window shape onto the three bins and estimates the true frequency and amplitude of that particular tone. The following illustration diagrams the concept of the algorithm.
==================
If you want the local maxima of the spectra, you can use the following code:
09-29-2010 01:27 PM
I couldn't do much to view your code because I don't have sound and vibration loaded. It would let me run the code but was unable to view the parameters for the peak search.
09-29-2010 06:03 PM
I don't see how the SVFA Get Spectrum Subset VI would work because of your above reasoning, but I did go ahead and write that into the code. It doesn't grab the max point either. My local NI guy was here today, and we ended up calling into NI to one of the helpers and he said the Peak Search VI creates more data points or basically increases the frequency resolution and then does a window. Is there another easy way to get a "true" max point (bin) within a range of frequencies?
09-30-2010 09:18 AM
The Get Spectrum Subset just gets the range of bins between start and stop. The Array Max & Min primitive gets the maximum value from the subset.
The posted snippet agrees with the value that you would see in the cursor table by moving the cursor to the max bin.
I think the best interpretation of the peak search algorithm is that it interpolates (based on the window shape) in order to identify tones that are 'between bins'. Regardless, if you want to pull the max value out of a specified range in the spectrum, use the Get Spectrum Subset VI AND Array Max & Min VI suggested above.
09-30-2010 09:33 AM - edited 09-30-2010 09:39 AM
The power spectrum in your top For Loop is not the same as the power spectrum in your bottom While Loop - the two spectra are computed from different time-domain blocks.
This seems like it could be a source of confusion when comparing peaks to the computed spectrum. What is the purpose of the top loop? bottom loop?