LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the power spectrum subset vi to actually start at 'my' frequency of interest instead of 'its own' frequency?

I'm trying to use the power spectrum subset vi from the sound and vibration toolbox to do a narrow band frequency analysis. The data is captured at 100 kHz and I'm interested in 3 bands; 0-400 Hz, 400-2000 Hz, and 2-20 kHz. No problem with the first two, I broke the data into subsets of 100 ksamples and did 16 averages for the first band and broke the data into 25 ksamples for the second with 32 averages. Those two bands work great.
 
The problem is with the third band. I've been trying to replicate the results from an HP spectrum analyzer and find that it uses 2-27.6 kHz to get 400 lines at 64 Hz intervals. My first problem is that in order to get 64 Hz resolution from 100 kHz data I need a block size of 1562.5. Rounding that up or down gets me something near 64 Hz resolution (64.0205 Hz for 1562 samples). I can probably live with that but get a start frequency of 1984.64 Hz instead of 2 kHz. If I drop the sample block down to 1500 I can get a start of 2 kHz but my resolution goes to ~66.667 Hz. That I can't live with.
 
Any ideas?
 
Thanks
 
Frank
0 Kudos
Message 1 of 3
(2,968 Views)

Hi Frank,

Your intervals (df or frequency resolution in SVT terms)  are the result of Acquisition rate/number of samples. In your case 100KS/s/1562S = ~64.02Hz as you've seen. What this means is that your frequencies come as multiples of 64.02 - in this case 2000/64.02 = 31.24. This rounds down to 31 which gives us 31*64.02 = 1984.64Hz. What this comes down to is that you will not be able to directly get 64Hz intervals starting at 2K.

There are a couple different ways to work with this though. The greatest common factor (who said you'd never need to use that again) 🙂 between 64 and 2000 is 16, so this is a good frequency resolution to shoot for. Working this out 100kS/S/16Hz = 6250 samples. This, in theory, should give us an exact start at 2000Hz (more on that later). We can then decimate the data (pull out every 4th sample) and we now have a data set with 64 Hz intervals starting at 2000Hz.

In practice, you'll notice that we again get a starting frequency (f0) of 1984Hz. This isn't a problem though, because we know that our magnitudes are at 16 Hz steps, so if we start at index 1 (instead of 0) in the magnitude array we will be starting at 1984 + 16 = 20 Hz. You can then pull out every 4th sample and you will have your desired data. Something along these lines should work -  

 

 

Another alternative would just be to use 100k samples and then just pull out every 64 sample. You could also just work with a higher resolution, but it sounds like you're running a comparison so that may not be an option.

Hepe this helps. Please post back if I didn't answer your question, or this doesn't work for you.

Cheers,

Andrew S.

National Instruments 

Message Edited by stilly32 on 12-28-2006 07:12 PM

Message Edited by stilly32 on 12-28-2006 07:12 PM

Message Edited by stilly32 on 12-28-2006 07:13 PM

Message Edited by stilly32 on 12-28-2006 07:13 PM

Message Edited by stilly32 on 12-28-2006 07:24 PM

Download All
Message 2 of 3
(2,952 Views)

Andrew,

Thanks, sort of, I've implemented something along those lines (no pun intended). The only problem is that now I'm going to be under-reporting the magnitudes in all of the frequencies of interest. I'll be partitioning the energy into all the other bins with the greater resolution and therefore not binning out that energy into the 64 Hz bins. I need to be able to do this with 64 Hz bins.

I've even tried resampling to the next higher and lower sampling rates that work out more amenable to the 64 Hz resolution I'm interested in. Given your insight into how the vi arrives at the start frequency, I'll go back to the resampling technique and see if I can't get the right combination of sampling rate and # samples to get a start at 2 kHz.

Frank

0 Kudos
Message 3 of 3
(2,934 Views)