LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Power spectrum density at 0.25 Hz resolution

Solved!
Go to solution

Hi,

My issue is similar to this thread. I am trying to get frequency resolution of 0.25 Hz while performing continuous PSD.

I have tried circular buffer, but it doesn't solve my problem.

There are 2 issues,

(i) results not matching with expected output

(ii) -Inf values in PSD, when input signal frequency is in integer multiple.

Pls note, I am using PSD block from Sound & Vibration library.

I have attached simplified version of code (LV12) and snippets herewith.

 

Please let me know, if any more details are required.

Thanks,

Nikunj

 

0 Kudos
Message 1 of 32
(3,724 Views)

Why are you enqueue-ing an array?

 

Enqueue elements instead. Then in the dequeuer, either wait for an element, or check if it times out.

 

Not that that will help your problem, but when there's a bug simplification is usually a good idea.

 

The first two iterations, those PSD VIs are called with uninitialized data. That might screw them up, and the result is put in the shift register. So it might never get better...

0 Kudos
Message 2 of 32
(3,699 Views)

If you have a piece of code that gives you the "expected" .25 Hz resolution, why aren't you using that?

 

Do you see the differences in the block diagram between the "actual" and the "expected"?

 

In order to get 1/4 Hz resolution on a spectrum, you need to collect 4 seconds worth of data before you analyze it.

0 Kudos
Message 3 of 32
(3,691 Views)

wiebe@CARYA wrote:

Why are you enqueue-ing an array?

 

Enqueue elements instead. Then in the dequeuer, either wait for an element, or check if it times out.

 

Not that that will help your problem, but when there's a bug simplification is usually a good idea.

 

The first two iterations, those PSD VIs are called with uninitialized data. That might screw them up, and the result is put in the shift register. So it might never get better...



Thanks for a quick reply.

 

I do understand your point. 

1) In my actual application, I am acquiring signals of multiple channels, hence i kept architecture same, i.e. enqueue-ing array of waveform. Also, I have used same architecture for 'testExpected.vi', which is giving proper output.

2) I initialized all 3 shift registers with waveform of 1000 points and 0 value, still output goes to -ve infinity @ 11hz.

 

 

0 Kudos
Message 4 of 32
(3,687 Views)

@RavensFan wrote:

If you have a piece of code that gives you the "expected" .25 Hz resolution, why aren't you using that?

 

Do you see the differences in the block diagram between the "actual" and the "expected"?

 

In order to get 1/4 Hz resolution on a spectrum, you need to collect 4 seconds worth of data before you analyze it.


 

Sorry, I don't understand your point.

As i understand, DeltaF = Fs/ N.

Hence, using shift register I accumulated data of previous 3 seconds and concatenated with current data, to get total 4 second data.

 

NOTE:

1) Though I mentioned incorrect time domain waveform, but now i understood, it's not a problem. It's going to be like that only.

2) Attached output from trialExpected @ 11hz.

0 Kudos
Message 5 of 32
(3,681 Views)

Sorry everyone for lengthy post and not asking precise question.

 

After studying little more, many things are clear. Even I was able to co-relate db level @11hz with signal amplitude.

My only queries remain are

(i) why output goes to -ve infinity in-case of circular buffering?

(ii) why output is not matching for both cases?

 

I have attached screenshots of both cases, ideal and actual.

Ideal/Expected output @11hzIdeal/Expected output @11hz

 

Actual output @11hzActual output @11hz

 VIs for both cases are attached in 1st post.

0 Kudos
Message 6 of 32
(3,663 Views)

@nik2013 wrote:
I do understand your point. 

1) In my actual application, I am acquiring signals of multiple channels, hence i kept architecture same, i.e. enqueue-ing array of waveform. Also, I have used same architecture for 'testExpected.vi', which is giving proper output.


OK, that is a valid reason.

 


@nik2013 2) I initialized all 3 shift registers with waveform of 1000 points and 0 value, still output goes to -ve infinity @ 11hz.

Just remember that initialized shift registers are always preferred, unless you want a memory effect. So even if you don't see an improvement now, I'd keep them initialized. If at some point you start the VI multiple times (sequentially), you will get side effects from previous runs with uninitialized SRs.

0 Kudos
Message 7 of 32
(3,637 Views)

As i understand, DeltaF = Fs/ N

 

Delta F = Fs/N

T (acquisition period ) = N*Fs

Delta F = Fs/ (T/Fs) = 1/T

 

As RavensFan stated. Just a different way of think about it. For example, a 10 s acquisition gives you a 0.1Hz resolution, irrespective of the sampling frequency.

 

mcduff

0 Kudos
Message 8 of 32
(3,625 Views)

@mcduff wrote:

As i understand, DeltaF = Fs/ N

 

Delta F = Fs/N

T (acquisition period ) = N*Fs

Delta F = Fs/ (T/Fs) = 1/T

 

As RavensFan stated. Just a different way of think about it. For example, a 10 s acquisition gives you a 0.1Hz resolution, irrespective of the sampling frequency.

 

mcduff


I understand that. But my query is, is my implementation of circular buffer correct? Because, results what I am getting is not matching with expected results.

0 Kudos
Message 9 of 32
(3,619 Views)

I do not see a circular buffer in your examples, you are just enqueuing data. You need to think about how you want to implement your buffer, it is lossy, do you want to skip adding points to it if it is busy processing, etc.

 

There are lots of other things in your example that could be fixed, but I do not know whether you just put it together for an example.

 

Attached is a real hack of the program that will get it to do what you want, but I highly suggest you just look at it to see what can be done and rethink you problem.

 

mcduff

0 Kudos
Message 10 of 32
(3,615 Views)