LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel loops & improved efficiency

I am developing an application that monitors & controls test chambers, and have quite a lot of VIs. I read amongst these pages that it is generally bad practice to have parallel loops in a VI, and one of my VIs has many - because the FP has six XY charts that constantly need updating.

The code required to update each graph is considerable because there are four variables to plot and each variable uses a buffer, which potentially can be very large to incorporate a long history.
I am a relatively new LabView programmer so do not know all the little tricks that are probably out there - but am gradually catching on, i.e. control refs, dynamic loading etc..

I'm conscious that I'll be using too much memory/resources as it will have to run simultaneously with other VIs, and ideally want to make the code as efficient as possible.

My questions/dilemmas are these:

1. I've been trying to make the code to update a graph into a subVI so that it can be called six times as opposed to my current method of having identical code for each graph. I've semi-succeeded in that I have made a subVI that uses control refs to change certain properties (like x-axis scale) but still require the paralled loops so that the code executes correctly. What are the implications of having say, 8 parallel while loops in one VI? (I am using the Wait function) It seems to me that I need them to get different tasks to operate at the same time. (This is because the loop for each graph is inside a case statement that determines if the chamber is running or not - if not then the graph code does not execute)
Once there is one while loop, anything outside that loop will not continue to execute until the loop has finished!

2. To create the buffer I'm using a subVI from an example in LabView (6.02) found in Fundamentals/Graph & Chart/Chart/XY Chart.vi. The subVI is called XY Chart Buffer. The VI is reentrant and allows control of the number of elements allowed in the array. I want to have a large history so the user can see upto 24hrs worth of readings, that is as many as 17280 elements. Can LabView cope with buffers this big if there are many instances of the buffer running at the same time for different variables? Is the size of RAM directly responsible for how big the buffers can be?

If anyone can offer any suggestions or advice i'd be very grateful. Attached is the VI i have talked about with code for only two graphs - one with a subVI using references and one with the code not inside a subVI.

Dan
0 Kudos
Message 1 of 2
(3,283 Views)
The major concerns with parallel loops are just the added processing, sharing data between parallel loops, and synchronization. Race conditions are often a concern when setting the value or properties of variables in multiple parallel loops. Most of these issues can be avoided by careful programming and use of the synchronization tools such as Queues and notifiers from the Advanced menu. The processing problem of having several parallel loops is of course minimized by having sufficient delays in the loops. In 6.1 it can be minimized more by using the new event structure to eliminate the need for polling front panel controls.

Maintaining a very large buffer of data is pricipally an issue of usable RAM, but may also cause speed and/or graphics issues
when graphs need to be redrawn. Beware of the fact that LabVIEW often needs to replicate data behind the scenes, so you will often end up using more memory than you thought you would. Also, consider the efficiency of how you are storing your data. Remember that contiguous blocks of memory are usually required for arrays, and therefore very large arrays are more difficult to allocate. You might consider using some amount of file I/O to periodically store data and then retrieve it as necessary.
Message 2 of 2
(3,283 Views)