Download presentation
Presentation is loading. Please wait.
1
National Instruments Confidential
2
2 LabVIEW Development Tips and Tricks Revealed Carl Ljungholm - LabVIEW Product Support Engineer Travis Hailey - LabVIEW Product Support Engineer
3
National Instruments Confidential Challenge Starting with an existing VI Add TCP communication
4
National Instruments Confidential Challenge Starting with an existing VI Add TCP communication How much time will it take??
5
National Instruments Confidential Merge VIs Reuse common pieces of code VIs on Functions palette can be configured to be merged when dropped Enabled by customizing palette Example: Dropping a Wait Until Next ms Multiple with delay already wired
6
National Instruments Confidential LabVIEW Development Tips and Tricks Program Architecture Building Applications Debugging Memory Management Performance Miscellaneous
7
7National Instruments Confidential Program Architecture
8
National Instruments Confidential Program Architecture - General Separate time-critical code from UI updates and data transfer Use templates from the New dialog –Producer/Consumer (Data) –Master/Slave Use subVIs! –Easier to test/debug –Can use VI Profiler
9
National Instruments Confidential Functional Global Variables Uninitialized shift registers store values Use in subVI to retain data between calls FGV can store data or be more complex –Enum input controls action Read or Write Initialize, Write, Close
10
National Instruments Confidential Databases (One-Element Queue) A queue containing one element can serve the same purpose Allows multiple subVIs with different connector panes to use same data Queue acts as a semaphore
11
11National Instruments Confidential Building Applications
12
National Instruments Confidential Passing Command Line Arguments Command line arguments can be passed to LabVIEW Use – (two dashes) to mark beginning of user arguments Read arguments using Application property For an executable all arguments can be passed to the VI –Option in Application Builder Application.Command Line Arguments
13
National Instruments Confidential Stripping Paths
14
14National Instruments Confidential Debugging
15
National Instruments Confidential Custom Probe Use your own indicator for probes –Can have a break condition –Can contain code Right-click wire and choose Custom Probe>New
16
National Instruments Confidential History Probe Combining custom probes and functional global variables gives a history probe Past values stored in shift register Display past values, calculate min/max/average
17
17National Instruments Confidential Memory Management
18
National Instruments Confidential Memory Management - General LabVIEW handles memory management automatically –You do not need to code when to allocate or deallocate memory –You have less control over when memory operations occur Performance can be improved by paying attention to memory
19
National Instruments Confidential Finding Memory Allocations Use to avoid unnecessary memory copies Shows a dot where memory is allocated Tools>Advanced>Show Buffer Allocations Can NOT remove all allocations
20
National Instruments Confidential The “Inplace” Algorithm A pass in the compilation of a VI where LabVIEW can discover opportunities to re-use a data allocation Rules: –LabVIEW is “by value” semantics –The data value at the source of a signal is always delivered to every destination –Many nodes in LabVIEW are natively “inplace”: they will modify the location of their input to produce their output –If the value on the input is no longer needed by other nodes, its location can contain the new value –If the value is still needed, a copy is made –The nodes of the diagram are “ordered” as this algorithm runs
21
National Instruments Confidential Hiding the Dots with Inplaceness (Avoiding memory allocations) Inplaceness allows reuse of memory Occurs when – Input and output have same datatype and size – Overwritten data is not needed Replace Array Subset is inplace Build Array is not inplace Use shift registers
22
National Instruments Confidential Wiring a Call Library Function The way you wire to a Call Library Function tells LabVIEW how to handle the data InputOutputInterpretation YesNoData not modified by DLL NoYesData allocated by DLL Yes Data allocated by LabVIEW and modified by DLL
23
23National Instruments Confidential Performance
24
National Instruments Confidential Improving SubVI Performance Inputs are marked as required –More efficient since new inputs always provided Terminals are outside of structure –New output data always provided –No need to reread controls Inplaceness is used between input and output terminals –Allows inplaceness in parent VI –Inplaceness can traverse hierarchy
25
National Instruments Confidential Performance Effects of Property Nodes Control and indicator property nodes are slow –Control properties require a thread swap to the UI thread to execute –Property nodes can not run in parallel –Many will force UI updates on completion of that node Write many properties with one node, or defer panel updates
26
National Instruments Confidential Do I have VI documentation? Do I have avoidable Coercion Dots? Do I have Debugging Enabled? Do I have Waits in While loops? Did I leave any Breakpoints? Do I have clean and forward Wiring? Are my VIs locked or Password protected? Do I have Wires under objects? Do I have Error Handling? Do I have Hidden Objects in my Structures? Do I have Default Icons? Do I have Broken VIs? VI Analyzer Checks Your Code 58 different tests !!
27
National Instruments Confidential VI Analyzer Checks Your Code Improve the overall quality/reliability of VIs Encourage good programming practices (documentation, etc.) Reduce code maintenance time by quickly finding stylistic and functional problems View results through interactive interface or in text- based format (HTML, ASCII)
28
28National Instruments Confidential Miscellaneous
29
National Instruments Confidential Custom Shaped SubVIs Make subVI icons smaller Leave white space in icon for all three color depths Example: –Probe error cluster –Clear error
30
National Instruments Confidential CTRL and Mouse Tricks Hold down the CTRL key and… Double-click subVI to open block diagram Drag a rectangle to create space Click terminal of two-terminal primitive to swap wires Shift+Ctrl to get Scroll tool and pane diagram or front panel Use scrollwheel on a case structure to scroll through cases Access second most useful tool with AutoTool More shorcuts in the online help – search for “Keyboard Shortcuts”
31
National Instruments Confidential Can You Do This? Get the strings of an enum? (with out VI Server) Sort clusters? Merge Errors (no subVI)?
32
National Instruments Confidential Want Additional Tips??? LabVIEW Help contains many tips In particular…
33
National Instruments Confidential Additional Resources LabVIEW Performance and Memory Management App NoteLabVIEW Performance and Memory Management The Need for Speed, vol 7, number 4 ( www.ltrpub.com) Managing Large Data Sets in LabVIEW Optimizing LabVIEW Applications II LabVIEW Development Guidelines, Ch 6, LabVIEW Style Guide, describes good VI design and implementation practices LabVIEW Books
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.