MORECHEMISTRY.COM::MORE CHEMISTRY ON THE WEB    
Home Member Area Links Events Publications Promotions
 

LabVIEW programming topics - optimize vis for speed


LabVIEW vi optimization tips

When your virtual instrument (VI) is too slow then take notice of the following methods that are available to optimize your vi for speed.

Run sub VI's as subroutines

This method will reduce the overhead when the sub VI is called. The payoff is that you cannot run the sub VI as a normal VI and that the sub VI is somewhat limited; like you can't use property nodes.

In LabVIEW 6.1 select:

File >> VI Properties >> Category: Execution >> Priority: Subroutine

Use property nodes rather than local variables

When you make a local variable you make a local copy of the original variable. When you make a property node you make a reference to the original value.
In the case of single values the use of local variables may still be prefered because of the increase in readability. In the case of larger structures, such as an array, it is worth the effort to make the right property node.

Don't use anti-aliasing

Anti-aliasing in graphs can be used to enhance the visual aspect of graphs. The disadvantage is the time it seems to consume.

Anti-aliasing graphs will create some extra overhead. This vi demonstrates the truth of that statement.

Play with the 'Repeats' and 'Delay time' in order to get a significant difference. Then turn off the anti-aliasing from the 'Waveform Graph w Anti-Aliasing' by a right-click on the 'Plot 1' legend and remove the mark by clicking on 'Anti-Aliased'.

antialising.vi

 

 

Consider small delays in parallel loops

There are many cases where using parallel loops in a VI is really convenient. If a loop doesn't need attention all the time then you should add a (small) delay. For example:

 

sample
In a VI with several parallel loops, the first loop monitors 15 analog values at the highest possible speed, and the second loop collects (stores in memory) values for later storage on disk. Omitting a delay in the second loop decreases the throughput by about 50%.
read more about this VI...

 

Keep the communication open

If you communicate with a serial device, or even with a DDE server, then keep the communication open. While you open the communication you create a reference that you may use throughout the lifespan of your VI. Just before the VI ends you can wire this reference to a close node.
Opening the communication takes typicaly 10 times longer than simple 'write command - read answer' structures.


Bart Boshuizen, 2006/01/16

 


© copyright 2000-2014, morechemistry.com
design by Bb.