LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak search outputs wrong value

Solved!
Go to solution

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.

0 Kudos
Message 1 of 13
(4,637 Views)

Change the extension from a .DAT to a .TXT then I will have a look at it.

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 13
(4,629 Views)

Here is the .dat file that my Viewer opens. Change the extension to .dat

0 Kudos
Message 3 of 13
(4,625 Views)

You may want to change my y-cursor display to display for sig figs.

0 Kudos
Message 4 of 13
(4,619 Views)

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!!

0 Kudos
Message 5 of 13
(4,582 Views)
Solution
Accepted by topic author LabViewer35242

The spectrum peak search VI is doing a curve fit to identify peaks. The peak search algorithm is described in the help:

 

SVFA Spectrum Peak Search Details

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:

Max Spectrum Value in Range.png

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 6 of 13
(4,544 Views)

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.

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 7 of 13
(4,539 Views)

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?

0 Kudos
Message 8 of 13
(4,520 Views)

The Get Spectrum Subset just gets the range of bins between start and stop. The Array Max.PNGArray 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.

Max Spectrum Value in Range and Cursor.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 9 of 13
(4,502 Views)

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. 

spectra are different.PNG

 

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?

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 10 of 13
(4,498 Views)