LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine changes in a signal (peaks, valleys and 'flat' zones)

Hello!

 

I am using a software to predict the values of a parameter as a function of time. The result is output in an excel file with the time on first column and the parameter values on the second column of a worksheet. When I represent the parameter values versus time in an XY chart it looks similar to a signal or waveform with no noise.

I would like to detect the peaks, the valleys and the 'flat' zones and place coursors where the actual 'flat' signal starts to increase or decrease. More precisely, or rather additionally, I would like to be able to isolate a peak or a plateau if the height is over a certain treshold limit.

By 'flat' zone I understand a portion of the signal that does not increase or decrease more abruptly than a certain treshold limit.

 

Is anybody aware of an example that may do something at least somewhat close to what I am describing? Any suggestions?

I have the LabView full development system with no additional packages or toolkits.

 

Thank you.

0 Kudos
Message 1 of 39
(5,776 Views)

Hi RPJ,

 

Thanks for your post and I hope your well today. 

 

I great VI in vi.lib I would recommend using is the Peak Detector:

 

Its outputs include,

Locations - the sample number

Amplitudes - the value at the peak/valley

2nd Derivatives - which you can use to test how abruptly/sharp the peaks/valleys are.

 

Its inputs include,

Theshold - they amplitude theshold

Width - how many samples above the theshold the peak/valley should be to be classed

Peak/Valley - type

 

You could use the 1st Derivative to find locations of flat zones (or use the 2nd derivative ..2nd Derivatives gives measurements of the second derivative of the amplitude at each of the peaks or valleys found in the current block of data. 2nd Derivatives gives an approximate measure of the sharpness of each peak or valley. If you are detecting peaks, these values are all negative. If you are detecting valleys, the values are all positive.)

 

I hope this helps, please let me know what you think,

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 39
(5,758 Views)

Thank you Hillman. This helps some.

 

Yes...I look at that function before I posted my message. However, I have some concerns:

1. The vi fits a function through the points and then detects the peaks/valleys through derivation? If yes, wouldn't this lead to some approximation of the actual peak value (due to function/curve fitting)?

2. Apparently this vi provides only peaks/valleys and their location but does not say anything about how to detect where the "mountain" starts and stops. Let's say you have a 'flat zone of signal, then the signal starts to go up, it reaches a peak and then it starts to go down, coming back to a steady state. Or, the signal is steady, then it starts to go up, then it reaches a plateau phase, then it goes up again to a peak, then it comes down to the first plateau and after a while it goes down where it started initially. How would I detect not only the peaks but also where the signal starts to go up and where the signal gets back to its steady state (to allow me to isolate not anly the peak but rather the entire mountain)?

3. The vi presents the second derivative results; how would you determine the first derivative results?

 

Any thoughts?

 

0 Kudos
Message 3 of 39
(5,753 Views)

Hi RPJ,


Thanks for you reply.

 

1#. It doesn't appear to produce any errors - it outputs the correct sample number for me -peak is sample 30 (result 29.50).

2#. To test the flat zone, you will need to implement logic to log when the derivative was zero (and then again when its no longer zero). I am not able to find anything higher level that would acheive this result. 

3#. Use the  Derivative.vi from the maths palette. 

 

What do you think, Have you got some code already? example?

 

Hope this helps, 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 4 of 39
(5,743 Views)

Hillman,

 

I believe your suggestions are good. Thank you.

I do not have signififcant code... I have to read two columns from a table in an access file that is zipped. I have enough trouble with this; then I will have to work out the peak valley stuff...

I'll work on it late this afternoon and get back. 

RPJ

0 Kudos
Message 5 of 39
(5,739 Views)
You may also use the Linear Fit VI for the flat part. Use the slope and residue output to determinate how flat you signal is.


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 39
(5,725 Views)

I attached some code and a data file that can be read.

It does not seem to be working for me. The peaks are off the actual datapoints that appear to be at maximum.

I am reading the time column and parameter 35 (P35 column).

 

Any suggestions?

0 Kudos
Message 7 of 39
(5,710 Views)

Hi RPJ,

 

Thanks for the update.

 

Could you please explain what isn't working? And when you say off how off are they?

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 8 of 39
(5,688 Views)

If you run the vi you will see that the red points that represent the peaks are not where the peaks are. They also seem to be placed all over the flat signal areas even though I used a fairly high treshold. Obviously I am doing something wrong, but what?

 

If you look at the top chart and magnify (for example use a scale of 0 to 30 sec on x axis) you will see that the red dots are not 'on top' of the peaks on X axis.

 

When I say peak detection I mean i want to detect the peak itself not somewhere there...

 

Does this clarify?

0 Kudos
Message 9 of 39
(5,686 Views)

Apparently my previous email did not clarify things. Sorry...

 

Does anybody have any type of viable example that allows selecting the peaks, the valleys and skips the 'flat' signal zones?

 

Thank you.

0 Kudos
Message 10 of 39
(5,654 Views)