LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate power over specific range of frequencies

Hello all,

 

I obtained a breathing signal with myRIO audio in port, and I'm trying to find power in specific frequency range over total power to indicate wheezing in the breathing sound. I plotted the spectrum of my signal using Spectral Measurements vi but I couldn't reach what I want, your help is much appreciated. 

0 Kudos
Message 1 of 5
(2,266 Views)

Until you attach your code (not a picture of the code, but the actual VI or VIs), we can only guess that "you did something wrong" ...

 

I can think of two ways to do this, one with a Filter, one without.  What do you know about Signals, signal analysis, Frequency Spectra, etc.?

 

Bob Schor

0 Kudos
Message 2 of 5
(2,226 Views)

Oh, sorry about that,

I assumed that because my code is dependent on myRIO device, and it just contains spectral measurement VI, there's is no need to upload anything.

anyway, I attached the code concerning the spectral analysis of my data, there's also time analysis, but it has nothing to do with the frequency, so there's no common VIs between the two other than the data acquisition.

I don't know much about the frequency analysis to be honest, i just know the Nyquist frequency, the wheezing occurs above 200 Hz, and the sampling frequency is 1kHz.

What I need at the end is to find the ratio of power above certain frequency over the total power of the signal, and based on that, I will determine the wheezing event.

Thank you

 

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

My fault -- I should have asked you to compress the folder containing your entire Project and attach that.  Your target is, of course, your myRIO, so we would need to open it on the Remote Target (or a simulated one), in particular because you are using Express VIs that refuse to "open up" so we can see how you are using them.

 

So now that you have explained what you want to do in a bit more detail, and have given some hints about how you are planning to do it (which I think may be not the ideal way to approach the "what" goal), I'll make some comments that might help you ...

 

  • Sampling and Signal Analysis.  Learn more about these topics.  If you sample at 1 kHz, the highest frequency you can resolve is 500 Hz.  Since you say that the "wheezing" signal is >200 Hz, you have barely a factor of 2 in the frequency range of interest.  I would probably recommend a sampling frequency of 10kHz.
  • Solve the "basic problems" first.  You are sampling in a loop and accumulating an array of undetermined length to do your spectral measurements.  Instead, write a routine that does away with the While Loop (or, alternatively, wire a "True" constant to the Stop indicator) and see what that looks like.  You can also do an FFT on it.  In fact, do away with the Sampling altogether and use the Waveform Generation functions in LabVIEW to synthesize a waveform with known frequency content to learn how to use the FFT routines.
  • Refine the question.  Are you trying to answer a "Yes or No", or a "When" question?  For example, you sample sounds for (say) a minute.  Do you want to know "Did wheezing occur during the entire sample" (yes or no) or "Was wheezing present at any time during the sample" (a "when" question, in addition to a yes or no)?

To answer the question raised by your title, simply read up a bit about the Power Spectrum of a signal and what it means, which should enable you to figure out how to do that part.

 

Bob Schor

0 Kudos
Message 4 of 5
(2,188 Views)

thank you for your answer,

I do not care about the time of the wheezing event, it's just a yes or no question.

regarding the sampling, i had a problem when sampling at 10kHz inside the timed loop, the number of samples in my x-axis was not related to the actual time of recording, i'm not having this problem at 1k sampling, i tried to search for the reason and i couldn't find anything, so if you can help me with that, i would really appreciate it.

0 Kudos
Message 5 of 5
(2,180 Views)