Basic Labview
Basic Labview
TM
Support Worldwide Technical Support and Product Information ni.com National Instruments Corporate Headquarters 11500 North Mopac Expressway Worldwide Offices Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599, Canada 800 433 3488, China 86 21 6555 7838, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 385 0 9 725 725 11, France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, India 91 80 41190000, Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970, Korea 82 02 3451 3400, Lebanon 961 0 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 0 348 433 466, New Zealand 0800 553 322, Norway 47 0 66 90 76 60, Poland 48 22 3390150, Portugal 351 210 311 210, Russia 7 095 783 68 51, Singapore 1800 226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 02 2377 2222, Thailand 662 278 6777, United Kingdom 44 0 1635 523545 For further support information, refer to the Technical Support and Professional Services appendix. To comment on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback. 20032006 National Instruments Corporation. All rights reserved. Austin, Texas 78759-3504 USA Tel: 512 683 0100
Important Information
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free. A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are covered by warranty. National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected. In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it. EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CUSTOMERS RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover damages, defects, malfunctions, or service failures caused by owners failure to follow the National Instruments installation, operation, or maintenance instructions; owners modification of the product; owners abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation. National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction. In regards to components used in USI (Xerces C++, ICU, and HDF5), the following copyrights apply. For a listing of the conditions and disclaimers, refer to the USICopyrights.chm. This product includes software developed by the Apache Software Foundation (http://www.apache.org/). Copyright 1999 The Apache Software Foundation. All rights reserved. Copyright 19952003 International Business Machines Corporation and others. All rights reserved. NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities Copyright 1998, 1999, 2000, 2001, 2003 by the Board of Trustees of the University of Illinois. All rights reserved.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on ni.com/legal for more information about National Instruments trademarks. FireWire is the trademark of Apple Computer, Inc., registered in the U.S. and other countries. Other product and company names mentioned herein are trademarks or trade names of their respective companies. Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have no agency, partnership, or joint-venture relationship with National Instruments.
Patents
For patents covering National Instruments products, refer to the appropriate location: HelpPatents in your software, the patents.txt file on your CD, or ni.com/patents.
DAMAGE, INJURY, OR DEATH, THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES, INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS. BECAUSE EACH END-USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS' TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT EVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELY RESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER NATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUT LIMITATION, THE APPROPRIATE DESIGN, PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.
Contents
About This Manual
Conventions ...................................................................................................................ix Related Documentation..................................................................................................x
Chapter 2 Customizing a VI
Building a VI from a Blank VI ......................................................................................2-1 Opening a Blank VI.........................................................................................2-1 Adding an Express VI That Simulates a Signal ..............................................2-2 Searching the Help and Modifying a Signal....................................................2-3 Customizing a User Interface from the Block Diagram..................................2-4 Configuring a VI to Run Continuously until the User Stops It .......................2-5 Using the Error List Window ..........................................................................2-7 Controlling the Speed of Execution ................................................................2-8
Contents
Using a Table to Display Data ........................................................................ 2-8 Searching for Examples .................................................................................. 2-9 Summary........................................................................................................................ 2-11 Using the LabVIEW Help Resources ............................................................. 2-11 Customizing the Block Diagram Code ........................................................... 2-12 Creating Controls and Indicators ...................................................... 2-12 Controlling When a VI Stops Running............................................. 2-12 Errors and Broken Wires .................................................................. 2-12 Displaying Data in a Table ............................................................... 2-13 Using the NI Example Finder ......................................................................... 2-13 Shortcuts.......................................................................................................... 2-13
vi
ni.com
Contents
vii
Conventions
The following conventions appear in this manual: The symbol leads you through nested menu items and dialog box options to a final action. The sequence FilePage SetupOptions directs you to pull down the File menu, select the Page Setup item, and select Options from the last dialog box. This icon denotes a tip, which alerts you to advisory information. This icon denotes a note, which alerts you to important information. bold Bold text denotes items that you must select or click in the software, such as menu items and dialog box options. Bold text also denotes parameter names, controls and indicators on the front panel, dialog boxes, sections of dialog boxes, menu names, and palette names. Italic text denotes variables, emphasis, a cross-reference, or an introduction to a key concept. Italic text also denotes text that is a placeholder for a word or value that you must supply. Text in this font denotes text or characters that you should enter from the keyboard, sections of code, programming examples, and syntax examples. This font is also used for the proper names of disk drives, paths, directories, programs, subprograms, subroutines, device names, operations, variables, filenames, and extensions.
italic
monospace
ix
monospace bold
Bold text in this font denotes the messages and responses that the computer automatically prints to the screen. This font also emphasizes lines of code that are different from the other examples. Text in this font denotes a specific platform and indicates that the text following it applies only to that platform.
(Mac OS) Press <Command>-click to perform the same action as a
Platform
right-click
right-click.
Related Documentation
The following documents contain information that you may find helpful as you read this manual: LabVIEW Release NotesUse these release notes to install and uninstall LabVIEW. The release notes also describe the system requirements for the LabVIEW software, including the LabVIEW Application Builder. LabVIEW HelpUse the LabVIEW Help to access information about LabVIEW programming concepts, step-by-step instructions for using LabVIEW, and reference information about LabVIEW VIs, functions, palettes, menus, tools, properties, methods, events, dialog boxes, and so on. The LabVIEW Help also lists the LabVIEW documentation resources available from National Instruments. Access the LabVIEW Help by selecting HelpSearch the LabVIEW Help. LabVIEW Quick Reference CardUse this card as a reference for information about help resources, keyboard shortcuts, data type terminals, and tools for editing, execution, and debugging.
ni.com
LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data, as well as tools to help you troubleshoot code you write. In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output displays. After you build the user interface, you add code using VIs and structures to control the front panel objects. The block diagram contains this code. You can use LabVIEW to communicate with hardware such as data acquisition, vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485 instruments.
1-1
Chapter 1
Launching LabVIEW
The Getting Started window, shown in Figure 1-2, appears when you launch LabVIEW. Use this window to create new VIs, select among the most recently opened LabVIEW files, find examples, and launch the LabVIEW Help. You also can access information and resources to help you learn about LabVIEW, such as specific manuals, help topics, and resources on the National Instruments Web site, ni.com.
1-2
ni.com
Chapter 1
The Getting Started window disappears when you open an existing file or create a new file. The Getting Started window reappears when you close all open front panels and block diagrams. You also can display the window from the front panel or block diagram by selecting ViewGetting Started Window.
1-3
Chapter 1
2. 3.
In the Getting Started window, click the New or VI from Template link to display the New dialog box. From the Create New list, select VIFrom TemplateTutorial (Getting Started)Generate and Display. This template VI generates and displays a signal. A preview and a brief description of the template VI appear in the Description section. Figure 1-3 shows the New dialog box and the preview of the Generate and Display template VI.
4.
Click the OK button to create a VI from the template. You also can double-click the name of the template VI in the Create New list to create a VI from a template.
1-4
ni.com
Chapter 1
5.
Examine the front panel of the VI. The user interface, or front panel, appears with a gray background and includes controls and indicators. The title bar of the front panel indicates that this window is the front panel for the Generate and Display VI.
If the front panel is not visible, you can display the front panel by selecting WindowShow Front Panel. You also can switch between the front panel window and block diagram window at any time by pressing the <Ctrl-E> keys. The <Ctrl> key in keyboard shortcuts corresponds to the (Mac OS) <Option> or <Command> key or (Linux) <Alt> key.
Note
6.
Select WindowShow Block Diagram and examine the block diagram of the VI. The block diagram appears with a white background and includes VIs and structures that control the front panel objects. The title bar of the block diagram indicates that this window is the block diagram for the Generate and Display VI.
7.
On the front panel toolbar, click the Run button, shown at left. You also can press the <Ctrl-R> keys to run a VI. A sine wave appears on the graph on the front panel. Stop the VI by clicking the STOP button, shown at left, on the front panel.
8.
Throughout these exercises, you can undo recent edits by selecting EditUndo or pressing the <Ctrl-Z> keys. 1. If the Controls palette, shown in Figure 1-4, is not visible on the front panel, select ViewControls Palette .
Tip
You can right-click any blank space on the front panel or the block diagram to display a temporary version of the Controls or Functions palettes. The Controls or Functions palette appears with a thumbtack icon in the upper left corner. Click the thumbtack to pin the palette so it is no longer temporary.
1-5
Chapter 1
2.
If you are a new LabVIEW user, the Controls palette opens with the Express subpalette visible by default. If you do not see the Express subpalette, click Express on the Controls palette to display the Express subpalette.
3.
Move the cursor over the icons on the Express subpalette to locate the Numeric Controls palette. When you move the cursor over icons on the Controls palette, the name of the subpalette, control, or indicator appears in a tip strip below the icon.
4. 5.
Click the Numeric Controls icon to display the Numeric Controls palette. Click the knob control on the Numeric Controls palette to attach the control to the cursor, then place the knob on the front panel to the left of the waveform graph. You will use this knob in a later exercise to control the amplitude of a signal.
6.
Select FileSave As and save the VI as Acquiring a Signal.vi in an easily accessible location.
1-6
ni.com
Chapter 1
1-7
Chapter 1
4. 5.
Click the OK button to save the current configuration and close the Configure Simulate Signal dialog box. Move the cursor over the down arrows at the bottom of the Simulate Signal Express VI. The down arrows indicate you can reveal hidden inputs and outputs by extending the border of the Express VI. When a double-headed arrow appears, shown at left, click and drag the border of the Express VI to add two rows. When you release the border, the Amplitude input appears. Because the Amplitude input appears on the block diagram, you can configure the amplitude of the sawtooth wave on the block diagram. In Figure 1-5, notice that Amplitude is an option in the Configure Simulate Signal dialog box. When inputs, such as Amplitude, appear on the block diagram and in the configuration dialog box, you can configure the inputs in either location.
6.
1-8
ni.com
Chapter 1
4.
1-9
Chapter 1
Running a VI
Running a VI executes the solution. Complete the following steps to run the Acquiring a Signal VI. 1. 2. 3. Display the front panel by pressing the <Ctrl-E> keys or by clicking the front panel. Click the Run button or press the <Ctrl-R> keys to run the VI. Move the cursor over the knob. The cursor becomes a hand, or the Operating tool, shown at left. Use the Operating tool to change the value of a control. 4. Using the Operating tool, turn the knob to adjust the amplitude of the sawtooth wave. The amplitude of the sawtooth wave changes as you turn the knob. As you change the amplitude, the Operating tool displays a tip strip that indicates the numeric value of the knob. The y-axis on the graph scales automatically to account for the change in amplitude. To indicate that the VI is running, the Run button changes to a darkened arrow, shown at left. You can change the value of most controls while a VI runs, but you cannot edit the VI in other ways while the VI runs. 5. Click the STOP button, shown at left, to stop the VI. The STOP button stops the VI after the VI completes the current iteration. The Abort Execution button, shown at left, stops the VI immediately, before the VI finishes the current iteration. Aborting a VI that uses external resources, such as external hardware, might leave the resources in an unknown state by not resetting or releasing them properly. Design the VIs you create with a stop button to avoid this problem.
1-10
ni.com
Chapter 1
Modifying a Signal
Complete the following steps to scale the signal by 10 and display the results in the graph on the front panel. 1. On the block diagram, use the Positioning tool to double-click the wire that connects the Simulate Signal Express VI to the Waveform Graph terminal, shown at left. Press the <Delete> key to delete this wire. If the Functions palette, shown in Figure 1-6, is not visible, select ViewFunctions Palette to display it. The Functions palette opens with the Express subpalette visible by default. If you have selected another subpalette, you can return to the Express subpalette by clicking Express on the Functions palette.
2. 3.
4.
On the Arithmetic & Comparison palette, select the Formula Express VI, shown at left, and place it on the block diagram inside the loop between the Simulate Signal Express VI and the Waveform Graph terminal. You can move the Waveform Graph terminal to the right to make more room between the Express VI and the terminal. The Configure Formula dialog box appears when you place the Express VI on the block diagram. When you place an Express VI on the block diagram, the configuration dialog box for that VI always appears automatically.
5.
Click the Help button, shown at left, in the bottom right corner of the Configure Formula dialog box to display the LabVIEW Help topic for this Express VI. The Formula help topic describes the Express VI, the configuration dialog box options, and the inputs and outputs of the Express VI. Each Express VI has a corresponding help topic you can access by clicking
1-11
Chapter 1
the Help button in the configuration dialog box or by right-clicking the Express VI and selecting Help from the shortcut menu. 6. 7. 8. In the Formula topic, find the dialog box option whose description indicates that it enters a variable into the formula. Minimize the LabVIEW Help to return to the Configure Formula dialog box. Change the text in the Label text box of the dialog box option you read about from X1 to Sawtooth to indicate the input value to the Formula Express VI. When you click in the String text box at the top of the Configure Formula dialog box, the text changes to match the label you entered. Define the value of the scaling factor by entering *10 after Sawtooth in the String text box. You can use the Input buttons in the configuration dialog box or you can use the *, 1, and 0 keyboard buttons to enter the scaling factor. If you use the Input buttons in the configuration dialog box, LabVIEW places the formula input after the Sawtooth input in the String text box. If you use the keyboard, click in the String text box after Sawtooth and enter the formula you want to appear in the text box.
9.
1-12
ni.com
Chapter 1
The Configure Formula dialog box should appear similar to Figure 1-7.
Figure 1-7. Configure Formula Dialog Box Note If you enter a formula in the String text box that is not valid, the Errors LED, in the upper right corner turns gray and displays the text Invalid Formula.
10. Click the OK button to save the current configuration and close the Configure Formula dialog box. 11. Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI. 12. When the Wiring tool appears, click the arrow on the Sawtooth output and then click the arrow on the Sawtooth input of the Formula Express VI, shown at left, to wire the two objects together. 13. Use the Wiring tool to wire the Result output of the Formula Express VI to the Waveform Graph terminal.
1-13
Chapter 1
Examine the wires connecting the Express VIs and terminals. The arrows on the Express VIs and terminals indicate the direction that the data flows along these wires. The block diagram should appear similar to Figure 1-8.
Tip
You can right-click any wire and select Clean Up Wire from the shortcut menu to have LabVIEW automatically find a route for the wire around existing objects on the block diagram. LabVIEW also routes a wire to decrease the number of bends in the wire.
14. Press the <Ctrl-S> keys or select FileSave to save the VI.
1-14
ni.com
Chapter 1
3. 4.
Press the <Ctrl-S> keys or select FileSave to save the VI. Return to the front panel, run the VI, and turn the knob control. The graph plots the sawtooth wave and the scaled signal. The maximum value on the y-axis automatically changes to be 10 times the knob value. This scaling occurs because you configured the Formula Express VI to generate a slope of 10.
5.
1-15
Chapter 1
The Knob Properties dialog box should appear similar to Figure 1-10.
3.
Click the Scale tab and in the Scale Style section, place a checkmark in the Show color ramp checkbox. The knob on the front panel updates to reflect these changes. Click the OK button to save the current configuration and close the Knob Properties dialog box. Save the VI. Reopen the Knob Properties dialog box and experiment with other properties of the knob. For example, on the Scale page, try changing the colors for the Marker text color by clicking the color box. Click the Cancel button to avoid applying any changes you made while experimenting. If you want to keep the changes you made, click the OK button.
4. 5. 6.
7.
1-16
ni.com
Chapter 1
3.
Right-click the waveform graph and select Properties from the shortcut menu to display the Waveform Graph Properties dialog box. On the Plots page, select Sawtooth from the pull-down menu. In the Colors section, click the Line color box to display the color picker. Select a new line color. Select Sawtooth (Formula Result) from the pull-down menu. Place a checkmark in the Do not use waveform names for plot names checkbox. In the Name text box, delete the current label and change the name of this plot to Scaled Sawtooth.
4.
5. 6. 7.
1-17
Chapter 1
8.
Click the OK button to save the current configuration and close the Waveform Graph Properties dialog box. The plot color on the front panel changes. Reopen the Waveform Graph Properties dialog box and experiment with other properties of the graph. For example, on the Scales page, try disabling automatic scaling and changing the minimum and maximum value of the y-axis.
9.
10. Click the Cancel button to avoid applying any changes you made while experimenting. If you want to keep the changes you made, click the OK button. 11. Save and close the VI.
Summary
The following topics are a summary of the main concepts you learned in this chapter.
Front Panel
The front panel is the user interface of a VI. You build the front panel by using controls and indicators, which are the interactive input and output terminals of the VI, respectively. Controls and indicators are located on the Controls palette. Controls are knobs, push buttons, dials, and other input mechanisms. Controls simulate instrument input mechanisms and supply data to the block diagram of the VI.
1-18
ni.com
Chapter 1
Indicators are graphs, LEDs, and other displays. Indicators simulate instrument output mechanisms and display data the block diagram acquires or generates.
Block Diagram
The block diagram contains the graphical source code, also known as G code or block diagram code, for how the VI runs. The block diagram code uses graphical representations of functions to control the front panel objects. Front panel objects appear as icon terminals on the block diagram. Wires connect control and indicator terminals to Express VIs, VIs, and functions. Data flows through the wires from controls to VIs and functions, from VIs and functions to other VIs and functions, and from VIs and functions to indicators. The movement of data through the nodes on the block diagram determines the execution order of the VIs and functions. This movement of data is known as dataflow programming.
Express VIs
Use Express VIs located on the Functions palette for common measurement tasks. When you place an Express VI on the block diagram, the dialog box you use to configure that Express VI appears by default. Set the options in this configuration dialog box to specify how the Express VI behaves. You also can double-click an Express VI or right-click an Express VI and select Properties from the shortcut menu to display the configuration dialog box. If you wire data to an Express VI and run it, the
1-19
Chapter 1
Express VI displays real data in the configuration dialog box. If you close and reopen the Express VI, the VI displays sample data in the configuration dialog box until you run the VI again. Express VIs appear on the block diagram as expandable nodes with icons surrounded by a blue field. You can resize an Express VI to display its inputs and outputs. The inputs and outputs you can display for the Express VI depend on how you configure the VI.
1-20
ni.com
Chapter 1
Shortcuts
This chapter introduced the following keyboard shortcuts.
Note The <Ctrl> key in these shortcuts corresponds to the (Mac OS) <Option> or <Command> key or (Linux) <Alt> key.
Function
Undoes the last action. Switches between the block diagram and the front panel window. Saves a VI.
1-21
Customizing a VI
You can choose one of many LabVIEW template VIs to use as a starting point when building VIs. However, sometimes you need to build a VI for which a template is not available. This chapter teaches you how to build and customize a VI without using a template.
Opening a Blank VI
If no template is available for the VI you want to build, you can start with a blank VI and add Express VIs to accomplish a specific task.
2-1
Chapter 2
Customizing a VI
Complete the following steps to open a blank VI. 1. In the Getting Started window, click the Blank VI link in the New section or press the <Ctrl-N> keys to open a blank VI. A blank front panel window and block diagram window appear.
Note
You also can open a blank VI by selecting FileNew VI or by selecting FileNew and selecting Blank VI from the Create New list. 2. If the Functions palette is not visible, right-click any blank space on the block diagram to display a temporary version of the Functions palette. Click the thumbtack, shown at left, in the upper left corner of the Functions palette to pin the palette so it is no longer temporary.
Tip
You also can press the <Ctrl-H> keys to display the Context Help window. (Mac OS) Press the <Command-Shift-H> keys.
2.
On the Functions palette, select the ExpressInput palette and move the cursor over one of the Express VIs on the Input palette. When you move the cursor over a VI, the Context Help window displays information about that VI.
3.
Use the information that appears in the Context Help window to find the Express VI that can simulate a sine wave signal.
2-2 ni.com
Chapter 2
Customizing a VI
Keep the Context Help window open. The context help provides useful information as you complete the rest of this exercise. 4. 5. Select the Express VI and place it on the block diagram. The Configure Simulate Signal dialog box appears. Move the cursor over the various options in the Configure Simulate Signal dialog box, such as Frequency (Hz), and Amplitude. Read the information that appears in the Context Help window. Configure the Simulate Signal Express VI to generate a sine wave with a frequency of 10.7 and amplitude of 2. The signal in the Result Preview window changes to reflect the configured sine wave. 7. 8. Click the OK button to save the current configuration and close the Configure Simulate Signal dialog box. Move the cursor over the Simulate Signal Express VI and read the information that appears in the Context Help window. The Context Help window displays configuration information about the Simulate Signal Express VI. 9. Save the VI as Reduce Samples.vi in an easily accessible location.
6.
2-3
Chapter 2
Customizing a VI
3. 4. 5. 6. 7. 8. 9.
Double-click the Sample Compression topic in the search results to display the topic that describes the Sample Compression Express VI. After you read the description of the Express VI, click the Place on the block diagram button to place the Express VI on the cursor. Move the cursor to the block diagram. Place the Sample Compression Express VI on the block diagram to the right of the Simulate Signal Express VI. Configure the Sample Compression Express VI to reduce the signal by a factor of 25 using the mean of these values. Click the OK button to save the current configuration and close the Configure Sample Compression dialog box. Use the Wiring tool to wire the Sine output of the Simulate Signal Express VI to the Signals input of the Sample Compression Express VI.
2.
Chapter 2
Customizing a VI
4.
Right-click the wire that connects the Sine output of the Simulate Signal Express VI to the Signals input of the Sample Compression Express VI and select CreateGraph Indicator from the shortcut menu. Use the Wiring tool to wire the Mean output of the Sample Compression Express VI to the Sine graph indicator. The Merge Signals function appears. Arrange the objects on the block diagram so they appear similar to Figure 2-3.
5.
6.
7.
Display the front panel. The controls and indicators you added appear on the front panel with labels that correspond to the inputs and outputs from which you created the controls and indicators.
Note
You might need to scroll or resize the front panel to see all controls and indicators. 8. Save the VI.
2-5
Chapter 2
Customizing a VI
The VI runs once and then stops. The front panel does not have a stop button. 2. 3. Display the block diagram. Click the Search button, shown at left, on the Functions palette, and enter While in the text box. LabVIEW searches as you type and displays any matches in the search results text box. LabVIEW displays a folder glyph to the left of subpalettes in the search results and displays a light blue glyph to the left of Express VIs in the search results. Double-click While Loop <<Execution Control>> to display the Execution Control subpalette and temporarily highlight the While Loop on the subpalette. Select the While Loop on the Execution Control palette. Move the cursor to the upper left corner of the block diagram. Click to place the top left corner of the While Loop. Drag the cursor diagonally to enclose all the Express VIs and wires, as shown in Figure 2-4.
4.
5. 6. 7.
Figure 2-4. Placing the While Loop around the Express VIs
8.
Click to create the While Loop around the Express VIs and wires. The While Loop, shown at left, appears with a STOP button wired to the conditional terminal. This While Loop is configured to stop when the user clicks the STOP button.
9.
Display the front panel and run the VI. The VI now runs until you click the STOP button. A While Loop executes the VIs and functions inside the loop until the user clicks the STOP button.
2-6
ni.com
Chapter 2
Customizing a VI
You also can move the Wiring tool over a broken wire to display a tip strip that describes why the wire is broken. This information also appears in the Context Help window when you move the Wiring tool over a broken wire.
Tip
6. 7.
In the errors and warnings list, double-click the Wire: has loose ends error to highlight the broken wire. Press the <Ctrl-B> keys to delete the broken wire.
Pressing the <Ctrl-B> keys deletes all broken wires on the block diagram. You can press the <Delete> key to delete only the selected wire. 8. Select ViewError List to display the Error list window. No errors appear in the errors and warnings field.
Tip
You also can press the <Ctrl-L> keys to display the Error list window. 9. Click the Close button to close the Error list window. The Run button no longer appears broken.
2-7
Chapter 2
Customizing a VI
2.
2-8
ni.com
Chapter 2
Customizing a VI
If you drag objects near the border of the While Loop, the loop resizes to enclose the Build Table Express VI and the Table terminal. When you place an object in a While Loop near the border, the loop resizes to add space for that object. 5. Use the Wiring tool to wire the Mean output of the Sample Compression Express VI to the Signals input of the Build Table Express VI. The block diagram should appear similar to Figure 2-5.
6. 7.
Display the front panel and run the VI. Click the Enable switch. If the Enable switch is on, the table displays the mean values of every 25 samples of the sine wave. If the Enable switch is off, the table does not record the mean values.
8. 9.
Stop the VI. Experiment with properties of the table by using the Table Properties dialog box. For example, try changing the number of columns to one.
2-9
Chapter 2
Customizing a VI
Complete the following steps to find and open an example that uses the Time Delay Express VI. 1. 2. Select HelpSearch the LabVIEW Help to display the LabVIEW Help. Click the Search tab, enter "time delay" in the Type in the word(s) to search for text box, and press the <Enter> key.
Tip Before you search, you can narrow the search results by placing a checkmark in the Search titles only checkbox near the bottom of the help window. You also can use operators such as AND, OR, and NEAR in the Type in the word(s) to search for text box to narrow the search results. Refer to the Using Help book on the Contents tab in the LabVIEW Help for more information about searching help.
3.
Click the Location column header to sort the search results by content type. Reference topics contain reference information about LabVIEW objects such as VIs, functions, palettes, menus, and tools. How-To topics contain step-by-step instructions for using LabVIEW. Concept topics contain information about LabVIEW programming concepts. Double-click the Time Delay search result to display the reference topic that describes the Time Delay Express VI. After you read the description of the Express VI, click the Open example button in the Example section near the bottom of the topic to open an example that uses the Time Delay Express VI. Click the Browse related examples button to open the NI Example Finder and display a list of examples similar to the example that uses this VI. The NI Example Finder searches among hundreds of examples, including all installed examples and the examples located on the NI Developer Zone at ni.com/zone. You can modify an example to fit an application, or you can copy and paste from one or more examples into a VI that you create. You also can right-click a VI or function on the block diagram or on a pinned palette and select Examples from the shortcut menu to display a help topic with links to examples for that VI or function. To launch the NI Example Finder and browse or search examples, select HelpFind Examples or click the Find Examples link in the Examples section of the Getting Started window.
4. 5.
6.
7.
After you experiment with the NI Example Finder and the example VIs, close the NI Example Finder.
2-10
ni.com
Chapter 2
Customizing a VI
Summary
The following topics are a summary of the main concepts you learned in this chapter.
2-11
Chapter 2
Customizing a VI
2-12
ni.com
Chapter 2
Customizing a VI
list window. Click the Help button for more information about why the wire is broken.
Shortcuts
This chapter introduced the following keyboard shortcuts.
Note The <Ctrl> key in these shortcuts corresponds to the (Mac OS) <Option> or <Command> key or (Linux) <Alt> key.
Function Opens a new, blank VI. Shows or hides the Context Help window. (Mac OS) Press the <Command-Shift-H> keys. Deletes all broken wires in a VI. Displays the Error list window.
2-13
LabVIEW includes a set of Express VIs that help you analyze signals. This chapter teaches you how to use LabVIEW to perform a basic analysis of a signal and how to save the analyzed data to a file.
Note The exercises in this chapter use Express VIs that are available only in the LabVIEW Full and Professional Development Systems.
Building an Analysis VI
In the following exercises, you will build a VI that generates a signal, filters the signal, indicates if the signal exceeds a certain limit, and records the data. After you complete the exercises, the front panel of the VI will look similar to the front panel in Figure 3-1.
You can complete the exercises in this chapter in approximately 40 minutes.
3-1
Chapter 3
3. 4. 5. 6.
3-2
ni.com
Chapter 3
Keep the Context Help window open. It will provide useful information as you complete the rest of this exercise. 7. On the front panel, remove the RMS indicator along with any broken wires on the block diagram that result from removing the indicator. To remove all broken wires from the block diagram, you can press the <Ctrl-B> keys. You will not use the RMS functionality of the Amplitude and Level Measurements Express VI for this exercise. However, you can use the Generate, Analyze, and Display template VI with the RMS functionality in a future project to reduce development time. 8. On the front panel, right-click the waveform graph indicator and select Properties from the shortcut menu. The Graph Properties dialog box appears. On the Appearance tab, place a checkmark in the Visible checkbox in the Label section and enter Unfiltered Signal in the text box.
9.
10. Click the OK button to save the configuration and close the Graph Properties dialog box. 11. Run the VI. The signal appears in the graph. 12. Click the STOP button to stop the VI.
Adding a Signal
The Simulate Signal Express VI simulates a sine wave by default. You can customize the simulated signal by changing the options in the Configure Simulate Signal dialog box. Complete the following steps to create an additional simulated signal that adds uniform white noise to the sine wave. 1. On the block diagram, use the Positioning tool to select the Simulate Signal Express VI. Hold down the <Ctrl> key and drag to create an additional Simulate Signal Express VI on the block diagram. (Mac OS) Hold down the <Option> key and drag. (Linux) Hold down the middle mouse button and drag. 2. Release the mouse button to place the copied Simulate Signal Express VI below the original Simulate Signal Express VI. LabVIEW updates the name of the copied Simulate Signal Express VI to Simulate Signal2.
3-3
Chapter 3
3. 4. 5. 6. 7. 8. 9.
Double-click the Simulate Signal2 Express VI to display the Configure Simulate Signal dialog box. Select Sine from the Signal type pull-down menu. Enter 60 in the Frequency (Hz) text box. Enter .1 in the Amplitude text box. Place a checkmark in the Add noise checkbox to add noise to the sine signal. Select Uniform White Noise from the Noise type pull-down menu. Enter 0.1 in the Noise amplitude text box.
10. Enter -1 in the Seed number text box. 11. In the Timing section, select the Run as fast as possible option. 12. In the Signal Name section, remove the checkmark from the Use signal type name checkbox. 13. Enter 60 Hz and Noise in the Signal name text box. When you change the signal name in the Configure Simulate Signal dialog box, LabVIEW changes the name of the signal output on the block diagram. Changing the signal name makes it easier for you to identify the signal type when you view the Express VI on the block diagram. The Result Preview section displays a random signal. The Configure Simulate Signal dialog box should appear similar to Figure 3-2.
3-4
ni.com
Chapter 3
14. Click the OK button to save the current configuration and close the Configure Simulate Signal dialog box.
2.
3-5
Chapter 3
Simulate Signal Express VIs and the Amplitude and Level Measurements Express VI. 3. The Configure Formula dialog box appears in the Label column. Change the label for X1 to Sine and the label for X2 to 60 Hz and Noise. Click the Input and + buttons to add Sine and 60 Hz and Noise together in the String text box. Click the OK button to save the current configuration and close the Configure Formula dialog box. Use the Wiring tool to wire the Sine output of the Simulate Signal Express VI to the Sine input of the Formula Express VI. Wire the 60 Hz and Noise output of the Simulate Signal2 Express VI to the 60 Hz and Noise input of the Formula Express VI. Wire the Result output of the Formula Express VI to the Unfiltered Signal indicator and to the Signals input of the Amplitude and Level Measurements Express VI. Display the front panel by pressing the <Ctrl-E> keys. The signal with added noise appears in the graph. 11. Click the STOP button to stop the VI. 12. Select FileSave As and save the VI as Analysis.vi in an easily accessible location.
4. 5. 6. 7. 8.
9.
Filtering a Signal
You can use the Filter Express VI to process signals through filters and windows. Complete the following steps to configure the Filter Express VI to filter the signal using an infinite impulse response (IIR) filter. 1. Remove the wire that connects the Result output of the Formula Express VI to the Signals input of the Amplitude and Level Measurements Express VI. Remove all broken wires that result from removing the wire. Search for the Filter Express VI and place it on the block diagram between the Simulate Signal2 Express VI and the Amplitude and Level Measurements Express VI. The Configure Filter dialog box appears. In the Filter Specifications section, change the Cutoff Frequency (Hz) to 25.
2. 3.
4.
3-6
ni.com
Chapter 3
5. 6. 7.
Click the OK button to save the configuration and close the Configure Filter dialog box. Display the front panel. Click the Unfiltered Signal waveform graph indicator on the front panel and press the <Ctrl> key while you drag to create an additional waveform graph indicator. Place the additional waveform graph indicator below the Unfiltered Signal waveform graph. Triple-click the Unfiltered Signal 2 label above the new waveform graph indictor and enter Filtered Signal to change the label of the indicator. You also can change the label on the Appearance page of the Graph Properties dialog box.
8. 9.
10. On the block diagram, wire the Result output of the Formula Express VI to the Signal input of the Filter Express VI. 11. Wire the Filtered Signal output of the Filter Express VI to the Signals input of the Amplitude and Level Measurements Express VI and to the input of the Filtered Signal waveform graph indicator. 12. Select FileSave. The block diagram of the Analysis VI should appear similar to Figure 3-3.
3-7
Chapter 3
Complete the following steps to change the format of the x-axis and y-axis of the Unfiltered Signal and Filtered Signal graphs. 1. On the front panel, right-click the Unfiltered Signal graph indicator and select Properties from the shortcut menu. The Graph Properties dialog box appears. On the Format and Precision page, select Time (X-Axis) from the top pull-down menu. In the Type list, select Automatic formatting. In the Digits field, enter 6 and select Significant digits from the Precision Type pull-down menu. Place a checkmark in the Hide trailing zeros checkbox. Select Amplitude (Y-Axis) from the top pull-down menu and repeat steps 35 so the y-axis configuration matches the x-axis configuration. On the Scales page, select Amplitude (Y-Axis). Remove the checkmark from the Autoscale checkbox. Enter -2.5 in the Minimum text box and 2.5 in the Maximum text box.
2. 3. 4. 5. 6. 7. 8. 9.
10. Click the OK button to save the configuration and close the Graph Properties dialog box. 11. Repeat steps 110 to configure the Filtered Signal graph indicator. The x-axis and the y-axis on the Unfiltered Signal and Filtered Signal graph indicators change to reflect the new configuration.
2. 3.
3-8
ni.com
Chapter 3
4.
Click the OK button to save the current configuration and close the Configure Amplitude and Level Measurements dialog box. The RMS output of the Amplitude and Level Measurements Express VI changes to reflect the new Peak to Peak output, shown at left. You will use the Peak to Peak output in a later exercise.
3-9
Chapter 3
3. 4.
Select the round LED indicator and place it on the front panel to the left of the waveform graphs. Double-click the Boolean label above the LED and enter Warning to change the label of the LED. You will use this LED in a later exercise to indicate when a value has exceeded its limit.
5. 6.
Select FileSave As to display the Save As dialog box. Read the various dialog box options. Select the Copy and Substitute copy for original radio buttons to create a copy of the original VI and immediately edit the copy. Click the Continue button and save the VI as Warning Light.vi in an easily accessible location.
7.
9.
10. In the Comparison Inputs section, select Value and enter 2 in the Value text box to assign a constant value at which you want the LED to light. 11. Click the OK button to save the current configuration and close the Configure Comparison dialog box. The name of the Comparison Express VI changes to reflect the operation of the Express VI, shown at left. Greater indicates that the Express VI does a greater than comparison. 12. Wire the Peak to Peak output of the Amplitude and Level Measurements Express VI to the Operand 1 input of the Greater Express VI. 13. Move the cursor over the wire that connects the Peak to Peak output to the Operand 1 input. 14. When the Positioning tool appears, right-click the wire that connects the Peak to Peak output to the Operand 1 input and select Create Numeric Indicator from the shortcut menu.
3-10
ni.com
Chapter 3
A Peak to Peak terminal, shown at left, appears on the block diagram. If the Peak to Peak terminal appears to be on top of the wires between the Express VIs, move the Express VIs and Peak to Peak terminal around to create more space. For example, move the Peak to Peak terminal into blank space above the Express VIs.
2.
Wire the Result output of the Greater Express VI to the Warning terminal. The block diagram should appear similar to Figure 3-5. Display the front panel. A numeric indicator labeled Peak to Peak appears on the front panel. This indicator displays the peak-to-peak value of the signal.
3.
4.
3-11
Chapter 3
When the peak-to-peak value exceeds 2.0, the Warning indicator lights. 5. 6. Click the STOP button to stop the VI. Save the VI.
3. 4.
3-12
ni.com
Chapter 3
2. 3. 4. 5.
3-13
Chapter 3
2. 3. 4.
5.
3-14
ni.com
Chapter 3
3-15
Chapter 3
Summary
The following topics are a summary of the main concepts you learned in this chapter.
Filtering Data
The Filter Express VI processes signals through filters and windows. You can use the Filter Express VI to remove noise from a signal.
Saving Data
The Write To Measurement File Express VI saves data that a VI generates and analyzes to a .lvm,.tdm, or .tdms measurement file. The text-based measurement file (.lvm) is a tab-delimited text file you can open with a spreadsheet application or a text-editing application. LabVIEW saves data with up to six digits of precision in a .lvm file. In addition to the data an Express VI generates, the .lvm file includes headers that contain information about the data, such as the date and time LabVIEW generated the data. The binary measurement file (.tdm) is a binary file that contains waveform data. Binary .tdm files provide higher accuracy for floating-point numbers, have a smaller disk footprint, and perform faster than text-based measurement files (.lvm). The TDM Streaming file (.tdms) is a binary file that provides faster writing performance than the .tdm file format and allows a simpler interface for defining properties. LabVIEW installs the LabVIEW Data directory in the default file directory of the operating system to help you organize and locate the data files LabVIEW generates. Refer to the LabVIEW Help for more information about writing data to and reading data from .lvm and .tdm files.
3-16
ni.com
This chapter introduces you to the Express VIs you use to acquire data and communicate with instruments on Windows. These exercises require data acquisition hardware. Refer to the Taking Measurements book on the Contents tab in the LabVIEW Help for information about acquiring data and communicating with instruments on all platforms.
Acquiring a Signal
In the following exercises, you will use the DAQ Assistant Express VI to create a task in NI-DAQmx. NI-DAQmx is a programming interface you can use to communicate with data acquisition devices. Refer to the Getting StartedGetting Started with DAQTaking an NI-DAQmx Measurement in LabVIEW book on the Contents tab in the LabVIEW Help for information about additional methods you can use to create NI-DAQmx tasks. The following exercises require that you have NI-DAQmx and an NI-DAQmx-supported device. Refer to the NI-DAQ Readme for the list of NI-DAQmx-supported devices. If you have a device that is supported only with Traditional NI-DAQ, refer to the Taking Measurements book on the Contents tab in the LabVIEW Help for information about using Traditional NI-DAQ (Legacy) for data acquisition.
Note
With NI-DAQmx 7.4 or later you can create NI-DAQmx simulated devices in MAX. An NI-DAQmx simulated device is a software replica of a DAQ device. Refer to the Measurement & Automation Explorer Help for NI-DAQmx for detailed instructions on creating an NI-DAQmx simulated device that you can use to complete the following exercises.
4-1
Chapter 4
In the following exercises, you will create an NI-DAQmx task that continuously takes a voltage reading and plots the data on a waveform graph.
You can complete the exercises in this chapter in approximately 30 minutes.
4. 5.
4-2
ni.com
Chapter 4
7. 8. 9.
In the Input Range section of the Settings page, enter 10 for the Max value and enter -10 for the Min value. On the Task Timing page, select the N Samples option. Enter a value of 1000 in the Samples To Read text box.
4-3
Chapter 4
3. 4.
On the block diagram, right-click the DAQ Assistant Express VI and select Properties from the shortcut menu to open the DAQ Assistant. Right-click Voltage in the list of channels and select Rename from the shortcut menu to display the Rename a channel or channels dialog box.
Tip
You also can select the name of the channel and press the <F2> key to display the Rename a channel or channels dialog box. 5. 6. 7. 8. In the New Name text box, enter First Voltage Reading, and click the OK button. In the DAQ Assistant dialog box, click the OK button to save the current configuration and close the DAQ Assistant. Display the front panel and run the VI. First Voltage Reading appears in the waveform graph plot legend. Save the VI.
4-4
ni.com
Chapter 4
3. 4. 5.
7.
If an error occurs or you click the stop button while the VI is running, the DAQ Assistant Express VI stops reading data and the stopped output returns a TRUE value and stops the While Loop.
4-5
Chapter 4
4.
The Instrument Driver Finder is available only on Windows and Linux. You must have Internet access to use the Instrument Driver Finder. You also can visit the NI Instrument Driver Network at ni.com/idnet to find a driver for an instrument.
4-6
ni.com
Chapter 4
Complete the following steps to search for and install an instrument driver using the Instrument Driver Finder. 1. 2. 3. Select ToolsInstrumentationFind Instrument Drivers or Help Find Instrument Drivers to launch the Instrument Driver Finder. Select National Instruments from the Manufacturer pull-down menu. Click the Search button. The folders on the Search Results page represent instrument drivers, and the contents of the folders represent the files that the Instrument Driver Finder can download and install. The Instrument Driver Finder opens the first driver folder in the list and selects a driver file. You can click different files and use the detailed information to the right to choose the correct driver for the instrument. Select the first instrument driver file from the Driver list and click the Install button. If you do not have an NI.com profile, select No, I Need to create a profile and click the Create Profile button to open a browser window in which you can create an NI.com profile. If you do have an NI.com profile, skip to step 7. Create a profile and return to the Instrument Driver Finder. Select Yes, fill in your email address and ni.com password, and click the Login button. Click the Close button after the Instrument Driver Finder downloads and installs the instrument driver into the labview\instr.lib directory and displays the path to the newly installed driver. Click the Close button to close the Instrument Driver Finder.
4. 5.
6. 7. 8.
9.
You also can create your own instrument drivers. Refer to the Controlling InstrumentsUsing Instrument Drivers book on the Contents tab in the LabVIEW Help for more information about creating instrument drivers.
You must have the Instrument I/O Assistant installed to use the Instrument I/O Assistant Express VI. You install the Instrument I/O Assistant from the National Instruments Device Drivers CD.
4-7
Chapter 4
Complete the following steps to use the Instrument I/O Assistant Express VI to select an instrument. 1. 2. Turn on the instrument you want to use. The instrument must be powered on to use the Instrument I/O Assistant Express VI. Select the Instrument I/O Assistant Express VI on the Input palette and place it on the block diagram. The Instrument I/O Assistant dialog box appears. Click the Show Help button, shown at left, in the upper right corner of the Instrument I/O Assistant dialog box. The help appears to the right of the dialog box. The top help window contains how-to information about using the Instrument I/O Assistant. The bottom help window provides context-sensitive help about components in the dialog box. 4. Click the Select Instrument link in the top help window and follow the instructions in the help window to select the instrument with which you want to communicate. If necessary, configure the properties of the instrument. If you want to minimize the help window, click the Hide Help button, shown at left, in the upper right corner of the Instrument I/O Assistant dialog box.
3.
5. 6.
identification number string that describes the instrument. If the instrument does not accept this command, refer to the reference manual for the instrument for a list of commands the instrument does accept. 3. Click the Run button, shown at left. The Instrument I/O Assistant sends the command to the instrument, and the instrument returns its identification information.
4-8
ni.com
Chapter 4
4.
Select ASCII only from the pull-down menu below the Byte index column of the response window to parse the instrument name as an ASCII string. You also can use the Instrument I/O Assistant to parse ASCII numbers and binary data. Click the Parsing help button, shown at left, in the Instrument I/O Assistant dialog box to display information about parsing data. In the ASCII representation column of the response window, click the value you want to parse. Enter a name for the token, or parsed data selection, in the Token name text box. The name that you entered in the Token name text box is the output of the Instrument I/O Assistant Express VI, shown at left.
5. 6. 7.
4-9
Chapter 4
Summary
The following topics are a summary of the main concepts you learned in this chapter.
Tasks
In NI-DAQmx, a task is a collection of one or more channels, timing, triggering, and other properties. Conceptually, a task represents a measurement or generation you want to perform. For example, you can configure a collection of channels for analog input operations. After you create a task, you can access the single task instead of configuring the channels individually to perform analog input operations. After you create a task, you can add or remove channels from that task. Refer to the Taking Measurements book on the Contents tab in the LabVIEW Help for more information about channels and tasks.
4-10
ni.com
Chapter 4
Instrument Drivers
Use the NI Instrument Driver Finder to search for and install LabVIEW Plug and Play instrument drivers without leaving the LabVIEW development environment. An instrument driver is a set of software routines that control a programmable instrument. Each routine corresponds to a programmatic operation such as configuring, reading from, writing to, and triggering the instrument. Use an instrument driver for instrument control when possible. National Instruments provides thousands of instrument drivers for a wide variety of instruments. Refer to the Controlling InstrumentsUsing Instrument Drivers book on the Contents tab in the LabVIEW Help for more information about the Instrument Driver Finder. You also can visit the NI Instrument Driver Network at ni.com/idnet to find a driver for an instrument, or you can create your own instrument drivers. Refer to the Controlling InstrumentsUsing Instrument Drivers book on the Contents tab in the LabVIEW Help for more information about creating instrument drivers.
4-11
The previous chapters in this manual introduce you to most of the LabVIEW features you need to build common measurement applications. As you familiarize yourself with the LabVIEW environment, you might find that you need to enhance VIs or that you need more fine-tuned control of the processes the VIs perform. This chapter introduces you to some of the concepts you should be familiar with as you start using other LabVIEW features. Refer to the Fundamentals book on the Contents tab in the LabVIEW Help for more information about these concepts. The Concepts books contain information about LabVIEW programming concepts, and the How-To books contain step-by-step instructions for using LabVIEW.
5-1
Chapter 5
VIs
When you place a VI on the block diagram, the VI is a subVI. When you double-click a subVI, its front panel appears, rather than a dialog box in which you can configure options. The icon for a VI appears in the upper right corner of the front panel and block diagram. This icon is the same as the icon that appears when you place the VI on the block diagram. You can use a VI you create as a subVI. Refer to the Fundamentals Creating VIs and SubVIs book on the Contents tab in the LabVIEW Help for more information about creating VIs and configuring them as subVIs. You also can save the configuration of an Express VI as a subVI. Refer to the FundamentalsBuilding the Block Diagram book on the Contents tab in the LabVIEW Help for more information about creating subVIs from Express VIs.
Functions
Functions are the fundamental operating elements of LabVIEW. Unlike VIs, functions do not have front panels or block diagrams.
5-2
ni.com
Chapter 5
Data Types
On the block diagram of a VI, the terminals for the front panel objects are different colors. The color and symbol of a terminal indicate the data type of the corresponding control or indicator. Colors also indicate the data types of wires, inputs, and outputs. The color of inputs and outputs of Express VIs indicate what type of data the input or output accepts or returns. Data types indicate which objects, inputs, and outputs you can wire together. For example, a switch has a green border, so you can wire a switch to any Express VI input with a green label. A knob has an orange border, so you can wire a knob to any Express VI input with an orange label. However, you cannot wire a knob to an input with a green label. The wires you create are the same color as the terminal. Refer to the FundamentalsBuilding the Block Diagram book on the Contents tab in the LabVIEW Help for more information about data types.
5-3
Chapter 5
5-4
ni.com
Chapter 5
Customize menusYou can configure which menu items appear when a user runs a VI. You also can create custom menus. Refer to the FundamentalsCreating VIs and SubVIs book on the Contents tab in the LabVIEW Help for more information about these features. Use LabVIEW projectsYou can use projects to group together LabVIEW files and non-LabVIEW files, create build specifications, and deploy or download files to multiple targets from one location. You must use a project to build applications and shared libraries. You also must use a project to work with an RT, FPGA, PDA, Touch Panel, DSP, or embedded target. Refer to the specific module documentation for more information about using projects with these targets. Refer to the FundamentalsOrganizing and Managing a Project book on the Contents tab in the LabVIEW Help for more information about using LabVIEW projects. Access other Windows applicationsYou can use LabVIEW as a .NET or ActiveX client to access the objects, properties, methods, and events associated with .NET server or ActiveX applications. Refer to the FundamentalsWindows Connectivity book on the Contents tab in the LabVIEW Help for more information about these features. Write mathematical formulas, equations, and scriptsYou can use various nodes to perform mathematical operations on the block diagram. You also can use the LabVIEW MathScript text-based language to write mathematical functions and scripts. Refer to the FundamentalsFormulas and Equations book on the Contents tab in the LabVIEW Help for more information about these features.
5-5
Visit the following sections of the National Instruments Web site at ni.com for technical support and professional services: SupportOnline technical support resources at ni.com/support include the following: Self-Help ResourcesFor answers and solutions, visit the award-winning National Instruments Web site for software drivers and updates, a searchable KnowledgeBase, product manuals, step-by-step troubleshooting wizards, thousands of example programs, tutorials, application notes, instrument drivers, and so on. Free Technical SupportAll registered users receive free Basic Service, which includes access to hundreds of Application Engineers worldwide in the NI Developer Exchange at ni.com/exchange. National Instruments Application Engineers make sure every question receives an answer. For information about other technical support options in your area, visit ni.com/services or contact your local office at ni.com/contact. Training and CertificationVisit ni.com/training for self-paced training, eLearning virtual classrooms, interactive CDs, and Certification program information. You also can register for instructor-led, hands-on courses at locations around the world. System IntegrationIf you have time constraints, limited in-house technical resources, or other project challenges, National Instruments Alliance Partner members can help. To learn more, call your local NI office or visit ni.com/alliance.
If you searched ni.com and could not find the answers you need, contact your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual. You also can visit the Worldwide Offices section of ni.com/niglobal to access the branch office Web sites, which provide up-to-date contact information, support phone numbers, email addresses, and current events.
A-1
Glossary
A
automatic scaling Ability of scales to adjust to the range of plotted values. On graph scales, autoscaling determines maximum and minimum scale values.
B
block diagram Pictorial description or representation of a program or algorithm. The block diagram consists of executable icons called nodes and wires that carry data between the nodes. The block diagram is the source code for the VI. The block diagram resides in the block diagram window of the VI. Front panel objects to manipulate and display Boolean (TRUE or FALSE) data. Button that replaces the Run button when a VI cannot run because of errors. VI that cannot run because of errors; signified by a broken arrow in the broken Run button.
G-1
Glossary
C
channel 1. Physicala terminal or pin at which you can measure or generate an analog or digital signal. A single physical channel can include more than one terminal, as in the case of a differential analog input channel or a digital port of eight lines. The name used for a counter physical channel is an exception because that physical channel name is not the name of the terminal where the counter measures or generates the digital signal. 2. Virtuala collection of property settings that can include a name, a physical channel, input terminal connections, the type of measurement or generation, and scaling information. You can define NI-DAQmx virtual channels outside a task (global) or inside a task (local). Configuring virtual channels is optional in Traditional NI-DAQ and earlier versions but is integral to every measurement you take in NI-DAQmx. In Traditional NI-DAQ, you configure virtual channels in MAX. In NI-DAQmx, you can configure virtual channels either in MAX or in a program, and you can configure channels as part of a task or separately. 3. Switcha switch channel represents any connection point on a switch. It can be made up of one or more signal wires (commonly one, two, or four), depending on the switch topology. A virtual channel cannot be created with a switch channel. Switch channels may be used only in the NI-DAQmx Switch functions and VIs. checkbox Small square box in a dialog box which you can select or clear. Checkboxes generally are associated with multiple options that you can set. You can select more than one checkbox. Terminal of a While Loop that contains a Boolean value that determines if the VI performs another iteration. Window that displays basic information about LabVIEW objects when you move the cursor over each object. Objects with context help information include VIs, functions, constants, structures, palettes, properties, methods, events, and dialog box components. Front panel object for entering data to a VI interactively or to a subVI programmatically, such as a knob, push button, or dial. Palette that contains front panel controls, indicators, and decorative objects. VI whose front panel, block diagram, or Icon Editor is the active window.
G-2
ni.com
Glossary
D
DAQ DAQ Assistant DAQ device See data acquisition (DAQ). A graphical interface for configuring measurement tasks, channels, and scales. A device that acquires or generates data and can contain multiple channels and conversion devices. DAQ devices include plug-in devices, PCMCIA cards, and DAQPad devices, which connect to a computer USB or IEEE 1394 (FireWire) port. SCXI modules are considered DAQ devices. 1. Acquiring and measuring analog or digital electrical signals from sensors, acquisition transducers, and test probes or fixtures. 2. Generating analog or digital electrical signals. data flow Programming system that consists of executable nodes that execute only when they receive all required input data. The nodes produce output data automatically when they execute. LabVIEW is a dataflow system. The movement of data through the nodes determines the execution order of the VIs and functions on the block diagram. Format for information. In LabVIEW, acceptable data types for most VIs and functions are numeric, array, string, Boolean, path, refnum, enumeration, waveform, and cluster. Direct current. Preset value. Many VI inputs use a default value if you do not specify a value. An instrument or controller you can access as a single entity that controls or monitors real-world I/O points. A device often is connected to a host computer through some type of communication network. See also DAQ device and measurement device. To use the cursor on the screen to select, move, copy, or delete objects. Software that controls a specific hardware device, such as a DAQ device. Data type used by Express VIs that includes the data associated with a signal and attributes that provide information about the signal, such as the name of the signal or the date and time LabVIEW acquired the data. Attributes specify how the signal appears on a graph or chart.
data type
DC default device
G-3
Glossary
E
Error list window error message Express VI Window that displays errors and warnings occurring in a VI and in some cases recommends how to correct the errors. Indication of a software or hardware malfunction or of an unacceptable data entry attempt. A subVI designed to aid in common measurement tasks. You configure an Express VI using a configuration dialog box.
F
For Loop front panel function Functions palette Iterative loop structure that executes its subdiagram a set number of times. Equivalent to text-based code: For i = 0 to n 1, do.... Interactive user interface of a VI. Front panel appearance imitates physical instruments, such as oscilloscopes and multimeters. Built-in execution element, comparable to an operator, function, or statement in a text-based programming language. Palette that contains VIs, functions, block diagram structures, and constants.
G
General Purpose Interface Bus GPIB. Synonymous with HP-IB. The standard bus used for controlling electronic instruments with a computer. Also called IEEE 488 bus because it is defined by ANSI/IEEE Standards 488-1978, 488.1-1987, and 488.2-1992. 2D display of one or more plots. A graph receives and plots data as a block.
graph
I
I/O Input/Output. The transfer of data to or from a computer system involving communications channels, operator input devices, and/or data acquisition and control interfaces. Graphical representation of a node on a block diagram.
icon
G-4
ni.com
Glossary
Front panel object that displays output, such as a graph or LED. A set of high-level functions that control and communicate with instrument hardware in a system.
Instrument I/O Assistant Add-on launched from the Instrument I/O Assistant Express VI that communicates with message-based instruments and graphically parses the response.
L
.lvm file
Tab-delimited text measurement file you can open with a spreadsheet application or a text-editing application. Text object used to name or describe objects or regions on the front panel or block diagram. Laboratory Virtual Instrument Engineering Workbench. LabVIEW is a graphical programming language that uses icons instead of lines of text to create programs. Light-emitting diode. Object a graph or chart owns to display the names and plot styles of plots on that graph or chart.
label LabVIEW
LED legend
M
MAX Measurement & Automation Explorer measurement device See Measurement & Automation Explorer. The standard National Instruments hardware configuration and diagnostic environment for Windows. DAQ devices such as the E Series multifunction I/O (MIO) devices, SCXI signal conditioning modules, and switch modules. Horizontal bar that lists the names of the main menus of an application. The menu bar appears below the title bar of a window. Each application has a menu bar that is distinct for that application, although some menus and commands are common to many applications.
menu bar
G-5
Glossary
N
NI-DAQ Driver software included with all NI DAQ devices and signal conditioning components. NI-DAQ is an extensive library of VIs and ANSI C functions you can call from an application development environment (ADE), such as LabVIEW, to program an NI measurement device, such as the M Series multifunction I/O (MIO) DAQ devices, signal conditioning modules, and switch modules. The latest NI-DAQ driver with new VIs, functions, and development tools for controlling measurement devices. The advantages of NI-DAQmx over earlier versions of NI-DAQ include the DAQ Assistant for configuring channels and measurement tasks for your device for use in LabVIEW, LabWindows/CVI, and Measurement Studio; NI-DAQmx simulation for most supported devices for testing and modifying applications without plugging in hardware; and a simpler, more intuitive API for creating DAQ applications using fewer functions and VIs than earlier versions of NI-DAQ. Program execution element. Nodes are analogous to statements, operators, functions, and subroutines in text-based programming languages. On a block diagram, nodes include functions, structures, and subVIs. Front panel objects to manipulate and display numeric data.
NI-DAQmx
node
O
object Operating tool Generic term for any item on the front panel or block diagram, including controls, indicators, structures, nodes, wires, and imported pictures. Tool to enter data into controls or to operate them.
P
palette plot Positioning tool Displays objects or tools you can use to build the front panel or block diagram. Graphical representation of an array of data shown either on a graph or a chart. Tool to move and resize objects.
G-6
ni.com
Glossary
A collection of LabVIEW files and non-LabVIEW files that you can use to create build specifications and deploy or download files to targets. Window in which you can create and edit LabVIEW projects. Dialog boxes accessed from the shortcut menu of a control or indicator that you can use to configure how the control or indicator appears in the front panel window. Menus accessed from a menu bar. Pull-down menu items are usually general in nature. PCI eXtensions for Instrumentation. A modular, computer-based instrumentation platform.
R
RMS Root Mean Square.
S
sample scale shortcut menu string structure subpalette subVI Single analog or digital input or output data point. Part of graph, chart, and some numeric controls and indicators that contains a series of marks or points at known intervals to denote units of measure. Menu accessed by right-clicking an object. Menu items pertain to that object specifically. Representation of a value as text. Program control element, such as a Flat Sequence structure, Stacked Sequence structure, Case structure, For Loop, While Loop, or Timed Loop. Palette that you access from another palette that is above the subpalette in hierarchy. VI used on the block diagram of another VI. Comparable to a subroutine.
G-7
Glossary
T
.tdm file .tdms file
Binary measurement file that contains waveform data. TDM Streaming file. Binary file that provides faster writing perfomance than the .tdm file format and allows a simpler interface for defining properties. A collection of one or more channels, timing, triggering, and other properties in NI-DAQmx. A task represents a measurement or generation you want to perform. VI that contains common controls and indicators from which you can build multiple VIs that perform similar functions. Access template VIs from the New dialog box. Object or region on a node through which data pass. Small yellow text banners that identify the terminal name and make it easier to identify terminals for wiring. Special cursor to perform specific operations. Bar that contains command buttons to run and debug VIs. An older driver with outdated APIs for developing data acquisition, instrumentation, and control applications for older National Instruments DAQ devices. You should use Traditional NI-DAQ (Legacy) only in certain circumstances. Refer to the NI-DAQ Readme for more information about when to use Traditional NI-DAQ (Legacy), including a complete list of supported devices, operating systems, and application software and language versions.
task
template VI
V
VI virtual instrument (VI) See virtual instrument (VI). Program in LabVIEW that models the appearance and function of a physical instrument. VME eXtensions for Instrumentation (bus).
VXI
G-8
ni.com
Glossary
W
waveform waveform chart While Loop wire Wiring tool Multiple voltage readings taken at a specific sampling rate. Indicator that plots data points at a certain rate. Loop structure that repeats a section of code until a condition occurs. Data path between nodes. Tool to define data paths between terminals.
G-9
Index
Symbols
.lvm files, 3-13, 3-16 .tdm files, 3-16 .tdms files, 3-16
B
blank VIs, 2-2 block diagram, 1-5, 1-19 customizing, 2-12 indicators, 3-16 placing objects from help, 2-11 showing, 1-7 broken Run button, 2-7 wires, 2-7, 2-12 Build Table Express VI, 2-8 building applications, 5-5 shared libraries, 5-5 VIs, 1-1 buttons adding, 3-13 Run, 1-5
A
acquiring information for instruments, 4-8 signals, 4-1 Acquiring a Signal VI block diagram (figure), 1-14 adding channels to tasks, 4-5 controls from the block diagram, 2-4 controls to the front panel, 1-5 graph indicators, 2-5 inputs to Express VIs, 1-8, 2-4, 3-14 multiple signals, 3-5 numeric indicators, 2-4 signals, 3-3 visual cues on front panel, 3-9 warning lights, 3-9 Amplitude and Level Measurements Express VI, 3-2 analyzing voltage, 3-8 analyzing signals, 3-8 applications building, 5-5 communicating with across networks, 5-4 Arithmetic & Comparison palette, 1-11
C
calling code from text-based languages, 5-4, 5-5 changing signal types, 1-7 channels, 4-2 adding to tasks, 4-5 renaming, 4-4 communicating with instruments, 4-6 with LabVIEW applications across networks, 5-4
I-1
Index
Comparison Express VI, 3-10 configuration dialog boxes, 1-19 configuring controls, 1-20 indicators, 1-20 Context Help window, 2-2, 2-11, 3-2 button, 2-2, 3-2 displaying configuration of Express VIs, 3-2 displaying errors, 2-12 figure, 2-2 showing, 2-2 controlling execution speed, 2-8 VIs programmatically, 5-4 controls, 1-18, 3-16, 5-1 adding from the block diagram, 2-4 adding to the front panel, 1-5 configuring, 1-20 creating, 2-4, 2-12 customizing, 1-15 data types, 5-3 numeric, 5-1 palette, 1-5 Controls palette, 1-5 figure, 1-6 showing all categories, 5-1 conventions used in this manual, ix Convert from/to Dynamic Data Express VIs, 5-3 creating controls, 2-4, 2-12 graph indicators, 2-5 indicators, 2-12 NI-DAQmx tasks, 4-2
customizing block diagrams, 2-12 controls, 1-15 front panels, 2-4 indicators, 1-17 menus, 5-5 simulated signals, 3-3
D
DAQ Assistant Express VI, 4-2, 4-10 DAQ devices, 4-2 data displaying from DAQ devices, 4-4 in tables, 2-8, 2-13 graphing from DAQ devices, 4-4 saving to a file, 3-12, 3-13 when prompted by a user, 3-14 storing, 3-13 data flow, 1-9, 1-14, 1-19 data types dynamic, 5-3 overview, 5-3 deleting wires, 1-11 deselecting objects, 1-9 displaying data from DAQ devices, 4-4 data in tables, 2-8, 2-13 errors in Context Help window, 2-12 signals in a graph, 1-14 documentation conventions used in this manual, ix introduction to this manual, ix NI resources, A-1
I-2
ni.com
Index
drivers instrument, 4-6 NI resources, A-1 dynamic data, 5-3 converting from and to, 5-3
E
Error list window, 2-7, 2-12 errors, 2-12 displaying in Context Help window, 2-12 list, 2-7, 2-12 window, 2-7, 2-12 example VIs NI Example Finder, 2-10 NI resources, A-1 Execution Control palette, 2-6 execution speed, controlling, 2-8 Express VIs, 1-19 Amplitude and Level Measurements, 3-2, 3-8 Build Table, 2-8 Comparison, 3-10 configuration dialog boxes, 1-19 Convert from/to Dynamic Data, 5-3 DAQ Assistant, 4-2, 4-10 Filter, 3-6 Formula, 1-11 inputs, 1-20 Instrument I/O Assistant, 4-7, 4-11 Scaling and Mapping, 1-11 Simulate Signals, 1-7 Time Delay, 2-8 Write To Measurement File, 3-12, 3-16
Formula Express VI, 1-11, 3-5 front panel, 1-5, 1-18 Acquiring a Signal VI (figure), 1-2 adding controls, 1-5 visual cues, 3-9 controls, 1-18, 3-16 customizing, 2-4 indicators, 1-19 modifying, 2-7 showing, 1-10 Warning Light VI (figure), 3-2 functions, 5-2 Merge Signals, 1-14, 2-5 Functions palette figure, 1-11 showing all categories, 5-2
G
Getting Started window, 1-4, 3-2 figure, 1-3 graph indicators, creating, 2-5 graphing data from DAQ devices, 4-4 two signals, 1-14 grouping files, 5-5
H
help Context Help window, 2-2, 2-11, 3-2 LabVIEW Help, 1-11, 1-20, 2-11 searching, 2-3, 2-10, 2-11 LabVIEW resources, 1-20, 2-11 searching, 2-3, 2-10, 2-11 technical support, A-1
F
files grouping, 5-5 saving to other formats, 5-4 Filter Express VI, 3-6
I-3
Index
I
indicators, 1-19, 3-16, 5-1 adding numeric, 2-4 configuring, 1-20 creating, 2-12 customizing, 1-17 data type, 5-3 numeric, 5-1 removing, 2-7 Input palette, 2-2 inputs, Express VI, 1-20 Instrument Driver Network, 4-6 instrument drivers, 4-6, 4-11 finding, 4-11 installing, 4-11 NI resources, A-1 Instrument I/O Assistant Express VI, 4-7, 4-11 instruments acquiring information, 4-8 communicating, 4-6 parsing information, 4-8 selecting, 4-7
M
manual. See documentation marquee, 2-8 menus, customizing, 5-5 Merge Signals function, 1-14, 2-5 figure, 1-15 modifying front panels, 2-7 signals, 1-11, 2-3
N
National Instruments support and services, A-1 New dialog box, 1-4, 1-18, 3-2 figure, 1-4 NI resources, A-1 support and services, A-1 NI Example Finder, 2-10 NI Instrument Driver Finder, 4-11 NI Instrument Driver Network, 4-6 NI-DAQmx tasks, 4-2, 4-10 creating, 4-2 testing, 4-4 numeric controls, 1-6, 5-1 palette, 1-6
K
knob control, customizing (figure), 1-16 KnowledgeBase, A-1
L
LabVIEW help resources, 2-11 other features, 5-1 projects, 5-5 LabVIEW Help, 1-11, 1-20, 2-11 searching, 2-3, 2-10, 2-11 LEDs, palette, 3-9 figure, 3-9 LVM. See .lvm files
O
objects deselecting, 1-9 wiring on the block diagram, 1-9 Operating tool, 1-10 outputs, Express VI, 1-20
I-4
ni.com
Index
P
palettes Arithmetic & Comparison, 1-11 Controls, 1-5 Execution Control, 2-6, 2-12 Functions, 1-11 Input, 2-2 LEDs, 3-9 searching, 2-6 showing all categories, 5-1, 5-2 parsing information for instruments, 4-8 placing objects on the block diagram from the help, 2-11 Positioning tool, 1-9 programatically controlling VIs, 5-4 programming examples (NI resources), A-1 projects, 5-5 property dialog boxes, 1-20, 1-21 publishing VIs on the Web, 5-4
searching examples, 2-10 help, 2-3, 2-10, 2-11 palettes, 2-6 selecting instruments, 4-7 objects, 1-9 shared libraries, building, 5-5 signals acquiring, 4-1 analyzing, 3-8 changing type, 1-7 graphing, 1-14 modifying, 1-11, 2-3 Simulate Signal Express VI, 1-7 simulated signals, customizing, 3-3 software (NI resources), A-1 subVIs, 5-2
T R
related documentation, 1-x removing indicators, 2-7 Run button, 1-5, 1-10 broken, 2-7, 2-12 running VIs, 1-10 continuously, 2-5 tables, 2-8 displaying data, 2-13 tasks adding new channels, 4-5 NI-DAQmx, 4-10 testing, 4-4 TDM. See .tdm files technical support, A-1 template VIs, 1-2, 1-3, 1-18 text-based languages, calling code, 5-4, 5-5 Time Delay Express VI, 2-8 tools Operating, 1-10 Positioning, 1-9 Wiring, 1-9 training and certification (NI resources), A-1 troubleshooting (NI resources), A-1
S
saving data different file formats, 5-4 Save Data VI block diagram (figure), 3-15 to files, 3-12, 3-13, 3-16 when prompted by user, 3-14, 3-15 Scaling and Mapping Express VI, 1-11 defining slope, 1-11
I-5
Index
U
user interface. See front panel
W
Warning Light VI block diagram (figure), 3-11 warning lights, adding, 3-9 Web resources, A-1 While Loop, 2-6 wires broken, 2-7, 2-12 deleting, 1-11 wiring objects on the block diagram, 1-9 tool, 1-9 Write to Measurement File Express VI, 3-12, 3-13, 3-16 saving data, 3-13
V
virtual instruments. See VIs VIs, 1-1, 5-2 blank, 2-1 building, 1-1 customizing menus, 5-5 icons, 5-2 new, 2-1 programmatically controlling, 5-4 publishing on the Web, 5-4 running, 1-10 continuously, 2-5 subVIs, 5-2 template, 1-2, 1-3, 1-18 voltage, analyzing, 3-8
I-6
ni.com