LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect peaks on a curve

Solved!
Go to solution

Hello application engineers,

 

I would like to find peaks on a curve that is obtained via data acquisition. I tried both Threshold Detection and Peak Detection, However, no success.  

 

The issue is that sample VIs compares a threshold with all values, while I just want to compare the threshold with a local value or moving value. I used a moving average as a base and added a Delta value to make a threshold. A peak should be identified when the peak has values greater then the "moving average + Delta".  The curve shows there are three narrow peaks at times of 250, 351 and 437 s respectively. 

 

Attached are the two VIs, one uses threshold detector VI, another uses peak detector VI. 

edmonton_0-1611024858721.png

edmonton_0-1611027469506.png

 The VIs simulate the data acquisition process and I like to detect the peaks while data acquisition is in progress. 

 

Can someone help me with the issue?

 

Best regards,

Gu

 

Download All
0 Kudos
Message 1 of 20
(2,769 Views)

here is maybe one possible solution

(since you post data it was possible to help 🙂 )

I used a highpass on the data , did a first peak search on the that highpass data

used the results to search on the raw data

finally recalc positions to x data

 

Q&D  no cleanup in the code 😄

Peak detection mod.vi.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 2 of 20
(2,731 Views)

in the highpass data you see another small peak around 400 😉

 

curious: What are you looking at ?

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 3 of 20
(2,729 Views)

Another hint: Seems that you are lookung at frequencies (vs impedances?)

the 250, 350 and 400 peak are 5,7 and 8 times the 50 Hz line frequency, so if 50 Hz is your line freq, make shure you are not false detecting EMC influences on you setup. 😄

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 4 of 20
(2,725 Views)

instead of a highpass  I used 1st derivative and PtbyPt routines ... and finally a peak detection on the raw data

(second coffee break)

play with the parameters 🙂 and see the different results for the first three detected peaks

 

Peak detection mod 2.vi.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 5 of 20
(2,707 Views)

Hi 

 

 

0 Kudos
Message 6 of 20
(2,698 Views)

here you go

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 7 of 20
(2,673 Views)

Hi Henrik,

 

Thank you very much for the converted 2015 file. The first order derivative followed by a point by point search is a very nice way of doing this, which can fit my live stream data process. I need to learn something more online for me to better understand the way you used for-loop. It is my first time to see using an array as a For-Loop's iteration N, and also first time to see bundle on right side of the loop.

 

Could you please also convert your  first  Vi that use high-pass filter, I would like to learn it more.

 

Regards,

Gu  

0 Kudos
Message 8 of 20
(2,666 Views)

try it

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 9 of 20
(2,657 Views)

Hi Henric,

 

Thank you for your kindly helps.

I have been using Labview since version 6.0, however, I just used it occasional when a project required, so I am not a very experienced user. Could you please help me to understand your way of solving my problem. I searched NI web for  related info, however, still need further learning from you. I post part of your code here for a reference.

 

edmonton_0-1611166047286.png

 

 

1.  On the right edge of the for loop, you bundled auto-index with a Boolean (peak found?). How were the two parameters bundled together, how the bundle pass values during iteration?

 

2. You used the same value for the first order derivative's inputs (x and initial condition), Could you please explain the idea behand it?

 

3. You used peak search offset, the reason and how  the value -20 was chosen?

 

I make a correction here as I mentioned that you used an array for loop iteration N, I noticed that it was my mistake. The array index was just behand the N, I moved the index down a bit to separate them.   

 

 

Best regards,

Gu

 

 

0 Kudos
Message 10 of 20
(2,633 Views)