5 What Is a Design Pattern? A template or framework for LabVIEW codeWidely accepted and well-knownEasily recognizableDesign patterns are a hot topic amongst LabVIEW developers. There are a number of different design patterns out there, all of which have their merits and potential drawbacks. Design patterns have emerged over the years as the LabVIEW development community has sought to solve a common set of problems. They are essentially templates that make up the foundation of many large LabVIEW applications. The frameworks that are most commonly referred to as design patterns are widely accepted by the LabVIEW development community and are very likely to be recognized by anyone who has familiarized themselves with the pattern before.So why should you care about design patterns? As many of you who are here are aware, there are a number of potential benefits when using design patterns…
6 Benefits of Using Design Patterns Simplify the development processDevelopers can easily understand codeDon’t have to “re-invent the wheel”Pre-existing solutions to common problemsReliabilityMany have been used for years - they are “tried and true”Large development community and resources onlineLabVIEW is often used to rapidly prototype small applications, but there is a rapidly increasing number of large applications being developed using LabVIEW. These applications often encompass large numbers of VIs being developed by groups of developers. Using a design pattern makes it easier for LabVIEW users to read and edit existing code and prevents them having to figure out how to solve classic problems for which the best possible answers already exist.Also, they’ve been put to the test. They’ve been refined and improved over the years and there are a handful of patterns that have emerged as being exceptionally useful, elegant and powerful. Because these design patterns are such a popular topic of discussion there are a number of online forums with examples, content and thoughts on various patterns (some even ship within LabVIEW)
7 Getting Started: How Do I Pick? Identify most important aspect of your application:Processes that require de-couplingClean, easy to read codeMission critical componentsSelect a template based upon potential to improveWhen determining which design pattern to use with your application you should already have the architecture of your application in mind and a feel for the various requirements of your application. As you’ll see when we go through these design patterns, they cater to certain scenarios and they aim to solve particular problems. Many of them can address multiple issues that you need help with in your application – it’s also common to see some of the patterns we’ll look at being used in conjunction with one another.If you’re trying to re-factor an existing application to use a design pattern make sure that the investment required will yield the benefit you seek. When applications reach a point at which they’ve become unruly and difficult to edit or manage they are frequently refactored using one of the patterns we’ll look at. However, this is obviously a time-consuming activity, so make sure it’s worth your while and try to take advantage of existing code as much as possible
8 CautionYou can needlessly complicate your life if you use an unnecessarily complex design pattern Don’t forget the most common design pattern of all… dataflow!Also, after this training when you go back to your LabVIEW application to apply what you’ve learned here, don’t forget my words of caution… basic dataflow is the most basic design patterns and a lot of times it’s all you need to get the job doneThere’s an entire thread on the NI discussion forums called ‘please don’t do it’ that discusses the ramifications of using an overly complicated design pattern for a fairly simple task. Make sure you select the least common denominator, ie: what is the least complicated method by which you can satisfy all the goals of your application?
9 Basic Tools Loops Shift Registers Case Structures Enumerated Constants Event StructuresThis slide should be extremely quick. The audience is likely already familiar with all of these items, but we want to make sure everyone has these ‘tools in their toolbelt.’BuildLoops – the two most common loops and the only ones we’ll need for this discussion are the for loop and while loop. The most significant difference is that the while loop iterates indefinitely until stopped, whereas a for loop always has a maximum number of iterationsShift registers – these are used instead of tunnels if you want to preserve data between iterations of a loop such as a for loop or while loop. On the for loop below I’ve used a set of stacked shift registers, which will remember values from previous iterationsCase Structures – allow you to conditionally execute code depending upon an input, which can be a boolean, string, number, etc… if the input has infinite possibilities, you can set a default case.Enumerated constants – Allow you to enumerate integer values using words. This is commonly used to govern the case of a case structure instead of just a number. We’ll discuss these more laterEvent structures – are similar to case structures, but they interrupt data flow by responding to events that occur. We’ll talk more about this in a moment as well
10 Today’s Discussion As we look at each design pattern, we’ll discuss A problem we are trying to solveBackgroundHow it worksTechnical implementationDemonstrationUse cases / considerationsAll the slides for each design pattern should follow this format. We’ll make a problem statement or describe a scenario we’re trying to address. Before talking about how to implement the solution, we’ll cover any specifics to that particular pattern that you’ll need to be familiar with (code components). Then we’ll discuss implementation and I’ll step you through some demos I’ve prepared. Finally, we’ll discuss when to use each design pattern and some considerations to be aware of.
11 Design Patterns Functional Global Variable State Machine / Statecharts Producer / ConsumerWe’ll start with a couple of simple design patterns and spend most of our time discussing the last two on this slide. I’ll try to go into low level detail on the last few and we’ll spend some time discussing variations of implementation and any other considerations.
12 Functional Global Variables How do I share data across a application without using Global or Local Variables?For those of you who have taken LabVIEW training, or if you’re just familiar with good programming practices, we’re constantly advising customers to not use local or global variables. They introduce a number of inefficiencies that don’t scale well if used multiple times in a single application. However, sometimes you have to break data flow and you need to send data between independent processes, so how do you do it?Lets look at Functional Global Variables. They offer a number of advantages over local and global variables that will allow communication across your project without suffering from the same drawbacks as global and local variables.
13 Background: Global and Local Variables Can cause race conditionsCreate copies of data in memoryCannot perform actions on dataCannot handle error wires
14 Breaking Down the Design Pattern While loopUninitialized shift registers have memoryCase structureEnumerated controlBefore I show you a functional global variable I want to make sure that everyone understands a few nuances of the components that are required for a Functional Global Variable. We talked about loops and shift registers earlier, but functional global variables rely upon a property of shift registers that we haven’t yet discussed:Uninitialized shift registers can be used as a memory locationWhen you assign a value to it, it doesn’t destroy or replace that data unless it is initialized or all callers are removed from memoryDemoOpen the “Explain Uninitialized Shift Registers.vi’ example program and follow the instructions on the block diagramFAQthey’ve been around since LabVIEW 2.0Also commonly called a VIG (VI Global), Uninitialized Shift Register Global (USR Global), or Action Engine
15 Demo Uninitialized Shift Registers Before I show you a functional global variable I want to make sure that everyone understands a few nuances of the components that are required for a Functional Global Variable. We talked about loops and shift registers earlier, but functional global variables rely upon a property of shift registers that we haven’t yet discussed:Uninitialized shift registers can be used as a memory locationWhen you assign a value to it, it doesn’t destroy or replace that data unless it is initialized or all callers are removed from memoryDemoOpen the “Explain Uninitialized Shift Registers.vi’ example program and follow the instructions on the block diagramFAQthey’ve been around since LabVIEW 2.0Also commonly called a VIG (VI Global), Uninitialized Shift Register Global (USR Global), or Action EngineDemo
16 How It Works: Basic Actions Set the value of the shift registerINITIALIZENow that you’ve demonstrated how uninitialized shift registers work, explain the basic working idea behind a fgv. This diagram shows how we can store a new value to the shift registerINITIALIZE
17 How It Works: Basic Actions Get the value currently stored in the shift registerGETSimilarly, we can retrieve the value stored as shownGET
18 How It Works: Action Engine Perform an operation upon stored value and save resultYou can also output the new valueACTIONPerhaps one of the most powerful aspects of a FGV is the ability to customize what actions are performed on the value stored in memory. The cloud in this diagram can represent any number of actions or computations that are to be performed upon any number of data-typesACTION
19 Technical Implementation Functional Global Variable is a Non-Reentrant SubVIActions can be performed upon dataEnumerator selects actionStores result in uninitialized shift registerLoop only executes onceA functional global VI is called as a subVI from your application.The only required parameter is the action to be performed.The initialize too can be passed in or be a constantNote that it only executes once because the stop button is always set to true
20 Demo Functional Global Variables Uninitialized shift register has memoryLoop only executes onceOnly used in Initialize caseFunctional Global VariablesAction determines which case is executedExamples of other ‘actions’Use the example VI to demonstrate initializing, incrementing and retrieving the value of a Functional Global VariableDemo
21 Benefits: Comparison Functional Global Variables Global and Local VariablesPrevent race conditionsNo copies of dataCan behave like action enginesCan handle error wiresTake time to makeCan cause race conditionsCreate copies of data in memoryCannot perform actions on dataCannot handle error wiresDrag and dropWe mentioned earlier in this presentation that FGV often make a good substit
22 Recommendations Use Cases Considerations Communicate data between code without connecting wiresPerform custom actions upon data while in storageConsiderationsAll owning VIs must stay in memoryUse clusters to reduce connector paneUsing stacked shift registers will track multiple iterationsIf a single parent VI that owns the functional global is stopped, then the data in the USR is destroyed, even if other parents are still active in memory. If this is a problem, consider using a queue, which is not destroyed until all references to it are stopped.If using a FGR to manage complex data, use a cluster to reduce the amount of connectors used
23 State MachineI need to execute a sequence of events, but the order is determined programmatically
24 Background Static Sequence Dynamic Sequence: Allows distinct states to operate in a programmatically determined sequenceThe diagram at the top is supposed to represent a diagram in which you always know the order of execution. The diagram below is meant to indicate that you will not know the order of execution until run-time. Each subVI has code inside of it that then determines what the next subVI will be.Allows you to execute code in an order determined at run-time
25 Soda Machine Soda costs $0.50 Initialize Wait Quarter Change Nickel No inputWaitNickel DepositedChange RequestedQuarter DepositedDime DepositedTotal < 50Total < 50Total < 50QuarterChangeNickelDimeTotal >= 50Total >= 50Total >= 50Each state has decision making code inside of it. For example, if you consider the Quarter state, it examines the total amount of money that has been added. If it is equal to or greater than the amount owed, it sends the application to the ‘vend’ state; otherwise, it returns to waitWalk the audience through an example of execution of this applicationTotal > 50VendTotal = 50ExitSoda costs $0.50
26 Breaking Down the Design Pattern Case Structure inside of a While LoopEach case is a stateCurrent state has decision making code that determines next stateUse enumerators to pass value of next state to shift registersThe standard LabVIEW state machine consists of a large while loop, a shift register to remember the current state, and a case structure that holds separate code to run for each state. (If you use an enum to pass around the value for the current state, the pattern becomes much easier to read – and if you use a typedef, you only need to edit the typedef once in order to add another state to the machine)Note that each frame in the case structure must contain code for deciding what state the process should go to next. I call this the “transition” code
27 How It Works Step Execution Transition Code FIRST STATE NEXT STATE Transition code determines next state based upon results of step executionCase structure has a case for every stateFIRST STATEStep ExecutionShift registers used to carry stateTransition CodeThe state machine pattern is one of the most widely recognized and highly useful design patterns for LabVIEW.This pattern neatly implements any algorithm explicitly described by a state diagram (flow charts work too…). More precisely, it implements any algorithm described by a “Moore machine” – that is, a state machine which performs a specific action for each state in the diagram. (Contrast this with the “Mealy machine” which performs an action for each transition…)NEXT STATEFIRST STATE
28 Transition Code Options Step ExecutionStep ExecutionEach of these case structures shows a different standard type of “transition code” – i.e. code that chooses the next state for the state machine.The top left code clearly shows that the “Init” state has only one transition, and hence goes directly to the “Power Up” state without making any decision at all. The top right code switches between two possible transitions – the “Init” state will go to the “Shut Down” state if the “Stop” button has been pressed, otherwise it goes to the “Power Up” state.The code at the bottom left is a little more complicated, but still a common LabVIEW construct. The code for this state returns an array of boolean values, one for each transition we could take. Along with that array of boolean values is another array of enum constants specifying the new states where each possible transition could go. The index of the first “True” boolean in the array corresponds to the index of the new state in the array of enums… (Well, almost, but you can figure out the details yourself – just remember that the “Search Array” function will return –1 if the value is not found).The code at the bottom right is functionally equivalent to the code to its left. It consists of a case structure embedded in a while loop. The case structure contains one diagram for each transition arrow that leaves the current state. Each of these diagrams has two outputs – a boolean value which specifies whether or not the transition should be taken, and an enumerated constant which specifies the state to which the transition goes. By using the loop index as input to the case structure, this code effectively runs through each transition diagram one by one, until it finds a diagram with a “TRUE” boolean output, and then outputs the new state to which that transition goes. (Note that it is important to make sure the last transition always outputs a TRUE value). Though this code may appear slightly more complicated than the code to the left, it does offer the ability to add names to transitions by “casting” the output of the loop index to an enumerated type. This allows you to add “automatic documentation” to your transition code…Step Execution
29 State MachineRun the example entitled “1-Coke Machine State Machine.vi”Use highlight execution to show how it moves between states in the same manner you illustrated earlier.In order to transition to the next design pattern, demonstrate how because the program is designed to poll for user input that when it’s busy executing code, that the program can miss input (ie: rapid clicking on the dime will cause the program to piss the ‘depositing’ of several of the dimes)This implementation uses a traditional state-machine implementation. The idle casepolls for events, which in this case is user input.If the user presses and de-selects an input suchas a coin or button quickly enough, the statemachine can potentially miss the input. In orderto detect the event, the input's value must bepolled before the user de-selects it.This is a processor intensive and ineffecient wayto detect user input.To demonstrate this problem, rapidly clickthe dime and notice that it does not detect allclicks.This example demonstrates the state machinedesign pattern, but it illustrates one of theproblems we'll address with a more sophisticatedimplementation later in this presentation.Demo
30 Recommendations Use Cases Considerations User interfaces Data determines next routineConsiderationsCreating an effective State Machine requires the designer to make a table of possible states.Use LabVIEW Statechart to abstract this process for more sophisticated applicationsState machines are common in applications that are basing decision making off of input from a user. Since your application can’t predict the next input from the user, a state machine can be implemented to go to certain states and thereby execute specific code based upon the input from a user while in a certain state.
31 Producer / ConsumerI have two processes that need to execute at the same time, and I need to make sure one can’t slow the other downI want to execute code in parallel and at asynchronous rates, but I need to communicate between them!I have two processes that need to execute at the same time, but I want them to be independent of one another, and I need to make sure one can’t slow the other down
32 BackgroundI want to execute code in parallel and at asynchronous rates, but I need to communicate between them!I have two processes that need to execute at the same time, but I want them to be independent of one another, and I need to make sure one can’t slow the other down
33 How It Works Master Slave 1 Slave 2 One or more slave loops are told by a master loop when they can runAllows for a-synchronous execution of loopsData-independence breaks dataflow and allows multi-threadingDe-couples processesSlave 1This gives you more control on how your application is timed, and gives the user more control over your application.The standard Master/Slave design pattern approach for this application would be to put the acquisition processes into two separate loops (slave loops), both driven by a master loop that polls the user interface (UI) controls to see if the parameters have been changed. To communicate with the slave loops, the master loop writes to local variables. This will ensure that each acquisition process will not affect the other, and that any delays caused by the user interface (for example, bringing up a dialog) will not delay any iteration of the acquisition processes.Counterexample: Data-acquisition and data-logging in the same loop. It would be difficult to increase the rate of DAQ without increasing rate of data logging. If they are separate of each other then this is easier to doSlave 2
34 Breaking Down the Design Pattern Data independent loops = MultithreadingMaster / slave relationshipCommunication and synchronization between loopsThe standard “design pattern” approach would be to put the acquisition processes in two separate loops, both of them driven by a master loop receives input from the UI controls. This will ensure that each acquisition process will not affect the other, and that any delays caused by the user interface (for example, bringing up a dialog), will not delay any iteration of the acquisition processes. The power of using this pattern is that it separates the data flow of your diagram into independent processes. However, in order for these to communicate, you will have to use some form of globally available, shared data. (e.g. locals, globals, occurrences, notifiers, and/or queues). This does break LabVIEW’s dataflow paradigm, leaves the door open for race conditions, and incurs a little more overhead than passing data by wire. (i.e. acquiring mutexes, etc.)The producer / consumer pattern is really just a subclass of the master / slave pattern where the main communication between the loops is via queue. Using queues rather than globals to pass data provides a buffering effect – if the data writer occasionally produces data faster than the reader can process it, data will not be lost. This can be especially useful for handling UI events that take a long time to complete (ex. Printing in response to a user)
35 Loop Communication Variables Occurrences Notifier Queues Semaphores RendezvousNow that we’ve discussed the concept of having multiple loops for separate processes, lets talk about how we can bridge those loops in order to communicate without creating any data-dependency. There are a number of different mechanisms we can use depending upon the communication required. For synchronization and timing an occurance or rendezous are helpful.We’re going to focus on the use of queuesNotifier Operations Functions Use the Notifier Operations functions to suspend the execution of a block diagram until you receive data from another section of the block diagram or from another VI running in the same application instance.Occurrences Functions Use the Occurrences functions to control separate, synchronous activities.Queue Operations Functions Use the Queue Operations functions to create a queue for communicating data between sections of a block diagram or from another VI.Rendezvous VIs Use the Rendezvous VIs to synchronize two or more separate, parallel tasks at specific points of execution. Each task that reaches the rendezvous waits until the specified number of tasks are waiting, at which point all tasks proceed with execution.Semaphore VIs Use the Semaphore VIs to limit the number of tasks that can simultaneously operate on a shared (protected) resource. A protected resource or critical section of code might include writing to global variables or communicating with external instruments.
36 Queues Adding Elements to the Queue De-queueing Elements Select the data-type the queue will holdReference to existing queue in memoryDe-queueing ElementsDequeue will wait for data or timeout (defaults to -1)
37 Producer / ConsumerOne loop produces data (via computation, DAQ, etc.) and puts the data in the queue.The other loop waits until there is data in the queue. Then it pulls the first element out of the queue and processes it.
38 Adding Your Own Design Patterns Many developers use some form of the design patterns we’ve looked at today for application development on a regular basis. If you or your company uses a custom design pattern regularly, you can actually add it into the design patterns folder in LabVIEW for easy access by yourself and other developersC:\Program Files\National Instruments\LabVIEW 8.5\templates\Frameworks\DesignPatterns
39 Resources Example Finder New >> Frameworks >> Design Patternsni.com/labview/powerExpressionflow.comVisit ni.com/info and enter exhkqe
42 What Is the NI LabVIEW Academy? The NI LabVIEW Academy program provides classroom curriculum, instructional materials, and hands-on exercises to high schools, community colleges, and universities for the specific purpose of teaching LabVIEW.LabVIEW Academy is for anyone seeking LabVIEW education and knowledge through an academic institution.Provides instructional materials
43 What Does the NI LabVIEW Academy Do? Empowers institutions to teach LabVIEWEmphasises LabVIEW professional certificationIncreases the pool of qualified LabVIEW developers
44 NI LabVIEW Academy Program Requirements Instructor RequirementsTwo instructors must be Certified LabVIEW Associate Developers (CLADs) and teach at participating organisationsProgram RequirementsCurrent teaching site licenseAt least one dedicated classroom (a computer lab will suffice)40 hours of classroom LabVIEW specific instruction timeOne PC per student (with LabVIEW software)NI DAQ equipment required for lab component (2:1 student ratio)Submit course syllabus to NI for approval
45 NI LabVIEW Academy Instructional Materials Instructor MaterialsLabVIEW Basics I & II Instructor ManualLabVIEW Basics I & II Lecture SlidesLabVIEW Basics I & II Exercises and SolutionsInstructor Version of Student Workbook50 LabVIEW Exam/Homework QuestionsStudent MaterialsLabVIEW Academy Workbook (student purchase)300+ questionsRecommended LabVIEW textbook (student purchase)
46 NI LabVIEW Academy Teaching Materials Curriculum for both learning LabVIEW and teaching LabVIEWNI LabVIEW Academy Teaching MaterialsRecommended LabVIEW Textbooks
49 NI LabVIEW Academy CLAD Opportunity The NI LabVIEW Academy gives students the opportunity to take the CLAD exam as part of the program
50 The NI LabVIEW Academy Bridging the Gap AcademicIndustry“LabVIEW is getting more popular in academia and industry and many researchers and companies are on the lookout for competent LabVIEW programmers. This program will help bridge the gap between the two.”– Khanjan Mehta, Professor, Penn State University“In our exhaustive search for qualified LabVIEW developers to fill key roles in our organization, we greatly anticipate the new pool of qualified candidates coming out of the National Instruments LabVIEW Academy schools.“– Marvin Landrum, Section Manager, Texas Instruments
53 Tips and Tricks to Speed NI LabVIEW Development Useful Nuggets to Save You Time 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.
54 Agenda 20 Tips and Tricks for LabVIEW Development Beginner: Simple tricks to save timeIntermediate: LabVIEW tips you probably did not know aboutAdvanced: Useful nuggets to put you ahead of the gameThis 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.
55 Automatically Select the Right Tool 1/20Avoid manually switching among many toolsOperate Value ToolPosition/Size/Select ToolAuto ToolEdit Text ToolConnect Wire ToolThe 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.
56 Hold down Ctrl + Space to launch Quick Drop Quickly Drop Palette Objects2/20Hold down Ctrl + Space to launch Quick DropCtrl + D – Create controls and indicators on selected diagram object(s)Ctrl + R – Remove diagram object(s) and reconnect wiresCtrl + T – Move control and indicator terminal labels to the left and right sidesThe Quick Drop dialogue 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-Space-Ctrl-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.DEMO 1Demo
57 / Design Pattern Templates Access via File New … Well-known designs 3/20Access via File New …Well-known designsProducer/ConsumerState MachineQueued Message HandlerUsing 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.
58 Switch Terminal Wires Easily 4/20Hold Down Ctrland Left-Click on Input TerminalWhen 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.DEMO 2Note: This works only for functions with two inputs when bothinputs have already been wiredDemo
59 Easily Scroll Through Structures 5/20You can use Ctrl + Mouse Scroll to scroll through:Case StructuresEvent StructuresStacked Sequence StructuresDiagram Disable StructuresSometimes 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.Ctrl + Mouse Scroll Wheel
60 Quickly Find the Right Palette 6/20Right-click on a block diagram object for a palette shortcutAddIndex ArrayTo More Specific ClassWhen 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.DEMO 3Demo
61 Easily Navigate Arrays 7/20Right-click on an array and select Visible Items >> Horizontal Scrollbar (or Visible Items >> Vertical Scrollbar)To view last element, select Advanced >> Show Last ElementBoth horizontal and vertical scrollbars available (depending on array dimensions)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.DEMO 4Demo
62 / Selective Insert Location 8 20 Right-Click Slightly above Wire Right-Click Slightly below WireYou 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 right-click 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.Wire Connected to Lower TerminalWire Connected to Upper Terminal
63 Block Diagram Clean-Up 9/20Block Diagram Clean-UpClick Clean Up Diagram button on toolbar or press Ctrl + UHighlight a portion of the diagram for partial cleanupRight-click and select “Exclude from Diagram Cleanup” optionNote: Only available in LabVIEW 8.6 and later.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 single-frame Flat Sequence Structure and then choose the cleanup exclusion option on that structure.DEMO 5Demo
64 / Quickly Wire Multiframe Structures 10/20Right-click an output tunnel and select “Linked Input Tunnel » Create & Wire Unwired Cases”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.DEMO 6Note: Only available in LabVIEW 8.6 and later
65 / Easily Assess 2D Array Size Matrix Size function replaces old method 11/20Matrix Size function replaces old methodAssess size of 2D array regardless of data typeNote: Only available in LabVIEW 2009 and laterPrior 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.
66 / Breakpoint Manager Select View » Breakpoint Manager 12/20Select View » Breakpoint ManagerRight-click and select Breakpoint » Breakpoint ManagerThe 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.DEMO 7Note: Only available in LabVIEW 8.6 and later
67 / Quickly Find VIs in the Project Window 13/20Ctrl + Shift +E from an open VI with open projectPressing Ctrl-Shift-E from an open VI, while its corresponding project is open will highlight the location of the VI in its owning project.Note: Only available in LabVIEW 2009 and later
68 Easily Add Enumeration Items 14/20Press Ctrl while hovering over an Enum to use the Text ToolUse Shift + Enter to repeatedly add itemsThe 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.DEMO 8Shift + EnterDemo
69 / Edit Multiple Objects Simultaneously 15/20Highlight all desired front panel or block diagram objectsRight-click and select “Properties”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.DEMO 9Demo
70 Automatically Create Control References 16/20Simply drag a control into a Control RefnumAutomatically creates a class-specific, type-specific referenceIt 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.Note: To keep the original control, use Ctrl-Drag instead
71 Drag and Drop to Save Time 17/20Drag an image into your VI iconSelect a file and drag into a path constantTake a URL from Internet Explorer and drag into a string constantDrag items from disk or Project Explorer into a LabVIEW block diagramDragging 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.
72 Quickly Browse Properties and Methods 18/20View >> Class BrowserShortcut: Ctrl + Shift + BDrag a property or method directly into your VIInstead 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!DEMO 10Demo
73 Implement a For Loop Progress Bar /1920Place Progress Bar VI inside a for loopOpens automatically after a specified amount of timeDownload sample code from ni.com/forums (search for “For Loop Progress Bar”)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!DEMO 11Demo
74 Automatically Analyse Your VIs 20/Tools >> VI Analyzer >> Analyze VIsCheck performance, style, UI, documentation, and moreSave LabVIEW VI Analyzer settings for later useThe VI Analyzer is a LabVIEW toolkit that allows you to check your code’s 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.DEMO 12Demo
75 Other ResourcesDarren’s LabVIEW Nuggets (decibel.ni.com/content/docs/DOC-4002)LAVA: Favorite Tips and Shortcuts (forums.lavag.org)LabVIEW Wiki (labviewwiki.org)