LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing CSV data for FFT analysis

Hi guys,

 

Sorry if this is a dumb question, but I searched for anything relevant and I couldn't find a problem that was close enough to what I needed. Part of the problem is that I am not that experienced in Labview (I am more Matlab, my coworker usually works on Labview but he is in Europe right now).

 

I am attempting to extract data from a CSV file that contains waveform data captured from an oscilloscope. I was hoping to 1) extract the data from the file in Labview and then 2) perform an FFT analysis on it.

 

Here is what I have gathered I should do so far:

 

1) Use the "Read from Spreadsheet" function to import the CSV file. All I've worked out so far is set the delimiter and add a control for the file select. Not sure where to go from here. And would the output of this function result in an array or a plot?

 

2) Using the information from the Read from Spreadsheet function, I would then use an FFT function (presumably under the Waveform Function menu) which would then take the data and output it in some way (graph, etc).

 

I am combing through tutorials and other cases similar to mine, but any help would be appreciated. Thanks.

 

I included a CSV file in case it was needed.

 

0 Kudos
Message 1 of 15
(6,660 Views)

Is this sort of what you're looking for?

 

FFT.png

Message 2 of 15
(6,642 Views)

That does look promising...so from how I interpret it, it looks like you are using a function that takes the CSV (or info inside the CSV) that posts it to an array, and then that array is fed into some soft of function which then results in a graph? Would you be able to explain further so that I could recreate it in my Labview? Thanks for the reply.

0 Kudos
Message 3 of 15
(6,635 Views)

If you've got LabVIEW 2013 or newer, simply save the image I posted (say, to the desktop) and then drag it into the block diagram. The code will automatically be created.

Message 4 of 15
(6,629 Views)

D'oh, thanks. That does make it much easier. 

 

I've enabled my Context Help button, and I see that you put the data from the CSV file into the box that is wired to the Spreadsheet String node of the "Spreadsheet String to Array" function. Would I be able to instead insert a control in there, so that I could select the CSV file? Or how would I select a different file? The reason why I am asking is that I think the Identifying info on the CSV file is messing up the array and possibly the FFT. I am really only interested in columns D and E on that file.

 

From there I see that the function outputs to an array, which also leads to the Index Array function. And then an FFT function. But I'm a bit lost on what exactly these are doing. 

 

Most examples I've seen use the Read from Spreadsheet function, was there a reason why you decided not to?

0 Kudos
Message 5 of 15
(6,620 Views)

I haven't messed with Read From Spreadsheet File.vi much before. After some quick testing, I can only get the first column of data out of it which is all zeros. It seems like you should be able to get columns D & E out without too much effort though.

 

In the code below, I'm pulling out column E (LabVIEW arrays are zero-indexed so a column index of 4 actually means the "fifth" column). I've reworked the code to include file I/O and also added some comments which will hopefully clear some of the hazy stuff up. If you're curious about what data is being passed through on any wires, right click and select either "Probe" or "Create > Indicator". They both do what amounts to basically the same thing (show the data on the wire) but the probe is a little less invasive.

 

 

FFT2.png

Message 6 of 15
(6,611 Views)

FFTMod.png

 

Just use the File I/O primitives Dave described above and feed the output to the spreadsheet string to array function. Also, there is nothing stopping you from manipulating that array once you create it. I'd use the Array Subset instead of Index Array to get the last 2 rows.

Message 7 of 15
(6,604 Views)

Thanks, Dave. Let me mess around a little bit with what you've made already, I don't want to bother you any more than I have to. I appreciate all of the help so far.

0 Kudos
Message 8 of 15
(6,590 Views)

Thank you also, Eric. Just for curiousity's sake, I also ran your VI, and  ended up getting quite a different graph than Dave's. I think the only difference was the Array Subset. I'm going to keep messing around with both, maybe clean up the CSV files (I am not sure if just column D/E are being calculated).

0 Kudos
Message 9 of 15
(6,572 Views)

@johnBURL wrote:

quite a different graph


I don't have access to LabVIEW on this machine but I think with the "length" parameter of Array Subset unwired, you get all remaining columns (which in this case is two data columns and a column of zeros). Try wiring a 2 constant.

0 Kudos
Message 10 of 15
(6,544 Views)