Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

peak detector in Measurement Studio for VB6.0

I got a problem in useing the peak detector of CWDSP(measurement studio for VB6.0). If I am not worng, I guess it's a syntex problem, but I just can't find the right way. The VB compiler indicate "type mismatch" error in the line containing "CWDSP1.PeakDetector...".

The detailed code are as fallowed:
(Note: Before the code, I read the numerical data from a txt file to Darray.)

Dim Peaklocation(300) As Variant
Dim Peakamplitute(300) As Variant
Dim SD(300) As Variant
Dim Init As Variant
Dim Endofd As Variant
Dim Thresh As Variant
Dim Widt As Variant
Dim Porv As Variant

Init = True
Endofd = False
Thresh = 0.5
Widt = 20
Porv = 0


CWDSP1.PeakDetector Darray, Thresh, Widt, Porv, Init, Endofd, Peaklocati
on, Peakamplitute, SD

End Sub
0 Kudos
Message 1 of 4
(6,453 Views)
Hello

Change your definition to the following

Dim Peaklocation As Variant
Dim Peakamplitute As Variant
Dim SD As Variant

The VB help for this function states that these parameters need to be defined as Variants and not as array of variants. The PeakDetector function will automatically allocate an array of doubles and populate the variant with it. You can then index the variant to obtain the data as you would an array.

I hope it helps

Bilal Durrani
NI
Bilal Durrani
NI
Message 2 of 4
(6,453 Views)
Dear Durrani:
Thank you so much!
I could perform the function very well now.

I have other two questions.
First, if I want to perform PeakDetector in real time, not post-run. Could I put the PeakDetector function in a for-loop, then continuously put the sampled data one by one to the array which are going to be analysed by PeakDetector? Or any alternative way would be better?

Second, to increase the accuracy of PeakDetector to detect the peak location, should I put my raw data to a butterworth low pass filter before I put it to peakdetector? Or the parameters: Threshold and Peak width of PeakDetector already cover the function of low pass filter.

Regards,
Ude
0 Kudos
Message 3 of 4
(6,453 Views)
You can use the PeakDetector function in a loop to process the data as its coming in. Check out the help for the Initialize and EndofData parameters of this function. You can pass consecutive data blocks to this function, but make sure you set Initialize and EndofData correctly.

You dont need to filter the data. Threshold and Peakwidth should take care of this for you.


Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 4
(6,453 Views)