LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on optimize intensity waterfall plot

I am working on a GUI, where needs a waterfall intensity plot. Every 20ms, a new line of data is added at the top of intensity plot, and the oldest line at the bottom is removed. Please refer to the attached VI for the demo.

I have 2 questions.

1. How to minimize the CPU consumption. There are many other tasks in my application. All of them needs to be fast. I must optimize the buffer building in the display loop. I have 3 methods in my mind:
A, the one in my demo. Build array and insert at the top, then resize the array.
B, Build array and insert at the bottom, delete the top row. And reverse the Y scale direction on the front panel.
C, Build 2 buffers, one is a loop queue, the other is display buffer. Insert
new data into the loop queue and sort the data and dump into display buffer.

Is C the best? Is B better than A? For C, I can set the queue a finite size (say 500 lines) and preview all of them in the display loop, this will cause the queue overflow. Is this a nice way out?


2. I think the load to CPU should not be too high in my demo, but the task manager\performance tells me CPU consumption is 100% always. Is this a bug of LV? It is happening on DAQ AI loop too.
0 Kudos
Message 1 of 3
(2,825 Views)
All your options build arrays at a number of locations, a very slow and memory consuming operation. Instead of building the arrays continously create arrays of the size you need in the start and use those arrays to hold the data. Update using replace array elements, that does not copy the whole array(s) and is thus much faster.

Avoiding array builds alltogether is difficult in this case though, but you can probably optimize the performance by applying a circular buffer design (make functional globals, one for each band, that act as circular buffers, instead of using a que).

In the example you are in effect updating the plots every 25 ms...which is way too fast for the human eye anyway, just refresh the plots every 2-300 ms. That way you will only read the circular
buffers every 2-300 ms as well, which is the slowest operation involved here...

You can probably find circular buffer examples here on the zone, if not let me know and I'll make an appropriate one for you.

Mads
0 Kudos
Message 2 of 3
(2,825 Views)
Thanks,

If I limit the size of the queue, will the queue act as a circular buffer?
0 Kudos
Message 3 of 3
(2,825 Views)