Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Welcome to the LabVIEW Development Days 2010 presentation, Tips and Tricks to Speed LabVIEW Development.

This presentation was created by Darren Nattinger, Senior Software Engineer, LabVIEW R&D and Kelly Rink, Applications Engineer, Applications Engineering Department.

Tips and Tricks to Speed LabVIEW Development

This presentation will cover 25 nuggets of information designed to reduce programming effort in LabVIEW and improve development time. The tips and tricks range from simple reminders of useful LabVIEW features, to advanced functions and tools. Hopefully, everyone will come out of the presentation with some new useful tricks to apply in their everyday programming.

Tips and Tricks to Speed LabVIEW Development

The Auto Tool can be found on top of the Tools Palette located under View >> Tools Palette. Though most LabVIEW users are aware of this feature (it is turned on by default), many users still use the Tab key to manually switch tools. Let this slide pose a challenge: try the Auto Tool for 30 days; the vast majority of LabVIEW programmers will find that the Auto Tool greatly speeds their development after a little practice.

Tips and Tricks to Speed LabVIEW Development

The Quick Drop dialog box can be used to specify a palette object or project item by name and then place the object on the block diagram or front panel. It is launched by pressing Ctrl-Space. Quick Drop eliminates the need to navigate through the palettes to find objects. In LabVIEW 2009, three keyboard shortcuts were added to Quick Drop. You can select one or more objects on the block diagram and Press Ctrl-Space-Ctrl-D to create controls and indicators for all unwired terminals. You can use Ctrl-SpaceCtrl-R to remove one or more diagram objects and wire up pass-through terminals of matching data types. Lastly, you can use Ctrl-Space-Ctrl-T to move control and indicator terminal labels to the left and right sides of the terminals.

Tips and Tricks to Speed LabVIEW Development

Using design pattern templates will greatly decrease development and maintenance time of a project. Templates consist of well known designs such as Producer/Consumer, State Machine, and Queued Message Handler patterns. The templates can be accessed through the File New menu.

Tips and Tricks to Speed LabVIEW Development

When connecting wires to a function like subtract or divide, it can be easy to accidentally connect each wire to the wrong input. Use the switcheroo tool to automatically swap the wire connections; just hold down Ctrl and left click on one of the input terminals. Note: the switcheroo tool only works for functions with two inputs when both inputs have already been wired. In addition, this tool only works when using the Auto Tool or Wiring Tool.

Tips and Tricks to Speed LabVIEW Development

Sometimes it can be difficult or time-consuming to scroll through a multi-frame structure such as a case structure, event structure, or stacked sequence structure. By holding down the Ctrl key and scrolling the mouse wheel, you can quickly flip through frames of these structures without having to click repetitively.

Tips and Tricks to Speed LabVIEW Development

When performing a specific task (such as File I/O), it is common to place several objects from the same palette on the block diagram. To quickly navigate to the same palette (or a related palette) as an object that you have already placed, right click on the object and select one of the available palette shortcuts. Note: you can also place frequently used objects on the Favorites palette; simply right click on a given object in its usual palette location and select Add Item to Favorites.

Tips and Tricks to Speed LabVIEW Development

Many LabVIEW users click on the array index control to (slowly) view array elements. To scroll through array elements much faster, right click on the array and choose Visible Items >> Horizontal <or Vertical> Scrollbar. In addition, you can easily view the last element of an array by selecting Advanced >> Show Last Element after right clicking on an array. There are both vertical and horizontal scrollbars, depending on how you are viewing your array.

Tips and Tricks to Speed LabVIEW Development

You can insert an object onto an existing wire by right-clicking slightly above or below the wire and selecting Insert. Position is important for this tip. If you rightclick slightly above the wire, your wire will be connected to the lower terminal of the object, and if you right-click slightly below the wire, the wire will be connected to the upper terminal of the object.

Tips and Tricks to Speed LabVIEW Development

10

LabVIEW 8.6 introduced the block diagram clean-up feature to straighten up your block diagram by rearranging and aligning controls and indicators, rerouting and straightening wires, etc You can access this feature by clicking the clean-up button on the tool bar or by pressing Ctrl-U. This feature was enhanced in LabVIEW 2009 by allowing you to cleanup a selected portion of your block diagram and exclude a section of your code from any cleanup operations. You can highlight a section of your code to only clean up that section, or exclude diagram structures from clean up by right clicking them and selecting "Exclude from Diagram Cleanup. If there is a section of code that you want to keep clean, but it doesn't have a containing structure, then you can wrap it in a singleframe Flat Sequence Structure and then choose the cleanup exclusion option on that structure.

Tips and Tricks to Speed LabVIEW Development

11

To automatically link tunnels, right-click an output tunnel and select Linked Input Tunnel > Create & Wire Unwired Cases. One situation where this option is especially helpful is adding a new pass-through wire to an existing case structure or event structure that has multiple frames. Another situation is adding a new frame to an existing case or event structure that already has linked tunnels. Linked tunnels are denoted by a white triangle on the edge of the input and output tunnels.

Tips and Tricks to Speed LabVIEW Development

12

Prior to LabVIEW 2009, you needed to use the Array Size function and an Index Array function to determine the number of rows and columns in a 2D array. LabVIEW 2009 introduced the Matrix Size function, which returns the number of rows and columns of the array directly, regardless of the data type of the array.

Tips and Tricks to Speed LabVIEW Development

13

The Breakpoint Manager in LabVIEW 8.6 and later allows you to view, enable, disable, and clear any breakpoints set on VIs in memory. You can launch the Breakpoint Manager by going to View Breakpoint Manager or by right clicking a diagram object and selecting Breakpoint Breakpoint Manager.

Tips and Tricks to Speed LabVIEW Development

14

Pressing Ctrl-Shift-E from an open VI, while its corresponding project is open will highlight the location of the VI in its owning project.

Tips and Tricks to Speed LabVIEW Development

15

The most common way to add or modify items in an enumeration is to right click on the Enum and select Edit Items. A much faster way to add enumeration items is to first press Ctrl while hovering over an Enum in order to change to the Edit Text Tool, click in the enum to start editing text, then use Shift + Enter to add multiple items. This method also works for Rings.

Tips and Tricks to Speed LabVIEW Development

16

LabVIEW users frequently need to open a VI reference for a VI that is next to the current file on disk. This slide shows several methods for doing this; the first method requires stripping down the current VIs path, and then building a new path by appending a new VI name to the stripped path. A slightly better way to accomplish the same task is wiring the current VIs path directly into the Build Path function, and then using the \Other_VI format for building the final path. Most users are not aware that a VI name can be passed directly into the Open VI Reference function, which will locate the VI in the current VIs directory; this is a lot easier than the previous two methods! It should also be noted that a subVI can be called dynamically simply by right clicking on that VI and selecting Call Setup.

Tips and Tricks to Speed LabVIEW Development

17

Highlighting multiple front panel or block diagram objects and navigating to their properties menu will allow you to modify all properties that overlap between the selected items. This can be a significant time saving feature, especially when working with similar front panel objects that share properties. The property list is much more limited for block diagram items. Block diagram constants are one of the few object types you can configure with the Properties dialog.

Tips and Tricks to Speed LabVIEW Development

18

It is easy to create a class-specific, type-specific control reference in LabVIEW without right clicking on a control reference and navigating through several menus. Simply drag a front panel control into a control Refnum to create a correspondingly typed reference; this tip can save a lot of work, especially when dealing with a class that can have more than one data type associated with it.

Tips and Tricks to Speed LabVIEW Development

19

Dragging and dropping items in LabVIEW is often overlooked; this tip can greatly reduce development time. For example, try dragging an image file directly into your front panel icon. This will automatically create an icon for your LabVIEW application by resizing your image. In addition, you can select any file (from your disk or desktop) and drag it directly into a path constant to automatically fill it in. Likewise, an Internet Explorer URL can be dragged into a string constant to reduce typing. One great way to improve efficiency while working with a LabVIEW project is to drag items (such as VIs and Classes) from disk or the Project Explorer window directly onto the LabVIEW block diagram.

Tips and Tricks to Speed LabVIEW Development

20

If a subVI requires relinking in your application, and this subVI is called in several places, there is an easy way to relink all the subVIs in a single operation. First you find all instances of the subVI in the Find dialog. Then, pick the subVI itself in the "Replace With" box, and then select the "Replace All" button. All found instances of the subVI will become relinked.

Tips and Tricks to Speed LabVIEW Development

21

The JKI Right-Click Framework for LabVIEW allows you to add editor features to custom right-click menus. These new features, called Right-Click Plugins, can be created by any member of the LabVIEW community. Examples of plugins include Justify Text, Wire Error Case Structure, Create Enum from String, and Insert Bundle by Name. This framework makes commonly used editor actions just a right-click away.

Tips and Tricks to Speed LabVIEW Development

22

Instead of browsing through several property nodes in order to (hopefully) find a certain property, use the Class Browser. This can be easily accessed by pressing Ctrl + Shift + B. Inside the Class Browser, you can select an Object Library (such as VI Server, DAQmx, or VISA) and a Class (e.g. Application or DAQmx Channel) to quickly view all available properties and methods. To search for a specific property, use the search feature. You can even drag and drop a property or method onto the block diagram in order to automatically create a property node or invoke node!

Tips and Tricks to Speed LabVIEW Development

23

One helpful LabVIEW feature that add-on developers frequently use is placing VIs in the [LabVIEW]\project folder to create new entries in the Tools menu. You can also place VIs in the [LabVIEW]\help folder to have them appear in the Help menu and in the [LabVIEW]\wizard folder to have them appear in the File menu. This functionality has been around for a long time, and there are even some private VI Server properties that help you determine the VI from which the menu option was selected. In LabVIEW 2009 and later, you can use [LabVIEW]\vi.lib\VIServer\Menu Launch VI Information.vi to get the App reference of the owning app for the VI from which the menu item was selected, along with the VI name. You can then wire these items to an Open VI Reference function to gain access to the VI from which the menu item was selected.

Tips and Tricks to Speed LabVIEW Development

24

Several VIs are available in the Advanced File I/O palette in LabVIEW 8.2 and later. Use the Recursive File List VI to automatically obtain a listing of files and folders in a directory or LLB. The Check if File or Folder Exists and Get File Extension VIs are fairly self explanatory; they provide quick ways to see if a file is present on disk, and get the extension of a file path without having to convert the path to a string and parse out the information. To see the common path between two files (or obtain the relative path from one file to the next), use the Compare Two Paths function. Finally, Generate Temporary File Path can automatically create unique file path in the temporary directory, and MD5 Checksum File will compute the MD5 message-digest of a file.

Tips and Tricks to Speed LabVIEW Development

25

A sample VI for implementing the For Loop progress bar is located as an attachment on (http://forums.ni.com/ni/board/message?board.id=170&message.id=192115). This VI automatically opens up a progress indicator if the For Loop it is placed in takes longer than a specified amount of time to complete; this is a great way to assure users that the program did not hang!

Tips and Tricks to Speed LabVIEW Development

26

The VI Analyzer is a LabVIEW toolkit that allows you to check your codes performance, user interface (UI), documentation, and several other areas. The VI Analyzer can quickly identify programming mistakes that would have taken hours to locate manually. You can also save VI Analyzer settings for later use.

Tips and Tricks to Speed LabVIEW Development

27

Front Panel > General > Connector pane terminals default to Required: CHECKED Saves debugging time used to discover instances where terminals on a subVI are accidentally left unwired. Block Diagram > General > Auto-insert Feedback Node in cycles: UNCHECKED Often Feedback Nodes magically appear while wiring, when we do not want them there. With this option unchecked, Feedback Nodes only appear if you actually drop them down. Block Diagram > Wiring > Enable auto wiring: CHECKED - Gets the wiring right 95% of the time; Press the spacebar the other 5% of the time to drop the object without auto wiring. Controls/Functions Palettes > Loading > Load palettes during launch - This is the option you must select if you want Quick Drop to be immediately usable after launching LabVIEW. Environment > General > Skip Getting Started window on launch: CHECKED Makes up some launch time speed lost with the Load palettes during launch selection. Environment > General > Maximum undo steps per VI: 99 - 8 undo steps is the default value. You may not need 99, but you often need more than 8. Environment > Saving VIs > Enable automatic saving for recovery: CHECKED For unexpected crashes and hangs so you do not lose everything. Source Control: ENABLED e.g. for perforce; really handy to be able to check in/out VIs directly from the LabVIEW project window.

Tips and Tricks to Speed LabVIEW Development

28

Tips and Tricks to Speed LabVIEW Development

29

Thank you for attending the Tips and Tricks to Speed LabVIEW Development session. Questions are welcome at this time.

Tips and Tricks to Speed LabVIEW Development

30

You might also like