Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Peak Detector Class

Hi,

 

I'm trying to use the peak detector class to find peak power points on an array of data (~170 points).

Can someone please explain to me what this class is doing when it finds values higher (and sometimes lower) than those values in

the input array?

 

 

Thanks

 

Curt

Dim peakPolarity As NationalInstruments.Analysis.Monitoring.PeakPolarity = peakPolarity.Peaks Dim peakDetect As NationalInstruments.Analysis.Monitoring.PeakDetector = _ New NationalInstruments.Analysis.Monitoring.PeakDetector(thresholdPeakNumericEdit.Value, pdWidthNumericEdit.Value, peakPolarity) 'Detect Peaks peakDetect.Detect(waveform, True, amplitudePeak, locationPeak, secondDerivativePeak) numOfPeaksFound = amplitudePeak.Length 'set the value of numOfPeaksFound in the numberOfPeaksFound text box. peaksFoundNumericEdit.Text = numOfPeaksFound amplitudePeakPlot.PlotXY(locationPeak, amplitudePeak) 'Plot Peaks on the signal waveform. TextBox1.AppendText("PD = " & pdWidthNumericEdit.Value & vbCrLf) TextBox1.AppendText("Loc" & vbTab & "Peak" & vbCrLf) For i = 0 To UBound(locationPeak) TextBox1.AppendText(FormatNumber(locationPeak(i), 2) & vbTab & _ FormatNumber(amplitudePeak(i), 2) & vbCrLf) Next

 

 

peakdetector.JPG

0 Kudos
Message 1 of 3
(4,268 Views)

Curt,

 

Have you taken a look at the dev zone on peak detection ?

 

 

3. The peak location function gives peak locations at fractional indices. It uses the quadratic fit algorithm and returns the peak locations as floating point numbers, not as integer index values. Therefore, the peak locations and amplitudes usually do not correspond to actual data points in the sampled input signal.

This feature is an advantage of the algorithm because it effectively interpolates between the data points while finding peaks and valleys. The function can therefore measure peaks that have a greater amplitude than any data points near the peak. This interpolation provides a good indication of the true value of the peak in the original analog signal.
 
So it looks like this is being caused by an interpolaton of the data. Though in the example below, the X values appear to be correct, so you could get the actual Y value based on the X values returned from the peakDetector. When you get a return of a lower amplitude than your signal, is the function still returning a correct X value?

 

 

 

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 2 of 3
(4,245 Views)

Hi Richard,

 

Thanks for the reply.  Yes,  the X values are correct.  I'll try to come up something that uses those x values to return the peak values from the measured data.

 

Thanks for your help.

 

Curt

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