From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to find peak value and valley value

helo everyone

 

i'm rai

 

i have some problem, i can not find peak value and valley value from my signal, maybe can you help me?

how to find peak value and valley value with using peak detector ? 

0 Kudos
Message 1 of 14
(5,263 Views)

What problems are you having with finding the peaks/valleys?  Your VI does not have any data in it and your description doesn't say.  

 

It looks like you found peakDetector PtByPt.vi -- you'll probably want to use peakDetector.vi instead (not "point to point"). 

 

Please run your VI , right click on the graph, and say "data operations >> make current values default", and then repost your VI with more details of the peak finding problem.  We'll be able to the the signal you're trying to analyze.

0 Kudos
Message 2 of 14
(5,251 Views)

thank you, my data from the acquisition of SpO2 sensor using arduino. I've been able to obtain the data SpO2.

 I need to know the value of peaks and valleys for find the value of the ratio.I still have not been able to obtain niali peaks and valleys.

and i have not understandwhat you mean?

Will you help me

0 Kudos
Message 3 of 14
(5,237 Views)
Please post at least a picture of your plotted data. Have you tried to use the function "peak detector.vi" instead of the one you had on your block diagram (peak detector ptbypt.via)?
0 Kudos
Message 4 of 14
(5,223 Views)

my block diagram

kjgf.PNG

 

I obtained the data in realtime using SpO2 sensor

g.PNG

0 Kudos
Message 5 of 14
(5,205 Views)

Here's the deal  You're trying to use the peak detector function on an array of data containing only one data point.  The analog read outputs a single point in this case and you're turning it into an array (of one point) using the initialize array function.  All of the wires that I've turned green in the first attachment contain one data point.

 

Second issue is that multiplying a 1D array of any length by a 1D array of length 1 (your 10000 scaling factor) will yield a 1D array of length 1.  In your case, that's another reason the peak detectors are not finding anything.

 

The simplest (but not the best) way to get your VI to work, given what you have, is to use the data you're storing in the chart.  It acts like a FIFO buffer of finite length (1024 samples unless you've changed that).  What I've done in the second screenshot is to use the history to feed all of your subsequent calculations.  Beware, the chart will remember history from run to run, too, so you might find peaks from the last time you ran the program unless you empty the history at each run.

 

Again, this is not the ideal solution but it should get you past the peak detect issue and you can work on a better data storage option at your leisure. 

 

I see that you're also finding peaks in the first while loop.  It has the same issue and a similar solution would work here, too.

Download All
0 Kudos
Message 6 of 14
(5,181 Views)

Are you running those pieces of code in parallel intentionally?  Or, did you have a linear order you wanted to run the code?

 

As a general rule, don't ever wire right to left.  It makes your code a mess and much harder to debug.

 

In the lower right corner it appears you have code that doesn't have anything wired as an input.  This means it will run independent of the other code you have in the loop.  You cannot tell when it'll run.  This creates something of a race condtion.  This may, or may not, pose a problem in your application.

 

Did you try changing the VI as suggested to get away from the point by point implementation?

0 Kudos
Message 7 of 14
(5,180 Views)

thank you very much for your suggestion.
i can find peak and valley value but ratio between peak and valley very small. it make me difficult to calculate spo2. do you know, how to find the value of the average peak and valley then stored temporarily after the complete data obtained stored data taken to calculate sppo2 ?

0 Kudos
Message 8 of 14
(5,149 Views)

Given the way your code is laid out and me not knowing how much data you're going to take before you analyze it, I'm going to suggest you write your individual analog samples to file as soon as they are taken.  

 

Open a file outside the outer while loop and pass the refnum in to the inner loop.  Set the file position to 0 bytes from the end and write your analog sample with every iteration.  When the sampling is done (outer while loop exits) read the data back from the file and do your analysis.

0 Kudos
Message 9 of 14
(5,133 Views)

i can't undestand with your suggestion, maybe you have some exampel for record data such as i want

0 Kudos
Message 10 of 14
(5,116 Views)