LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimizing a vi

Could anyone give a little advise on how to optimize the attached vi.  This is a sub VI wherein I send in a image ROI Global Rectangle and a full data array.  I want to grab only a section of that array (specified by the Global Rectangle) and send it back.

 

This Sub VI works but it is prohibitively slow (as much as a second).  I tried a few other methods in the hopes that the nested for loop was inherently slow.  All methods I tried are also slow.  There must be an efficient (fast) way to do this since there is not much to accomplish.

 

 

Any suggestions

 

0 Kudos
Message 1 of 6
(3,179 Views)

1.  Bring your controls outside the loops.  Leaving them inside forces the execution to check the UI for changes on every iteration.
2.  Avoid using the Value attribute to write a new value to a control within the same VI.  It is OK to use that for updating values on other VIs only if it is done occasionally, but certainly not in a For loop.
2.  Try to maintain consistent data types, those little red dots represent conversion which means data copies being made behind the scenes.

 

I did a quick refactor of your VI.  See if it meets your needs.

 

Are you using a FLIR A-series?  We are using those on a project right now.

 

Dan Press

Certified LabVIEW Architect

PrimeTest Automation

Message Edited by Photon Dan on 07-20-2009 02:59 PM
Message 2 of 6
(3,168 Views)

I addition to the above:

 

  • Don't use controls as initializers, use plain diagram constants. You min, max and mean are not needed.
  • Your shift registers have no functionality at all. Accumulate the data in shift registers instead. No property nodes needed.
  • WHy do you need three diagram constants of 273.15. One is enough! Don't be afraid to branch a wire!

 

You could just reshape and take a subset, e.g. as follows:

 

Message Edited by altenbach on 07-20-2009 01:44 PM
Message 3 of 6
(3,148 Views)

If you want to use two loops (maybe it's more efficient in memory?), simply correctly initialize the shift registers:

 

zero for the ave

Inf for the Min

-Inf for the Max

 

Here's a quick draft.

 

Message Edited by altenbach on 07-20-2009 02:21 PM
0 Kudos
Message 4 of 6
(3,123 Views)

Good day Photon Dan,

 

 

Could you please further explain the following " 2.  Avoid using the Value attribute to write a new value to a control within the same VI.  It is OK to use that for updating values on other VIs only if it is done occasionally, but certainly not in a For loop."

 

or kindly direct me to an article or notes about this .

 

 

Regards

 

 

Abasani

0 Kudos
Message 5 of 6
(2,998 Views)
See this section of the LabVIEW help.
0 Kudos
Message 6 of 6
(2,975 Views)