130 likes | 318 Views
Speeding Up Your VIs. 參考 NI 官方教材: LabVIEW Intermediate II for 7. Speeding Up Your VIs. Improve memory use Use efficient array functions Carefully manipulate strings and arrays Avoid unnecessarily complex data structures. Reduce I/O overhead GPIB Data Acquisition File I/O Networking
E N D
Speeding Up Your VIs 參考NI官方教材: LabVIEW Intermediate II for 7
Speeding Up Your VIs • Improve memory use • Use efficient array functions • Carefully manipulate strings and arrays • Avoid unnecessarily complex data structures • Reduce I/O overhead • GPIB • Data Acquisition • File I/O • Networking • Reduce screen updates • Use efficient indicators (graphs and charts) • Eliminate unnecessary controls/indicators
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) Fast Method(One I/O call)
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. Slow Method Fast Method
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
Screen Display Example Slow Method(updates chart 1 point at a time) Fast Method(updates chart 100 points at a time)
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.
Reduce Unnecessary Computation in Loops • Avoid putting calculation in loops that produce same value each iteration • Avoid unnecessarily accessing global variables in loops
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
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 occurring
Updating the Value of a Front Panel Object Good Better Best
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!