From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

peak detector

Solved!
Go to solution

Hi,

 

I've been trying to use the peak detector to determine the most present frequency in a frequency spectrum but I can't understant why there's a gap between the locations of the peaks that the peak detector returns and the actual peaks. Here is a picture that will make it clear :

 

gap.JPG

 

Can you help me to fix it ? It'll be great to be able to use it... 

0 Kudos
Message 1 of 7
(3,874 Views)
You should post a screenshot of the peak finding code section or your actual code so we can better identify what exactly you're doing and perhaps offer a solution.
0 Kudos
Message 2 of 7
(3,865 Views)

here's the code, i'm not sure you'll understand everything, but anyway, I checked I was using the same df or dt when I create the waveform signal (by the way is it the same thing for labview?), so I don't really understand. I tried (in the "PIC+FFT" subVI) to synchronize the curves using coefficients, but it didn't work.peak-finding-area.JPG

Peak finding area in my VI

pic+fft.JPG

"PIC+FFT" subVI shown upper

peakdetector.JPG

"Peak detector" code

0 Kudos
Message 3 of 7
(3,861 Views)

This is an expected behaviour depending on the width input. Please read below extract from the help of Peak Detector.vi.

 

width specifies the number of consecutive data points to use in the quadratic least squares fit. width is coerced to a value greater than or equal to 3. The value should be no more than about 1/2 of the half-width of the peaks/valleys and can be much smaller (but > 2) for noise-free data. Large widths can reduce the apparent amplitude of peaks and shift the apparent location. For noisy data, this modification is unimportant since the noise obscures the actual peak. Ideally, width should be as small as possible but must be balanced against the possibility of false peak detection due to noise.

 

0 Kudos
Message 4 of 7
(3,860 Views)

Using higher width obviously reduces the amplitude but doesn't change the location of the peaks, I just tried it, going up to 50 !

Have you got any other ideas ?

0 Kudos
Message 5 of 7
(3,853 Views)
Solution
Accepted by topic author davidfabreguette

I have seen this before. And the problem is not the peak detector. It is a bug in your program. It looks like you do some timing operations on your signal like changing t0(this add some offset in time). If you forget to to the same on the peak locations the peaks will misplaced.

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 6 of 7
(3,819 Views)

You were right, I was using a "wait" function in a while loop. Somehow, I don't really know why, it was causing a delay between the first and the second curve..., I deleted and it works now, :smileywink:

 

Thanks very much for the help ! 

 

0 Kudos
Message 7 of 7
(3,791 Views)