LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with location in peak detector

Hello everyone.


I am programming a software to obtain data from a spectrophotometer using a driver provided by the manufacturer. Now I am trying to acquire the data and simultaneously detect peaks in signal using the Peak Detector VI. But I am having problems to detect the correct location of each peak. 

I found in the documentation that the time location of each peak is defined by "Time Locations[i] = t0 + dt*Locations[i]". In addition, I have found that " dt = A double numeric that describes the difference in time in milliseconds between each sample in the signal ". With these informations, I concluded that my "dt" is equal to my integration time of my spectrophotometer (it is the time between each measurement), but doing this multiplication of dt with my location array gives a wrong location of my peaks.
Can someone help me?

I have sent a VI simulating the acquisition of the sinal (a sine wave) and the subVI necessary to run this test VI.

 

Download All
0 Kudos
Message 1 of 5
(2,846 Views)

Can you describe the way in which the location that is reported is wrong? Running your code, it looks accurate to me. It is reporting the first sample at the peak value rather than the last one. Are you instead wanting the midpoint of all samples at the peak value, or something like that?

______________________________________________________________________
The avatar is for the best weapon in any game ever. But nobody goes there anymore.

CLAD, LV2013, LV2015
0 Kudos
Message 2 of 5
(2,783 Views)

Hello! Thanks for the reply.

 

Yes ! I want to retrieve the exact X-point where the peak is. As you said, it appears that the peak detector VI is returning the first sample at the peak, making those X-locations points look a little bit shifted to the left.

 

 

 

0 Kudos
Message 3 of 5
(2,771 Views)

Okay. I've run your code again and I'm noticing that the first sample is actually not at the 0th index of the x-axis array--it's probably actually plotting one sample late, which looks to be the same difference between the peak location and the actual max value in the region.

 

Make sure you know what definition of peaks you're using and what it represents. If you actually want the midpoint, what you actually need to do is do a curve fit to the local region of data and use the location of the max value of that. Accurately representing the data you're collecting, the peak is actually all the points at that maximum value within the local region, or at least the location of the peak is any of the points between the first and last points at the max value.

______________________________________________________________________
The avatar is for the best weapon in any game ever. But nobody goes there anymore.

CLAD, LV2013, LV2015
0 Kudos
Message 4 of 5
(2,756 Views)

Hello, thanks for the reply.

Sorry, but I did not understand well what you said. Can you explain again ?

Just to add in the discussion: the smaller the integration time (or the time between the plots in the graph) the more shifted to the left the values will be.

Message 5 of 5
(2,751 Views)