Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

AnalogWaveformGraph PeakDetector

Hi,

 

I am having a problem trying to detect peaks and valleys in an AnalogWaveformGraph.

 

(I am showing just the parts of the code which I felt was pertinent to the discussion here)

 

I collect analog current as;

 

           Private waveformData As AnalogWaveform(Of Double)

 

 

This works great for plotting using;

 

          WaveformGraph1.PlotWaveform(waveformData)

 

 

Now I am trying to detect the peaks and valleys using;

 

        Dim peakPolarity As NationalInstruments.Analysis.Monitoring.PeakPolarity
        Dim peakDetect As NationalInstruments.Analysis.Monitoring.PeakDetector = New NationalInstruments.Analysis.Monitoring.PeakDetector(0, 0, peakPolarity)
 

        peakPolarity = NationalInstruments.Analysis.Monitoring.PeakPolarity.Peaks
        peakDetect.Detect(waveformData, True, amplitudePeak, locationPeak, secondDerivativePeak)

 

 

The problem is that the "waveformData" input throws this error;

 

        Value of type 'NationalInstruments.AnalogWaveform(Of Double)' cannot be converted to '1-dimensional array of Double'

 

 

So I'm thinking, the AnalogWaveform data is 2D (T, Value) and the PeakDetector is looking for a 1D array of data?

 

 

I tried setting up a sub to convert the waveformData to a standard "double array" I named "waveformArray" so I could extract just the 1 dimension from it;

 

        Dim waveformArray() As Double = New Double(samplesToReadNumeric - 1) {}
        Dim i As Integer

        For i = 0 To (samplesToReadNumeric - 1)
            waveformArray(i) = waveformData(i, )
        Next i

 

But I receive and error stating "Class 'NationalInstruments.AnalogWaveform(Of Double)' cannot be indexed because it has no default property."

 

I looked through all of your examples, including the "PeakDetector" located under "Analysis", but this shows the detector working on a standard double array and I couldn't find any examples with an AnalogWaveform.

 

I know there is an AnalogWaveformPeakDetector in Labview, but I can't seem to find one in Measurement Studio with VisualBasic 2010, am I missing something?

 

 

Thank You,

 

Bill

 

 

0 Kudos
Message 1 of 2
(6,402 Views)

I figured it out... for anyone else who might have the same issue, the "Samples.Item.Value" is what you need to index, samplesToReadNumeric = the size of the waveFormData collected as AnalogWaveform(Of Double);

 

Dim waveformArray() As Double = New Double(samplesToReadNumeric - 1) {}

Dim i As Integer

 

        'Convert waveFormData to waveformArray
        For i = 0 To (samplesToReadNumeric - 1)
            waveformArray(i) = waveformData.Samples.Item(i).Value
        Next i

 

Then you can run the PeakDetector on your new Array;

 

        'Detection of Peaks
        peakPolarity = NationalInstruments.Analysis.Monitoring.PeakPolarity.Peaks
        peakDetect.Detect(waveformArray, True, amplitudePeak, locationPeak, secondDerivativePeak)

0 Kudos
Message 2 of 2
(6,389 Views)