08-09-2016 04:02 PM - edited 08-09-2016 04:03 PM
Hello,
I have a Waveform and I need to perform a FFT and plot its Magnitude. Since I have absolutely no previous experience with C# I have a difficult time tracking methods and data types through the forest of NI classes.
I would appreciate if someone can help me with my situation:
----------------------
SIgnal[] is the array of samples...
Waveform is SIgnal bundled with dt and t0...
FFT method in Transforms class insists on ComplexDouble input and I don'y know how to convert my SIgnal[doubles] into ComplexDouble...
If (unlike in LV) I cannot perform FFT of a waveform what is the resulting df between smaples of the resulting array? - Is it just 1/dt? What is the notion of df with respect to dt?...
Any issues with graphing spectrum (FFT)?...
----------------------
PS: I am trying to graph on a web form!
Thanks in advance,
08-10-2016 03:20 PM
Hey there!
It seems like the preferable route to take with this would be to convert the array of doubles to an array of ComplexDoubles. I saw that there is an Implicit conversion function in C# that will let you convert a double to a complex value. Can you take a look at this and see if you can apply it to your application?
Complex Implicit Conversion (Double to Complex)
08-13-2016 01:30 PM
Hello Mathew,
Thank you for responding, but I am not able to solve this (in LabVIEW) trivial issue - performing an FFT of a waveform and graph it in .NET! I cannot find my way through the classes and methods within them. Given the Waveform (with dt and t0) can you write for me the sequence for performing the FFT, extract the Magnitude and Graph the Magnitude? Also, what happens to the df? - Is it calculated implicitely, or must it be explicitely calculated from dt and be supplied to the graph?
Thanks in advance,
08-15-2016
04:38 PM
- last edited on
06-12-2025
12:26 AM
by
Content Cleaner
Hello,
There are a large number of sample programs that can show you how to get started with .NET programming with National Instruments hardware/software. While there is not anything that directly shows the FFT, it should give you some background on how to get started in general.
Text Based NI-DAQmx Data Acquisition Examples
http://www.ni.com/example/6999/en/
In addition, this other forum goes more in depth on how the user actually coded the FFT in c#. I recommend reading through the following link and seeing how that helps.
https://forums.ni.com/t5/Measurement-Studio-for-NET/C-Fast-Fourier-Transform/td-p/1175437
Best,
Shamik C
Applications Engineer
National Instruments
08-15-2016 06:44 PM
Hello Shamik,
Thank you for responding. I do not need to learn .NET, I need a vendor info - classes details so one can use them. The question is simple - which class can provide the "get magnitude", what is the resolution of the spectrum (df) or how to calculate df with respect to already known dt!
Since documentation/help is totally lacking info/examples on functionality, I have to ask so I can use it. What I ask for is not something I need to search for in others' guesses. The inventor should tell me straght forward, since I know what I am looking for.
The 2nd link gives me what I have already figured out, but not the functional sepcification I would like to read like in the LV help for example.
Thanks in advance,
08-16-2016
02:56 PM
- last edited on
06-12-2025
12:26 AM
by
Content Cleaner
If all you're looking for is calculating the df from a known dt, then that just has to do with the properties of an FFT. Depending on the sampling frequency, this creates the bandwidth of the spectrum measurement. The df is acquired by dividing this bandwidth by the number of samples used to calculate the FFT. So get your bandwidth from the dt and get your df from the bin size.
There won't be LabVIEW help on how an FFT works, but I'm still unclear what you hope to get from an example. Do you just want a function that's output is the magnitude and that magnitude has an f0, df, and and mag? That would be FFT Spectrum (Mag-Phase) in LabVIEW.
08-16-2016 04:29 PM
Mathew,
It is easy in LabVIEW, I have a problem to perform the FFT in C# - I cannot firnd my way through the (undocumented) classes.
Can you point out where is the method/function to get a FFT (magnitude) from a waveform or an array of samples, and the sequence how to do it?
Again, I know how to do it in LabVIEW, I do not know how to get the FFT in .NET and I just need it for a demo.
Thank you,
08-17-2016 12:37 PM
It doesn't seem that there is a direct equivalent to the LabVIEW function. Just one that outputs a double. There is a loaded Fft Method that takes an int32 value for the FFT size. Using this and the sample rate known for the data, you can calculate df. Like in my previous post, you get the bandwidth of the signal based on sampling frequency and divide it by the FFT size to get the df value.