LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resolution of Power Spectral Density

Hi, 

 

I would like to know whether it is possible to change the frequency resolution of the power spectral density function. 

 

Currently I have a continuous signal with 20kHz sample rate, block size 2000 samples. 

 

Passing this through the "FFT Power Spectrum and PSD" function gives me a frequency array from 0Hz-10kHz as expected.

 

The default frequency resolution seems to be 10Hz, giving me 1000 points

 

I would like to increase the fft size so that I have a frequency resolution of 1Hz. 

 

Is it possible to do this in labview without zero padding the signal?

0 Kudos
Message 1 of 8
(2,932 Views)

Hi benny,

 

I would like to increase the fft size so that I have a frequency resolution of 1Hz. 

Is it possible to do this in labview without zero padding the signal?

From your last sentence I guess you know the basics of FFT, but to be sure I repeat them for you: frequency resolution is given by "sample rate" / "number of samples". The more samples at a given rate the higher the resolution…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 2 of 8
(2,905 Views)

 

Thanks for your reply, 

 

Yeah I understand that, I was just wondering whether there was a way for LabVIEW to handle this rather than doing it explicitly - ie if you did this FFT in matlab, you can specify FFT length and it will do the zero padding for you, which may be a bit cleaner and more memory efficient. 

 

I have already implemented my code with zero padding, so will continue to do that if its the best way. 

 

Cheers,

Ben

0 Kudos
Message 3 of 8
(2,885 Views)

Zero padding won't give you more resolution, just more points. Zero padding a "continuous time signal" is also very questionable. Typically one pads in the frequency domain. Padding in the time domain is useful if the signal is not continuous but e.g. a decaying response to a pulse.

 

 

0 Kudos
Message 4 of 8
(2,879 Views)

Im not sure what you mean by that altenbach - padding changes the frequency bin size and therefore the resolution does it not?

 

In terms of continuous or not - the data is acquired in blocks anyway, so in effect it is a series of discontinuous data blocks. 

 

Do you have any other ideas then?

 

I need a frequency resolution of 1Hz or so whilst keeping an update rate of roughly 10Hz, so increasing the block size isnt an option. 

0 Kudos
Message 5 of 8
(2,858 Views)

Hi Benny,

 

I need a frequency resolution of 1Hz or so whilst keeping an update rate of roughly 10Hz, so increasing the block size isnt an option.

Increasing the block size is your ONLY option!

You can still read your DAQ data with a block size of 2000 samples to maintain an update rate of 10Hz, but you also can keep an internal buffer of 20k samples for your FFT calculation!

Use a ring buffer of 20k elements to maintain the samples of the last second for your FFT…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 6 of 8
(2,851 Views)

I agree with Gerd's comment that you *need* a bigger block size to improve your frequency resolution meaningfully.   But instead of having to implement your own software circular buffer, you may be able to just use the buffer already managed by the DAQmx AI task.

 

Essentially, you'll be asking for a sliding window of data.  The block size will be 1000 samples (1 sec at 1000 Hz) to provide 1 Hz resolution.  Every 100 msec, you'll slide the 1000-sample window along by another 100 samples and recompute your PSD, giving you a 10 Hz update rate.  Do realize that each update uses 90% same data as previous update, 10 % fresh data.

 

Here's a link to a snippet that illustrates how to configure your AI task for this kind of thing.   Note that you'll need to tweak it a bit such as adding some delay time between starting the task and asking for samples from the past.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



0 Kudos
Message 7 of 8
(2,839 Views)

@bennymacca wrote:

Im not sure what you mean by that altenbach - padding changes the frequency bin size and therefore the resolution does it not?

 

In terms of continuous or not - the data is acquired in blocks anyway, so in effect it is a series of discontinuous data blocks. 

 

Do you have any other ideas then?

 

I need a frequency resolution of 1Hz or so whilst keeping an update rate of roughly 10Hz, so increasing the block size isnt an option. 



Hi,

Did you find solution to your problem?

As I am also facing the same issue, and circular buffer doesn't solve the same.

 

Regards,

Nikunj

0 Kudos
Message 8 of 8
(2,385 Views)