Equipment Needed for this Course

1,489 views
1,401 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,489
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
80
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • We’re in good company - another Top 50 Milestones for the Electronics Industry award went to the personal computer.
  • LabVIEW is not a new programming language, and it was not developed overnight. It is backed by almost 20 years of continuous innovation, and our customers benefit from the expertise this experience brings. These 20 years of innovation also created a worldwide network of users who have created thousands of VIs, hundreds of user groups, and a major presence in the world of measurement and automation. LabVIEW 1.0 was first introduced for Macintosh in October 1986. Since then, we continue to combine new, innovative concepts with constant improvement. Today, LabVIEW is the industry standard for test and measurement development software. Things to consider bringing out: LabVIEW 4 introduced the “undo” feature. LabVIEW 7 can interface with .NET. If you have a personal story of filing a CAR that got fixed for a newer version of LabVIEW, talk about it here. Point out that the only way LabVIEW can get better is from comments and critiques from the users and that you can champion any requests they may have. Acquire, Analyze, and Present with NI LabVIEW 32 ni.com
  • NI LabVIEW takes full advantage of current and emerging commercial technologies such as operating systems, communications buses, and major technology changes such as .NET. Additionally, LabVIEW is a multiplatform programming language, which means you can take the LabVIEW source code you have written on one platform and reuse it on any of the other supported platforms. The application you develop runs without any modifications. The only exception is if your LabVIEW code contains operating system-specific calls that only execute on a given platform. © National Instruments Corporation 33 Acquire, Analyze, and Present with NI LabVIEW Seminar
  • Delivers a vision for engineers to deploy LabVIEW anywhere they want. Continued innovation to enable engineers deploy LabVIEW from workstations to personal computers to distributed systems to embedded applications. Someday soon, we may even see sensors powerful enough to use house LabVIEW. Not only is LabVIEW everywhere, but it offers something for every scientist and engineer. All levels of users, ranging from experienced to non-programmers, will benefit from the interactive, configurable tools and in LabVIEW 7 Express, enabling LabVIEW to be used as a one integrated tool for measurement and automation throughout the design process.
  • B. Course Description and Prerequisites The LabVIEW Introduction course teaches you to make optimum use of LabVIEW for developing your test and measurement applications. The course is divided into lessons, each covering a topic or a set of topics. Each lesson consists of: An introduction that describes the lesson’s purpose and what you will learn. A discussion of the topics. A summary that outlines important concepts and skills taught in the lesson. The course prerequisites include familiarity with the Windows operating system, familiarity with computer components such as the mouse, keyboard, connection ports, and plug-in slots, and experience writing algorithms in the form of flowcharts or block diagrams. C. Course Goals The course goals are listed on the slide above. Read through each goal now.
  • D. Course Non-Goals The items listed above are not discussed in this course.
  • LabVIEW programs are called virtual instruments (VIs). Stress that controls equal inputs, indicators equal outputs. Each VI contains three main parts: Front Panel – How the user interacts with the VI. Block Diagram – The code that controls the program. Icon/Connector – Means of connecting a VI to other VIs.
  • This slide shows the startup screen for LabVIEW 7.0 The LabVIEW dialog box includes the following components: A menu bar with standard items such as File»Exit. A set of buttons for creating and opening VIs, configuring DAQ devices, and finding helpful information. Click the New button to create a new VI. Click the arrow on the New button to choose to open a blank VI or to open the New dialog box. Click the Open button to open an existing VI. Click the arrow on the Open button to open recent files. Click the Configure button to configure your DAQ devices. Click the arrow next on the Configure button to configure LabVIEW. Click the Help button to launch LabVIEW Help. Click the arrow on the Help button for other Help options, including the Example Finder.
  • Click the New button to create a new VI. Click the arrow on the New button to choose to open a blank VI or to open the New dialog box.
  • When you click the New button, the New dialog box appears. You also can select File»New to display this dialog box. Select a template in the Create new listbox to display the front panel in the Front Panel Preview section, to display the block diagram in the Block Diagram Preview section, and to display a description of the template in the Description section. Select a template and click the OK button to start building a VI or other LabVIEW document. Press the <Ctrl-N> keys to bypass this dialog box and create a new empty VI.
  • The menus at the top of a VI window contain items common to other applications, such as Open, Save, Copy, and Paste, and other items specific to LabVIEW. Some menu items also list shortcut key combinations. Some menu items are unavailable while a VI is in run mode. The File menu contains items used for basic file operations, such as opening, closing, saving, and printing files. The Edit menu contains items that allow you to search for and modify LabVIEW files and their components. The Operate menu contains items you use to control the operation of your VIs. The Tools menu contains items for configuring LabVIEW, your projects, and your VIs. The Browse menu contains items that allow you to view aspects of the current VI and its hierarchy. The Window menu contains items that allow you to configure the appearance of the current windows and palettes. You also can access the Error List window and view the contents of the clipboard. The Help menu contains items to explaining and define LabVIEW features and other components, provide full LabVIEW documentation, and access National Instruments technical support.
  • This slide represents the front panel of a typical VI. Point out the elements in the Panel window: Panel Toolbar: contains tools and command buttons used to control the VI. Discuss the controls, indicators, and labels.
  • This slide shows the block diagram for the front panel on the last slide. Point out front panel object terminals, constants, and nodes. (Note the Wait Until Next ms Multiple function, Divide function, subVI, and wires.) Reinforce front panel object-terminal relationship.
  • Launch LabVIEW and discuss the buttons using the computer; never use the abort button or continuous run button when doing demonstrations. Set a good example! Tools used to create, modify, debug, and execute VIs: Panel Toolbar: Located in the Panel window. Broken Run: Click on it to find errors. Continuous Run: Use for testing sections of code. Should use a while/for loop for repeating parts of a diagram in an application. Stop: Not a clean way to terminate the program. Avoid using it. Use a switch on the panel. Diagram Toolbar: Additional tools to debug the VI. Briefly explain each button. Tell the class we will discuss them in more detail when we talk about debugging. When running a VI, the font, alignment, and distribution rings disappear because they are editing tools.
  • Graphical, floating palettes. Tools can be used for editing, debugging, and operating VIs. You can hide/show palettes by enabling or disabling them via the Window menu. Shortcut key (shift-right click - Windows) Although most will use the automatic tool selection, it is important that user understand the difference between the different tools so that they know when to use it. For example, when hovering over a boolean control, you may have the labeling tool, the selection tool or the operating tool depending on where the mouse cursor is. How do you know when to click? Demonstrate! Be sure to know all the correct names for the tools in the palette and take your time familiarizing students with their names. In particular, stress the difference between the Position/Resizing Tool and the Operator as students will often have the wrong tool and if you can vocally instruct them to get the correct tool it causes much less frustration.
  • Graphical, floating palettes. You can access the Controls palette only from the Panel window. If palettes are not displayed, you can access them via the Window menu and select the Show Controls palette. OR, right click on open area of front panel or diagram window to display Controls palette.
  • Graphical, floating palettes. You can access the Functions palette only from the Block Diagram window. If palettes are not displayed, you can access them via the Window menu and select the Show Functions palette. OR, right click on open area of front panel or diagram window to display Functions palette.
  • Graphical, floating palettes. If palettes are not displayed, you can access them via the Window menu and select the Show Functions/Controls palette. OR, right click on open area of panel or diagram window to display Controls and Functions palettes, respectively. Click on subpalettes to access functions, controls, VIs. You can tack down palettes and subpalettes using the pushpin. Tack down by clicking on the pushpin on the top left corner of the palette. Once tacked down you can set the palette options and use the find tool.
  • Use the buttons on top of the palette windows to navigate, search, and edit the palettes. You can search for controls, VIs, and functions that either contain certain words or start with certain words. Double clicking a search result opens the palette that contains the search result. You also can click and drag the name of the control, VI, or function directly to the front panel or block diagram.
  • For all platforms, the LabVIEW system consists of the LabVIEW application and associated files. Describe these files and directories: vi.lib, Examples, Help, user.lib, instr.lib. Windows - LabVIEW Directory (shown above) LabVIEW: Starts the LabVIEW program. MacOS - LabVIEW Folder and System Folder. LabVIEW: LabVIEW and other associated files. Sun - LabVIEW Directory LabVIEW: Starts the LabVIEW program. Other associated files. HP-UX - Same directory structure and contents as Sun except for GPIB. There are several other supporting programs. ibconf and ibic do the same thing as on the Sun.
  • Creating the front panel (user interface): Built with controls and indicators: Controls: Supply data to the VI. Indicators: Display data generated by the VI. They can find out if it is a control or indicator by checking the right-click menu of the object and referring to the third item (Change to Indicator or Change to Control) Explain graphics on slide: Numeric controls: Point out increment buttons. Numeric indicators: No increment buttons. Boolean objects: Ask class which Boolean is a control and which is an indicator. Explain that even though an LED is an indicator in the real world, it can be changed to a control in LabVIEW. Demonstrate.
  • Right-click menus: Most often used LabVIEW menus. Most LabVIEW objects have these menus for modification of attributes pertaining to that object. Functions/Controls palettes are available as right-click menus.
  • Explain the options available for the numeric control, as shown on the slide. Also explain that property pages will differ dependant on the object selected.
  • The block diagram is the “code” for the VI. Note: Wires can cross each other. You will see dots at the wire junctions, and a small gap in the wire showing that wires do not connect. If dots at wire junctions have been turned off, go to Options (Tools menu)»Block Diagram and select Show dots at wire junctions. Point out border difference and arrow direction on controls and indicator terminals. Composed of nodes, terminals, and wires: Nodes: Program execution elements (analogous to statements, functions, and subroutines). Functions: Built-in nodes for elementary functions. SubVIs: VIs you design and later call from the diagram of another VI. Structures: Control the program flow.
  • Note that you can have all functions be placed as expandable nodes by enabling an option in the Tools >> Options >> New to LabVIEW 7.0 menu. You can change from an expandable function/node to an icon view, but if the option is not enabled you cannot change from the icon view to the expandable node.
  • Not a complete list of data types; just ones that are used frequently through this course. Explain that in LabVIEW, you use wires to connect multiple terminals together to pass data in a VI. The wires must be connected to inputs and outputs that are compatible with the data that is transferred with the wire, therefore understanding the different data types is key to correct wiring. Explain the difference in colors and thicknesses. Explain that arrays and strings will be covered later in the course. Also, dynamic data type does not change width based on contents. Students are often looking for a more detailed list of all the data types in LabVIEW. If they ask about that, point them to the Help >> VI, Function, & How-To Help… On the Index Tab, search for data types and double click on the keyword to get a display on all of the data types and terminal representations in LabVIEW.
  • Demonstrate wiring by placing two controls, one indicator, and an Add function. Use the Help window (point out how terminals in the Help window flash when the tool passes over the actual function terminal). right-click on the Add function and select Show Terminals. Point out Tip Strips. If students really struggle with wiring, remember that they can enable the Terminal view and that can help. If that is still not enough, they can enable the option to have nodes placed as expandable. That won’t fix all problems, and the last option is to reduce the monitor resolution to something like 800x600.
  • Most text based programs execute in an control flow model. Dataflow is the principle that governs how LabVIEW programs execute. Explain the diagram on this slide with emphasis on dataflow. The node executes when data is available at all of its input terminals. The node supplies data on output terminals when it finishes execution. Not executed left to right nor top to bottom. Test understanding by asking class what will happen first when this program runs. Then, build the above diagram on your computer and demonstrate the dataflow using execution highlighting. It is helpful to start out by asking the class what they think will happen first on this block diagram. You will get answers from Number 1-4, random number, etc., but eventually someone will say that there is no way to know. Then, show will execution highlighting.
  • If required is unwired, receive error when running program. If recommended is unwired, receive warning when running program. If optional is unwired, no effect when running program. Give examples! The more examples of how you have used things to solve customer problems, the more they will trust you. Something that every LabVIEW supporter uses is Context Help. Explain how we cannot all be responsible for knowing what every function or VI does and we do not expect that of them, either, but that Context Help is our encyclopedia for VIs and functions. This is also a good place to begin getting them to think about good documentation practices of their own VIs so that users of their programs can get the same help.
  • Use an example program to demonstrate the help tools. Suggestion: Open help and search the index using ‘menus’. You can then show the class where they can find information on the menu items discusses in the earlier slide.
  • Use the buttons on top of the palette windows to navigate, search, and edit the palettes. You can search for controls, VIs, and functions that either contain certain words or start with certain words. Double clicking a search result opens the palette that contains the search result. You also can click and drag the name of the control, VI, or function directly to the front panel or block diagram.
  • When your VI is not executable, a broken arrow is displayed in the Run button in the palette. Execution Highlighting: Animates the diagram and traces the flow of the data, allowing you to view intermediate values. Click on the light bulb on the toolbar. Finding Errors: To list errors, click on the broken arrow. To locate the bad object, click on the error message.
  • Probe: Used to view values in arrays and clusters. Click on wires with the Probe tool or right-click on the wire to set probes. Create a probe when you want to have more control over how LabVIEW probes the data that flow through a wire. When you create a new probe, the data type of the probe matches the data type of the wire you right-click. Custom probes are also available - show if time permits. Breakpoint: Set pauses at different locations on the diagram. Click on wires or objects with the Breakpoint tool to set breakpoints. Conditional probe: a probe on which conditions can be set for when to break at the probe. It is VERY easy to place additional breakpoints on a VI. Teach students that if their program is not running correctly and they think they may have a breakpoint…somewhere…that they can use the Edit >> Find, Other – Breakpoints search tool to locate all breakpoints placed on their block diagrams!
  • Single stepping: executes the diagram node by node. You can access single stepping from the diagram toolbar by using the step functions found on the diagram toolbar. Use Step Into/Step Over to begin single stepping. Step Into: Steps into a node. If there is a subVI, it will then bring up the subVI diagram and enable single stepping through it. Step Over: Executes nodes but visually does not single step through nodes. Step Out: Steps out of nodes, if the diagram has completed execution; click on Step Out to terminate single stepping mode.
  • Do not immediately display this slide. Suggested questions for class participation: What are the two main windows in the LabVIEW environment? What do the Panel and Diagram Toolbars contain? What are the differences between controls and functions? Where are each located? What are the three palettes in the LabVIEW environment? What are pop-up menus? How are they used? How do you get help? Review slide: The purpose of Lesson One was to introduce the LabVIEW environment and some simple VI concepts, LV help, and debugging techniques. When in doubt, right click!!
  • See the tips and tricks and the end of the chapter to practice.
  • Demonstrate these techniques so that students can practice them throughout the course. Highlight the following tips: Hot keys (ctrl -b, ctrl-e, etc.) Accessing functions and controls palettes by right-clicking Accessing tools palette temporarily by shift - right-click (Windows) or shift - command - click (Mac) Tab to toggle through toolbars Spacebar to toggle between positioning and operating tool (panel toolbar) Spacebar to toggle between positioning and wiring tools (diagram toolbar) Wiring: spacebar to change direction Wiring: click with right mouse click to terminate wiring once started Undo and Redo in the Edit menu 1 st Day Lunch
  • LabVIEW is hierarchical in nature: You can have many layers of VIs. Very modular, easy to debug and change. This is why LabVIEW is so powerful. Explain the example in the slide: Show the relationship between front panel objects and their corresponding terminals on the block diagram. Power: control for stopping the measurements. Temperature History: indicator that displays the temperatures that have been read.
  • A subVI is analogous to a subroutine. When creating a VI, you should: Start with the top-level VI and define input and output. Construct subVIs as necessary to implement the desired functionality in the block diagram. The modular approach makes applications easier to debug and maintain. Explain diagram. (The functionality of the subVI does not matter for this example. The important point is the passing of two numeric inputs and one numeric output.)
  • Icon: Means of turning a VI into an object that can be used in other programs (compare it to a subroutine). Graphically represents the VI in the block diagram of other VIs. Connector: Terminals define where to wire inputs and outputs. Analogous to parameters of a subroutine. Terminals correspond to controls and indicators on the front panel. Hidden under the icon unless the user chooses to view it.
  • Instructor: Build this example subVI slope.vi on your computer and demonstrate creating an icon/connector and calling the VI from another VI along with the next four slides.
  • Every VI has its icon displayed in the upper right corner of the Panel and Diagram windows. (The default is a LabVIEW icon.) Use Icon Editor to design the icon. From the Panel or Diagram window, right-click on the icon and select Edit Icon... Design separate icons for monochrome, 16-bit color, and 256-bit color modes. You must design a monochrome icon if you want the icon to display on the Functions palette. Use the Copy From command to make a copy from one color mode to another. Double-click on Select tool and press delete to clear icon Double-click on Rectangle tool to add border around icon Keep it simple, its not an art lesson Using your computer, demonstrate each tool in the Icon Editor and draw a simple icon. You can also copy and paste into the icon editor.
  • The connector is a programmatic interface to a VI: Data passes from controls and to indicators via terminals on the connector. The connector is defined by assigning Front Panel objects to input and output terminals. Demonstrate the Show Connector option: A Connector Pane replaces the icon. Pattern selection is based on objects on the front panel. To select a different pattern, right-click on the connector and choose Patterns. Note the various ways to rotate and flip patterns.
  • Demonstrate how you can illustrate which terminal is attached to which control/indicator. Click on a terminal or control.
  • Connector continued.
  • You can use any VI that has an icon and connector as a subVI in the block diagram of another VI. Drag the icon pane to the diagram of the target VI. Select the Select a VI... option from the Functions palette. The file dialog box is displayed. Select any VI file. Add commonly used VIs to the Functions palette by placing them in User.lib in the LabVIEW directory. SubVIs are analogous to a subroutine: A node is not a subVI itself, just a subroutine call. Identical nodes in the diagram call the same subVI. To open, double-click the left mouse button on the icon. Changes to a subVI: Saved in memory until the subVI is saved to disk. Affect all calls to it, not just the node used to open it.
  • Classify controls or outputs as required, recommended, or optional to remind users to wire inputs or outputs. Classify by being in the connector pane and selecting This connector is >>. Help windows show classifications as shown above (for example, bold for a required terminal). Demonstrate using a DAQ VI Required classification - If input is not wired, VI will be broken. Will be displayed in bold text in Help Menu Recommended classification - Displayed as plain text in Help menu Optional classification - dims description or hides the description in the Simple View of the Help window.
  • Can modularize VIs after the fact by using the Create SubVI option. Creates front panel, wires diagram, and creates Connector with a default icon for you. All you need to do is save once modularized. Two steps: 1. Select portion of diagram to be encompassed in subVI and 2. Select Create SubVI from the Edit menu. Some hooks to be aware - check the Users Manual
  • Do not immediately display this slide. Suggested questions for class participation: A VI used as a subVI must have what two parts? How do you create an icon? How do you define a connector? How do you load a subVI into a LabVIEW diagram? How can you modularize the program in your diagram? Review the slide: The purpose of Lesson Two was to introduce the hierarchical nature of LabVIEW and the concept of subVIs. The ability to call VIs as subVIs facilitates modular block diagrams. Applications are more flexible and easier to understand, debug, and modify. Online help provides information about each node. Modularize whenever possible.
  • While Loops execute a sequence of events while a condition is True (analogous to a “Do...While” statement). While Loop functionality: A While Loop executes the code contained inside it until a Boolean False is passed to the conditional terminal. Thus, it always executes at least once. The iteration terminal contains the number of executions (zero-indexed).
  • Place loops in your diagram by selecting them from the Structures palette of the Functions palette (demonstrate): When selected, the mouse cursor becomes a special pointer that you use to enclose the section of code you want to repeat. Click the mouse button to define the top-left corner, click the mouse button again at the bottom-right corner, and the While Loop boundary is created around the selected code. Drag or drop additional nodes in the While Loop if needed.
  • A For Loop executes the diagram inside its border for a predetermined number of iterations (analogous to a “For...Next” statement). Explain the difference between While Loops and For Loops: While Loops run until a condition is met. For Loops run a predetermined number of times.
  • Enclose nodes inside the For Loop the same way as in a While Loop. N is the count terminal—It specifies how many times the loop will execute. i is the iteration terminal—It specifies the number of loops executed at any iteration. Next, we will learn more about timing functions and numeric conversion; two important issues to understand when building a looping architecture.
  • Take the time to carefully explain the above slide. This chart is also printed in the book; have them follow along on page 3-10. Show how this function times on a ms Multiple; not a definite passage of time. Show how you could lose some time on the first loop due to pre-loop code.
  • Take the time to carefully explain the above slide. Show how this function counts the number of ms passing. Show how the time per loop may not be consistent since the code could take a variable amount of time. Explain that both the Time Delay Express VI and the Wait (ms) VI work the same way. Follow on page 3-11
  • The default representation of a numeric control or indicator is a double-precision floating-point number. LabVIEW can represent a number as: Byte (8-bit) signed or unsigned integer. Word (16-bit) signed or unsigned integer. Long (32-bit) signed or unsigned integer. Single-precision (32-bit) floating-point number. Double-precision (64-bit) floating-point number. Extended-precision (96-bit*) floating-point number. * Depends upon the operating system When two terminals of different data types are wired together, LabVIEW will convert one numeric to the same representation as the other. This is signified by a gray “coercion dot.” Class participation: Ask why the while loop MUST convert an input to an integer. <hint: can you have 1.5 loops?>
  • If you wire two different numeric data types to a numeric function that expects the inputs to be the same data type, LabVIEW converts one of the terminals to the same representation as the other terminal. PREPARE for this slide. Carefully read and think through how to explain the last bullet point. A good idea is to use LabVIEW to demonstrate this point. Place a For Loop on the block diagram (note that they have not been introduced to for loops at this time, so use your best judgment about doing this first), wire a double precision numeric to the number of iterations input. Wire the index output through an increment and then out of the For loop, disabling indexing. Run the VI to show that 3.4 rounds to 3. 3.49 rounds to 3. 3.5 rounds to 4. 4.49 rounds to 4. 4.5 rounds to 4!
  • Shift registers transfer data from one iteration to the next: Right click on the left or right side of a For Loop or a While Loop and select Add Shift Register. The right terminal stores data at the end of an iteration. Data appears at the left terminal at the start of the next iteration. A shift register adapts to any data type wired into it. Stress why you need a shift register—to retain values from one iteration to the next. Explain the slide in detail. Go slowly and repeat yourself.
  • You can configure the shift register to remember values from several previous iterations. Right click on the left terminal and choose Add Element to create additional terminals. Explain the slide: The shift register allows you to access values from the past three iterations if you have three terminals. This method is different from using separate shift registers: One shift register with added terminals is storing multiple previous values of one variable. Multiple shift registers maintain a single previous value of multiple variables. Demonstrate the difference between adding a shift register vs. adding an element to a shift register.
  • If you place the Feedback Node on the wire before you branch the wire that connects the data to the tunnel, the Feedback Node passes each value to the tunnel. If you place the Feedback Node on the wire after you branch the wire that connects data to the tunnel, the Feedback Node passes each value back to the input of the VI or function and then passes the last value to the tunnel. A good way to visualize this is to think of the execution as starting at the feedback node.
  • Do not immediately display this slide. Suggested questions for class participation: What structure must ALWAYS run at least once? What structures are used to repeat execution of certain functions? How can you control the speed at which the loop executes? Describe the difference between the three types of charts. Why would you want to use a shift register? Why would you want to use a feedback node? How do you retain multiple values from previous iterations? Review the slide: The purpose of Lesson Four was to introduce LabVIEW structures. Structures control the flow of data in a VI.
  • Arrays are lists of elements of the same data type. They are analogous to arrays in traditional languages. Arrays can have one or more dimensions. Arrays can have up to 2^31 elements per dimension. Actual array sizes that students can create is limited by memory. Elements are accessed by “index”. The index ranges from 0 to N-1 (N = number of elements in the array). Arrays are zero-indexed (first element is zero) in each dimension. A 2D array is analogous to a spreadsheet or table. Example: Temperature readings and time stamp. One column is time values, and the other column is readings. Point out element (2,3) and element (3,2) on the slide. Be careful to specify the element you really want. Example: The first element in an array is array (0), not array(1).
  • Creating arrays in LabVIEW: Choose Array from the Array and Cluster palette You can place any data type in an array shell except an array. You cannot have an array of arrays; use a 2D array instead. Two components: index and data object. Emphasize that this is a two-step process. Students often place only empty array shells on the front panel. Remind them they must place a data type inside the array shell. Demonstrate the following on your computer: Create a numeric array. Point out index and data object components. Show how to create a 2D array. Show how to display multiple array elements. Show that index elements always reference the upper-leftmost object in the array display. Show how elements in an array are initially “grayed-out,” indicating that a portion of the array has not been defined.
  • Creating array constants uses the same two-step process as a front panel array. Select an array constant from the Array subpalette of the Functions palette. Place a constant data type inside the empty array shell. Note again that the data types are “grayed-out” and must be manually defined if the user wants to store values in the array constant.
  • For Loops and While Loops can index and accumulate arrays at their boundaries. This is known as auto-indexing. The indexing point on the boundary is called a tunnel. The For Loop default is auto-indexing enabled. The While Loop default is auto-indexing disabled. Examples: Enable auto-indexing to collect values within the loop and build the array. All values are placed in array upon exiting loop. Disable auto-indexing if you are interested only in the final value.
  • You can use two nested For Loops to create a 2D array. Auto- indexing must be enabled for both. Inner loop creates column elements. Outer loop creates row elements. Explain the different line thicknesses. Demonstrate on your computer: How to change indexing and line thickness. Enable Indexing in pop-up menu means indexing is currently disabled. The menu choice is the opposite of the current index mode. Students get confused about this feature.
  • If you enable auto-indexing on an array wired to a For Loop input terminal, LabVIEW sets the count terminal to the array size so you do not need to wire the count terminal. In the following example, the For Loop executes a number of times equal to the number of elements in the array. Normally, if the count terminal of the For Loop is not wired, the run arrow is broken. However, in this case the run arrow is not broken. Auto-indexing can be used on input arrays: For calculations to be performed on each element of array, use auto-indexing. To pass the entire array into a loop, disable auto-indexing.
  • LabVIEW has many functions to manipulate arrays in the Array subpalette of the Functions palette. Array Size: The number of elements in the input array: 1D array: Output is a numeric. Multidimensional array: Array output with elements signifying size of each dimension. (Example: A 2 x 4 array will output array of two elements, with first element = 2 and second element = 4). Initialize Array: Creates an array of n dimensions containing the value tied to the element input. Initialize array can be “stretched out” to add more “ dimension size” input terminals. You must have one “ dimension size” input terminal for each dimension in the array.
  • Returns a portion of an array starting at index and containing length elements. For example, if you use the previous array as the input, the Array Subset function returns the following array for an index of 2 and a length of 3.
  • Build Array: Concatenates elements together into one array or concatenates multiple arrays together into arrays of higher dimension. Build array can be “stretched-out” to add additional input terminals Input terminals are set as Array input or Element input. Popping up on the input terminals allows selection of Change to Array/Element input. To concatenate arrays or elements together into one longer array, arrays must be tied to Array input terminals and single elements must be tied to Element input terminals. To create a higher dimensional array, arrays must be tied to Element input terminals. Students often are confused by the difference. Demonstrate on your machine the difference between “Array” and “ Element” input.
  • Index Array: accesses a specific element of the input array. Index Array can be “stretched-out” to add more index terminals. You must have one index terminal for each dimension in the input array. The slide example shows accessing a single element of a one-dimensional array. Index Array does not remove the element from the array. Remind students that arrays start their indices at zero. Index 2 in the example actually accesses the third element in the array.
  • LabVIEW arithmetic functions are polymorphic: Inputs to these functions can be of different types. The node automatically performs the appropriate function on unlike data. Greatly simplifies array arithmetic. Examples of polymorphism in slide: Scalar+Scalar: Scalar addition. Scalar+Array: The scalar is added to each element of array. Array+Array: Each element of one array is added to the corresponding element of other array. Remind students that polymorphism does not perform matrix arithmetic when inputs are 2D arrays (for example, two 2D array inputs to a multiply function does element by element multiplication, not matrix multiplication). Show an example on polymorphism if the class does not understand the concept.
  • Do not immediately display this slide. Suggested questions for class participation: What is an array? Where might it be used? How would I create a 2D array of numeric controls? How can a loop create an array? Which loops can be used to do so? What does “polymorphic” mean?
  • Equipment Needed for this Course

    1. 1. LabVIEW Introduction Course Semester National Instruments 11500 N. Mopac Expressway Austin, Texas 78759 (512) 683-0100
    2. 2. <ul><li>Graphical Programming for Test, Measurement, and Control </li></ul><ul><ul><li>Rapid application development with Express VIs and easy-to-use graphical environment </li></ul></ul><ul><ul><li>Interactive measurement assistants and powerful redesigned DAQ interface for connecting to all types of I/O </li></ul></ul><ul><ul><li>Expanded targeting options from Real-Time to FPGA to PDA </li></ul></ul><ul><ul><li>Localized in French, German, and Japanese (Korean documentation) </li></ul></ul>
    3. 3. LabVIEW Awards <ul><li>Readers of Electronic Design name invention of LabVIEW as one of the Top 50 Milestones for the Electronics Industry </li></ul><ul><li>LabVIEW 6.1 receives IAN Automation Excellence Award of 2002 </li></ul><ul><li>Design News awards LabVIEW 6i Best Computer Productivity Tool of 2000 </li></ul><ul><li>LabVIEW 6i chosen the “Best of the Best” in the software category by readers of Evaluation Engineering </li></ul>
    4. 4. May 2003 January 2002 August 2000 March 1998 February 1996 August 1993 September 1992 January 1990 October 1986 April 1983 <ul><li>• LabVIEW 7 Express VIs, I/O Assistants, FPGA/PDA targets </li></ul><ul><li>LabVIEW 6.1 Enhanced networking capabilities, analysis </li></ul><ul><li>LabVIEW 6 i Internet-ready measurement intelligence </li></ul><ul><li>• LabVIEW 5.0 ActiveX, Multithreading </li></ul><ul><li>• LabVIEW 4.0 Added professional tools, improved debugging </li></ul><ul><li>• LabVIEW 3.0 Multiplatform version of LabVIEW </li></ul><ul><li>• LabVIEW for Windows </li></ul><ul><li>• LabVIEW 2.0 for Macintosh </li></ul><ul><li>• LabVIEW 1.0 for Macintosh </li></ul><ul><li>• LabVIEW project begins </li></ul>NI LabVIEW: A History of Innovation
    5. 5. Leveraging Commercial Technologies <ul><li>Third-Party Software </li></ul><ul><ul><li>Wolfram Research Mathematica ® </li></ul></ul><ul><ul><li>Microsoft Excel ® </li></ul></ul><ul><ul><li>The MathWorks MATLAB ® and Simulink ® </li></ul></ul><ul><ul><li>MathSoft MathCAD ® </li></ul></ul><ul><ul><li>Electronic Workbench MultiSim ® </li></ul></ul><ul><ul><li>Texas Instruments Code Composer Studio ® </li></ul></ul><ul><ul><li>Ansoft RF circuit design software </li></ul></ul><ul><ul><li>Microsoft Access ® </li></ul></ul><ul><ul><li>Microsoft SQL Server ® </li></ul></ul><ul><ul><li>Oracle ® </li></ul></ul><ul><li>Communication Protocols </li></ul><ul><ul><li>Ethernet </li></ul></ul><ul><ul><li>CAN </li></ul></ul><ul><ul><li>DeviceNet </li></ul></ul><ul><ul><li>USB </li></ul></ul><ul><ul><li>IEEE 1394 </li></ul></ul><ul><ul><li>RS-232 </li></ul></ul><ul><ul><li>GPIB </li></ul></ul><ul><ul><li>RS-485 </li></ul></ul>
    6. 6. PC, Mac, Linux, Sun LabVIEW Everywhere Networked I/O PC Boards Workstation Handheld Embedded (FPGA) Industrial Computer (PXI) Wireless Sensor Tektronix Open Windows Oscilloscopes
    7. 7. The LabVIEW Family NI LabVIEW Graphical Programming Software for Measurement and Automation LabVIEW Real-Time Module LabVIEW FPGA Module LabVIEW PDA Module LabVIEW Datalogging and Supervisory Control Module
    8. 8. <ul><li>Acquire, Analyze, and Present </li></ul>Nearly all test, measurement, and control applications can be divided into 3 main components: the ability to acquire , analyze , and present data. LabVIEW is the easiest, most powerful tool for acquiring, analyzing, and presenting real-world data.
    9. 9. Acquire with LabVIEW <ul><li>LabVIEW can acquire data using the following devices and more: </li></ul><ul><ul><li>GPIB, Serial, Ethernet, VXI, PXI Instruments </li></ul></ul><ul><ul><li>Data Acquisition (DAQ) </li></ul></ul><ul><ul><li>PCI eXtensions for Instrumentation (PXI) </li></ul></ul><ul><ul><li>Image Acquisition (IMAQ) </li></ul></ul><ul><ul><li>Motion Control </li></ul></ul><ul><ul><li>Real-Time (RT) PXI </li></ul></ul><ul><ul><li>PLC (through OPC Server) </li></ul></ul><ul><ul><li>PDA </li></ul></ul><ul><ul><li>Modular Instruments </li></ul></ul><ul><li>LabVIEW is tightly integrated with all NI hardware, in addition to connecting to thousands of I/O devices from hundreds of different vendors. </li></ul>
    10. 10. Analyze with LabVIEW <ul><li>LabVIEW includes the following tools to help you analyze your data: </li></ul><ul><ul><li>More than 400 measurement analysis functions for Differential Equations, Optimization, Curve Fitting, Calculus, Linear Algebra, Statistics, etc. </li></ul></ul><ul><ul><li>12 new Express VIs specifically designed for measurement analysis, including filtering and spectral analysis </li></ul></ul><ul><ul><li>Signal Processing VIs for Filtering, Windowing, Transforms, Peak Detection, Harmonic Analysis, Spectrum Analysis, etc. </li></ul></ul><ul><li>Powerful measurement analysis is built in to the LabVIEW development environment. </li></ul>
    11. 11. Present with LabVIEW <ul><li>LabVIEW includes the following tools to help you present your data: </li></ul><ul><ul><li>On your machine — Graphs, Charts, Tables, Gauges, Meters, Tanks, 3D Controls, Picture Control, 3D Graphs (Windows Only), Report Generation (Windows Only) </li></ul></ul><ul><ul><li>Over the Internet — Web Publishing Tools, Datasocket (Windows Only), TCP/IP, VI Server, Remote Panels, Email </li></ul></ul><ul><ul><li>Enterprise Connectivity Toolset — SQL Tools (Databases), Internet Tools (FTP, Telnet, HTML) </li></ul></ul>Presentation with LabVIEW can be done on your PC or over a network, or you can take advantage of additional applications such as DIAdem.
    12. 12. Course Map Introduction to LabVIEW Repetition & Loops Modular Programming VI Customization Data Acquisition & Waveforms Instrument Control Arrays Plotting Data Clusters Decision Making in a VI Strings and File I/O
    13. 13. Course Goals <ul><li>Understand front panels, block diagrams, and connectors/icons </li></ul><ul><li>Use the programming structures and data types that exist in LabVIEW </li></ul><ul><li>Use various editing and debugging techniques </li></ul><ul><li>Create and save your own VIs so you can use them as subVIs </li></ul><ul><li>Display and log your data </li></ul><ul><li>Create applications that use plug-in data acquisition (DAQ) boards </li></ul><ul><li>Create applications that use GPIB and serial port instruments </li></ul>This course prepares you to:
    14. 14. Course Non-Goals <ul><li>Every built-in LabVIEW object, function, or library VI </li></ul><ul><li>Analog-to-digital (A/D) theory </li></ul><ul><li>The detailed operation of the serial port or GPIB bus </li></ul><ul><li>How to develop an instrument driver </li></ul>It is not the purpose of this course to discuss the following:
    15. 15. Lesson 1 Introduction to LabVIEW <ul><li>TOPICS </li></ul><ul><li>LabVIEW Environment </li></ul><ul><li>Front Panel </li></ul><ul><li>Block Diagram </li></ul><ul><li>Dataflow Programming </li></ul><ul><li>LabVIEW Help and Manuals </li></ul><ul><li>Debugging a VI </li></ul>
    16. 16. Virtual Instruments (VIs) <ul><li>Front Panel </li></ul><ul><ul><li>Controls = Inputs </li></ul></ul><ul><ul><li>Indicators = Outputs </li></ul></ul><ul><li>Block Diagram </li></ul><ul><ul><li>Accompanying “program” for front panel </li></ul></ul><ul><ul><li>Components wired together </li></ul></ul>
    17. 17. LabVIEW Dialog Box
    18. 18. Creating a new VI <ul><ul><ul><li>File»New VI to open a blank VI </li></ul></ul></ul><ul><li>File»New… to open the New dialog box and configure a VI template, global variable, control, etc… </li></ul>
    19. 19. Template Browser
    20. 20. Menu F ile E dit O perate T ools B rowse W indow H elp
    21. 21. Front Panel Window Front Panel Toolbar Graph Legend Boolean Control Waveform Graph Icon Plot Legend Scale Legend Waveform Graph Owned Label
    22. 22. Block Diagram Window Wire Data Graph Terminal SubVI While Loop Structure Block Diagram Toolbar Divide Function Numeric Constant Timing Function Boolean Control Terminal
    23. 23. Front Panel and Block Diagram Toolbars Run button Continuous Run button Abort button Pause/Continue button <ul><li>Execution Highlighting button </li></ul><ul><li>Step Into button </li></ul><ul><li>Step Over button </li></ul><ul><li>Step Out button </li></ul>Warning indicator Enter button Broken Run button Font ring Alignment ring Distribution ring Resize ring Reorder ring Context Help Button Additional Buttons on the Block Diagram Toolbar
    24. 24. Tools Palette <ul><li>LabVIEW automatically selects the tool needed </li></ul><ul><li>Available on the front panel and the block diagram </li></ul><ul><li>A tool is a special operating mode of the mouse cursor </li></ul><ul><li>Use the tools to operate and modify front panel and block diagram objects </li></ul><ul><li>To show the tools palette, select Window»Show Tools Palette </li></ul>
    25. 25. Front Panel − Controls Palette Controls Palette Contains the most commonly used controls All Controls Palette Shows all controls
    26. 26. Block Diagram − Functions Palette Functions Palette Contains the Express VIs (interactive VIs with configurable dialog page) and the most commonly used functions All Functions Palette Shows all functions
    27. 27. Palette Tools <ul><li>Graphical, floating palettes </li></ul><ul><li>Subpalettes can be converted to floating palettes </li></ul><ul><li>Use Palette Options to change palette view from Express to Advanced </li></ul>Search Palette Options Click pushpin to tack down palette Up to Owning Palette
    28. 28. Searching for Controls, VIs, and Functions <ul><li>Press the search button to perform text searches of the palettes </li></ul><ul><li>Click and drag an item from the search window to the block diagram or double-click an item to open the owning palette </li></ul>
    29. 29. Customize Control & Function Palette <ul><li>Keep vi.lib in the LabVIEW 7.0 directory </li></ul><ul><li>Place items in user.lib or instr.lib to have them appear in the Controls and Functions palettes </li></ul>Programs» National Instruments»LabVIEW 7.0
    30. 30. Creating a VI Front Panel Build the front panel with controls (inputs) and indicators (outputs) Numeric Control Numeric Indicator Owned Labels Increment Buttons Boolean Control Boolean Indicator
    31. 31. Shortcut Menus for Front Panel Objects Right-click the label to access its shortcut menu Right-click the digital display to access its shortcut menu
    32. 32. Property Page <ul><li>Right-click a control or indicator on the front panel and select Properties from the shortcut menu to access the property dialog box for that object </li></ul>
    33. 33. Creating a VI Block Diagram Nodes Wires Control Terminals Block Diagram Front Panel Indicator Terminals
    34. 34. Express VIs, VIs and Functions <ul><li>Express VIs : interactive VIs with configurable dialog page </li></ul><ul><li>Standard VIs : modularized VIs customized by wiring </li></ul><ul><li>Functions: fundamental operating elements of LabVIEW; no front panel or block diagram </li></ul>
    35. 35. Block Diagram Nodes Icon Expandable Node Expanded Node <ul><li>Function Generator VI </li></ul><ul><li>Same VI, viewed three different ways </li></ul><ul><li>Yellow field designates a standard VI </li></ul><ul><li>Blue field designates an Express VI </li></ul>
    36. 36. Block Diagram Terminals <ul><li>Terminals are entry and exit ports that exchange information between the panel and diagram </li></ul><ul><li>Terminals are analogous to parameters and constants in text-based programming languages </li></ul><ul><li>Right-click and toggle View As Icon to change the icon view </li></ul>
    37. 37. Wiring the Block Diagram Scalar Numeric Boolean String 2D Array 1D Array Dynamic
    38. 38. Wiring Techniques Hot Spot <ul><li>Automatic Wiring </li></ul><ul><li>Use Context Help Window when wiring </li></ul><ul><li>Right-click wire and select Clean Up Wire </li></ul><ul><li>Tip Strips </li></ul><ul><li>Automatic wire routing </li></ul><ul><li>Right-click terminals and select Visible Items»Terminals </li></ul>View the terminal connections to a function
    39. 39. Dataflow Programming <ul><li>Block diagram executes dependent on the flow of data; block diagram does NOT execute left to right </li></ul><ul><li>Node executes when data is available to ALL input terminals </li></ul><ul><li>Nodes supply data to all output terminals when done </li></ul>
    40. 40. Context Help <ul><li>To display the Context Help window, select Help»Show Context Help , press the <Ctrl-H> keys, or press the Show Context Help Window button in the toolbar </li></ul><ul><li>Move cursor over object to display help </li></ul><ul><li>Connections: Required – bold Recommended – normal Optional - dimmed </li></ul>Simple/Detailed Context Help Lock Help More Help
    41. 41. LabVIEW Help <ul><li>Click the More Help button in the Context Help window </li></ul><ul><li>Select Help»VI, Function, & How-To Help </li></ul><ul><li>Click the sentence Click here for more help in the Context Help window. </li></ul><ul><li>Contains detailed descriptions of most palettes, menus, tools, VIs, and functions, step-by-step instructions for using LabVIEW features, links to the LabVIEW Tutorial, PDF versions of all the LabVIEW manuals and Application Notes, and technical support resources. </li></ul>
    42. 42. NI Example Finder <ul><li>To find an example, select Help»Find Examples </li></ul><ul><li>Web-integrated </li></ul><ul><li>Search by keyword, example type, hardware type, etc. </li></ul>
    43. 43. Debugging Techniques Finding Errors Click on broken Run button. A window showing the error appears Execution Highlighting Click on Execution Highlighting button; data flow is animated using bubbles. Values are displayed on wires.
    44. 44. Debugging Techniques Probe Right-click on wire and select probe and it shows data as it flows through the wire segment Breakpoints Right-click on wire and select Set Breakpoint; pause execution at the breakpoint. Conditional Probe Combination of a breakpoint and a probe. Right-click on wire and select custom probe.
    45. 45. Debugging Techniques Step Into, Over, and Out buttons for Single Stepping Click on Step Into button to enable single stepping Once Single Stepping has begun, the button steps into nodes Click on Step Over button to enable single stepping or to step over nodes Click on Step Out button to step out of nodes
    46. 46. Summary <ul><li>Virtual instruments (VIs) have three main parts — the front panel, the block diagram, and the icon and connector pane </li></ul><ul><li>The front panel is the user interface of a LabVIEW program and the block diagram is the executable code </li></ul><ul><li>The block diagram contains the graphical source code composed of nodes, terminals, and wires </li></ul><ul><li>Use Express VIs, standard VIs and functions on the block diagram to create your measurement code. For the most common requirements, use Express VIs with interactive configuration dialogs to define your application. </li></ul><ul><li>Floating Palettes: Tools Palette, Controls Palette (only when Front Panel Window is active), and Functions Palette (only when Block Diagram Window is active) </li></ul><ul><li>There are help utilities including the Context Help Window and LabVIEW Help </li></ul>
    47. 47. Summary <ul><li>Place controls (inputs) and indicators (outputs) in the front panel window </li></ul><ul><li>Use the Operating tool to manipulate panel objects. Use the Positioning tool to select, move, and resize panel objects. Use the Wiring tool to connect diagram objects </li></ul><ul><li>Control terminals have thicker borders than indicator terminals </li></ul><ul><li>All front panel objects have property pages and shortcut menus </li></ul><ul><li>Wiring is the mechanism to control dataflow and produce LabVIEW programs </li></ul><ul><li>Broken Run arrow means a nonexecutable VI </li></ul><ul><li>Various debugging tools and options available such as setting probes and breakpoints, execution highlighting, and single stepping </li></ul>
    48. 48. Tips <ul><li>• Common keyboard shortcuts </li></ul><ul><li>Access Tools Palette with <shift>-right-click </li></ul><ul><li>Increment/Decrement faster using <shift> key </li></ul><ul><li>Tools»Options selection — set preferences in LabVIEW </li></ul><ul><li>VI Properties (File menu) </li></ul>Windows Sun Linux MacOS <Ctrl-R> <  -R> <M-R> <  -R> Run a VI <Ctrl-F> <  -F> <M-F> <  -F> Find object <Ctrl-H> <  -H> <M-H> <  -H> Activate Context Help window <Ctrl-B> <  -B> <M-B> <  -B> Remove all broken wires <Ctrl-W> <  -W> <M-W> <  -W> Close the active window <Ctrl-E> <  -E> <M-E> <  -E> Toggle btwn Diagram/Panel Window
    49. 49. Lesson 2 Modular Programming <ul><li>TOPICS </li></ul><ul><li>SubVIs </li></ul><ul><li>Icon and Connector Pane </li></ul><ul><li>Using SubVIs </li></ul><ul><li>Creating a SubVI from sections of a VI </li></ul>
    50. 50. LabVIEW Hierarchy SubVI
    51. 51. SubVIs Function Pseudo Code function average (in1, in2, out) { out = (in1 + in2)/2.0; } SubVI Block Diagram Calling Program Pseudo Code main { average (point1, point2, pointavg) } Calling VI Block Diagram
    52. 52. Icon/Connector An icon represents a VI in other block diagrams A connector passes data to and receives data from a subVI through terminals Icon Connector terminals terminals
    53. 53. SubVI Example – Calculating Slope <ul><li>A VI within another VI is called a subVI </li></ul><ul><li>To use a VI as a subVI, create an icon and a connector pane after building the front panel and block diagram </li></ul>
    54. 54. Creating the Icon <ul><li>Icon: graphical representation of a VI </li></ul><ul><li>Right-click in the icon pane (Panel or Diagram) </li></ul><ul><li>Always create a black and white icon </li></ul>Default Icon Create a custom icon
    55. 55. Creating the Connector Right-click the icon (Front Panel only)
    56. 56. Creating the Connector - continued Click with wiring tool
    57. 57. The Connector Pane Terminal colors match the data types to which they are connected Click the terminal to see its associated front panel object
    58. 58. Using a VI as a SubVI All Functions » Select a VI… <OR> Drag icon onto target diagram
    59. 59. Help and Classifying Terminals <ul><li>Classify inputs and outputs: </li></ul><ul><li>Required — Error if no connection </li></ul><ul><li>Recommended — Warning if no connection </li></ul><ul><li>Optional — No effect if no connection </li></ul>
    60. 60. Create SubVI Option <ul><li>Enclose area to be converted into a subVI </li></ul><ul><li>Select Create SubVI from the Edit Menu </li></ul>
    61. 61. Summary <ul><li>VIs can be used as subVIs after you make the icon and connector </li></ul><ul><li>Icon created using Icon Editor </li></ul><ul><li>Connector defined by choosing number of terminals </li></ul><ul><li>Load subVIs using the Select a VI option in the All Functions palette or dragging the icon onto a new diagram </li></ul><ul><li>Online help for subVIs using the Show Context Help option </li></ul><ul><li>Descriptions document functionality </li></ul><ul><li>Use Create SubVI feature to easily modularize the block diagram </li></ul>
    62. 62. Lesson 3 Repetition and Loops <ul><li>TOPICS </li></ul><ul><li>While Loops </li></ul><ul><li>For Loops </li></ul><ul><li>Accessing Previous Loop Data </li></ul>
    63. 63. While Loops LabVIEW While Loop Flow Chart Pseudo Code Repeat (code); Until Condition met; End;
    64. 64. While Loops 1. Select While Loop 2. Enclose code to be repeated 3. Drop or drag additional nodes and then wire
    65. 65. Select the Loop Condition <ul><li>Click the Conditional Terminal with the Operating tool to define when the loop stops </li></ul><ul><li>Default: Stop if True </li></ul>Iteration Terminal Conditional Terminal
    66. 66. Structure Tunnels <ul><li>Tunnels feed data into and out of structures. </li></ul><ul><li>The tunnel is a block that appears on the border; the color of the block is related to the data type wired to the tunnel. </li></ul><ul><li>When a tunnel passes data into a loop, the loop executes only after data arrive at the tunnel. </li></ul><ul><li>Data pass out of a loop after the loop terminates. </li></ul>
    67. 67. For Loops LabVIEW For Loop Flow Chart Pseudo Code N=100; i=0; Until i=N: Repeat (code; i=i+1); End;
    68. 68. For Loops <ul><li>In Structures subpalette of Functions palette </li></ul><ul><li>Enclose code to be repeated and/or resize and add nodes inside boundary </li></ul><ul><li>Executes diagram inside of loop a predetermined number of times </li></ul>Count terminal (Numerical input) Wait Until Next ms Multiple function
    69. 69. Wait Functions Wait Until Next ms Multiple Functions»Time & Dialog palette
    70. 70. Wait Functions Wait (ms) Functions»Time & Dialog palette Time Delay Functions»Time & Dialog palette
    71. 71. Numeric Conversion <ul><li>Numerics default to double-precision (8 bytes) or long integer (4 bytes) </li></ul><ul><li>LabVIEW automatically converts to different representations </li></ul><ul><li>For Loop count terminal always converts to a long integer </li></ul><ul><li>Gray coercion dot on terminal indicates conversion </li></ul>
    72. 72. Numeric Conversion <ul><li>LabVIEW chooses the representation that uses more bits. </li></ul><ul><li>If the number of bits is the same, LabVIEW chooses unsigned over signed. </li></ul><ul><li>To choose the representation, right-click on the terminal and select Representation. </li></ul><ul><li>When LabVIEW converts floating-point numerics to integers, it rounds to the nearest integer. LabVIEW rounds x.5 to the nearest even integer. For example, LabVIEW rounds 2.5 to 2 and 3.5 to 4. </li></ul>
    73. 73. Accessing Previous Loop Data – Shift Register • Available at left or right border of loop structures • Right-click the border and select Add Shift Register • Right terminal stores data on completion of iteration • Left terminal provides stored data at beginning of next iteration Before Loop Begins First Iteration Second Iteration Last Iteration Initial Value Value 1 Value 1 Value 2 Value 2 Value 3 Value 3 Initial Value
    74. 74. Additional Shift Register Elements Latest value is passed to right terminal Right-click the left terminal to add new elements Previous values are available at the left terminals Right-click the border for a new shift register 1 loop ago 2 loops ago 3 loops ago
    75. 75. Feedback Nodes <ul><li>Appears automatically in a For Loop or While Loop if you wire the output of a subVI, function, or group of subVIs and functions to the input of that same VI, function, or group. </li></ul><ul><li>Stores data when the loop completes an iteration, sends that value to the next iteration of the loop, and transfers any data type </li></ul>
    76. 76. Feedback Node <ul><li>Wire from output to input to automatically create a feedback node </li></ul><ul><li><OR> </li></ul><ul><li>Place a feedback node from the Functions»Structures palette </li></ul>
    77. 77. Initialized Shift Registers & Feedback Nodes Run Once VI stops execution Run Again Output = 5 Output = 5 Output = 5 Output = 5
    78. 78. Uninitialized Shift Registers & Feedback Nodes Run Once VI stops execution Run Again Output = 8 Output = 4 Output = 4 Output = 8
    79. 79. Summary <ul><li>Two structures to repeat execution: While Loop and For Loop </li></ul><ul><li>Loop timing controlled using Wait Until Next ms Multiple function, the Wait (ms) function, or the Time Delay Express VI. </li></ul><ul><li>Coercion dots appear where LabVIEW coerces a numeric representation of one terminal to match the numeric representation of another terminal </li></ul><ul><li>Feedback nodes and shift registers transfer data values from one iteration to the next </li></ul><ul><li>Use shift registers only when more than one past iteration is needed </li></ul>
    80. 80. Lesson 4 Arrays <ul><li>TOPICS </li></ul><ul><li>Introduction to Arrays </li></ul><ul><li>Auto Indexing Arrays </li></ul><ul><li>Array Functions </li></ul><ul><li>Polymorphism </li></ul>
    81. 81. Arrays • Collection of data elements that are of same type • One or more dimensions, up to 2 elements per dimension • Elements accessed by their index; first element is index 0 31 index 10-element array 2D array Five row by seven column array of 35 elements 0 1 2 3 4 5 6 0 1 2 3 4 1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7 0 1 2 3 4 5 6 7 8 9
    82. 82. Array Controls and Indicators Add Dimension for 2D arrays 1. Select the Array shell from the Controls palette 2. Place data object inside shell
    83. 83. Creating Array Constants 1. Select Array Constant shell from the Array subpalette 2. Place the data object in the array shell
    84. 84. Auto-Indexing <ul><li>Loops can accumulate arrays at their boundaries with auto-indexing </li></ul><ul><li>For Loops auto-index by default </li></ul><ul><li>While Loops output the final value by default </li></ul><ul><li>Right-click on tunnel and enable/disable auto-indexing </li></ul>Wire becomes thicker Wire remains the same size Auto-Indexing Disabled Auto-Indexing Enabled Only one value (last iteration) is passed out of the loop 1D Array 0 1 2 3 4 5
    85. 85. Creating 2D Arrays <ul><li>Inner loop creates column elements </li></ul><ul><li>Outer loop stacks them into rows </li></ul>1D Array 0 1 2 3 4 5 2D Array
    86. 86. Auto-Index Input <ul><li>An array input can be used to set the For Loop count terminal </li></ul><ul><li>Number of elements in the array equals the count terminal input </li></ul><ul><li>Run arrow not broken </li></ul>
    87. 87. Common Array Functions Array Size Initialize Array
    88. 88. Common Array Functions Array Subset
    89. 89. The Build Array Function Building a higher dimension array Concatenate Inputs Appending an element default
    90. 90. The Index Array Function Extracting an Element Extracting an Element of a Row Extracting a Row
    91. 91. Polymorphism Function inputs can be of different types All LabVIEW arithmetic functions are polymorphic Scalar + Scalar Array + Scalar Combination Result Scalar Array Array Array + Array Array + Array Array
    92. 92. Summary <ul><li>Arrays group data elements of the same type. You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. </li></ul><ul><li>The array index is zero-based, which means it is in the range 0 to n – 1, where n is the number of elements in the array. </li></ul><ul><li>To create an array control or indicator, select an Array on the Controls»Array & Cluster palette, place it on the front panel, and drag a control or indicator into the array shell. </li></ul><ul><li>If you wire an array to a For Loop or While Loop input tunnel, you can read and process every element in that array by enabling auto-indexing. </li></ul><ul><li>By default, LabVIEW enables auto-indexing in For Loops and disables auto-indexing in While Loops. </li></ul><ul><li>Polymorphism is the ability of a function to adjust to input data of different data structures. </li></ul>

    ×