From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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 of Noisy Data, Accuracy?

I made a very a simple peak detector program that detects and stores peaks/valleys of a noisy sinusoid.

 

Although not noticeable when the incoming data is clean, the peaks and valleys detected are not exactly at the position of the actual peaks/valleys. i.e. there is an "accuracy" problem. See the attached screenshot, where the peaks/valleys are highlighted, and are obviously not aligned with the incoming data (in red).

 

How does the native Peak Detector actually find these peaks/valleys, and how can I avoid the error?

 

Thanks!

Download All
0 Kudos
Message 1 of 4
(3,455 Views)

Based on what you have posted, the peak/valley detector is working correctly.  You have a noisy signal, so the "peak" location will not necessarily be at the highest or lowest point of your data.  The algorithm essentially does a least squares fit to a parabola around each peak/valley, then returns the peak/valley of the parabola.

 

If you want better location values, increase the width input to the peak/valley finder.  This may cause minor height issues, since a sine wave is not a parabola.  Alternately, since you know your input is a sine wave, you can do your own least squares fit to a sine using more points at each peak/valley, or, better yet, fit the entire signal.

 

Ultimately, though, if you want better analysis, you need to reduce the noise on the input signal.  You can do this by prefiltering it (watch out for phase shifts), but it would be better to reduce the noise in your measurement system.

Message 2 of 4
(3,417 Views)

Thanks for the reply.

 

Trouble is the noise in my signal may be mechanical noise, and I want to detect the peaks of my noisy data.

 

Is there a peak detector that fits the incoming data with, say, a spline -- such that the "noisy peaks" are accounted for and hence detected?

0 Kudos
Message 3 of 4
(3,412 Views)

Your current implementation is already working well.  The major discrepancy between your data and the peak locations appears to be noise, not signal.  If you want to determine the peak/valley values of signal + noise, you have a plethora of options (although I must admit I think this is probably a bad idea - you should probably be looking for peaks in the signal, not signal+noise).

 

  1. Take a small section of data around the peak/valley and determine the max/min of that section.  This will be your signal + noise peak/valley.
  2. Use a completely different algorithm.  Since you have noise, you need to avoid picking local minima/maxima, so you will need some sort of a prefilter.  One possibility is to use a running boxcar average to filter the data (do this as a convolution of a short square impulse with your signal).  Take the derivative of this (use Savitzky-Golay convolution), then look for zero crossings.  At each zero crossing, look in the original data for max/min, as in number 1.
  3. Different algorithm #2 - Use a Savitzky-Golay convolution to find the derivative.  Use a higher order than 2 (four or more) and at least nine points in your convolution kernel.  Look for zero crossings.  This is very similar to the way the peak/valley currently works, but allows you to use a higher order polynomial.  You then need to go back to your original data to find a peak/valley.

All of these basically do the same thing.  They filter the data to help eliminate noise issues, find nominal values for the peaks, then search the original data for the actual peak/valley.

 

 

0 Kudos
Message 4 of 4
(3,384 Views)