Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

RealFft throws error, what is the proper format?? Please help!

All,

 

I am hoping that someone can help me with this.  I have been reading all I can here, and I have not been able to make this work.  Would really appreciate someone pointing me in the right direction please.

 

All I am trying to do, is to plot the FFT of a Low-pass filtered accelerometer signal,

 

Using NationalInstruments.Analysis.Dsp.Transforms.RealFft(waveform) in c#, according to the examples given (analysis/filtering).

 

My waveform array, has about 430 values, ranging in values from + to - and I have defined it as double[] waveform.  The entries in the Array look something like this:

"-115.395938987398
-220.355718034111
-194.509250764914
-144.174816090961
-195.916661592532
-184.986891347911
-139.366644956414
-153.343694465293
-103.792322014381
-36.8463180547753
-70.012989029029
-46.268235716388
-9.89187992741799
-4.98874037090368
7.4840283756633
35.238625914635
24.4750060459582
77.5220291336239
99.8803020723934

 

No matter what I try, when calling the FFt Function(Example)

//

FFTValue = new ComplexDouble[datasize];

// Calculate the FFT of waveform array.
FFTValue = NationalInstruments.Analysis.Dsp.Transforms.RealFft(waveform);

//

I always get an exception.  What format must the data be in?  Is the way that I am passing the data to the RealFft function wrong?

 

I looked at the example for filtering/FFT, and the data passed to the RealFft function looks something like this from that example:

 

0
176.335575687742
285.316954888546
285.316954888546
176.335575687742
0
-176.335575687742
-285.316954888546
-285.316954888546
-176.335575687742
0
176.335575687742
285.316954888546
285.316954888546
176.335575687742
0
-176.335575687742
-285.316954888546
-285.316954888546
-176.335575687742

 

Why is there a Zero every four entries? Must my data also be in this format?  This should be straight forward, but I am sure I am doing something stupid, or I am missing something obvious....Can someone please shine some light on this?  I am at a loss as to how I can make this work..

 

thank you all kindly in advance!

 

-S

0 Kudos
Message 1 of 4
(4,716 Views)

Hi,


You should be able to give it just a double[] as the input, like you have in your code. I’m not sure why the example data is formatted that way, it certainly isn’t required to have a 0 every 4 values. Could you post what the exception is that you see? Does it occur at compile-time or run-time?

0 Kudos
Message 2 of 4
(4,684 Views)

Hi kevin,

 

Thank you VERY much for replying to mt plea for help 🙂

 

The exception is this:

 

"The Type initializer for 'NationalInstruments.Analysis.Dsp.Transforms' Threw an exception"

 

No other information.  It happens when I hit a button, to pass the array to the function, again, like in the example.

 

I am using this in Visual Studio 2013, after following the instructions to import the tools and references.  No matter how I try presenting it the data, it throws this exception.

 

Does the data need to be a power of two?  Most other DSPs seem to require this, not sure about this implementation?  I am also making sure the data in the array is valid, and as you can see from my previous post, nothing really special about it....at a loss at this point.

 

Also, does the array need an imaginary part after the real part?  again, other implementations I have seen also require this, hence my question on the format.

 

Thanks again!

0 Kudos
Message 3 of 4
(4,681 Views)

Hi All,

 

I think I have solved this, as I tried to generate a signal, and I got a License error.  It all has to do with this:

 

http://zone.ni.com/reference/en-XX/help/372636F-01/mstudiowebhelp/html/licensingnetwithoutintegratio...

 

Needed to manually generate a licenses.licx file, as it does not happen with Visual Studio 2013.  Cant wait for MS 2015!  Integrtation with VS 2013 has been nothing but a pain...

 

For the time being, seems to be working, but will post back if something else happens....

 

thanks all.

0 Kudos
Message 4 of 4
(4,661 Views)