LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT freq/mag response given CSV with time value and measurement

I am trying to generate a FFT frequency response given an input signal from a CSV file.

 

The file contains time and measurements data.  The first column is time (100 µs increments, sampling rate was 10 kHz).  The second column is an accelerometer reading.

 

I'm able to read the CSV and have generated FFT data with both the generic FFT function and the Spectral Measurement function but in both cases I have not entered sampling rate and am unsure how to generate an accurate frequency response.  I was originally using these instructions to generate an FFT in Excel: http://www.stem2.org/je/Excel_FFT_Instructions.pdf but I believe there is an error, as it states sampling frequency is total data divided by time interval between data points. 

 

I was calculating a FFT magnitude column by multiplying FFT results by multiplying 2 divided by number of samples by absolute value of the imaginary component of the FFT:

   2/n * IMABS(fft result)

 

Then I was calculating the FFT frequency using by setting the first row (array value) to 0 and incrementing by sampling frequency / total number of samples. 

 

I started to do this with LabVIEW but am unsure how to create the array mentioned in the last step and also figured that this must be a common enough task that there is a way to do it with the build-in tools.

 

Any advice would be appreciated.

 

Thanks!

 

 

0 Kudos
Message 1 of 8
(3,981 Views)

This is the broken mess of a VI and a screenshot of data format that I am currently working with.  My end goal is to have a chart showing frequency vs. magnitude. 

 

 

Download All
0 Kudos
Message 2 of 8
(3,973 Views)
You should create a waveform data type. With the Read From Spreadsheet File (or whatever it's called in 2015), extract the columns. With the build waveform function, dt is time(1) minus time (0). The Y array is your amplitude column.
0 Kudos
Message 3 of 8
(3,967 Views)

Thanks for the quick response.  I'll give this a try.

0 Kudos
Message 4 of 8
(3,959 Views)

Attached looks like it is working well.  The graph wouldn't automatically switch from time to frequency, would it (I changed the title manually).

Download All
0 Kudos
Message 5 of 8
(3,953 Views)
You should use a function that accepts a waveform. You should calculate the dt based on what is in the file. Swapping the 2D array is silly.
0 Kudos
Message 6 of 8
(3,933 Views)

I presume it looks like it was written by someone with next to no experience since, well it was.  Thanks for the tips.

 

I'm still struggling along with this.  Have been using simulated waveforms and seeing how the different functions look in an attemt to learn more. 

 

I converted this http://www.stem2.org/je/Excel_FFT_Instructions.pdf to LabVIEW and the spectral response looked correct.  I feel more comfortable with this than simply using the Auto Power Spectrum VI w/o understanding how it works (I'm using the trial version, waiting for a PO to clear).

 

Not sure what you meant by "you should use a function that accepts a waveform."  I was trying to build the data that I had into a waveform for use with the FFT function.  I understand the dt calculation, plan to do this for the final program - was just in a hurry to test and see if what I was doing worked at all.

 

 

 

 

0 Kudos
Message 7 of 8
(3,886 Views)
There are specific fft/spectral analysis functions that use a waveform as an input and use the dt value that is in there.
0 Kudos
Message 8 of 8
(3,876 Views)