Speeding Up Your VIs
Download
Report
Transcript Speeding Up Your VIs
Speeding Up Your VIs
參考NI官方教材:
LabVIEW Intermediate II for 7
LabVIEW.com.tw
LabVIEW Community
Speeding Up Your VIs
Reduce I/O
overhead
GPIB
Data Acquisition
File I/O
Networking
Reduce screen
updates
Use efficient
indicators (graphs and
charts)
LabVIEW.com.tw
Eliminate
• Improve memory use
– Use efficient array
functions
– Carefully manipulate
strings and arrays
– Avoid unnecessarily
complex data
structures
LabVIEW Community
Reduce Number of I/O Operations
• File I/O, GPIB, DAQ, Networking VIs
• I/O VIs take much more time than computational operation
• Minimize the number of I/O calls
– Transfer a lot of data in each call
– Use multiple-point DAQ VIs instead of single-point VIs
Slow Method
(many I/O calls)
LabVIEW.com.tw
Fast Method
(One I/O call)
LabVIEW Community
Reduce Opening and Closing of
Resources
• Use low-level VIs to
reduce the number of
times a resource is
opened and closed.
• In Slow Method, the file is
opened and closed 100
times.
• In Fast Method,
the file is opened
and closed
only once.
LabVIEW.com.tw
Slow Method
Fast Method
LabVIEW Community
Reduce Screen Display Updates
• Updating front panel objects can be time consuming
• Use efficient controls and indicators
• Graphs and charts redraw when they receive new data and
therefore affect execution speed
• Minimize display overhead by designing subVI’s with front panels
closed during execution
• Use multiple-update plotting methods
– Minimizes the number of chart updates
– Get highest data display rates
LabVIEW.com.tw
LabVIEW Community
Screen Display Example
Slow Method
(updates chart
1 point at a time)
Fast Method
(updates chart
100 points at a time)
LabVIEW.com.tw
LabVIEW Community
Reduce SubVI Overhead
• Each subVI call involves certain overhead (tens of µs); not
significant, but this can add up if the subVI is placed inside
a looping structure.
• Do not display the front panels of subVIs called in a loop
running at high speed.
• If possible, place the looping structure inside the subVI
instead.
LabVIEW.com.tw
LabVIEW Community
Reduce Unnecessary Computation in
Loops
• Avoid putting calculation in loops that produce same value each iteration
• Avoid unnecessarily accessing global variables in loops
LabVIEW.com.tw
LabVIEW Community
Global and Local Variables
Each read of a variable creates a new
data buffer for the data
Can add up significantly if using large
arrays, strings or complex data structures
Using a wire is always more efficient,
both in memory and execution time
LabVIEW.com.tw
LabVIEW Community
Property Nodes and Control References
Runs in the user interface thread
Using a property node or control
reference results in a thread swap which
causes a loss in efficiency
Do not use a property node or a control
reference only to update the value of a
control
If changing other properties, adding a
value update does not cause a further
loss
since thread swap is already
LabVIEW.com.tw
LabVIEW Community
occurring
Updating the Value of a Front Panel
Object
Good
LabVIEW.com.tw
Better
Best
LabVIEW Community
Updating the Value of a Front Panel
Object
Bad
LabVIEW.com.tw
Good
LabVIEW Community
Create Efficient Parallel Diagrams
• LabVIEW periodically switches between parallel loops
• Use the Wait (ms) function - this ensures that less important loops use
less processor time
• A wait of 0 will also free the processor for other tasks!
LabVIEW.com.tw
LabVIEW Community