`
`LabVIEW User Manual
`
`November 2001 Edition
`Part Number 320999D-01
`
`1
`
`APPLE 1027
`
`
`
`Worldwide Technical Support and Product Information
`ni.com
`
`National Instruments Corporate Headquarters
`11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100
`
`Worldwide Offices
`Australia 03 9879 5166, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Brazil 011 284 5011,
`Canada (Calgary) 403 274 9391, Canada (Montreal) 514 288 5722, Canada (Ottawa) 613 233 5949,
`Canada (Québec) 514 694 8521, Canada (Toronto) 905 785 0085, China (Shanghai) 021 6555 7838,
`China (ShenZhen) 0755 3904939, Czech Republic 02 2423 5774, Denmark 45 76 26 00, Finland 09 725 725 11,
`France 01 48 14 24 24, Germany 089 741 31 30, Greece 30 1 42 96 427, Hong Kong 2645 3186,
`India 91805275406, Israel 03 6120092, Italy 02 413091, Japan 03 5472 2970, Korea 02 596 7456,
`Malaysia 603 9596711, Mexico 001 800 010 0793, Netherlands 0348 433466, New Zealand 09 914 0488,
`Norway 32 27 73 00, Poland 0 22 528 94 06, Portugal 351 1 726 9011, Russia 095 2387139,
`Singapore 2265886, Slovenia 386 3 425 4200, South Africa 11 805 8197, Spain 91 640 0085,
`Sweden 08 587 895 00, Switzerland 056 200 51 51, Taiwan 02 2528 7227, United Kingdom 01635 523545
`
`For further support information, see the Technical Support Resources appendix. To comment on the
`documentation, send e-mail to techpubs@ni.com.
`
`© 1992, 2001 National Instruments Corporation. All rights reserved.
`
`2
`
`
`
`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. CUSTOMER’S 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 owner’s failure to follow the National Instruments installation, operation, or
`maintenance instructions; owner’s modification of the product; owner’s 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.
`Portions © 1991-1999 Compuware Corporation
`Uses libmng, an open-source initiative by Gerard Juyn, © 2000, 2001 G. Juyn, www.libmng.com
`Based in part on the works of the Independant JPEG Group (IJG) © 1991-1998, Thomas G. Lane, www.ijg.org
`Uses lcms (little CMS) by Marti Maria Saguer, distributed under LGPL, www.littlecms.com
`Uses zlib, a patent-free (de)compression-library, © 1995-1998 Jean-loup Gailly and Mark Adler,
`http://www.info-zip.org/pub/infozip/zlib
`Trademarks
`ComponentWorks™, DAQPad™, DataSocket™, HiQ™, HiQ-Script™, LabVIEW™, National Instruments™, NI™, ni.com™, NI-488™,
`NI-488.2™, NI-DAQ™, NI-FBUS™, NI-VISA™, and SCXI™ are trademarks of National Instruments Corporation.
`Product and company names mentioned herein are trademarks or trade names of their respective companies.
`Patents
`The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications. Refer to
`ni.com/legal/patents for the most current list of patents covering this product.
`The LabVIEW software is covered by one or more of the following Patents: United States Patent No(s): 4,901,221; 4,914,568; 5,291,587;
`5,301,301; 5,301,336; 5,475,851; 5,481,740; 5,481,741; 5,497,500; 5,504,917; 5,583,988; 5,610,828; 5,652,909; 5,732,277; 5,734,863;
`5,737,622; 5,764,546; 5,784,275; 5,821,934; 5,847,953; 5,905,649; 5,920,479; 5,974,254; 5,990,906; 6,064,812; 6,064,816; 6,102,965;
`6,138,270; D384051; D387750; D384050; D384052; European Patent No(s).: 0242131; Japanese Patent No(s).: 3,016,783; Canadian Patent
`No(s).: 1285655
`Various other software products may be included with this version of LabVIEW. If any software products listed below are included, they are
`covered by various Patents as follows:
`The LabVIEW Signal Processing Toolset is covered by one or more of the following Patents: U.S. Patent No(s).: 5,353,233; 6,108,609;
`European Patent No(s).: 0632899; Japanese Patent No(s).: 2,697,957
`The LabVIEW Datalogging and Supervisory Control Module is covered by one or more of the following Patents: U.S. Patent No(s).: 5,966,532;
`6,053,951
`LabVIEW Real-Time is covered by one or more of the following Patents: U.S. Patent No(s).: 6,173,438
`The LabVIEW PID Control Toolset is covered by one or more of the following Patents: U.S. Patent No(s).: 6,081,751
`The IVI Driver Toolset is covered by one or more of the following Patents: U.S. Patent No(s).: 5,963,726; 6,085,156
`The NI-VISA software is covered by one or more of the following Patents: U.S. Patent No(s).: 5,724,272; 5,710,727; 5,847,955; 5,640,572;
`5,771,388; 5,627,988; 5,717,614
`The NI-DAQ software is covered by one or more of the following Patents: U.S. Patent No(s).: 5,619,702; 6,067,584; 6,096,094; 6,052,743;
`6,148,438; 5,926,775; 5,987,530; 6,073,205
`
`3
`
`
`
`The NI-488 or NI-488.2 (NI-GPIB) software is covered by one or more of the following Patents: U.S. Patent No(s).: 5,974,541; 5,964,892;
`5,958,028; 5,987,530; 6,073,205
`The NI-FBUS software, including one or more of the NI-FBUS Configurator software or the NI-FBUS Monitor software, is covered by one or
`more of the following Patents: U.S. Patent No(s).: 5,854,890; 5,796,721; 5,850,523; 5,971,581; 6,141,596; 6,076,952; 5,978,850
`WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS
`(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF
`RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN
`ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT
`INJURY TO A HUMAN.
`(2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE
`IMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY,
`COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERS
`AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND
`HARDWARE COMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL
`DEVICES, TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR
`MISUSES, OR ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE
`HEREAFTER COLLECTIVELY TERMED “SYSTEM FAILURES”). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD
`CREATE A RISK OF HARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD
`NOT BE RELIANT SOLELY UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID
`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.
`
`4
`
`
`
`Contents
`
`About This Manual
`Organization of This Manual .........................................................................................xvii
`Conventions ...................................................................................................................xviii
`
`PART I
`LabVIEW Concepts
`
`Chapter 1
`Introduction to LabVIEW
`LabVIEW Documentation Resources............................................................................1-1
`LabVIEW Example VIs and Tools................................................................................1-3
`LabVIEW Example VIs ..................................................................................1-3
`LabVIEW Tools ..............................................................................................1-3
`
`Chapter 2
`Introduction to Virtual Instruments
`Front Panel .....................................................................................................................2-1
`Block Diagram ...............................................................................................................2-2
`Terminals.........................................................................................................2-3
`Nodes...............................................................................................................2-4
`Wires................................................................................................................2-4
`Structures.........................................................................................................2-4
`Icon and Connector Pane ...............................................................................................2-4
`Using and Customizing VIs and SubVIs .......................................................................2-5
`
`Chapter 3
`LabVIEW Environment
`Controls Palette..............................................................................................................3-1
`Functions Palette............................................................................................................3-1
`Navigating the Controls and Functions Palettes ............................................................3-2
`Tools Palette ..................................................................................................................3-2
`Menus and the Toolbar ..................................................................................................3-3
`Menus ..............................................................................................................3-3
`Shortcut Menus................................................................................................3-3
`Shortcut Menus in Run Mode ...........................................................3-3
`Toolbar ............................................................................................................3-4
`
`© National Instruments Corporation
`
`v
`
`LabVIEW User Manual
`
`5
`
`
`
`Contents
`
`Customizing Your Work Environment ......................................................................... 3-4
`Customizing the Controls and Functions Palettes........................................... 3-4
`Adding VIs and Controls to the User Library and the Instrument
`Library ........................................................................................... 3-4
`Creating and Editing Palette Views.................................................. 3-5
`How LabVIEW Stores Views ............................................ 3-5
`Building ActiveX Subpalettes .......................................................... 3-5
`Representing Toolsets in the Palettes ............................................... 3-6
`Setting Work Environment Options................................................................ 3-6
`How LabVIEW Stores Options ........................................................ 3-6
`Windows............................................................................. 3-6
`Macintosh ........................................................................... 3-6
`UNIX.................................................................................. 3-7
`
`Chapter 4
`Building the Front Panel
`Configuring Objects on the Front Panel........................................................................ 4-1
`Showing and Hiding Optional Elements......................................................... 4-2
`Changing Controls to Indicators and Vice Versa............................................ 4-2
`Replacing Front Panel Objects........................................................................ 4-2
`Setting Keyboard Shortcuts for Controls ........................................................ 4-3
`Controlling Button Behavior with Key Navigation.......................... 4-3
`Setting the Navigation Order of Front Panel Objects....................... 4-4
`Coloring Objects ............................................................................................. 4-4
`Using Imported Graphics ................................................................................ 4-4
`Grouping and Locking Objects ....................................................................... 4-5
`Resizing Objects ............................................................................................. 4-5
`Scaling Front Panel Objects............................................................................ 4-5
`Adding Space to Front Panel without Resizing Window ............................... 4-7
`Front Panel Controls and Indicators .............................................................................. 4-7
`3D and Classic Controls and Indicators.......................................................... 4-7
`Slides, Knobs, Dials, and Digital Displays ..................................................... 4-8
`Slide Controls and Indicators ........................................................... 4-8
`Rotary Controls and Indicators......................................................... 4-8
`Digital Controls and Indicators......................................................... 4-9
`Color Boxes ...................................................................................... 4-9
`Color Ramps ..................................................................................... 4-9
`Buttons, Switches, and Lights......................................................................... 4-10
`Text Entry Boxes, Labels, and Path Displays................................................. 4-10
`String Controls and Indicators .......................................................... 4-10
`Path Controls and Indicators............................................................. 4-10
`Invalid Paths....................................................................... 4-11
`Empty Paths........................................................................ 4-11
`
`LabVIEW User Manual
`
`vi
`
`ni.com
`
`6
`
`
`
`Contents
`
`Array and Cluster Controls and Indicators......................................................4-11
`Tab Controls......................................................................................4-11
`Listboxes..........................................................................................................4-12
`Ring and Enumerated Type Controls and Indicators ......................................4-13
`Ring Controls ....................................................................................4-13
`Enumerated Type Controls ...............................................................4-13
`Advanced Enumerated Type Controls and Indicators ........4-13
`I/O Name Controls and Indicators...................................................................4-14
`Waveform Control ............................................................................4-15
`References to Objects or Applications ............................................................4-15
`Dialog Controls ...............................................................................................4-15
`Labeling .........................................................................................................................4-16
`Captions...........................................................................................................4-16
`Text Characteristics .......................................................................................................4-17
`Designing User Interfaces..............................................................................................4-18
`Using Front Panel Controls and Indicators .....................................................4-18
`Designing Dialog Boxes..................................................................................4-19
`Selecting the Screen Size.................................................................................4-19
`
`Chapter 5
`Building the Block Diagram
`Relationship between Front Panel Objects and Block Diagram Terminals...................5-1
`Block Diagram Objects..................................................................................................5-1
`Block Diagram Terminals ...............................................................................5-1
`Control and Indicator Data Types.....................................................5-2
`Constants...........................................................................................5-4
`Universal Constants............................................................5-4
`User-Defined Constants......................................................5-4
`Block Diagram Nodes .....................................................................................5-5
`Functions Overview .......................................................................................................5-6
`Numeric Functions ..........................................................................................5-6
`Boolean Functions ...........................................................................................5-6
`String Functions...............................................................................................5-7
`Array Functions ...............................................................................................5-7
`Cluster Functions.............................................................................................5-7
`Comparison Functions.....................................................................................5-8
`Time and Dialog Functions .............................................................................5-8
`File I/O Functions............................................................................................5-8
`Waveform Functions .......................................................................................5-8
`Application Control Functions ........................................................................5-9
`Advanced Functions ........................................................................................5-9
`Adding Terminals to Block Diagram Functions .............................................5-9
`
`© National Instruments Corporation
`
`vii
`
`LabVIEW User Manual
`
`7
`
`
`
`Contents
`
`Using Wires to Link Block Diagram Objects................................................................ 5-10
`Automatically Wiring Objects ........................................................................ 5-11
`Manually Wiring Objects................................................................................ 5-12
`Selecting Wires ............................................................................................... 5-12
`Removing Broken Wires................................................................................. 5-12
`Coercion Dots ................................................................................................. 5-12
`Polymorphic VIs and Functions .................................................................................... 5-13
`Polymorphic VIs ............................................................................................. 5-13
`Building Polymorphic VIs................................................................ 5-14
`Polymorphic Functions ................................................................................... 5-16
`Handling Variant Data................................................................................................... 5-16
`Numeric Units and Strict Type Checking ..................................................................... 5-17
`Units and Strict Type Checking ...................................................................... 5-18
`Block Diagram Data Flow............................................................................................. 5-20
`Data Dependency and Artificial Data Dependency ........................................ 5-20
`Missing Data Dependencies ............................................................. 5-21
`Data Flow and Managing Memory ................................................................. 5-21
`Designing the Block Diagram ....................................................................................... 5-22
`
`Chapter 6
`Running and Debugging VIs
`Running VIs................................................................................................................... 6-1
`Configuring How a VI Runs ........................................................................... 6-1
`Correcting Broken VIs .................................................................................................. 6-2
`Finding Causes for Broken VIs....................................................................... 6-2
`Common Causes of Broken VIs...................................................................... 6-3
`Debugging Techniques.................................................................................................. 6-3
`Execution Highlighting ................................................................................... 6-4
`Single-Stepping............................................................................................... 6-4
`Probe Tool....................................................................................................... 6-4
`Breakpoints ..................................................................................................... 6-5
`Suspending Execution..................................................................................... 6-5
`Determining the Current Instance of a SubVI .................................. 6-6
`Commenting Out Sections of Block Diagrams............................................... 6-6
`Disabling Debugging Tools........................................................................................... 6-6
`Undefined or Unexpected Data ..................................................................................... 6-7
`Unexpected and Default Data in Loops .......................................................... 6-7
`For Loops.......................................................................................... 6-7
`While Loops ..................................................................................... 6-8
`Default Data in Arrays .................................................................................... 6-8
`Preventing Undefined Data............................................................................. 6-8
`Error Checking and Error Handling .............................................................................. 6-8
`Checking for Errors......................................................................................... 6-9
`
`LabVIEW User Manual
`
`viii
`
`ni.com
`
`8
`
`
`
`Contents
`
`Error Handling.................................................................................................6-9
`Error Clusters ....................................................................................6-10
`Using While Loops for Error Handling ............................................6-10
`Using Case Structures for Error Handling ........................................6-10
`
`Chapter 7
`Creating VIs and SubVIs
`Planning and Designing Your Project ...........................................................................7-1
`Designing Projects with Multiple Developers.................................................7-2
`Using Built-In VIs and Functions ..................................................................................7-2
`Building Instrument Control and Data Acquisition VIs and Functions ..........7-2
`Building VIs That Access Other VIs...............................................................7-3
`Building VIs That Communicate with Other Applications.............................7-3
`SubVIs ...........................................................................................................................7-4
`Watching for Common Operations .................................................................7-4
`Setting up the Connector Pane ........................................................................7-6
`Setting Required, Recommended, and Optional Inputs
`and Outputs ....................................................................................7-7
`Creating an Icon ..............................................................................................7-8
`Creating SubVIs from Sections of a VI...........................................................7-8
`Designing SubVIs............................................................................................7-8
`Viewing the Hierarchy of VIs .........................................................................7-9
`Saving VIs......................................................................................................................7-10
`Advantages of Saving VIs as Individual Files ................................................7-10
`Advantages of Saving VIs as Libraries ...........................................................7-10
`Managing VIs in Libraries...............................................................................7-11
`Naming VIs .....................................................................................................7-11
`Saving for a Previous Version.........................................................................7-11
`Distributing VIs .............................................................................................................7-12
`Building Stand-Alone Applications and Shared Libraries ............................................7-12
`
`PART II
`Building and Editing VIs
`
`Chapter 8
`Loop and Case Structures
`For Loop and While Loop Structures ............................................................................8-2
`For Loops.........................................................................................................8-2
`While Loops ....................................................................................................8-2
`Avoiding Infinite While Loops .........................................................8-3
`
`© National Instruments Corporation
`
`ix
`
`LabVIEW User Manual
`
`9
`
`
`
`Contents
`
`Auto-Indexing Loops ...................................................................................... 8-4
`Auto-Indexing to Set the For Loop Count........................................ 8-4
`Auto-Indexing with While Loops..................................................... 8-5
`Shift Registers in Loops.................................................................................. 8-5
`Controlling Timing ......................................................................................... 8-6
`Case and Sequence Structures ....................................................................................... 8-6
`Case Structures................................................................................................ 8-6
`Case Selector Values and Data Types .............................................. 8-7
`Input and Output Tunnels ................................................................. 8-8
`Using Case Structures for Error Handling........................................ 8-8
`Sequence Structures ........................................................................................ 8-8
`Avoiding Overusing Sequence Structures ........................................ 8-10
`Event-Driven Programming .......................................................................................... 8-11
`What Are Events? ........................................................................................... 8-11
`Using Events in LabVIEW ............................................................................. 8-12
`Event Structures .............................................................................................. 8-12
`Configuring Events ......................................................................................... 8-13
`Filter and Notify Events ................................................................... 8-13
`Event Example.................................................................................. 8-14
`
`Chapter 9
`Grouping Data Using Strings, Arrays, and Clusters
`Strings............................................................................................................................ 9-1
`Strings on the Front Panel............................................................................... 9-2
`String Display Types ........................................................................ 9-2
`Tables .............................................................................................................. 9-2
`Programmatically Editing Strings................................................................... 9-3
`Formatting Strings........................................................................................... 9-4
`Format Specifiers.............................................................................. 9-4
`Numerics and Strings ...................................................................................... 9-5
`Converting Data Types to XML ..................................................................... 9-5
`Using XML-Based Data Types ........................................................ 9-6
`LabVIEW XML Schema .................................................................. 9-7
`Grouping Data with Arrays and Clusters ...................................................................... 9-8
`Arrays.............................................................................................................. 9-8
`Indexes.............................................................................................. 9-8
`Examples of Arrays .......................................................................... 9-8
`