1 / 115

The Infinity ProjectSM LabVIEW for The Infinity Project

Topics. Understand the components of a Virtual InstrumentBecome familiar with common LabVIEW data types and functions Build your own simple programsInterface programs with the Speedy-33 and USB Webcam. Section I. Running Examples in LabVIEW for the Infinity ProjectComponents of a LabVIEW applicationWiringLabVIEW HelpDebugging.

brooke
Download Presentation

The Infinity ProjectSM LabVIEW for The Infinity Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    2. Topics Understand the components of a Virtual Instrument Become familiar with common LabVIEW data types and functions Build your own simple programs Interface programs with the Speedy-33 and USB Webcam This is a list of the objectives of the course. This course prepares you to do the following: • Use LabVIEW to create applications. • Understand front panels, block diagrams, and icons and connector panes. • Use built-in LabVIEW functions. • Create and save programs in LabVIEW so you can use them as subroutines. This course does not describe any of the following: • Programming theory • Every built-in LabVIEW function or object • Analog-to-digital (A/D) theoryThis is a list of the objectives of the course. This course prepares you to do the following: • Use LabVIEW to create applications. • Understand front panels, block diagrams, and icons and connector panes. • Use built-in LabVIEW functions. • Create and save programs in LabVIEW so you can use them as subroutines. This course does not describe any of the following: • Programming theory • Every built-in LabVIEW function or object • Analog-to-digital (A/D) theory

    3. Section I Running Examples in LabVIEW for the Infinity Project Components of a LabVIEW application Wiring LabVIEW Help Debugging

    4. LabVIEW for The Infinity Project Splash Screen Point out how to open Examples with the Chapter, Theme & Lab Save an Example to edit for later How to create custom programs on your computer or on the Speedy-33 Open a saved Lab Test your Speedy-33 Quit Button! Point out how to open Examples with the Chapter, Theme & Lab Save an Example to edit for later How to create custom programs on your computer or on the Speedy-33 Open a saved Lab Test your Speedy-33 Quit Button!

    5. Exercise 1: Opening an Example for LabVIEW for The Infinity Project Start to familiarize yourself with the LabVIEW for Infinity environment. Directions: Open and run Lab 1.1.2: Testing Your system – Microphone and Cosine

    6. LabVIEW Programs Are Called Virtual Instruments (VIs) 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. The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. Stress that controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. Every front panel control or indicator has a corresponding terminal on the block diagram. When a VI is run, values from controls flow through the block diagram, where they are used in the functions on the diagram, and the results are passed into other functions or indicators.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. The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. Stress that controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. Every front panel control or indicator has a corresponding terminal on the block diagram. When a VI is run, values from controls flow through the block diagram, where they are used in the functions on the diagram, and the results are passed into other functions or indicators.

    7. LabVIEW Project Group and organize VIs Hardware and I/O management Manage VIs for multiple targets Build libraries and executables Manage large LabVIEW applications Enable version tracking and management LabVIEW Project Note: Explain to students, when you save a project, LabVIEW creates a project file (.lvproj), which includes configure information, build information, deployment information, reference to the files in the project, etc. Use projects to group together LabVIEW files and non-LabVIEW files, create build specifications, and deploy or download files to targets. A target is a device or machine on which a VI runs. When you save a project, LabVIEW creates a project file (.lvproj), which includes configuration information, build information, deployment information, references to files in the project, and so on. You must use a project to build stand-alone applications and shared libraries. You also must use a project to work with an RT, FPGA, or PDA target. Refer to the specific module documentation for more information about using projects with the LabVIEW Real-Time, FPGA, and PDA Modules. Project-style LabVIEW Plug and Play instrument drivers use the project and project library features in LabVIEW 8.0. You can use project-style drivers in the same way as previous LabVIEW Plug and Play drivers. Project Explorer Window Use the Project Explorer window to create and edit projects. Select File»New Project to display the Project Explorer window. You also can select Project»New Project or select File»New and then select Empty Project in the New dialog box to display the Project Explorer window. LabVIEW Project Note: Explain to students, when you save a project, LabVIEW creates a project file (.lvproj), which includes configure information, build information, deployment information, reference to the files in the project, etc. Use projects to group together LabVIEW files and non-LabVIEW files, create build specifications, and deploy or download files to targets. A target is a device or machine on which a VI runs. When you save a project, LabVIEW creates a project file (.lvproj), which includes configuration information, build information, deployment information, references to files in the project, and so on. You must use a project to build stand-alone applications and shared libraries. You also must use a project to work with an RT, FPGA, or PDA target. Refer to the specific module documentation for more information about using projects with the LabVIEW Real-Time, FPGA, and PDA Modules. Project-style LabVIEW Plug and Play instrument drivers use the project and project library features in LabVIEW 8.0. You can use project-style drivers in the same way as previous LabVIEW Plug and Play drivers. Project Explorer Window Use the Project Explorer window to create and edit projects. Select File»New Project to display the Project Explorer window. You also can select Project»New Project or select File»New and then select Empty Project in the New dialog box to display the Project Explorer window.

    8. VI Front Panel Note: Use lab 2.3.1 as an example when going over the front panel. The front panel is the user interface of the VI. You build the front panel with controls and indicators, which are the interactive input and output terminals of the VI, respectively. Controls are knobs, pushbuttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays. Controls simulate instrument input devices and supply data to the block diagram of the VI. Indicators simulate instrument output devices and display data the block diagram acquires or generates. In this picture, the Power switch is a boolean control. A boolean contains either a true or false value. The value is false until the switch is pressed. When the switch is pressed, the value becomes true. The temperature history indicator is a waveform graph. It displays multiple numbers. In this case, the graph will plot Deg F versus Time (sec). The front panel also contains a toolbar, whose functions we will discuss later. Note: Use lab 2.3.1 as an example when going over the front panel. The front panel is the user interface of the VI. You build the front panel with controls and indicators, which are the interactive input and output terminals of the VI, respectively. Controls are knobs, pushbuttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays. Controls simulate instrument input devices and supply data to the block diagram of the VI. Indicators simulate instrument output devices and display data the block diagram acquires or generates. In this picture, the Power switch is a boolean control. A boolean contains either a true or false value. The value is false until the switch is pressed. When the switch is pressed, the value becomes true. The temperature history indicator is a waveform graph. It displays multiple numbers. In this case, the graph will plot Deg F versus Time (sec). The front panel also contains a toolbar, whose functions we will discuss later.

    9. VI Block Diagram Note: Mention how to Tile the front panel and block diagram (CTRL-T) The block diagram contains this graphical source code. Front panel objects appear as terminals on the block diagram. Additionally, the block diagram contains functions and structures from built-in LabVIEW VI libraries. Wires connect each of the nodes on the block diagram, including control and indicator terminals, functions, and structures. In this block diagram, the subVI Temp calls the subroutine which retrieves a temperature from a Data Acquisition (DAQ) board. This temperature is plotted along with the running average temperature on the waveform graph Temperature History. The Power switch is a boolean control on the Front Panel which will stop execution of the While Loop. The While Loop also contains a Timing Function to control how frequently the loop iterates. Note: Mention how to Tile the front panel and block diagram (CTRL-T) The block diagram contains this graphical source code. Front panel objects appear as terminals on the block diagram. Additionally, the block diagram contains functions and structures from built-in LabVIEW VI libraries. Wires connect each of the nodes on the block diagram, including control and indicator terminals, functions, and structures. In this block diagram, the subVI Temp calls the subroutine which retrieves a temperature from a Data Acquisition (DAQ) board. This temperature is plotted along with the running average temperature on the waveform graph Temperature History. The Power switch is a boolean control on the Front Panel which will stop execution of the While Loop. The While Loop also contains a Timing Function to control how frequently the loop iterates.

    10. Instructor: Relay to students that functions are the building blocks of all VIs. LabVIEW 7.0 introduced a new type of subVI called Express VIs. These are interactive VIs that have a configuration dialog box that allows the user to customize the functionality of the Express VI. LabVIEW then generates a subVI based on these settings. SubVIs are VIs (consisting of a front panel and a block diagram) that are used within another VI. Functions are the building blocks of all VIs. Functions do not have a front panel or a block diagram.Instructor: Relay to students that functions are the building blocks of all VIs. LabVIEW 7.0 introduced a new type of subVI called Express VIs. These are interactive VIs that have a configuration dialog box that allows the user to customize the functionality of the Express VI. LabVIEW then generates a subVI based on these settings. SubVIs are VIs (consisting of a front panel and a block diagram) that are used within another VI. Functions are the building blocks of all VIs. Functions do not have a front panel or a block diagram.

    11. What Types of Controls and Indicators are Available? Numeric Data Number input and display Analog Sliders, Dials, and Gauges Boolean Data Buttons and LEDs Array & Matrix Data Numeric Display Chart Graph XY Graph Intensity Graph 3D graph: point, surface, and model Decorations Tab Control Arrows Other Strings and text boxes Picture/Image Display ActiveX Controls DEMO! Note: Open a blank VI and add some controls, knobs, slider, etc. Controls and Indicators are Front Panel items that allow the user to interact with your program to both provide input and display results. You can access Controls and Indicators by right-clicking the front panel. In addition, you will get additional controls and indicators when you install toolkits and modules. For example, when you install the Control Design tools, you will get specialized plots such as Bode and Nyquist plots that are not available by default. DEMO! Note: Open a blank VI and add some controls, knobs, slider, etc. Controls and Indicators are Front Panel items that allow the user to interact with your program to both provide input and display results. You can access Controls and Indicators by right-clicking the front panel. In addition, you will get additional controls and indicators when you install toolkits and modules. For example, when you install the Control Design tools, you will get specialized plots such as Bode and Nyquist plots that are not available by default.

    12. Control & Indicator Properties Properties are characteristics or qualities about an object Properties can be found by right clicking on a Control or Indicator Properties Include: Size Color Plot Style Plot color Features include: Cursors Scaling Properties are all the qualities of a front panel object. With properties, you can set or read such characteristics as foreground and background color, data formatting and precision, visibility, descriptive text, size and location on the front panel, and so on.Properties are all the qualities of a front panel object. With properties, you can set or read such characteristics as foreground and background color, data formatting and precision, visibility, descriptive text, size and location on the front panel, and so on.

    13. What Types of Functions are Available? Input and Output Signal and Data Simulation Acquire and Generate Real Signals with DAQ Instrument I/O Assistant (Serial & GPIB) ActiveX for communication with other programs Analysis Signal Processing Statistics Advanced Math and Formulas Continuous Time Solver Storage File I/O Note: Highlight logic functions! The main function types for IP are signal and data simulation and signal processing. LabVIEW includes several hundreds of pre-built functions that help you to acquire, analyze, and present data. You would generally use these functions as outlined on the slide above. LabVIEW Toolkits Additional toolkits are available for adding domain specific functionality to LabVIEW. These toolkits include: Note: Highlight logic functions! The main function types for IP are signal and data simulation and signal processing. LabVIEW includes several hundreds of pre-built functions that help you to acquire, analyze, and present data. You would generally use these functions as outlined on the slide above. LabVIEW Toolkits Additional toolkits are available for adding domain specific functionality to LabVIEW. These toolkits include:

    14. Searching for Controls, VIs, and Functions 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. 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.

    15. Tools Palette Note: Mouse cursor placement is crucial! If automatic tool selection is enabled and you move the cursor over objects on the front panel or block diagram, LabVIEW automatically selects the corresponding tool from the Tools palette. Toggle automatic tool selection by clicking the Automatic Tool Selection button in the Tools palette. Use the Operating tool to change the values of a control or select the text within a control. Use the Positioning tool to select, move, or resize objects. The Positioning tool changes shape when it moves over a corner of a resizable object. Use the Labeling tool to edit text and create free labels. The Labeling tool changes to a cursor when you create free labels. Use the Wiring tool to wire objects together on the block diagram. Note: The keyboard shortcut to get the tools pallet is Shift + Right-click.Note: Mouse cursor placement is crucial! If automatic tool selection is enabled and you move the cursor over objects on the front panel or block diagram, LabVIEW automatically selects the corresponding tool from the Tools palette. Toggle automatic tool selection by clicking the Automatic Tool Selection button in the Tools palette. Use the Operating tool to change the values of a control or select the text within a control. Use the Positioning tool to select, move, or resize objects. The Positioning tool changes shape when it moves over a corner of a resizable object. Use the Labeling tool to edit text and create free labels. The Labeling tool changes to a cursor when you create free labels. Use the Wiring tool to wire objects together on the block diagram. Note: The keyboard shortcut to get the tools pallet is Shift + Right-click.

    16. Status Toolbar Note: Demo high-level. Not all the buttons on this toolbar are enabled for all VIs. Also depending on whether or not a new VI is opened on Speedy-33 or on the computer. Click the Run button to run the VI. While the VI runs, the Run button appears with a black arrow if the VI is a top-level VI, meaning it has no callers and therefore is not a subVI. Click the Continuous Run button to run the VI until you abort or pause it. You also can click the button again to disable continuous running. While the VI runs, the Abort Execution button appears. Click this button to stop the VI immediately. Note: Avoid using the Abort Execution button to stop a VI. Either let the VI complete its data flow or design a method to stop the VI programmatically. By doing so, the VI is at a known state. For example, place a button on the front panel that stops the VI when you click it. Click the Pause button to pause a running VI. When you click the Pause button, LabVIEW highlights on the block diagram the location where you paused execution. Click the Pause button again to continue running the VI. Select the Text Settings pull-down menu to change the font settings for the VI, including size, style, and color.Note: Demo high-level. Not all the buttons on this toolbar are enabled for all VIs. Also depending on whether or not a new VI is opened on Speedy-33 or on the computer. Click the Run button to run the VI. While the VI runs, the Run button appears with a black arrow if the VI is a top-level VI, meaning it has no callers and therefore is not a subVI. Click the Continuous Run button to run the VI until you abort or pause it. You also can click the button again to disable continuous running. While the VI runs, the Abort Execution button appears. Click this button to stop the VI immediately. Note: Avoid using the Abort Execution button to stop a VI. Either let the VI complete its data flow or design a method to stop the VI programmatically. By doing so, the VI is at a known state. For example, place a button on the front panel that stops the VI when you click it. Click the Pause button to pause a running VI. When you click the Pause button, LabVIEW highlights on the block diagram the location where you paused execution. Click the Pause button again to continue running the VI. Select the Text Settings pull-down menu to change the font settings for the VI, including size, style, and color.

    17. Select The Align Objects pull-down menu to align objects along axes, including vertical, top edge, left, and so on. Select the Distribute Objects pull-down menu to space objects evenly, including gaps, compression, and so on. Select the Resize Objects pull-down menu to change the width and height of front panel objects. Select the Reorder pull-down menu when you have objects that overlap each other and you want to define which one is in front or back of another. Select one of the objects with the Positioning tool and then select from Move Forward, Move Backward, Move To Front, and Move To Back. <the following items only appear on the bock diagram toolbar> Click the Highlight Execution button to see the flow of data through the block diagram. Click the button again to disable execution highlighting. Click the Step Into button to single-step into a loop, subVI, and so on. Single-stepping through a VI steps through the VI node to node. Each node blinks to denote when it is ready to execute. By stepping into the node, you are ready to single-step inside the node. Click the Step Over button to step over a loop, subVI, and so on. By stepping over the node, you execute the node without single-stepping through the node. Click the Step Out button to step out of a loop, subVI, and so on. By stepping out of a node, you complete single-stepping through the node and go to the next node.Select The Align Objects pull-down menu to align objects along axes, including vertical, top edge, left, and so on. Select the Distribute Objects pull-down menu to space objects evenly, including gaps, compression, and so on. Select the Resize Objects pull-down menu to change the width and height of front panel objects. Select the Reorder pull-down menu when you have objects that overlap each other and you want to define which one is in front or back of another. Select one of the objects with the Positioning tool and then select from Move Forward, Move Backward, Move To Front, and Move To Back. <the following items only appear on the bock diagram toolbar> Click the Highlight Execution button to see the flow of data through the block diagram. Click the button again to disable execution highlighting. Click the Step Into button to single-step into a loop, subVI, and so on. Single-stepping through a VI steps through the VI node to node. Each node blinks to denote when it is ready to execute. By stepping into the node, you are ready to single-step inside the node. Click the Step Over button to step over a loop, subVI, and so on. By stepping over the node, you execute the node without single-stepping through the node. Click the Step Out button to step out of a loop, subVI, and so on. By stepping out of a node, you complete single-stepping through the node and go to the next node.

    18. Review of Data Types Found in LabVIEW LabVIEW utilizes many common datatypes. These Datatypes include: Boolean, Numeric, Arrays, Strings, Clusters, and more. The color and symbol of each terminal indicate the data type of the control or indicator. Control terminals have a thicker border than indicator terminals. Also, arrows appear on front panel terminals to indicate whether the terminal is a control or an indicator. An arrow appears on the right if the terminal is a control, and an arrow appears on the left if the terminal is an indicator. Definitions Array: Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. An array can have one or more dimensions and as many as (231) – 1 elements per dimension, memory permitting. Cluster: Clusters group data elements of mixed types, such as a bundle of wires in a telephone cable, where each wire in the cable represents a different element of the cluster. See Help»Search the LabVIEW Help… for more information. The LabVIEW User Manual on ni.com provides additional reference for data types found in LabVIEW. LabVIEW utilizes many common datatypes. These Datatypes include: Boolean, Numeric, Arrays, Strings, Clusters, and more. The color and symbol of each terminal indicate the data type of the control or indicator. Control terminals have a thicker border than indicator terminals. Also, arrows appear on front panel terminals to indicate whether the terminal is a control or an indicator. An arrow appears on the right if the terminal is a control, and an arrow appears on the left if the terminal is an indicator. Definitions Array: Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. An array can have one or more dimensions and as many as (231) – 1 elements per dimension, memory permitting. Cluster: Clusters group data elements of mixed types, such as a bundle of wires in a telephone cable, where each wire in the cable represents a different element of the cluster. See Help»Search the LabVIEW Help… for more information. The LabVIEW User Manual on ni.com provides additional reference for data types found in LabVIEW.

    19. Note: Good with exercise 2 on next page. LabVIEW follows a dataflow model for running VIs. A block diagram node executes when all its inputs are available. When a node completes execution, it supplies data to its output terminals and passes the output data to the next node in the dataflow path. Visual Basic, C++, JAVA, and most other text-based programming languages follow a control flow model of program execution. In control flow, the sequential order of program elements determines the execution order of a program. Consider the block diagram above. It adds two numbers and then subtracts 50.0 from the result of the addition. In this case, the block diagram executes from left to right, not because the objects are placed in that order, but because one of the inputs of the Subtract function is not valid until the Add function has finished executing and passed the data to the Subtract function. Remember that a node executes only when data are available at all of its input terminals, and it supplies data to its output terminals only when it finishes execution. In the code to the right, consider which code segment would execute first—the Add, Random Number, or Divide function. You cannot know because inputs to the Add and Divide functions are available at the same time, and the Random Number function has no inputs. In a situation where one code segment must execute before another, and no data dependency exists between the functions, use a Sequence structure to force the order of execution. Note: Good with exercise 2 on next page. LabVIEW follows a dataflow model for running VIs. A block diagram node executes when all its inputs are available. When a node completes execution, it supplies data to its output terminals and passes the output data to the next node in the dataflow path. Visual Basic, C++, JAVA, and most other text-based programming languages follow a control flow model of program execution. In control flow, the sequential order of program elements determines the execution order of a program. Consider the block diagram above. It adds two numbers and then subtracts 50.0 from the result of the addition. In this case, the block diagram executes from left to right, not because the objects are placed in that order, but because one of the inputs of the Subtract function is not valid until the Add function has finished executing and passed the data to the Subtract function. Remember that a node executes only when data are available at all of its input terminals, and it supplies data to its output terminals only when it finishes execution. In the code to the right, consider which code segment would execute first—the Add, Random Number, or Divide function. You cannot know because inputs to the Add and Divide functions are available at the same time, and the Random Number function has no inputs. In a situation where one code segment must execute before another, and no data dependency exists between the functions, use a Sequence structure to force the order of execution.

    20. Exercise 2: Dataflow Understand how dataflow determines the execution order in a VI. Directions: Build the following VI in LabVIEW: Run the program in Highlight Execution mode and notice how data flows through the wires. 1. Which of the following functions executes first? Add * Subtract Unknown 2. Which of the following functions executes first? Random Number Add Unknown * 3. Which of the following functions execute last? Random Number Subtract * Add Unknown 1. Which of the following functions executes first? Add * Subtract Unknown 2. Which of the following functions executes first? Random Number Add Unknown * 3. Which of the following functions execute last? Random Number Subtract * Add Unknown

    21. Wiring Tips – Block Diagram In addition to Front Panel terminals, the Block diagram contains functions. Each function may have multiple input and output terminals. Wiring to these terminals is an important part of LabVIEW programming. Once you have some experience programming in LabVIEW, wiring will become easy. At first, you may need some assistance. Here are some tips to get you started: The wiring tool is used to wire to the nodes of the functions. When you “aim” with the wiring tool, aim with the end of the wire hanging from the spool. This is where the wire will be placed. As you move the wiring tool over functions, watch for the yellow tip strip. This will tell you the name of the terminal you are wiring to. As you move the wiring tool over a terminal, it will flash. This will help you identify where the wire will attach. For more help with the terminals, right-click on the function and select Visible Items>>Terminals. The function’s picture will be pulled back to reveal the connection terminals. Notice the colors- these match the data types used by the front panel terminals. For additional help, select Help>>Show Context Help, or press CTRL+H. This will bring up the context help window. As you move your mouse over the function, this window will show you the function, terminals, and a brief help description. Use this with the other tools to help you as you wire. In addition to Front Panel terminals, the Block diagram contains functions. Each function may have multiple input and output terminals. Wiring to these terminals is an important part of LabVIEW programming. Once you have some experience programming in LabVIEW, wiring will become easy. At first, you may need some assistance. Here are some tips to get you started: The wiring tool is used to wire to the nodes of the functions. When you “aim” with the wiring tool, aim with the end of the wire hanging from the spool. This is where the wire will be placed. As you move the wiring tool over functions, watch for the yellow tip strip. This will tell you the name of the terminal you are wiring to. As you move the wiring tool over a terminal, it will flash. This will help you identify where the wire will attach. For more help with the terminals, right-click on the function and select Visible Items>>Terminals. The function’s picture will be pulled back to reveal the connection terminals. Notice the colors- these match the data types used by the front panel terminals. For additional help, select Help>>Show Context Help, or press CTRL+H. This will bring up the context help window. As you move your mouse over the function, this window will show you the function, terminals, and a brief help description. Use this with the other tools to help you as you wire.

    22. If your wiring becomes doesn’t look very good, right-click on the particular wire in question and choose Clean Up Wire to automatically re-route that wire. Wiring is very flexible in LabVIEW. Experiment with keystroke and clicking combinations when wiring. Here are some of the most often used features: Single, double, and triple clicking a wire selects the wire for movement or deletion Clicking while wiring tacks down a bend in the wire Right-clicking or pressing Escape while wiring cancels the wiring operation Don’t worry about wire colors- LabVIEW will automatically select the right wire for each situation. Automatically Wiring Objects LabVIEW automatically wires objects as you place them on the block diagram. You also can automatically wire objects already on the block diagram. LabVIEW connects the terminals that best match and leaves terminals that do not match unconnected. As you move a selected object close to other objects on the block diagram, LabVIEW draws temporary wires to show you valid connections. When you release the mouse button to place the object on the block diagram, LabVIEW automatically connects the wires. Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool. You can adjust the automatic wiring settings by selecting Tools » Options and selecting Block Diagram from the top pull-down menu. If your wiring becomes doesn’t look very good, right-click on the particular wire in question and choose Clean Up Wire to automatically re-route that wire. Wiring is very flexible in LabVIEW. Experiment with keystroke and clicking combinations when wiring. Here are some of the most often used features: Single, double, and triple clicking a wire selects the wire for movement or deletion Clicking while wiring tacks down a bend in the wire Right-clicking or pressing Escape while wiring cancels the wiring operation Don’t worry about wire colors- LabVIEW will automatically select the right wire for each situation. Automatically Wiring Objects LabVIEW automatically wires objects as you place them on the block diagram. You also can automatically wire objects already on the block diagram. LabVIEW connects the terminals that best match and leaves terminals that do not match unconnected. As you move a selected object close to other objects on the block diagram, LabVIEW draws temporary wires to show you valid connections. When you release the mouse button to place the object on the block diagram, LabVIEW automatically connects the wires. Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool. You can adjust the automatic wiring settings by selecting Tools » Options and selecting Block Diagram from the top pull-down menu.

    23. When you create an object on the Front Panel, a terminal will be created on the Block Diagram. These terminals give you access to the Front Panel objects from the Block Diagram code. Each terminal contains useful information about the Front Panel object it corresponds to. For example, the color and symbols provide information about the data type. For example: The dynamic data type is a polymorphic data type represented by dark blue terminals. Boolean terminals are green with TF lettering. In general, blue terminals should wire to blue terminals, green to green, and so on. This is not a hard-and-fast rule; LabVIEW will allow a user to connect a blue terminal (dynamic data) to an orange terminal (fractional value), for example. But in most cases, look for a match in colors. Controls have an arrow on the right side and have a thick border. Indicators have an arrow on the left and a thin border. Logic rules apply to wiring in LabVIEW: Each wire must have one (but only one) source (or control), and each wire may have multiple destinations (or indicators). When you create an object on the Front Panel, a terminal will be created on the Block Diagram. These terminals give you access to the Front Panel objects from the Block Diagram code. Each terminal contains useful information about the Front Panel object it corresponds to. For example, the color and symbols provide information about the data type. For example: The dynamic data type is a polymorphic data type represented by dark blue terminals. Boolean terminals are green with TF lettering. In general, blue terminals should wire to blue terminals, green to green, and so on. This is not a hard-and-fast rule; LabVIEW will allow a user to connect a blue terminal (dynamic data) to an orange terminal (fractional value), for example. But in most cases, look for a match in colors. Controls have an arrow on the right side and have a thick border. Indicators have an arrow on the left and a thin border. Logic rules apply to wiring in LabVIEW: Each wire must have one (but only one) source (or control), and each wire may have multiple destinations (or indicators).

    24. Help Options Note: Skip if already covered. Use the Context Help window and the LabVIEW Help to help you build and edit VIs. Refer to the LabVIEW Help and manuals for more information. Context Help Window To display the Context Help window, select Help»Show Context Help or press the <Ctrl-H> keys. When you move the cursor over front panel and block diagram objects, the Context Help window displays the icon for subVIs, functions, constants, controls, and indicators, with wires attached to each terminal. When you move the cursor over dialog box options, the Context Help window displays descriptions of those options. In the window, required connections are bold, recommended connections are plain text, and optional connections are dimmed or do not appear. Above is an example Context Help window. Click the Simple/Detailed Context Help button located on the lower left corner of the Context Help window to change between simple and detailed context help. The simple mode emphasizes the important connections. Optional terminals are shown by wire stubs, informing you that other connections exist. Click the Lock Context Help button to lock the current contents of the Context Help window. When the contents are locked, moving the cursor over another object does not change the contents of the window. To unlock the window, click the button again. You also can access this option from the Help menu.Note: Skip if already covered. Use the Context Help window and the LabVIEW Help to help you build and edit VIs. Refer to the LabVIEW Help and manuals for more information. Context Help Window To display the Context Help window, select Help»Show Context Help or press the <Ctrl-H> keys. When you move the cursor over front panel and block diagram objects, the Context Help window displays the icon for subVIs, functions, constants, controls, and indicators, with wires attached to each terminal. When you move the cursor over dialog box options, the Context Help window displays descriptions of those options. In the window, required connections are bold, recommended connections are plain text, and optional connections are dimmed or do not appear. Above is an example Context Help window. Click the Simple/Detailed Context Help button located on the lower left corner of the Context Help window to change between simple and detailed context help. The simple mode emphasizes the important connections. Optional terminals are shown by wire stubs, informing you that other connections exist. Click the Lock Context Help button to lock the current contents of the Context Help window. When the contents are locked, moving the cursor over another object does not change the contents of the window. To unlock the window, click the button again. You also can access this option from the Help menu.

    25. Click the More Help button to display the corresponding topic in the LabVIEW Help, which describes the object in detail. LabVIEW Help You can access the LabVIEW Help either by clicking the More Help button in the Context Help window, selecting Help»VI, Function, & How-To Help, clicking the sentence Click here for more help in the Context Help window, or pressing <Ctrl-?>. The LabVIEW Help contains detailed descriptions of most palettes, menus, tools, VIs, and functions. It also includes step-by-step instructions for using LabVIEW features and links to the LabVIEW Tutorial, PDF versions of all the LabVIEW manuals and Application Notes, and technical support resources on the National Instruments Web site. Click the More Help button to display the corresponding topic in the LabVIEW Help, which describes the object in detail. LabVIEW Help You can access the LabVIEW Help either by clicking the More Help button in the Context Help window, selecting Help»VI, Function, & How-To Help, clicking the sentence Click here for more help in the Context Help window, or pressing <Ctrl-?>. The LabVIEW Help contains detailed descriptions of most palettes, menus, tools, VIs, and functions. It also includes step-by-step instructions for using LabVIEW features and links to the LabVIEW Tutorial, PDF versions of all the LabVIEW manuals and Application Notes, and technical support resources on the National Instruments Web site.

    26. Debugging Techniques When your VI is not executable, a broken arrow is displayed in the Run button in the palette. Finding Errors: To list errors, click on the broken arrow. To locate the bad object, click on the error message. 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. 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. Breakpoint: Set pauses at different locations on the diagram. Click on wires or objects with the Breakpoint tool to set breakpoints. Use Debug Demonstrate VI from BASICS.LLB to demonstrate the options and tools. When your VI is not executable, a broken arrow is displayed in the Run button in the palette. Finding Errors: To list errors, click on the broken arrow. To locate the bad object, click on the error message. 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. 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. Breakpoint: Set pauses at different locations on the diagram. Click on wires or objects with the Breakpoint tool to set breakpoints. Use Debug Demonstrate VI from BASICS.LLB to demonstrate the options and tools.

    27. Demonstration 2: Debugging Use the debugging tools built into LabVIEW to determine why the VI is broken. How do you know the VI is not working? How can you find the errors in the VI?

    28. Tips for Working in LabVIEW Keystroke Shortcuts <Ctrl-H> – Activate/Deactivate Context Help Window <Ctrl-B> – Remove Broken Wires From Block Diagram <Ctrl-E> – Toggle Between Front Panel and Block Diagram <Ctrl-T> – Tile the Front Panel and Block Diagram <Ctrl-Z> – Undo (Also in Edit Menu) Tools » Options… – Set Preferences in LabVIEW VI Properties – Configure VI Appearance, Documentation, etc. Note: To all instructors, have laminated copies of this at all workstations in your lab for students to reference. Note 2: Mention Tool>>Options>>Block Diagram>>Place block diagram terminals as icons (to save space on block diagram) LabVIEW has many keystroke shortcuts that make working easier. The most common shortcuts are listed above. While the Automatic Selection Tool is great for choosing the tool you would like to use in LabVIEW, there are sometimes cases when you want manual control. Use the Tab key to toggle between the four most common tools (Operate Value, Position/Size/Select, Edit Text, Set Color on Front Panel and Operate Value, Position/Size/Select, Edit Text, Connect Wire on Block Diagram). Once you are finished with the tool you choose, you can press <Shift-Tab> to turn the Automatic Selection Tool on. In the Tools » Options… dialog, there are many configurable options for customizing your Front Panel, Block Diagram, Colors, Printing, and much more. Similar to the LabVIEW Options, you can configure VI specific properties by going to File » VI Properties… There you can document the VI, change the appearance of the window, and customize it in several other ways.Note: To all instructors, have laminated copies of this at all workstations in your lab for students to reference. Note 2: Mention Tool>>Options>>Block Diagram>>Place block diagram terminals as icons (to save space on block diagram) LabVIEW has many keystroke shortcuts that make working easier. The most common shortcuts are listed above. While the Automatic Selection Tool is great for choosing the tool you would like to use in LabVIEW, there are sometimes cases when you want manual control. Use the Tab key to toggle between the four most common tools (Operate Value, Position/Size/Select, Edit Text, Set Color on Front Panel and Operate Value, Position/Size/Select, Edit Text, Connect Wire on Block Diagram). Once you are finished with the tool you choose, you can press <Shift-Tab> to turn the Automatic Selection Tool on. In the Tools » Options… dialog, there are many configurable options for customizing your Front Panel, Block Diagram, Colors, Printing, and much more. Similar to the LabVIEW Options, you can configure VI specific properties by going to File » VI Properties… There you can document the VI, change the appearance of the window, and customize it in several other ways.

    29. Exercise 3: Create another VI Create a VI to compute the slope of a line.

    30. Section II – SubVIs, Structures, and Charts SubVIs While Loop For Loop Shift Registers Case Structures Sequence Structures

    31. Modularity in LabVIEW – SubVIs Note: Analogy ideas – cookie cutter, thermometer Modularity defines the degree to which your VI is composed of discrete components such that a change to one component has minimal impact on other components. In LabVIEW these separate components are called subVIs. Creating subVIs out of your code increases the readability and reusability of your VIs. In the upper image, we see repeated code allowing the user to choose between temperature scales. Since this portion of this code is identical in both cases, we can create a subVI for it. This will make the code more readable, by being less clustered, and will allow us to reuse code easily. As you can see, the code is far less cluttered now, achieves the exact same functionality and if needed, the temperature scale selection portion of the code can be reused in other applications very easily. Any portion of LabVIEW code can be turned into a subVI that in turn can be used by other LabVIEW code. Note: Analogy ideas – cookie cutter, thermometer Modularity defines the degree to which your VI is composed of discrete components such that a change to one component has minimal impact on other components. In LabVIEW these separate components are called subVIs. Creating subVIs out of your code increases the readability and reusability of your VIs. In the upper image, we see repeated code allowing the user to choose between temperature scales. Since this portion of this code is identical in both cases, we can create a subVI for it. This will make the code more readable, by being less clustered, and will allow us to reuse code easily. As you can see, the code is far less cluttered now, achieves the exact same functionality and if needed, the temperature scale selection portion of the code can be reused in other applications very easily. Any portion of LabVIEW code can be turned into a subVI that in turn can be used by other LabVIEW code.

    32. Create SubVI Enclose area to be converted into a subVI. Select Edit»Create SubVI from the Edit Menu. Creating SubVIs A subVI node corresponds to a subroutine call in text-based programming languages. A block diagram that contains several identical subVI nodes calls the same subVI several times. The subVI controls and indicators receive data from and return data to the block diagram of the calling VI. Click the Select a VI icon or text on the Functions palette, navigate to and double-click a VI, and place the VI on a block diagram to create a subVI call to that VI. A subVI input and output terminals and the icon can be easily customized. Follow the instructions below to quickly create a subVI. Creating SubVIs from Sections of a VI Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit»Create SubVI. An icon for the new subVI replaces the selected section of the block diagram. LabVIEW creates controls and indicators for the new subVI, automatically configures the connector pane based on the number of control and indicator terminals you selected, and wires the subVI to the existing wires. See Help»Search the LabVIEW Help…»SubVIs for more information.Creating SubVIs A subVI node corresponds to a subroutine call in text-based programming languages. A block diagram that contains several identical subVI nodes calls the same subVI several times. The subVI controls and indicators receive data from and return data to the block diagram of the calling VI. Click the Select a VI icon or text on the Functions palette, navigate to and double-click a VI, and place the VI on a block diagram to create a subVI call to that VI. A subVI input and output terminals and the icon can be easily customized. Follow the instructions below to quickly create a subVI. Creating SubVIs from Sections of a VI Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit»Create SubVI. An icon for the new subVI replaces the selected section of the block diagram. LabVIEW creates controls and indicators for the new subVI, automatically configures the connector pane based on the number of control and indicator terminals you selected, and wires the subVI to the existing wires. See Help»Search the LabVIEW Help…»SubVIs for more information.

    33. A subVI node corresponds to a subroutine call in text-based programming languages. The node is not the subVI itself, just as a subroutine call statement in a program is not the subroutine itself. A block diagram that contains several identical subVI nodes calls the same subVI several times. The modular approach makes applications easier to debug and maintain. 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. A subVI node corresponds to a subroutine call in text-based programming languages. The node is not the subVI itself, just as a subroutine call statement in a program is not the subroutine itself. A block diagram that contains several identical subVI nodes calls the same subVI several times. The modular approach makes applications easier to debug and maintain. 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.

    34. SubVIs A SubVI is a VI that can be used within another VI Similar to a subroutine Advantages Modular Easier to debug Don’t have to recreate code Require less memory Note: Explain WHY you would want subVIs. After you build a VI and create its icon and connector pane, you can use it in another VI. A VI within another VI is called a subVI. A subVI corresponds to a subroutine in text-based programming languages. Using subVIs helps you manage changes and debug the block diagram quickly.Note: Explain WHY you would want subVIs. After you build a VI and create its icon and connector pane, you can use it in another VI. A VI within another VI is called a subVI. A subVI corresponds to a subroutine in text-based programming languages. Using subVIs helps you manage changes and debug the block diagram quickly.

    35. While Loops Note: While Loop is automatically added in Speedy-33 VIs Based on the Flow Chart, must the code execute at least once? -Yes! While loops are similar to a coach telling his athletes to run around the track or do a drill over and over until he says to stop (sending a boolean true to the conditional stop). The iteration block [i] keeps track of the number of loops and no data can leave until the coach says you’re done looping. Real World Use: Capture images from the webcam until I say stop.Note: While Loop is automatically added in Speedy-33 VIs Based on the Flow Chart, must the code execute at least once? -Yes! While loops are similar to a coach telling his athletes to run around the track or do a drill over and over until he says to stop (sending a boolean true to the conditional stop). The iteration block [i] keeps track of the number of loops and no data can leave until the coach says you’re done looping. Real World Use: Capture images from the webcam until I say stop.

    36. For Loops Similar to a coach telling his athletes to run laps or do a drill a certain number of times. The iteration box [i] keeps track. No data can leave until the task is done. Real World Use: Capture 50 images from the webcam.Similar to a coach telling his athletes to run laps or do a drill a certain number of times. The iteration box [i] keeps track. No data can leave until the task is done. Real World Use: Capture 50 images from the webcam.

    37. Loops While Loops i terminal counts iteration Always runs at least once Runs until stop condition is met Tunnels automatically output last value Both the While and For Loops are located on the Functions»Structures palette. The For Loop differs from the While Loop in that the For Loop executes a set number of times. A While Loop stops executing the subdiagram only if the value at the conditional terminal exists. While Loops Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop, shown at the top right, executes a subdiagram until a condition is met. The While Loop executes the sub diagram until the conditional terminal, an input terminal, receives a specific Boolean value. The default behavior and appearance of the conditional terminal is Stop If True. When a conditional terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal receives a TRUE value. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0. For Loops A For Loop, shown above, executes a subdiagram a set number of times. The value in the count terminal (an input terminal) represented by the N, indicates how many times to repeat the subdiagram. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0.Both the While and For Loops are located on the Functions»Structures palette. The For Loop differs from the While Loop in that the For Loop executes a set number of times. A While Loop stops executing the subdiagram only if the value at the conditional terminal exists. While Loops Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop, shown at the top right, executes a subdiagram until a condition is met. The While Loop executes the sub diagram until the conditional terminal, an input terminal, receives a specific Boolean value. The default behavior and appearance of the conditional terminal is Stop If True. When a conditional terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal receives a TRUE value. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0. For Loops A For Loop, shown above, executes a subdiagram a set number of times. The value in the count terminal (an input terminal) represented by the N, indicates how many times to repeat the subdiagram. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0.

    38. Note: Build a While Loop and a For Loop. Use highlight execution to examine data flow. Place loops in your diagram by selecting them from the Structures palette of the Functions palette: 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.Note: Build a While Loop and a For Loop. Use highlight execution to examine data flow. Place loops in your diagram by selecting them from the Structures palette of the Functions palette: 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.

    39. How Do I Time a Loop? Loop Time Delay Configure the Time Delay Express VI for seconds to wait each iteration of the loop (works on For and While loops). Note: Add time delay and run VI again. Time Delay The Time Delay Express VI delays execution by a specified number of seconds. Following the rules of Data Flow Programming, the while loop will not iterate until all tasks inside of it are complete, thus delaying each iteration of the loop. Timed Loops Executes each iteration of the loop at the period you specify. Use the Timed Loop when you want to develop VIs with multi-rate timing capabilities, precise timing, feedback on loop execution, timing characteristics that change dynamically, or several levels of execution priority. Double-click the Input Node or right-click the Input Node and select Configure Timed Loop from the shortcut menu to display the Loop Configuration dialog box, where you can configure the Timed Loop. The values you enter in the Loop Configuration dialog box appear as options in the Input Node.Note: Add time delay and run VI again. Time Delay The Time Delay Express VI delays execution by a specified number of seconds. Following the rules of Data Flow Programming, the while loop will not iterate until all tasks inside of it are complete, thus delaying each iteration of the loop. Timed Loops Executes each iteration of the loop at the period you specify. Use the Timed Loop when you want to develop VIs with multi-rate timing capabilities, precise timing, feedback on loop execution, timing characteristics that change dynamically, or several levels of execution priority. Double-click the Input Node or right-click the Input Node and select Configure Timed Loop from the shortcut menu to display the Loop Configuration dialog box, where you can configure the Timed Loop. The values you enter in the Loop Configuration dialog box appear as options in the Input Node.

    40. DEMO shift registers by adding previous # with 1 using shift register. Analogy: Redial on phone (always gets replaced with the last number you dialed), or if you look back to multiple past iterations it is like a call log. Real World Use: Averaging and Finding Max & Min (compare each new data point to the current max or min) 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. An input of 0 would result in an output of 5 the first iteration, 10 the second iteration and 15 the third iteration. Said another way, shift registers are used to retain values from one iteration to the next. They are valuable for many applications that have memory or feedback between states. The feedback node is another representation of the same concept. (pictured below) Both programs pictured behave the same. See Help»Search the LabVIEW Help… for more information. <<PAUSE/BREAK>>DEMO shift registers by adding previous # with 1 using shift register. Analogy: Redial on phone (always gets replaced with the last number you dialed), or if you look back to multiple past iterations it is like a call log. Real World Use: Averaging and Finding Max & Min (compare each new data point to the current max or min) 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. An input of 0 would result in an output of 5 the first iteration, 10 the second iteration and 15 the third iteration. Said another way, shift registers are used to retain values from one iteration to the next. They are valuable for many applications that have memory or feedback between states. The feedback node is another representation of the same concept. (pictured below) Both programs pictured behave the same. See Help»Search the LabVIEW Help… for more information. <<PAUSE/BREAK>>

    41. How Do I Make Decisions in LabVIEW? Case Structures Select DEMO case structures! Analogy: Vending Machine… you only get one choice Case Structure The Case Structure has one or more subdiagrams, or cases, exactly one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be boolean, string, integer, or enumerated type. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. It is found at Functions»Programming»Structures»Case Structure. Select Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming» Comparison»Select. Example a: Boolean input: Simple if-then case. If the Boolean input is TRUE, the true case will execute; otherwise the FALSE case will execute. Example b: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW will choose the default case. Example c: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator.DEMO case structures! Analogy: Vending Machine… you only get one choice Case Structure The Case Structure has one or more subdiagrams, or cases, exactly one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be boolean, string, integer, or enumerated type. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. It is found at Functions»Programming»Structures»Case Structure. Select Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming» Comparison»Select. Example a: Boolean input: Simple if-then case. If the Boolean input is TRUE, the true case will execute; otherwise the FALSE case will execute. Example b: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW will choose the default case. Example c: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator.

    42. Section III – Arrays, Charts, Graphs, File I/O Build arrays Charts Graphs Write to file Read from file Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. An array can have one or more dimensions and as many as 2^31 – 1 elements per dimension, memory permitting. You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. Consider using arrays when you work with a collection of similar data and when you perform repetitive computations. Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration of a loop produces one element of the array. Array elements are ordered. An array uses an index so you can readily access any particular element. The 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. For example, n = 9 for the nine planets, so the index ranges from 0 to 8. Earth is the third planet, so it has an index of 2. File I/O operations pass data to and from files. Use the File I/O VIs and functions located on the Functions » File I/O palette to handle all aspects of file I/O. In this class we will cover reading and writing spreadsheet files using the Express VIs for File I/O. Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. An array can have one or more dimensions and as many as 2^31 – 1 elements per dimension, memory permitting. You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. Consider using arrays when you work with a collection of similar data and when you perform repetitive computations. Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration of a loop produces one element of the array. Array elements are ordered. An array uses an index so you can readily access any particular element. The 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. For example, n = 9 for the nine planets, so the index ranges from 0 to 8. Earth is the third planet, so it has an index of 2. File I/O operations pass data to and from files. Use the File I/O VIs and functions located on the Functions » File I/O palette to handle all aspects of file I/O. In this class we will cover reading and writing spreadsheet files using the Express VIs for File I/O.

    43. Arrays An array consists of elements and dimensions Elements: data that make up the array Dimension: rows, columns Index: position of an element in the array A collection of the same data type Note: Valet parking analogy (elements, dimension, index) Note: Valet parking analogy (elements, dimension, index)

    44. Creating an Array (Step 1 of 2) From the Functions » Advanced » Programming » Array subpalette, select the Array icon. To create an array control or indicator as shown, select an array on the Controls»Modern»Array, Matrix, and Cluster palette, place it on the front panel, and drag a control or indicator into the array shell. If you attempt to drag an invalid control or indicator such as an XY graph into the array shell, you are unable to drop the control or indicator in the array shell. You must insert an object in the array shell before you use the array on the block diagram. Otherwise, the array terminal appears black with an empty bracket. To create an array control or indicator as shown, select an array on the Controls»Modern»Array, Matrix, and Cluster palette, place it on the front panel, and drag a control or indicator into the array shell. If you attempt to drag an invalid control or indicator such as an XY graph into the array shell, you are unable to drop the control or indicator in the array shell. You must insert an object in the array shell before you use the array on the block diagram. Otherwise, the array terminal appears black with an empty bracket.

    45. Create an Array (Step 2 of 2) Place an Array Shell. Insert datatype into the shell (i.e. Numeric Control). Analogy: Valet Parking To add dimensions to an array one at a time, right-click the index display and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many dimensions as you want. 1D Array Viewing a Single Element: 1D Array Viewing Multiple Elements: 2D Array Viewing a Single Element: 2D Array Viewing Multiple Elements: Analogy: Valet Parking To add dimensions to an array one at a time, right-click the index display and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many dimensions as you want. 1D Array Viewing a Single Element: 1D Array Viewing Multiple Elements: 2D Array Viewing a Single Element: 2D Array Viewing Multiple Elements:

    46. Building Arrays with Loops (Auto-Indexing) DEMO auto-indexing to create an array 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. DEMO auto-indexing to create an array 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.

    47. Charts – Add 1 data point at a time with history Waveform chart – special numeric indicator that can display a history of values Chart updates with each individual point it receives The waveform chart is a special numeric indicator that displays one or more plots. The waveform chart is located on the Controls»Modern»Graph palette. Waveform charts can display single or multiple plots. The following front panel shows an example of a multi-plot waveform chart. You can change the min and max values of either the x or y axis by double clicking on the value with the labeling tool and typing the new value. Similarly, you can change the label of the axis. You can also right click the plot legend and change the style, shape, and color of the trace that is displayed on the chart.The waveform chart is a special numeric indicator that displays one or more plots. The waveform chart is located on the Controls»Modern»Graph palette. Waveform charts can display single or multiple plots. The following front panel shows an example of a multi-plot waveform chart. You can change the min and max values of either the x or y axis by double clicking on the value with the labeling tool and typing the new value. Similarly, you can change the label of the axis. You can also right click the plot legend and change the style, shape, and color of the trace that is displayed on the chart.

    48. Graphs – Display many data points at once Graphs are very powerful indicators in LabVIEW. The can are highly customizable, and can be used to concisely display a great deal of information. The properties page of the graph allows you to display settings for plot types, scale and cursor options, and many other features of the graph. To open the properties page, right-click the graph on the front panel and choose Properties. Note: Graphs also allow you to create technical paper quality graphics with the “export simplified image” function. Right-click the graph, select Data Operations»Export Simplified Image…Graphs are very powerful indicators in LabVIEW. The can are highly customizable, and can be used to concisely display a great deal of information. The properties page of the graph allows you to display settings for plot types, scale and cursor options, and many other features of the graph. To open the properties page, right-click the graph on the front panel and choose Properties. Note: Graphs also allow you to create technical paper quality graphics with the “export simplified image” function. Right-click the graph, select Data Operations»Export Simplified Image…

    49. Wiring Data into Charts Single Plot Charts Multiplot Charts You can wire a scalar output directly to a waveform chart to display one plot. To display multiple plots on one chart, use the Merge Signals function found in the Functions >> Signal Manipulation palette. The Merge Signal function bundles multiple outputs to plot on the waveform chart. To add more plots, use the Positioning tool to resize the Merge Signal function. The context help contains very good information on how the different ways to wire data into charts.You can wire a scalar output directly to a waveform chart to display one plot. To display multiple plots on one chart, use the Merge Signals function found in the Functions >> Signal Manipulation palette. The Merge Signal function bundles multiple outputs to plot on the waveform chart. To add more plots, use the Positioning tool to resize the Merge Signal function. The context help contains very good information on how the different ways to wire data into charts.

    50. Exercise 4 – Using loops Directions: Place a Waveform Graph and a Waveform Chart on the Front Panel. Place a while loop on the block diagram. Wire a Boolean Control to the Conditional Terminal. Place a Wait ms VI in the while loop. Wire a constant of 500 to the input of the Wait. Place a random number generator inside the while loop. Put the waveform chart inside the while loop. Wire the random number to the chart. Place the waveform graph outside the while loop. Wire the random number through the while loop to the input of the waveform graph, right-click on the tunnel, and select Enable Indexing. Demo the solution first, so they know what they are building. This exercise should take 15-20 minutes. Instructions: Create a VI that generates a random number at a specified rate and displays the readings on a Waveform Chart until stopped by the user. Connect the termination terminal to a front panel stop button, and add a slider control to the front panel. The slider control should range from 0 to 2000 in value, and be connected to the Time Delay Express VI function inside your while loop. Save the VI as “Use a loop.vi”.Demo the solution first, so they know what they are building. This exercise should take 15-20 minutes. Instructions: Create a VI that generates a random number at a specified rate and displays the readings on a Waveform Chart until stopped by the user. Connect the termination terminal to a front panel stop button, and add a slider control to the front panel. The slider control should range from 0 to 2000 in value, and be connected to the Time Delay Express VI function inside your while loop. Save the VI as “Use a loop.vi”.

    51. File I/O File I/O – passing data to and from files - Files can be binary, text, or spreadsheet - Write/Read LabVIEW Measurements file (*.lvm) SKIP! File I/O operations pass data to and from files. In LabVIEW, you can use File I/O functions to: Open and close data files Read data from and write data to files Read from and writ to spreadsheet-formatted files Move and rename files and directories Change file characteristics Create, modify, and read a configuration file Write to or read from LabVIEW Measurements files. In this course we will examine how to write to or read from LabVIEW Measurements files (*.lvm files). Note: Data from the Speedy-33 cannot be written to file.SKIP! File I/O operations pass data to and from files. In LabVIEW, you can use File I/O functions to: Open and close data files Read data from and write data to files Read from and writ to spreadsheet-formatted files Move and rename files and directories Change file characteristics Create, modify, and read a configuration file Write to or read from LabVIEW Measurements files. In this course we will examine how to write to or read from LabVIEW Measurements files (*.lvm files). Note: Data from the Speedy-33 cannot be written to file.

    52. Write LabVIEW Measurement File Includes the open, write, close and error handling functions Handles formatting the string with either a tab or comma delimiter Merge Signals function is used to combine data into the dynamic data type The Write LVM file can write to spreadsheet files. However, its main purpose is for logging data, that will be used in LabVIEW. This VI creates a .lvm file which can be opened in a spreadsheet application. For simple spreadsheet files, use the Express VIs: Write LVM and Read LVM.The Write LVM file can write to spreadsheet files. However, its main purpose is for logging data, that will be used in LabVIEW. This VI creates a .lvm file which can be opened in a spreadsheet application. For simple spreadsheet files, use the Express VIs: Write LVM and Read LVM.

    53. Section IV – USB Webcam USB Webcam Hardware USB Webcam Software LabVIEW for Infinity palettes for the USB Webcam Demo Exercise

    54. Working with the USB Webcam Hardware USB camera DirectShow filter Software LabVIEW Infinity Vision Development Module NI-IMAQ For USB Cameras For the USB camera to be compatible with NI software, the USB camera must have a DirectShow filter which is an API created by Microsoft. This should be documented in the USB camera’s manuals. Most USB webcams out there do have DirectShow filters. The software needed to acquire from USB cameras are LabVIEW, Vision Development Module, and NI-IMAQ For USB Cameras. All of these are included in LabVIEW Infinity.For the USB camera to be compatible with NI software, the USB camera must have a DirectShow filter which is an API created by Microsoft. This should be documented in the USB camera’s manuals. Most USB webcams out there do have DirectShow filters. The software needed to acquire from USB cameras are LabVIEW, Vision Development Module, and NI-IMAQ For USB Cameras. All of these are included in LabVIEW Infinity.

    55. Working with the USB Webcam Acquire Images USB webcam to Computer Process Images Measurements Pattern Matching OCR And more… Using NI’s software, we can acquire images from a USB webcam into our computers. After acquiring the image, we can also use functions to process these images. Example processing functions: Measurements (calculate length/width) Pattern Matching (find reoccurring instances of a template image) OCR (optical character recognition – read alphanumeric characters on an image)Using NI’s software, we can acquire images from a USB webcam into our computers. After acquiring the image, we can also use functions to process these images. Example processing functions: Measurements (calculate length/width) Pattern Matching (find reoccurring instances of a template image) OCR (optical character recognition – read alphanumeric characters on an image)

    56. Sequence Structure – Forcing an order of Execution DEMO case structures! Case Structure The Case Structure has one or more subdiagrams, or cases, exactly one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be boolean, string, integer, or enumerated type. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. It is found at Functions»Programming»Structures»Case Structure. Select - Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming» Comparison»Select. Example a: Boolean input: Simple if-then case. If the Boolean input is TRUE, the true case will execute; otherwise the FALSE case will execute. Example b: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW will choose the default case. Example c: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator.DEMO case structures! Case Structure The Case Structure has one or more subdiagrams, or cases, exactly one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be boolean, string, integer, or enumerated type. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. It is found at Functions»Programming»Structures»Case Structure. Select - Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming» Comparison»Select. Example a: Boolean input: Simple if-then case. If the Boolean input is TRUE, the true case will execute; otherwise the FALSE case will execute. Example b: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW will choose the default case. Example c: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator.

    57. USB Webcam Functions Initialize & Close Create Image & Dispose Image Acquisition & Processing General overview of IMAQ USB functions IMAQ USB Enumerate Cameras Returns list of connected USB cameras IMAQ USB Init Creates a session to the specified USB camera IMAQ USB Close Closes the session created by IMAQ USB Init IMAQ Create Creates memory space to store an image IMAQ Dispose Destroys an image and frees the space the image occupied in memory IMAQ USB Snap Acquires an image from the USB Camera Processing functions Threshold, Edge Detection, IMAQ Add, etc General overview of IMAQ USB functions IMAQ USB Enumerate Cameras Returns list of connected USB cameras IMAQ USB Init Creates a session to the specified USB camera IMAQ USB Close Closes the session created by IMAQ USB Init IMAQ Create Creates memory space to store an image IMAQ Dispose Destroys an image and frees the space the image occupied in memory IMAQ USB Snap Acquires an image from the USB Camera Processing functions Threshold, Edge Detection, IMAQ Add, etc

    58. Demonstration 3: USB Webcam This demo modifies an existing program to measure the horizontal width on a specified section of a picture taken with the USB Webcam.

    59. Exercise 5: USB Webcam Save Lab 4.1.3 to your desktop as “Lab 4.1.3 Edit” Follow through the block diagram of this Lab Note: Save lab to desktopNote: Save lab to desktop

    60. Working with the USB Webcam To get to the Vision and Motion palette go to the Functions Palette » Advanced » Vision and Motion. Vision Sub-Palettes Vision Utilities Image Processing : Filters, Analysis, etc. Machine Vision IMAQ USB : initialize, snap image, close Take a minute to have them just browse through the vision palette to get a feel for their options.Take a minute to have them just browse through the vision palette to get a feel for their options.

    61. Section V – Speedy-33 Working with the Speedy-33 Inputs and outputs Creating an Application for the Speedy-33 Note: For Master Instructors, cover this Wed. afternoon Thurs. morning.Note: For Master Instructors, cover this Wed. afternoon Thurs. morning.

    62. Working with the Speedy-33

    63. Creating a Speedy-33 Application

    64. Speedy-33 Inputs and Outputs You can place I/O elements on the block diagram through the Speedy-33 Project or through the functions palette.

    65. Creating a Speedy-33 Application

    66. Function Palette Differences for Speedy-33

    67. Exercise 6: Working with the Speedy-33

    68. Exercise 6: Working with the Speedy-33 (cont’d)

    69. Exercise 6: Working with the Speedy-33 (cont’d)

    70. Where Do I Go From Here? Example programs (Help» Find Examples…) LabVIEW Student Edition (www.ni.com/labviewse) Web resources (ni.com) NI Developer Zone (zone.ni.com) Tutorials and Knowledgebase Articles (www.ni.com/support) Info-labview newsgroup (www.info-labview.org/) Discussion Forums: (www.ni.com/forums) Where do you go from here? National Instruments offers a wide range of instructional courseware to expand your knowledge. Please visit ni.com/academic for programs and resources available. The LabVIEW Student Edition is a available from our website. In includes Learning With LabVIEW, a textbook written by Dr. Bob Bishop from the University of Texas at Austin. The web is the best place to turn in order to find information on LabVIEW. Ni.com is designed to be the one stop resource to find information. The NI Developer Zone (“NIDZ”) is a place for developers to meet, discuss design issues, and post content. Application Notes can be downloaded from ni.com/support on a variety of topics. Info-labview is a newsgroup maintained by a third party. There is an exhaustive library of LabVIEW instrument drivers available for download from NIDZ. Where do you go from here? National Instruments offers a wide range of instructional courseware to expand your knowledge. Please visit ni.com/academic for programs and resources available. The LabVIEW Student Edition is a available from our website. In includes Learning With LabVIEW, a textbook written by Dr. Bob Bishop from the University of Texas at Austin. The web is the best place to turn in order to find information on LabVIEW. Ni.com is designed to be the one stop resource to find information. The NI Developer Zone (“NIDZ”) is a place for developers to meet, discuss design issues, and post content. Application Notes can be downloaded from ni.com/support on a variety of topics. Info-labview is a newsgroup maintained by a third party. There is an exhaustive library of LabVIEW instrument drivers available for download from NIDZ.

    71. Additional Resources NI Academic Web & Student Corner http://www.ni.com/academic Connexions: Full LabVIEW Training Course www.cnx.rice.edu Or search for “LabVIEW basics” LabVIEW Certification LabVIEW Fundamentals Exam (free on www.ni.com/academic) Certified LabVIEW Associate Developer Exam (industry recognized certification ) Get your own copy of LabVIEW Student Edition www.ni.com/academic

    72. Advanced LabVIEW Topics These are topics important to successful programming of larger and more complex LabVIEW applications. If we do not have the time to cover these topics in class, it is highly recommended that you review them on your own. Note: Do not present in class beyond this point.Note: Do not present in class beyond this point.

    73. Advanced Topics Index Examples in LabVIEW DataTypes Boolean String Enumerated List Error Checking and Handling Connecting Broken Vis Debugging Creating a SubVI Tunnels in While Loops and For Loops Shift Registers Communicating between While loops Local Variables Shared Variables Arrays

    74. Virtual Instrument Examples in LabVIEW Help The Example Finder is a great resource for programmers new to LabVIEW. 1. From any Project, VI front panel, or VI block diagram, go to Help » Find Examples. 2. You can browse examples by categories, or you can use a keyword search. Click the Search tab to open the keyword browser. 3. Click on any program to see a detailed description of the example. Double-click on the VI name to launch a specific example. Examine the VI and run it. Change the frequencies and types of the input signals and notice how the display on the graph changes. Change the Signal Processing Window and Filter options. After you have examined the VI and the different options you can change, stop the VI by pressing the Stop button. Note You also can open the VI by clicking the Open VI button and navigating to labview\examples\apps\demos.llb\Signal Generation and Processing.vi.The Example Finder is a great resource for programmers new to LabVIEW. 1. From any Project, VI front panel, or VI block diagram, go to Help » Find Examples. 2. You can browse examples by categories, or you can use a keyword search. Click the Search tab to open the keyword browser. 3. Click on any program to see a detailed description of the example. Double-click on the VI name to launch a specific example. Examine the VI and run it. Change the frequencies and types of the input signals and notice how the display on the graph changes. Change the Signal Processing Window and Filter options. After you have examined the VI and the different options you can change, stop the VI by pressing the Stop button. Note You also can open the VI by clicking the Open VI button and navigating to labview\examples\apps\demos.llb\Signal Generation and Processing.vi.

    75. Data Types – Numerics The numeric data type represents numbers of various types To change the representation of a numeric, right-click the control, indicator, or constant, and select Representation from the shortcut menu

    76. Data Types – Boolean Behavior of Boolean controls is specified by the mechanical action In LabVIEW, the Boolean data type is represented with the color green

    77. Data Types – String A sequence of displayable or non-displayable ASCII characters On the front panel, strings appear as tables, text entry boxes, and labels Change the display type from the short-cut menu: Normal, ‘\’ Codes, Password and Hex Edit and manipulate strings with the String functions on the block diagram In LabVIEW, the string data type is represented with the color pink

    78. Data Types – Enum An enum represents a pair of values, a string and a numeric, where the enum can be one of a defined list of values

    79. Data Types – Enum Enum: enumerated control, constant, or indicator Enums are useful because it is easier to manipulate numbers than strings on the block diagram

    80. Error Checking and Error Handling – Automatic Error Handling LabVIEW automatically handles any known error when a VI runs by: suspending execution, highlighting the subVI or function where the error occurred, and displaying the Error dialog box Select File»VI Properties and select Execution from the Category pull-down menu to disable automatic error handling for a specific VI

    81. Error Checking and Error Handling – Manual Error Handling To disable automatic error handling for a subVI or function, wire its error out cluster to the error in cluster of another subVI or function or to an error out indicator Use the LabVIEW error handling VIs, functions, and parameters to manage errors

    82. Error Checking and Error Handling – Error Clusters Use the error cluster controls and indicators to create error inputs and outputs in subVIs The error in and error out clusters include the following components of information: Status Code Source

    83. Correcting Broken VIs Common Issues: Broken wire You wired a Boolean control to a String indicator You wired a Numeric control to a Numeric control A required block diagram terminal is unwired A subVI is broken or you edited its connector pane after you placed its icon on the block diagram of the VI

    84. Debugging Techniques Your VI isn’t broken, but you are getting unexpected data or behavior Any unwired or hidden subVIs? Incorrect default data being used? Undefined data being passed? Numeric representation correct? Node execution order correct?

    85. Debugging Techniques – Execution Highlighting Use execution highlighting to watch the data flow through the block diagram If the VI runs more slowly than expected, confirm that you turned off execution highlighting in subVIs

    86. Debugging Techniques – Single Stepping Single-step through the VI to view each action of the VI on the block diagram Suspend the execution of a subVI to edit values of controls and indicators, to control the number of times it runs, or to go back to the beginning of the execution of the subVI Open subVI and select Operate»Suspend When Called from the shortcut menu

    87. Debugging Techniques – Probes Use the Probe tool to observe intermediate data values and to check the error output of VIs and functions, especially those performing I/O Retain the values in the wires so that you can probe wires for data after execution has finished

    88. Debugging Techniques – Breakpoints When you reach a breakpoint during execution, the VI pauses and the Pause button appears red You can take the following actions at a breakpoint: Single-step through execution using the single-stepping buttons Probe wires to check intermediate values Change values of front panel controls Click the Pause button to continue running to the next breakpoint or until the VI finishes running

    89. Steps to Create a SubVI Create the Icon Create the Connector Assign Terminals Save the VI Insert the VI into a Top Level VI

    90. Icon and Connector An icon represents a VI in other block diagrams A connector shows available terminals for data transfer Every VI displays an icon, shown above, in the upper right corner of the front panel and block diagram windows. An icon is a graphical representation of a VI. It can contain text, images, or a combination of both. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI. The connector shows terminals available for transfer or data to and from the subVI. There are several connector patterns to choose from. Right click on the connector and select the pattern from the Patterns menu. From there you can assign controls and indicators on the front panel to the connector terminal, as we will see later. Every VI displays an icon, shown above, in the upper right corner of the front panel and block diagram windows. An icon is a graphical representation of a VI. It can contain text, images, or a combination of both. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI. The connector shows terminals available for transfer or data to and from the subVI. There are several connector patterns to choose from. Right click on the connector and select the pattern from the Patterns menu. From there you can assign controls and indicators on the front panel to the connector terminal, as we will see later.

    91. Create the Icon Right-click on the icon in the block diagram or front panel Create custom icons to replace the default icon by right-clicking the icon in the upper right corner of the front panel or block diagram and selecting Edit Icon from the shortcut menu or by double-clicking the icon in the upper right corner of the front panel. You also can edit icons by selecting File»VI Properties, selecting General from the Category pull-down menu, and clicking the Edit Icon button. Use the tools on the left side of the Icon Editor dialog box to create the icon design in the editing area. The normal size image of the icon appears in the appropriate box to the right of the editing area. You also can drag a graphic from anywhere in your file system and drop it in the upper right corner of the front panel or block diagram. LabVIEW converts the graphic to a 32 × 32 pixel icon. Create custom icons to replace the default icon by right-clicking the icon in the upper right corner of the front panel or block diagram and selecting Edit Icon from the shortcut menu or by double-clicking the icon in the upper right corner of the front panel. You also can edit icons by selecting File»VI Properties, selecting General from the Category pull-down menu, and clicking the Edit Icon button. Use the tools on the left side of the Icon Editor dialog box to create the icon design in the editing area. The normal size image of the icon appears in the appropriate box to the right of the editing area. You also can drag a graphic from anywhere in your file system and drop it in the upper right corner of the front panel or block diagram. LabVIEW converts the graphic to a 32 × 32 pixel icon.

    92. Create the Connector To use a VI as a subVI, you need to build a connector pane. The connector pane is a set of terminals that corresponds to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages. The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI. Define connections by assigning a front panel control or indicator to each of the connector pane terminals. To define a connector pane, right-click the icon in the upper right corner of the front panel window and select Show Connector from the shortcut menu. The connector pane replaces the icon. Each rectangle on the connector pane represents a terminal. Use the rectangles to assign inputs and outputs. The number of terminals LabVIEW displays on the connector pane depends on the number of controls and indicators on the front panel. The above front panel has four controls and one indicator, so LabVIEW displays four input terminals and one output terminal on the connector pane.To use a VI as a subVI, you need to build a connector pane. The connector pane is a set of terminals that corresponds to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages. The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI. Define connections by assigning a front panel control or indicator to each of the connector pane terminals. To define a connector pane, right-click the icon in the upper right corner of the front panel window and select Show Connector from the shortcut menu. The connector pane replaces the icon. Each rectangle on the connector pane represents a terminal. Use the rectangles to assign inputs and outputs. The number of terminals LabVIEW displays on the connector pane depends on the number of controls and indicators on the front panel. The above front panel has four controls and one indicator, so LabVIEW displays four input terminals and one output terminal on the connector pane.

    93. Assign Terminals After you select a pattern to use for your connector pane, you must define connections by assigning a front panel control or indicator to each of the connector pane terminals. When you link controls and indicators to the connector pane, place inputs on the left and outputs on the right to prevent complicated, unclear wiring patterns in your VIs. To assign a terminal to a front panel control or indicator, click a terminal of the connector pane. Click the front panel control or indicator you want to assign to the terminal. Click an open area of the front panel. The terminal changes to the data type color of the control to indicate that you connected the terminal. You also can select the control or indicator first and then select the terminal. Make sure you save the VI after you have made the terminal assignments.After you select a pattern to use for your connector pane, you must define connections by assigning a front panel control or indicator to each of the connector pane terminals. When you link controls and indicators to the connector pane, place inputs on the left and outputs on the right to prevent complicated, unclear wiring patterns in your VIs. To assign a terminal to a front panel control or indicator, click a terminal of the connector pane. Click the front panel control or indicator you want to assign to the terminal. Click an open area of the front panel. The terminal changes to the data type color of the control to indicate that you connected the terminal. You also can select the control or indicator first and then select the terminal. Make sure you save the VI after you have made the terminal assignments.

    94. Save The VI Choose an Easy to Remember Location Organize by Functionality Save Similar VIs into one directory (e.g. Math Utilities) Organize by Application Save all VIs Used for a Specific Application into one directory or library file (e.g. Lab 1 – Frequency Response) Library Files (.llbs) combine many VI’s into a single file, ideal for transferring entire applications across computers There are several ways to organize your subVIs. The most common way is to organize by application. In this case, all the VI’s for a particular application are saved into the same directory or into a VI Library file. Saving into a library file allows you to transport an entire application within a single file. Saving into library is simple. After clicking Save As…, click New VI Library. This will allow you to name the library, and then save your VI into it. To add subsequent VI’s, simply double click the .llb file from the standard Save window, and give the VI a name. There are several ways to organize your subVIs. The most common way is to organize by application. In this case, all the VI’s for a particular application are saved into the same directory or into a VI Library file. Saving into a library file allows you to transport an entire application within a single file. Saving into library is simple. After clicking Save As…, click New VI Library. This will allow you to name the library, and then save your VI into it. To add subsequent VI’s, simply double click the .llb file from the standard Save window, and give the VI a name.

    95. Insert the SubVI into a Top Level VI After you build a VI and create its icon and connector pane, you can use it as a subVI. To place a subVI on the block diagram, select Functions»Select a VI. Navigate to and double-click the VI you want to use as a subVI and place it on the block diagram. You also can place an open VI on the block diagram of another open VI by using the Positioning tool to click the icon in the upper right corner of the front panel or block diagram of the VI you want to use as a subVI and drag the icon to the block diagram of the other VI.After you build a VI and create its icon and connector pane, you can use it as a subVI. To place a subVI on the block diagram, select Functions»Select a VI. Navigate to and double-click the VI you want to use as a subVI and place it on the block diagram. You also can place an open VI on the block diagram of another open VI by using the Positioning tool to click the icon in the upper right corner of the front panel or block diagram of the VI you want to use as a subVI and drag the icon to the block diagram of the other VI.

    96. While Loops – Tunnels Tunnels transfer data into and out of structures The tunnel adopts the color of the data type wired to the tunnel Data pass out of a loop after the loop terminates When a tunnel passes data into a loop, the loop executes only after data arrive at the tunnel

    97. While Loops - Error Checking and Error Handling Use an error cluster in a While Loop to stop the While Loop if an error occurs

    98. Iterative Data Transfer When programming with loops, you often need to know the values of data from previous iterations of the loop Shift registers transfer values from one loop iteration to the next

    99. Iterative Data Transfer – Shift Registers Right-click the border and select Add Shift Register from the shortcut menu Right shift register stores data on completion of an iteration Left shift register provides stored data at beginning of the next iteration

    100. Iterative Data Transfer – Initializing

    101. Communicating between loops There is no way to communicate between parallel loops using data flow. Data cannot enter or leave a structure while it’s still running via dataflow. Variables are block diagram elements that allow you to access or store data in another location. Local variables store data in front panel controls and indicators. Variables allow you to circumvent normal dataflow by passing data from one place to another without connecting the two places with a wire There is no way to communicate between parallel loops using data flow. Data cannot enter or leave a structure while it’s still running via dataflow. Variables are block diagram elements that allow you to access or store data in another location. Local variables store data in front panel controls and indicators. Variables allow you to circumvent normal dataflow by passing data from one place to another without connecting the two places with a wire

    102. Local variables are located in the Structures subpalette of the Functions palette. When you place a local variable on the diagram, it contains by default the name (owned label) of the first object you placed on the front panel. You use a local variable by first selecting the object you want to access. You can either click on the local variable with the Operating tool and select the object (by owned label) you want to access, or pop up on the local variable and choose the object from the Select Item menu. Next, you must decide to either read or write to the object. Right click on the local variable and choose Change To Read or Change to Write.Local variables are located in the Structures subpalette of the Functions palette. When you place a local variable on the diagram, it contains by default the name (owned label) of the first object you placed on the front panel. You use a local variable by first selecting the object you want to access. You can either click on the local variable with the Operating tool and select the object (by owned label) you want to access, or pop up on the local variable and choose the object from the Select Item menu. Next, you must decide to either read or write to the object. Right click on the local variable and choose Change To Read or Change to Write.

    103. Creating Local Variables Right-click the Variable and select Change To Read. This means that instead of writing data to local variable we read data already written to the variable. Repeat the process for the Stop button. Right-click on the Stop Button on the Front Panel and change the Mechanical Action to Switch When Released. Local Variables cannot store latched Boolean data. The finished code will look as follows: Run the VI. Notice how we can control the LED values and stop two loops with one control. Save the VI. (End of Exercise)Right-click the Variable and select Change To Read. This means that instead of writing data to local variable we read data already written to the variable. Repeat the process for the Stop button. Right-click on the Stop Button on the Front Panel and change the Mechanical Action to Switch When Released. Local Variables cannot store latched Boolean data. The finished code will look as follows: Run the VI. Notice how we can control the LED values and stop two loops with one control. Save the VI. (End of Exercise)

    104. Shared Variables Shared Variables are used to send data between VIs. Variable Types: Single Process: share the data among VIs on the local computer. Network-published: communicate between VIs, remote computers, and hardware through the Shared Variable Engine. Shared Variable must exist within a project library. Shared Variable must be deployed to be available to other projects and remote computers. Shared variables are used to share data among VIs or between locations in an application that cannot be connected with wires. There are two variable types: Single Process: create shared variables that you want to read and write on a single computer. Network-published: create shared variables that you want to read and write on remote computers and targets on the same network. These shared variables must be inside project libraries. If you create a shared variable from a target or folder that is not inside a project library, LabVIEW creates a new project library and places the shared variable inside. You must deploy a shared variable for the variable to be available to other projects and remote computers. You can do by running the VI in which the shared variable resides. You also can right-click the owning project library of the shared variable and select Deploy from the shortcut menu. Shared variables are used to share data among VIs or between locations in an application that cannot be connected with wires. There are two variable types: Single Process: create shared variables that you want to read and write on a single computer. Network-published: create shared variables that you want to read and write on remote computers and targets on the same network. These shared variables must be inside project libraries. If you create a shared variable from a target or folder that is not inside a project library, LabVIEW creates a new project library and places the shared variable inside. You must deploy a shared variable for the variable to be available to other projects and remote computers. You can do by running the VI in which the shared variable resides. You also can right-click the owning project library of the shared variable and select Deploy from the shortcut menu.

    105. Arrays An array consists of elements and dimensions Elements: data that make up the array Dimension: the length, height, or depth of an array An array can have one or more dimensions and as many as (231)–1 elements per dimension, memory permitting Consider using arrays when you work with a collection of similar data and when you perform repetitive computations

    106. Arrays The first element shown in the array (3.00) is at index 1 and the second element (1.00) is at index 2 The element at index 0 is not shown in this image, because element 1 is selected in the index display The element selected in the index display always refers to the element shown in the upper left corner of the element display

    107. Arrays – Creating Place an array shell on the front panel Drag a data object or element into the array shell

    108. Arrays – 2D Array Stores elements in a grid Requires a column index and a row index to locate an element, both of which are zero-based To create a multidimensional array on the front panel, right-click the index display and select Add Dimension from the shortcut menu You also can resize the index display until you have as many dimensions as you want

    109. Arrays – Initializing You can initialize an array, or leave it uninitialized For initialized arrays, you define the number of elements in each dimension, and the contents of each element Uninitialized arrays have dimension but no elements

    110. Arrays – Auto-indexing If you wire an array to or from a For Loop or While Loop, you can link each iteration of the loop to an element in that array by enabling auto-indexing on tunnel The tunnel changes from a solid square to the image shown above to indicate auto-indexing

    111. Arrays – Auto-indexing Input For Loop executes a number of times equal to the number of elements in the array

    112. Arrays – Auto-indexing Output When you auto-index an array output tunnel, the output array receives a new element from every iteration of the loop Auto-indexed output arrays are always equal in size to the number of iterations

    113. Arrays – Creating 2D Arrays You can use two For Loops, one inside the other, to create a 2D array

    114. Textual Math in LabVIEW Integrate existing scripts with LabVIEW for faster development Interactive, easy-to-use, hands-on learning environment Develop algorithms, explore mathematical concepts, and analyze results using a single environment Freedom to choose the most effective syntax, whether graphical or textual within one VI Overview With the release of National Instruments LabVIEW 8, you have new freedom to choose the most effective syntax for technical computing, whether you are developing algorithms, exploring DSP concepts, or analyzing results. You can instrument your scripts and develop algorithms on the block diagram by interacting with popular third-party math tools such as The MathWorks Inc. MATLAB software, Mathematica, Maple, Mathcad, IDL and Xmath. Use of these math tools with LabVIEW is achieved in a variety of ways depending on the vendor as listed below: Native LabVIEW textual math node: MathScript node, Formula node Communication with vendor software through LabVIEW node: Xmath node, MATLAB script node, Maple* node, IDL* node Communication with vendor software through VI Server: Mathematica* VIs, and Mathcad* VIs In LabVIEW 8, you can combine the intuitive LabVIEW graphical dataflow programming with MathScript, a math-oriented textual programming language that is generally compatible with popular m-file script language. *LabVIEW toolkit specific to the math tool must be installed.Overview With the release of National Instruments LabVIEW 8, you have new freedom to choose the most effective syntax for technical computing, whether you are developing algorithms, exploring DSP concepts, or analyzing results. You can instrument your scripts and develop algorithms on the block diagram by interacting with popular third-party math tools such as The MathWorks Inc. MATLAB software, Mathematica, Maple, Mathcad, IDL and Xmath. Use of these math tools with LabVIEW is achieved in a variety of ways depending on the vendor as listed below: Native LabVIEW textual math node: MathScript node, Formula node Communication with vendor software through LabVIEW node: Xmath node, MATLAB script node, Maple* node, IDL* node Communication with vendor software through VI Server: Mathematica* VIs, and Mathcad* VIs In LabVIEW 8, you can combine the intuitive LabVIEW graphical dataflow programming with MathScript, a math-oriented textual programming language that is generally compatible with popular m-file script language.

    115. Math with the MathScript Node Implement equations and algorithms textually Input and Output variables created at the border Generally compatible with popular m-file script language Terminate statements with a semicolon to disable immediate output The MathScript Node enhances LabVIEW by adding a native text-based language for mathematical algorithm implementation in the graphical programming environment. M-file scripts you’ve written and saved from the MathScript window can be opened and used in the MathScript node. M-file scripts you created in other math software will generally run as well. The MathScript allows you to pick the syntax you are most comfortable with to solve the problem. Equations can be instrumented with the MathScript Node for parameter exploration, simulation, or deployment in a final application. The MathScript Node: Located in the Programming»Structures subpalette. Resizable box for entering textual computations directly into block diagrams. To add variables, right-click and choose Add Input or Add Output. Name variables as they are used in formula. (Names are case sensitive.) The data type of the output can be changed by right-clicking the input or output node. Statements should be terminated with a semicolon to suppress output. Ability to import & export m-files by right-clicking on the node. The MathScript Node enhances LabVIEW by adding a native text-based language for mathematical algorithm implementation in the graphical programming environment. M-file scripts you’ve written and saved from the MathScript window can be opened and used in the MathScript node. M-file scripts you created in other math software will generally run as well. The MathScript allows you to pick the syntax you are most comfortable with to solve the problem. Equations can be instrumented with the MathScript Node for parameter exploration, simulation, or deployment in a final application. The MathScript Node: Located in the Programming»Structures subpalette. Resizable box for entering textual computations directly into block diagrams. To add variables, right-click and choose Add Input or Add Output. Name variables as they are used in formula. (Names are case sensitive.) The data type of the output can be changed by right-clicking the input or output node. Statements should be terminated with a semicolon to suppress output. Ability to import & export m-files by right-clicking on the node.

    116. The Interactive MathScript Window Rapidly develop and test algorithms The MathScript Window provides an interactive environment where equations can be prototyped and calculations can be made. The MathScript Window and Node share a common syntax and global variables making the move from prototype to implementation seamless. The data preview pane provides a convenient way to view variable data as numbers, graphically, or audibly (with soundcard support). Help for MathScript Help for the environment can be accessed using the Mathscript Interactive Environment Window. Type Help in the command window for an introduction to MathScript help. Help followed by a function will display help specific to that function. Features of the interactive MathScript Window: Prototype equations and formulas through the command Window Easily access function help by typing Help <function> in the Command Window Select a variable to display its data in the Preview Pane and even listen to the result Write, Save, Load, and Run m-files using the Script tab Share data between the MathScript Node in LabVIEW and the MathScript Window using Global Variables Advanced plotting features and image export features The MathScript Window provides an interactive environment where equations can be prototyped and calculations can be made. The MathScript Window and Node share a common syntax and global variables making the move from prototype to implementation seamless. The data preview pane provides a convenient way to view variable data as numbers, graphically, or audibly (with soundcard support). Help for MathScript Help for the environment can be accessed using the Mathscript Interactive Environment Window. Type Help in the command window for an introduction to MathScript help. Help followed by a function will display help specific to that function. Features of the interactive MathScript Window: Prototype equations and formulas through the command Window Easily access function help by typing Help <function> in the Command Window Select a variable to display its data in the Preview Pane and even listen to the result Write, Save, Load, and Run m-files using the Script tab Share data between the MathScript Node in LabVIEW and the MathScript Window using Global Variables Advanced plotting features and image export features

More Related