LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Will more function globals or sub vis slow down realtime DAQ or display

I need to do high sampling rate DAQ with varient data process and display.

 

Shall I intend to put all the code into one vi to accelarate the speed,  or can I use more function global or sub vis to make the structure looks more reasonable.

 

Just worry how the compiler handle the data transfer when call function global or sub vis.

 

Will it creat new data copy and slow down the speed. Thanks.

0 Kudos
Message 1 of 5
(2,817 Views)

Don't worry about speed issues when calling subVIs - it adds an amount so small that it's not worth worrying about.

 

One thing to avoid is local / global variables holding LARGE data structures.  Reading those forces a copy to be made and that takes extra memory / time.

 

Consider a producer-consumer architecture:

A PRODUCER loop waits on data, and puts data into a queue when ready. 

A CONSUMER loop waits on data in the queue, and processes it when ready.

 

The idea is that the PRODUCER loop is largely doing nothing except waiting for input data.  If you do it right (no polling, now) then it mostly yields the CPU for other tasks.

The CONSUMER loop is processing data block N, AT THE SAME TIME as block N+1 is being acquired.

 

This promotes maximum CPU usage, and the DAQ and processing can occur simultaneously.  Hiccups in the process don't upset the balance.

 

I think there are examples related to producer-consumer architecture.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 5
(2,802 Views)

Thanks, actually I am using it now.

 

But now face more complex application. There are 2 seperate display plot, displaying data from same source but through different processing. 

 

After read the data from queue, one loop will push data into 2 function global.

 

The other 2 loops in charge of the data processing and display will keep checking the version of the 2 function global. When new data arrive, they will process and display seperately. I just use shift register to store the data for display.

 

But now it may more complex, when user make a event on one of the plot, it will change the data processing and display mode for another plot also. To achieve it, I may use another 2 function globals for display data only. And read and display the data when their version change.

 

I am not sure if there are too many function globals and will slow down the real time display and processing.

Or any better solution.

 

 

 

0 Kudos
Message 3 of 5
(2,795 Views)

The other 2 loops in charge of the data processing and display will keep checking the version of the 2 function global. 

 

For high performance, you want to avoid this sort of thing. Basically, you're polling the functional global to see if it has new data. Polling will eat the CPU unless you include WAIT periods, but doing that slows your responsiveness.

 

Consider using custom events.

 

For the sake of discussion, let's say you need to process data in the TIME domain (1) and the FREQUENCY domain (2).

 

You create two events: NEW TIME DATA and NEW FREQ DATA, each carrying an array of DBL (the time-domain data from the DAQ).

 

The DAQ routine, when it gets a new data block fires both these events, feeding it the new data. 

 

 

Your TIME DOMAIN loop (1) has registered for one event.  When that event is triggered, the code accepts the data, and does whatever it needs to do (filters the time domain, graphs it, writes to file, averages, whatever).

 

Another loop (2) has registered for the OTHER event.  When THAT event is triggered, the code accepts the data, performs FFT on it, and  does whatever it needs to do (filters the frequency domain, graphs it, writes to file, averages, whatever).

 

Or you could do the same thing with queues.

 

When the use changes conditions, you change which event you listen to, or which queue you consume from. 

 

 

The idea is that you want to avoid polling.  Let the system tell YOU when data is available. Don't be asking the system if it's available. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 4 of 5
(2,791 Views)

Thanks, I will try it.

 

Why I use Function Global is the displayed data must be stored some where. Because

 

1. The display data is a processed historical data period buffer with first in first out.

 

2. When the data for one display has been seperated into groups by user, the data points for another display should also be seperated into groups according. There will be interaction between them.

 

Please see the attached screenshot. But still not very clear. Any suggestion? 

Download All
0 Kudos
Message 5 of 5
(2,767 Views)