LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unresponsive UI when plotting in log scale

Hello, I have a program that reads data from waveform signals from a binary files as an input and as output plots the waveform signal with its FFT. The files are of about 2-5M points that I use to get a precise FFT. When I plot the FFT I obviously want to use a log scale in the X axis, but when I set up the plot in the front panel with this scale, the whole UI becomes unresponsive and laggy, something that does not happen when in the FFT plot I have the linear scale in the X axis. The program does not perform any other operation other than plotting from the file, and it becomes unresponsive even when it is not doing any operation.I attach a screenshot of the most important part of my code.

 

If someone can help me I would be greatful,

 

 

 

 

0 Kudos
Message 1 of 15
(4,276 Views)

Please share your whole project, are you running "continously"? 

Since you only read and process the file once, i dont understand why it becomes laggy after that unless im not understanding correctly

=======
My Channel: https://www.youtube.com/@LV_Lab

0 Kudos
Message 2 of 15
(4,244 Views)

A truncated picture is no useful for troubleshooting. Attach your VI.

 

What's the purpose of the FOR loop and what is the number of iterations? What's the size of the 2D array? What's the meaning of the data in the 2D array? D What's the purpose of doing an FFT of the phase? Do you really think you need express VIs? Make sure you leave out the zero-frequency for the X-axis. It is not possible to show that on a log scale.

0 Kudos
Message 3 of 15
(4,240 Views)

@javielas1232 wrote:

Hello, I have a program that reads data from waveform signals from a binary files as an input and as output plots the waveform signal with its FFT. The files are of about 2-5M points that I use to get a precise FFT. When I plot the FFT I obviously want to use a log scale in the X axis, but when I set up the plot in the front panel with this scale, the whole UI becomes unresponsive and laggy, something that does not happen when in the FFT plot I have the linear scale in the X axis. The program does not perform any other operation other than plotting from the file, and it becomes unresponsive even when it is not doing any operation.I attach a screenshot of the most important part of my code.

 

If someone can help me I would be greatful,


From your picture it looks like you have Magnitude and Phase information, then you want the PSD of the Phase signal. I am assuming you have a HD monitor or so, thus your plot can only be at most a few thousand pixels wide. Plotting 2-5M points on a 1000 point wide plot will be slow. Take your FFT data and decimate it before plotting. I recommend a Min-Max decimation based on the plot size, that way you will still see the peaks. When you zoom in on details in the plot, redo the decimation with new limits, that way you can see detail. See here or here for a decimation idea. Once the data is decimated the display will be much faster.

0 Kudos
Message 4 of 15
(4,205 Views)

Ok I attach the whole VI with some small modifications from the one that I sent in the picture. Now it has the possibility to decimate the array that I use for plotting the phase and the FFT, which obviously it helps for the plotting of the FFT, but I would prefer to do it as @mcduff proposed, decimating just before the plotting, which unfortunately did not work for me (probably I did not implement it correctly). I alyso attach a zip file which includes the file that the VI opens and plots, so that you can test it properly.

 

Now I reply to you questions:

The array has the data in the format: Intensity1-Phase1-Intensity2-Phase2-...

so I use the for loop to go through them

The number of interations vaires according to the numbers of channels in the file

The columns of the array depends on how many channels I have in the file (usually 4 to 8), and the number of rows depends on how many rows I read from the file, usually all of them that are about 3M

I use the FFT because I want to detect the main frequency for each channel (in the file that I attach there is only one signal), and I use a express VI because I am not so interested in the time to execute the VI, just that I should not get laggy when I move around the screen once I plot in the VI.

If you disable the Log scale for the X-axis, I can move around the screen easily.

 

0 Kudos
Message 5 of 15
(4,178 Views)

It becomes laggy when you move around the screen once it is plotted. And I also want to to solve this since it is the base of a bigger project that should run continously. You can check the whole VI with an example file in the message that I replied to @altenbach

0 Kudos
Message 6 of 15
(4,174 Views)

Thank you for your help,

Yes, decimating before plotting the FFT is definitely the way to go. Unfortunately, I tried to implement your suggested code, and I could not get it to work properly, the spikes do not look very good(quite likely because of a bad implementation on my side). I also tried to decimate the whole array and it definietly helps to get the whole VI more fluid. I attached my whole code in the reply to @altenbach if you want to take a look.

0 Kudos
Message 7 of 15
(4,170 Views)

I quickly looked over your code and there are issues, unfortunately, I need to head to a meeting and don't have time to write something new, I can only offer suggestions.

 

When you decimate the data set, you are doing a linear decimation of all 187,500 points and displaying it on your plot that is about 500 pixels wide. If you look at the linear scale picture below between the original data set and the decimated data set you would be hard pressed to tell the difference (I did not modify the x-axis, so ignore the numbers on it). As soon as you expand the X-scale or have a log based X-axis, then the decimation needs to be redone. If you still have a linear x-scale, then you should redo the decimation between the new end points. If you have a log scale, you need to decimate such that you sample points higher at low frequencies because the scale is expanded, and sample high frequency points at a lower rate because the scale is compressed. So you would need to modify the decimation vi to traverse the original data set in a non-linear manner. That is the mod you need to do.

 

Snap141.png

 

EDIT: You would also need to change your graph type to a X-Y plot if you decimate logarithmically as the sample spacing would no longer be linear.

0 Kudos
Message 8 of 15
(4,156 Views)

Quick, dirty, unsatisfying way to quickly decimate the data for log display.

 

Multiply the plot width by a value between 5 - 10; it will make the plot seem bigger and reduce the decimation. See below for decimated plot in your program where the width is increased by a factor of 7.

 

(Note I cannot make sense of all of your code, the following is but one suggestion)

 

Snap144.pngSnap145.png

Message 9 of 15
(4,147 Views)

Whenever you are plotting larger datasets especially when graph scaling needs to happen use the defer FP Udates method to force single redrawing of the plot area and Scales.  

 

All of the behind the scenes stuff can happen with a single push from the transfer buffer to the FP display but normally LabVIEW tries to update the display as soon as each transfer is ready.  That CAN and does require extra time switching processes that each require the single UI Thread.  Read the LabVIEW Help file on the Defer FP Updates method for more details.  Then remember to use it!


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 15
(4,138 Views)