From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save a FFT in fixed time steps

Solved!
Go to solution

Hello!

 

I'm new to LabView and I work with version 12.0. I developed my VI by searching through the internet and using the help option, but now I came to a point, where I can't find a solution.

I'm analyzing a signal, which i meassure continiously with 2Mhz.(Puffer=10 000).

Until now I saved the FFT by activating the save-case via the boolean operator. This was ok for the purpose to document the rough behaviour of the signal, but I need a continuos record now.

It would be perfect to make a snapshot of the FFT in fixed time steps and save the data with the according time in an excel file. The result in the first place should be something like a matrix which i can use for a further postprocessing.

I would like to run this VI over probably some hours and I figured out, that too much data is created.

Is there a possibilty to save for example only every 10th data point or any other way to reduce the amount of data?

 

Attached you find my attempt so far.

 

With kind regards

 

0 Kudos
Message 1 of 13
(4,031 Views)

Hi Mr. Pete,

 

I hope I did not misunderstood your requirements, What I did was the following:

 

If I am not wrong using the manual boolean switch, you are storing 1 sample data at every iteration of the loop. If so, What I have done is that I hhave created a counter check whereby I initiate the counter to 0 at the beginning of the program (resets counter every time you start the VI). So when the Vi runs, if the 10th data (i.e. 10 iterations) is not reached, it will go to false case and in the false case, the counter increments by 1. This counter value is transfered to the next loop via shift registers.   

 

fft.JPG

So when the counter reaches 10, it should trigger the case structure to be true. In the true case, I will store the data to the TDMS and reset the counter. With the counter reset, the process will repeat again. 

 

fft2.JPG

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 2 of 13
(4,000 Views)

Hey!

 

Thank you for the fast answer. This helps a lot, great. 🙂

The next problem I have is that I'd like to save the data of every snapshot in a seperate column. So far, data is just attached to the existing in the same column. This would cause some troubles, because I'll gather a huge amount of data by the time and Excel is not able to handle so much data in one column. Is there a way to write every data snapshot in a sperate column. I add a screenshot how I'd image the sheet.

 

Thanks again and with kind reards!

0 Kudos
Message 3 of 13
(3,987 Views)
Solution
Accepted by topic author Mr.Pete

Hi Mr. Pete,

 

You're welcome. If you want the VI to write to TDMS as shown in your attached screenshot, you can amend the code as follows:

 

So since for every "True case", we are to store the data in a column. So what we want to do is that for every true we are to write to different column but with a different header such as FFT 1, FFT 2 and etc. So at the true case as shown below, you'll need to add a counter (we'll call it column counter) that increments every time it is true. Of course we need to initialize the column counter outside the while loop so that we will start at FFT 1 every time the VI starts. Let's say for the first true trigger from the data storing counter, the column counter equals to 1. This column counter however, needs to be converted to string so we use "format into string.vi". So since we are using a common name, we'll use FFT at the beginning of the conconate string.vi. As the results of the conconate string.vi will be "FFT 1" and the data will be stored in a column called "FFT 1". This will be repeated for every column counter increment (note that this column counter increment only occurs if the case is true).

 

fft 3.JPG

So since we don't want to have this VI write on the same column continuously while the VI is running continuously. We are to make use of the shift registers to inherit the value brought forth from the previous iteration to the next. Meaning that the column counter will always be 1 until the next 10 data points. So when the loop iteration is not equals to 10, the column counter is still at 1 until when the loop iteration equals to 10 (meaning 10th data point), the case structure becomes true and the column counter equals to 2 and therefore storing in the column "FFT 2"

FFT 4.JPG

So this process continues for the FFT 2, FFT 3 and etc. until you stop the vi.

 

TDMS result.JPG

 

Hope it helps.

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 4 of 13
(3,979 Views)

Lennard C.,

 

I thank you very much. This is a great solution and exactly what I was looking for! You made my day. 🙂

Thanks again.

 

All the best,

Mr. Pete

0 Kudos
Message 5 of 13
(3,975 Views)

Hi Mr. Pete,

 

You're welcome. Smiley Happy

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 6 of 13
(3,971 Views)

Hey!

 

I would need a good advice one more time. Is it possible to save the frequencies of the FFT in an external excel file aswell?

 

With kind regards,

Mr. Pete

0 Kudos
Message 7 of 13
(3,922 Views)

Hi Mr.Pete,

 

When you mention saving frequencies, do you mean the FFT peak frequencies or the frequencies of the whole x-axis?

 

Thanks 

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 8 of 13
(3,905 Views)

Hi Lennard. C,

 

I mean the frequencies of the whole x-axis. The thing is, that i found a lot about the peak frequencies but no thread about how to save the frequencies of the x-axis as well.

 

Thank you,

 

With kind regards,

Mr. Pete

0 Kudos
Message 9 of 13
(3,898 Views)

Hi Mr. Pete,

 

Sorry for the late reply. Was quite busy lately. I did play around with the current code to see if we can extract the whole x-axis values. Unfortunatley, I wasn't able to do so. Howevever, I am able to extract the waveform attributes: start time (t0), time interval in frequency between data points in the waveform (dt) and data values of the waveform (Y). So since we know that each points in the data has a dt interval and we know the t0 is usually 0 so perhaps you can try to create your own x axis since we know the number of Y points that we gather from the graph and increment from 0 with time interval of dt.

 

To extract the waveform to determine what is its dt and to, you can do as below:

Capture.JPG

 

What I did was I take the Dynamic Data signal and use "Convert from Dynamic Data" to 1D array of waveform. This is to convert it to a normal waveform. I used Index Array to extract one of the array and use "Get Waveform Components" to get t0, dt or y values from the waveform. 

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 10 of 13
(3,872 Views)