LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I get a running tally of peaks/valleys in live acquisition?

I am acquiring live data and cannot get a peak detect vi to actually select a peak from data. they simply look at the threshold value an flag anything over it. changing the width setting prevents the vi's working at all.
0 Kudos
Message 1 of 12
(4,154 Views)
Are you using the Waveform peak detector or the Analysis one (does it take a waveform or an array as input)? I've had pretty good luck with the former. You might try increasing the threshold until some of those extra flagged points you mentioned drop away. If the VI fails entirely, you may be using too small of a setting for Width. Can you attach a sample of the data you are processing, with a text description of which points are considered legitimate peaks for your test system?
0 Kudos
Message 2 of 12
(4,154 Views)
Thanks Ian
I am using the analysis one ptbypt under the analyze ptbypt section. I'm inputing in raw data numbers not an array. lowering the width to 1 is the only way I can get any peak detect response. as the max/min levels vary a bit and the pk to pk level is not large its difficult to raise the threshold. the attached file contains a signal sample containing a piece of data where the series of deep valleys are the points of interest.
0 Kudos
Message 3 of 12
(4,154 Views)
Are you entering an absolute or relative threshold? In your example, the deep valleys appear to be 500 units deep or so, but their amplitudes are all near 130,000. The latter is the value you need to feed into the peak detector. In the attached example, I fed a running average into the peak and valley thresholds of the detector, with reasonably good results. I also added a quick kludge: the peaks were being marked one data point after the actual peak (due to the "width" parameter being 3), so I used a shift register. I'm sure you'll find a more elegant way to mark the peaks, but I just wanted to throw together a fast example.
0 Kudos
Message 4 of 12
(4,154 Views)
it looks really good. I reckon I can drop that in and use it to look at the valleys though I have a question if I can trouble you - What does the peak detect do outside the 'for' loop?
0 Kudos
Message 5 of 12
(4,154 Views)
Oh, that--I just wanted to make sure that the first time it was called, the peak detector's internal buffer was cleared (the 'Initialize' input is set to True). It would probably have been better just to wire 'i=0' inside the loop instead. Hindsight is 20/20, eh?
0 Kudos
Message 6 of 12
(4,154 Views)
I stand to be corrected, but since 'Peak Detector PtbyPt.vi' is re-entrant, it really should be initialized inside the loop as unDees has pointed out.
=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 7 of 12
(4,154 Views)
I've incorporated this into my vi but get strange results. I've attached the full vi to see if anyone knows the problem - I may be doing something silly or impossible.
0 Kudos
Message 8 of 12
(4,154 Views)
I think you've taken too much of unDees demo into your vi. You don't want the For loop and don't need the Split 1D array. You can move the For loop's shift register to your While loop.
As it stands: you get a point, convert it to a 1-D array (which has only 1 element), then split the array into the 1st element and the remainder. The remainder is empty and you're feeding this emptiness to the pt by pt average and peak detector.
=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 9 of 12
(4,154 Views)
I see what you mean, thanks! the peak detect is working now and I can use it. would increasing the width help prevent it registering so many peaks in noisy data?
0 Kudos
Message 10 of 12
(4,154 Views)