Labview manuales

LabVIEW Tutorial Manual

LabVIEW ®TutorialManualJanuary 1996 EditionPart Number 320998A-01© Copyright 1993, 1996 National Instruments Corporation. All Rights Reserved.


Internet SupportGPIB: [email protected]: [email protected]: [email protected]LabVIEW: [email protected]: [email protected]: [email protected]: [email protected] Site: ftp.natinst.comWeb Address: http://www.natinst.comBulletin Board SupportBBS United States: (512) 794-5422 or (800) 327-3077BBS United Kingdom: 01635 551422BBS France: 1 48 65 15 59FaxBack Support(512) 418-1111 or (800) 329-7177Telephone Support (U.S.)Tel: (512) 795-8248Fax: (512) 794-5678 or (800) 328-2203International OfficesAustralia 03 9 879 9422, Austria 0662 45 79 90 0, Belgium 02 757 00 20,Canada (Ontario) 519 622 9310, Canada (Québec) 514 694 8521, Denmark 45 76 26 00,Finland 90 527 2321, France 1 48 14 24 24, Germany 089 741 31 30, Hong Kong 2645 3186,Italy 02 48301892, Japan 03 5472 2970, Korea 02 596 7456, Mexico 95 800 010 0793,Netherlands 0348 433466, Norway 32 84 84 00, Singapore 2265886, Spain 91 640 0085,Sweden 08 730 49 70, Switzerland 056 200 51 51, Taiwan 02 377 1200, U.K. 01635 523545National Instruments Corporate Headquarters6504 Bridge Point Parkway Austin, TX 78730-5039 Tel: (512) 794-0100


Important InformationWarrantyCopyrightTrademarksThe media on which you receive National Instruments software are warranted not to fail to execute programminginstructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidencedby receipts or other documentation. National Instruments will, at its option, repair or replace software media that donot execute programming instructions if National Instruments receives notice of such defects during the warrantyperiod. 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 outsideof the package before any equipment will be accepted for warranty work. National Instruments will pay the shippingcosts of returning to the owner parts which are covered by warranty.National Instruments believes that the information in this manual is accurate. The document has been carefullyreviewed for technical accuracy. In the event that technical or typographical errors exist, National Instrumentsreserves the right to make changes to subsequent editions of this document without prior notice to holders of thisedition. The reader should consult National Instruments if errors are suspected. In no event shall NationalInstruments 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, ANDSPECIFICALLY 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 NATIONALINSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTSWILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL ORCONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the liability of NationalInstruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any actionagainst National Instruments must be brought within one year after the cause of action accrues. National Instrumentsshall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty providedherein does not cover damages, defects, malfunctions, or service failures caused by owner’s failure to follow theNational 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, orother events outside reasonable control.Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic ormechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole orin part, without the prior written consent of National Instruments Corporation.LabVIEW ® and NI-488M are trademarks of National Instruments Corporation.Product and company names listed are trademarks or trade names of their respective companies.WARNING REGARDING MEDICAL AND CLINICAL USE OF NATIONAL INSTRUMENTS PRODUCTSNational Instruments products are not designed with components and testing intended to ensure a level of reliabilitysuitable for use in treatment and diagnosis of humans. Applications of National Instruments products involvingmedical or clinical treatment can create a potential for accidental injury caused by product failure, or by errors on thepart of the user or application designer. Any use or application of National Instruments products for or involvingmedical or clinical treatment must be performed by properly trained and qualified medical personnel, and alltraditional medical safeguards, equipment, and procedures that are appropriate in the particular situation to preventserious injury or death should always continue to be used when National Instruments products are being used.National Instruments products are NOT intended to be a substitute for any form of established process, procedure, orequipment used to monitor or safeguard human health and safety in medical or clinical treatment.


TableofContentsAbout This ManualOrganization of This Manual ........................................................................................ixConventions Used in This Manual ................................................................................xiRelated Documentation .................................................................................................xiiCustomer Communication ............................................................................................xiiiCustomer Education ......................................................................................................xiiiChapter 1Introduction to LabVIEWChapter Information ......................................................................................................1-2What Is LabVIEW? .......................................................................................................1-2How Does LabVIEW Work? ........................................................................................1-3Installing LabVIEW ......................................................................................................1-4LabVIEW Files ...............................................................................................1-4Virtual Instruments .......................................................................................................1-4Front Panel ......................................................................................................1-5Front Panel Toolbar ..........................................................................1-7Block Diagram ................................................................................................1-9Hierarchy ........................................................................................................1-11Icon/Connector Pane .......................................................................................1-12Tools Palette ..................................................................................................................1-14Editing Techniques .......................................................................................................1-15Controls Palette .............................................................................................................1-18Controls and Indicators .................................................................................................1-19Numeric Controls and Indicators ....................................................................1-19Boolean Controls and Indicators ....................................................................1-20Configuring Controls and Indicators ..............................................................1-20Functions Palette ...........................................................................................................1-21Building a VI .................................................................................................................1-21Front Panel ......................................................................................................1-23Block Diagram ................................................................................................1-24Wiring Techniques ...........................................................................1-27Tip Strips ..........................................................................................1-28Showing Terminals ..........................................................................1-28Wire Stretching ................................................................................1-29© National Instruments Corporation i LabVIEWTutorialManual


Table of ContentsSelecting and Deleting Wires .......................................................... 1-29Bad Wires ........................................................................................ 1-30Create & Wire Controls, Constants, and Indicators ....................................... 1-30Run the VI ...................................................................................................... 1-31Documenting the VI ....................................................................................... 1-32Saving and Loading VIs ................................................................................. 1-34Summary ....................................................................................................................... 1-36Chapter 2Creating a SubVIUnderstanding Hierarchy............................................................................................... 2-1Creating the SubVI ....................................................................................................... 2-1Icon ................................................................................................................. 2-2Icon Editor Tools and Buttons ......................................................... 2-2Connector ....................................................................................................... 2-4Using a VI as a SubVI .................................................................................................. 2-6Front Panel ..................................................................................................... 2-6Block Diagram ............................................................................................... 2-7Block Diagram Toolbar ................................................................... 2-8Some Debugging Techniques .......................................................... 2-9Opening, Operating, and Changing SubVIs ................................................... 2-12Hierarchy Window ......................................................................................... 2-13Search Hierarchy ............................................................................. 2-14Online Help for SubVI Nodes ........................................................................ 2-15Simple/Complex Help View ............................................................ 2-15Links to Online Help Files ............................................................... 2-16Summary ....................................................................................................................... 2-17Chapter 3Loops and ChartsUsing While Loops and Charts ..................................................................................... 3-1Front Panel .................................................................................................... 3-2Block Diagram .............................................................................................. 3-3Mechanical Action of Boolean Switches ........................................ 3-6Adding Timing ................................................................................ 3-7For Loop ...................................................................................................................... 3-9Numeric Conversion ..................................................................................... 3-10Using a For Loop ......................................................................................................... 3-12Front Panel .................................................................................................... 3-12Block Diagram .............................................................................................. 3-13Shift Registers ............................................................................................................. 3-14Using Shift Registers ................................................................................................... 3-16LabVIEWTutorialManual ii © National Instruments Corporation


Table of ContentsFront Panel .................................................................................................... 3-16Block Diagram .............................................................................................. 3-17Multiplot Charts .............................................................................. 3-19Customizing Charts ........................................................................ 3-20Different Chart Modes .................................................................... 3-22Summary ..................................................................................................................... 3-23Additional Topics ........................................................................................................ 3-24Customizing Charts ....................................................................................... 3-24Faster Chart Updates ...................................................................... 3-24Stacked Versus Overlaid Plots ....................................................... 3-24Using Loops ................................................................................................................ 3-24Testing a While Loop before Execution ....................................................... 3-24Using Uninitialized Shift Registers .............................................................. 3-26Chapter 4Arrays, Clusters, and GraphsArrays ........................................................................................................................... 4-1Array Controls, Constants, and Indicators ..................................................... 4-1Graphs ............................................................................................................ 4-2Creating an Array with Auto-Indexing ........................................................................ 4-2Front Panel ..................................................................................................... 4-2Block Diagram ............................................................................................... 4-4Multiplot Graphs ............................................................................. 4-7Polymorphism .................................................................................. 4-8Using Auto-Indexing on Input Arrays .......................................................................... 4-9Using Auto-Indexing to Set the For Loop Count ........................................... 4-10Using the Initialize Array Function ............................................................... 4-11Using the Graph and Analysis VIs ............................................................................... 4-12Front Panel ..................................................................................................... 4-13Block Diagram ............................................................................................... 4-13Using Arrays ................................................................................................................ 4-15Creating and Initializing Arrays ..................................................................... 4-15Using the Build Array Function ..................................................................... 4-16Finding the Size of an Array .......................................................................... 4-18Using the Array Subset Function ................................................................... 4-18Using the Index Array Function .................................................................... 4-19Summary ...................................................................................................................... 4-22Additional Topics ......................................................................................................... 4-23More About Arrays ........................................................................................ 4-23Efficient Memory Usage: Minimizing Data Copies ...................................... 4-23Customizing Graphs ....................................................................................... 4-23Graph Cursors .................................................................................. 4-24© National Instruments Corporation iii LabVIEWTutorialManual


Table of ContentsIntensity Plots ................................................................................................. 4-25Data Acquisition Arrays (Windows, Macintosh, and Sun) ............................ 4-25Graph Examples ............................................................................................. 4-25Chapter 5Case and Sequence Structures and the Formula NodeUsing the Case Structure .............................................................................................. 5-1Front Panel ..................................................................................................... 5-1Block Diagram ............................................................................................... 5-2VI Logic ......................................................................................................... 5-4Using the Sequence Structure ....................................................................................... 5-5Front Panel ..................................................................................................... 5-5Modifying the Numeric Format ....................................................... 5-5Setting the Data Range .................................................................... 5-7Block Diagram ............................................................................................... 5-8Formula Node ............................................................................................................... 5-11Using the Formula Node .............................................................................................. 5-13Front Panel ..................................................................................................... 5-14Block Diagram ............................................................................................... 5-15Summary ....................................................................................................................... 5-16Additional Topics ......................................................................................................... 5-17More Information on Case and Sequence Structures ..................................... 5-17Timing with Sequence Structures .................................................................. 5-17More Information on Formula Nodes ............................................................ 5-17Artificial Data Dependency ............................................................................ 5-17Chapter 6Strings and File I/OStrings ........................................................................................................................... 6-1Creating String Controls and Indicators ......................................................... 6-1Strings and File I/O ........................................................................................ 6-2Using String Functions ................................................................................................. 6-2Front Panel ..................................................................................................... 6-2Block Diagram ............................................................................................... 6-3Using Format Strings .................................................................................................... 6-4Front Panel ..................................................................................................... 6-4Block Diagram ............................................................................................... 6-5More String Functions .................................................................................................. 6-7Front Panel ..................................................................................................... 6-7Block Diagram ............................................................................................... 6-8File I/O .......................................................................................................................... 6-9File I/O Functions ......................................................................................................... 6-10LabVIEWTutorialManual iv © National Instruments Corporation


Table of ContentsWriting to a Spreadsheet File ....................................................................................... 6-11Front Panel ..................................................................................................... 6-12Block Diagram ............................................................................................... 6-12Appending Data to a File .............................................................................................. 6-14Front Panel ..................................................................................................... 6-14Block Diagram ............................................................................................... 6-15Reading Data from a File ............................................................................................. 6-16Front Panel ..................................................................................................... 6-17Block Diagram ............................................................................................... 6-17Using the File I/O Functions ........................................................................................ 6-18Specifying a File ............................................................................................ 6-18Paths and Refnums ......................................................................................... 6-19File I/O Examples .......................................................................................... 6-20Summary ...................................................................................................................... 6-20Additional Topics ......................................................................................................... 6-21Datalog Files .................................................................................................. 6-21Binary Byte Stream Files ............................................................................... 6-22Error I/O in File I/O Functions ...................................................................... 6-22Chapter 7Customizing VIsVI Setup ........................................................................................................................ 7-1Setting Window Options ................................................................................ 7-2SubVI Node Setup ........................................................................................................ 7-3Using Setup Options for a SubVI ................................................................................. 7-3Front Panel ..................................................................................................... 7-4Block Diagram ............................................................................................... 7-4Front Panel ....................................................................................... 7-7Block Diagram ................................................................................. 7-8Custom Controls and Indicators ................................................................................... 7-10Summary ...................................................................................................................... 7-13Additional Topics ......................................................................................................... 7-13Simulating a Control/Indicator ...................................................................... 7-13Using the Control Editor ................................................................................ 7-14Chapter 8Data Acquisition and Instrument ControlUsing LabVIEW to Acquire Data ................................................................................ 8-1About Plug-in Data Acquisition Boards (Windows, Macintosh, and Sun) .................. 8-2About VISA .................................................................................................................. 8-2About GPIB .................................................................................................................. 8-3About Serial Ports ........................................................................................................ 8-4© National Instruments Corporation v LabVIEWTutorialManual


Table of ContentsUsing Serial Ports ......................................................................................................... 8-5Front Panel ..................................................................................................... 8-5Block Diagram ............................................................................................... 8-6About VXI for Windows, Macintosh, and Sun ............................................................ 8-7About Instrument Drivers ............................................................................................. 8-8Using Instrument Drivers ............................................................................................. 8-9Front Panel ..................................................................................................... 8-9Block Diagram ............................................................................................... 8-10Using a Frequency Response Test VI .......................................................................... 8-13Front Panel ..................................................................................................... 8-14Block Diagram ............................................................................................... 8-15Writing a Test Sequencer ............................................................................................. 8-17Front Panel ..................................................................................................... 8-17Block Diagram ............................................................................................... 8-18Summary ....................................................................................................................... 8-19Additional Topics ......................................................................................................... 8-20Error Handling ............................................................................................... 8-20Waveform Transfers ....................................................................................... 8-21ASCII Waveforms ........................................................................... 8-21Binary Waveforms ........................................................................... 8-22Chapter 9Programming Tips and Debugging TechniquesProgramming Tips ........................................................................................................ 9-1Debugging Techniques ................................................................................................. 9-5Finding Errors ................................................................................................ 9-5Single Stepping Through a VI ........................................................................ 9-5Execution Highlighting .................................................................................. 9-6Debugging a VI ............................................................................................................ 9-6Front Panel ..................................................................................................... 9-6Block Diagram ............................................................................................... 9-7Opening the Front Panels of SubVIs ............................................................................ 9-9Summary ....................................................................................................................... 9-10Chapter 10Program DesignUse Top-Down Design ................................................................................................. 10-1Make a List of User Requirements ................................................................. 10-1Design the VI hierarchy ................................................................................. 10-2Write the Program .......................................................................................... 10-3Plan Ahead with Connector Patterns ............................................................................ 10-3SubVIs with Required Inputs ......................................................................... 10-5LabVIEWTutorialManual vi © National Instruments Corporation


Table of ContentsGood Diagram Style ..................................................................................................... 10-5Avoid Oversized Diagrams ............................................................................ 10-5Watch for Common Operations ..................................................................... 10-6Use Left-to-Right Layouts ............................................................................. 10-7Check for Errors ............................................................................................. 10-7Watch Out for Missing Dependencies ........................................................... 10-9Avoid Overuse of Sequence Structures ......................................................... 10-10Study the Examples ........................................................................................ 10-10Chapter 11Where to Go from HereOther Useful Documentation ........................................................................................ 11-1For Information on Advanced Topics .......................................................................... 11-2Appendix ACustomer CommunicationGlossaryIndex© National Instruments Corporation vii LabVIEWTutorialManual


AboutThisManualOrganization of This ManualThe LabVIEWTutorial contains the information you need to get startedwith the Laboratory Virtual Instrument Engineering Workbench(LabVIEW) software package. LabVIEW simplifies scientificcomputation, process control, and test and measurement applications,and you can also use it for a wide variety of other programmingapplications.This manual gives you an overview of the fundamental concepts ofLabVIEW, and includes lessons to teach you what you need to know tobuild your own virtual instruments (VIs) as quickly as possible. Thismanual does not explain every LabVIEW feature. Its goal is tointroduce the most important LabVIEW features in the context ofaddressing programming tasks.This manual presumes that you know how to operate your computerand that you are familiar with its operating system.Each chapter discusses a different LabVIEW concept, although youcan design a VI that may incorporate several of these basic concepts.Therefore, we encourage you to work through the entire tutorial beforeyou begin building your application.Some of the chapters in this tutorial include an Additional Topicssection, which gives an overview of advanced LabVIEW features andrefers you to other documentation and example VIs.This manual is organized as follows:• Chapter 1, Introduction to LabVIEW, describes what LabVIEW is,what a Virtual Instrument (VI) is, how to use the LabVIEWenvironment (windows, menus, palettes, and tools), how tooperate VIs, how to edit VIs, and how to create VIs.© National Instruments Corporation ix LabVIEWTutorialManual


About This Manual• Chapter 2, Creating a SubVI, describes what a subVI is, teaches youhow to create the icon and connector, and teaches you how to use a VIas a subVI.• Chapter 3, Loops and Charts, introduces While Loops, teaches youhow to display data in a chart, teaches you about shift registers andhow to use them, and teaches you how to use For Loops.• Chapter 4, Arrays, Clusters, and Graphs, discusses how to createarrays, use basic array functions, clusters, and graphs. You also learnwhat polymorphism is, and how to use graphs to display data.• Chapter 5, Case and Sequence Structures and the Formula Node,describes how to use the Case structure and Sequence structure,sequence locals and Formula Nodes.• Chapter 6, Strings and File I/O, teaches you how to create stringcontrols and indicators and teaches you how to use string functions,file input and output operations, save data to files in spreadsheets, andwrite data to and read data from text files.• Chapter 7, Customizing VIs, shows you how to use the VI and subVIsetup options and how to make custom controls and indicators.• Chapter 8, Data Acquisition (for Windows, Macintosh, and Sun) andInstrument Control, discusses how to acquire data from a plug-in dataacquisition board, teaches you about VISA, teaches you about GPIB,shows you how to control a serial port interface from LabVIEW,discusses VXI (for Windows, Macintosh, and Sun), teaches you aboutinstrument drivers and how to use them, and teaches you about usinga Frequency Response Test VI.• Chapter 9, Programming Tips and Debugging Techniques, gives youtips for programming and debugging VIs and teaches you editingtechniques.• Chapter 10, Program Design, offers some techniques to use whencreating programs and offers programming style suggestions.• Chapter 11, Where to Go From Here, contains information on otheruseful resources to examine as you build your LabVIEWapplications.• The Appendix, Customer Communication, contains forms you canuse to request help from National Instruments or to comment on ourproducts and manuals.LabVIEWTutorialManual x © National Instruments Corporation


About This Manual• The Glossary contains an alphabetical list of terms used in thismanual, including abbreviations, acronyms, metric prefixes,mnemonics, and symbols.• The Index contains an alphabetical list of key terms and topics in thistutorial, including the page where you can find each one.Conventions Used in This Manualbolditalicbold italicmonospaceThe following conventions are used in this manual:Bold text denotes menus, menu items, or dialog box buttons or options. Inaddition, bold text denotes VI input and output parameters.Italic text denotes emphasis, a cross reference, or an introduction to a keyconcept.Bold italic text denotes a note, caution, or warning.Monospace font denotes text or characters that you enter using thekeyboard. Sections of code, programming examples, syntax examples,and messages and responses that the computer automatically prints to thescreen also appear in this font.italic Italic text in this font denotes that you must supply the appropriate wordsmonospace or values in the place of these items. Angle brackets enclose the name of a key on the keyboard—for example,.- A hyphen between two or more key names enclosed in angle bracketsdenotes that you should simultaneously press the named keys–forexample, .» The » symbol leads you through nested menu items and dialog boxoptions to a final action. The sequencepathsFile»Page Setup»Options»Substitute Fontsdirects you to pull down the File menu, select the Page Setup item, selectOptions, and finally select the Substitute Fonts option from the lastdialog box.Paths in this manual are denoted using backslashes (\) to separate drivenames, directories, and files, as in drivename\dir1name\dir2name\myfile.© National Instruments Corporation xi LabVIEWTutorialManual


About This ManualIEEE 488.1 and IEEE 488.1 and IEEE 488.2 refer to the ANSI/IEEE Standard 488.1-1987IEEE 488.2 and the ANSI/IEEE Standard 488.2-1987, respectively, which definethe GPIB.Warning: This icon to the left of bold italicized text denotes a warning, which alertsyou to the possibility of damage to you or your equipment.Caution:Note:This icon to the left of bold italicized text denotes a caution, which alertsyou to the possibility of data loss or a system crash.This icon to the left of bold italicized text denotes a note, which alerts youto important information.Related DocumentationAbbreviations, acronyms, metric prefixes, mnemonics, symbols, andterms are listed in the Glossary.The following documents contain information that you may findhelpful as you read this manual:• LabVIEW Analysis VI Reference ManualLabVIEW Code Interface Reference ManualLabVIEW Communication VI Reference ManualLabVIEW Data Acquisition Basics Manual (Windows, Macintosh,and Sun)• LabVIEW Data Acquisition VI Reference Manual (Windows,Macintosh, and Sun)• LabVIEW Instrument I/O VI Reference ManualLabVIEW User Manual• ANSI/IEEE Standard 488.1-1987, IEEE Standard Digital Interfacefor Programmable Instrumentation• ANSI/IEEE Standard 488.2-1987, IEEE Standard Codes, Formats,Protocols, and Common Commands• LabVIEW Function Reference Manual available online; printedversion available by request.LabVIEWTutorialManual xii © National Instruments Corporation


About This ManualCustomer CommunicationCustomer EducationNational Instruments wants to receive your comments on our productsand manuals. We are interested in the applications you develop withour products, and we want to help if you have problems with them. Tomake it easy for you to contact us, this manual contains comment andconfiguration forms for you to complete. These forms are in theAppendix, Customer Communication, at the end of this manual.National Instruments offers hands-on LabVIEW Basics and Advancedcourses to help you quickly master LabVIEW and develop successfulapplications. The comprehensive Basics course not only teaches youLabVIEW fundamentals, but also gives you hands-on experiencedeveloping data acquisition and instrument control applications. Thefollow-up Advanced course teaches you how to maximize theperformance and efficiency of LabVIEW applications. ContactNational Instruments for a detailed course catalog and for course feesand dates.© National Instruments Corporation xiii LabVIEWTutorialManual


Introduction to LabVIEWChapter1This chapter describes what LabVIEW is, what a VirtualInstrument (VI) is, how to use the LabVIEW environment (windows,menus, palettes, and tools), how to operate VIs, how to edit VIs, andhow to create VIs.Because LabVIEW is such a feature-rich program developmentsystem, this tutorial cannot practically show you how to solve everypossible programming problem. Instead, this tutorial explains thetheory behind LabVIEW, contains exercises to teach you to use theLabVIEW programming tools, and guides you through practical uses ofLabVIEW features as applied to actual programming tasks.If you would like more training after using this manual, NationalInstruments offers hands-on LabVIEW courses to help you quicklymaster LabVIEW and develop successful applications.The comprehensive LabVIEW Basics course not only teaches youLabVIEW fundamentals, but also gives you hands-on experiencedeveloping data acquisition (for Windows, Macintosh, and Sun) andinstrument control applications. The follow-up LabVIEW Advancedcourse teaches you how to maximize the performance and efficiency ofLabVIEW applications in addition to teaching you the advancedfeatures of LabVIEW.For a detailed course catalog and for course fees and dates, refer to theaddress page on the inside front cover of this manual for informationabout contacting National Instruments.© National Instruments Corporation 1-1 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWChapter InformationWhat Is LabVIEW?Each chapter begins with a section like the one that follows, listing thelearning objectives for that chapter.You Will Learn:• What LabVIEW is.• What a Virtual Instrument (VI) is.• How to use the LabVIEW environment (windows and palettes).• How to operate VIs.• How to edit VIs.• How to create VIs.LabVIEW is a program development application, much like variouscommercial C or BASIC development systems, or NationalInstruments LabWindows. However, LabVIEW is different from thoseapplications in one important respect. Other programming systems usetext-based languages to create lines of code, while LabVIEW uses agraphical programming language, G, to create programs in blockdiagram form.You can use LabVIEW with little programming experience. LabVIEWuses terminology, icons, and ideas familiar to scientists and engineersand relies on graphical symbols rather than textual language to describeprogramming actions.LabVIEW has extensive libraries of functions and subroutines for mostprogramming tasks. For Windows, Macintosh, and Sun, LabVIEWcontains application specific libraries for data acquisition and VXIinstrument control. LabVIEW also contains application-specificlibraries for GPIB and serial instrument control, data analysis, datapresentation, and data storage. LabVIEW includes conventionalprogram development tools, so you can set breakpoints, animateprogram execution to see how data passes through the program, andsingle-step through the program to make debugging and programdevelopment easier.LabVIEWTutorialManual 1-2 © National Instruments Corporation


Chapter 1Introduction to LabVIEWHow Does LabVIEW Work?LabVIEW includes libraries of functions and development toolsdesigned specifically for instrument control. For Windows, Macintosh,and Sun, LabVIEW also contains libraries of functions anddevelopment tools for data acquisition. LabVIEW programs are calledvirtual instruments (VIs) because their appearance and operationimitate actual instruments. However, they are analogous to functionsfrom conventional language programs. VIs have both an interactiveuser interface and a source code equivalent, and accept parametersfrom higher-level VIs. The following are descriptions of these three VIfeatures.• VIs contain an interactive user interface, which is called the frontpanel, because it simulates the panel of a physical instrument. Thefront panel can contain knobs, push buttons, graphs, and othercontrols and indicators. You input data using a keyboard andmouse, and then view the results on the computer screen.• VIs receive instructions from a block diagram, which youconstruct in G. The block diagram supplies a pictorial solution toa programming problem. The block diagram contains the sourcecode for the VI.• VIs use a hierarchical and modular structure. You can use them astop-level programs, or as subprograms within other programs orsubprograms. A VI within another VI is called a subVI. The iconand connector pane of a VI work like a graphical parameter list sothat other VIs can pass data to it as a subVI.With these features, LabVIEW promotes and adheres to the concept ofmodular programming. You divide an application into a series of tasks,which you can divide again until a complicated application becomes aseries of simple subtasks. You build a VI to accomplish each subtaskand then combine those VIs on another block diagram to accomplishthe larger task. Finally, your top-level VI contains a collection ofsubVIs that represent application functions.Because you can execute each subVI by itself, apart from the rest of theapplication, debugging is much easier. Furthermore, many low-levelsubVIs often perform tasks common to several applications, so that youcan develop a specialized set of subVIs suited to applications you canconstruct.© National Instruments Corporation 1-3 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWInstalling LabVIEWFor instructions on how to install LabVIEW, see your LabVIEWrelease notes.After installing LabVIEW, the default configuration setting is correctfor the purposes of this tutorial. If you would like to explore LabVIEWconfiguration options, see the Preferences Dialog Boxes section ofChapter 8, Customizing Your LabVIEW Environment, in the LabVIEWUser Manual.LabVIEW FilesThe LabVIEW system consists of the LabVIEW application and anumber of associated files.Virtual InstrumentsLabVIEW uses several directories and files from the hard drive to storeinformation necessary to create your VIs. These directories and filesinclude, among others:• The vi.lib directory. This directory contains libraries of VIs,such as analysis VIs.• The examples directory. This directory contains many sampleVIs that demonstrate LabVIEW’s program functionality.• The tutorial.llb library. This file, located in the vi.libdirectory, contains a library of VIs that this tutorial uses.You can access the contents of these files and directories from withinthe LabVIEW environment.LabVIEW programs are called virtual instruments (VIs). VIs havethree main parts: the front panel, the block diagram, and theicon/connector.OBJECTIVETo open, examine, and operate a VI, and to familiarize yourself withthe basic concepts of a virtual instrument.LabVIEWTutorialManual 1-4 © National Instruments Corporation


Chapter 1Introduction to LabVIEWFront Panel1. (Windows) Open LabVIEW by double-clicking with the mousebutton on the LabVIEW icon in the LabVIEW group. If this is thefirst time you have opened LabVIEW, the program prompts you toenter your name, the name of your company, and your LabVIEWserial number.(Macintosh) Launch LabVIEW by double-clicking on theLabVIEW icon in the LabVIEW folder. If this is the first time youhave launched LabVIEW, the program prompts you to enter yourname, the name of your company, and your LabVIEW serialnumber.(UNIX) Launch LabVIEW by typing labview in ashell window. If LabVIEW is not in your executable path, youmust type in the path to the LabVIEW executable followed bylabview, as shown in the following example./usr/lib/labview/labview(All Platforms) After a few moments, a blank, untitled front panelappears.© National Instruments Corporation 1-5 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEW2. Open the Temperature System Demo VI by following these steps.a. Select File»Open.b. Double-click on examples. Double-click on apps.Double-click on tempsys.llb.c. Double-click on Temperature System Demo.vi.While the VI loads, a dialog box appears, which describes the name ofthe VI currently loading, the name of the hard drive that the VI islocated on, the directories and paths being searched, and the number ofthe VI in the loading process. The following illustration shows thedialog box that appears when you load the Temperature System DemoVI.After a few moments, the Temperature System Demo VI front panelappears, as the following illustration shows. The front panel containsLabVIEWTutorialManual 1-6 © National Instruments Corporation


Chapter 1Introduction to LabVIEWseveral numeric controls, Boolean switches, slide controls, knobcontrols, charts, graphs, and a thermometer indicator.Front Panel ToolbarThe front panel contains a toolbar of command buttons and statusindicators that you use for running and debugging VIs. It also containsfont options and alignment and distribution options for editing VIs.Front Panel Toolbar:Run button–Runs the VIContinuous run button–Runs the VI over and over; useful fordebuggingStop button–Aborts VI execution© National Instruments Corporation 1-7 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWPause/Continue button–Pauses VI execution/Continues VI executionFont ring–Sets font options, including font type, size, style, and colorAlignment ring–Sets alignment options, including vertical, top edge,left, and so on, for two or more objectsDistribution ring–Sets distribution options, including gaps,compression, and so on, for two or more objects1. On the front panel, run the VI by clicking on the run button in thetoolbar.The button changes appearance to indicate that the VI is running.The Temperature System Demo VI simulates a temperature monitoringapplication. The VI takes temperature readings and displays them inthe thermometer indicator and on the chart. The Update Period slidecontrols how fast the VI acquires the new temperature readings.LabVIEW also plots high and low temperature limits on the chart,which you can change using the Temperature Range knobs in themiddle left border. If the current temperature reading is out of the setrange, LEDs light up next to the thermometer.This VI continues to run until you click the Acquisition switch to Off.You can also turn the data analysis on and off. The analysis consists ofa running calculation of the mean and standard deviation of thetemperature values and a histogram of the temperature values.2. Use the Operating tool to change the values of the high and lowlimits. First, highlight the old value, either by double-clicking onthe value you want to change, or by clicking and dragging acrossthe value with the Labeling tool. When the initial value ishighlighted, type a new value and press (Windows); (Macintosh); (Sun); or (HP-UX).You can also click on the enter button in the toolbar, or click themouse in an open area of the window to enter the new value.3. Change the Update Period slide control, shown in the followingillustration, by placing the Operating tool on the slider anddragging it to a new location.LabVIEWTutorialManual 1-8 © National Instruments Corporation


Chapter 1Introduction to LabVIEWLabelDigital DisplayScroll ButtonSliderHousing4. Practice adjusting the other controls.5. Stop the VI by clicking on the Acquisition switch. The VI may notstop immediately because the VI has to wait for the last equationor analysis set to complete operation.Note:You should always wait for a VI to complete execution or you shoulddesign a method to stop it, such as placing a switch on the front panel. Inthis case, the VI collects the last set of temperature values, performs theanalysis, and comes to a completion when you click the Acquisitionswitch.Although the VI stops if you click on the stop button in the toolbar, this isnot the best way to stop VIs because the stop button halts the programimmediately. This may interrupt critical I/O functions, and so it isprobably not desirable.Block DiagramThe following block diagram represents a complete LabVIEWapplication, and is an example of how intricate LabVIEWprogramming can be. Subsequent chapters in this tutorial detailstructures and elements mentioned in this section. It is not necessary tounderstand all of these block diagram elements at this time toappreciate the nature of a block diagram.© National Instruments Corporation 1-9 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWFor LoopWhile LoopShift RegistersCase Structure1. Open the block diagram of the Temperature System Demo VI bychoosing Windows»Show Diagram.2. Examine the different objects in the block diagram.Each front panel has an accompanying block diagram, which is the VIequivalent of a program. You build the block diagram using thegraphical programming language, G. You can think of the blockdiagram as source code. The components of the block diagramrepresent program nodes such as For Loops, Case structures, andmultiplication functions. The components are wired together to showthe flow of data within the block diagram.The outermost structure is a While Loop. It continues to run what isinside of it until the Acquisition switch is set to Off. The arrowterminals on the border of the While Loop are called Shift Registers andstore values from one iteration of the loop to the next. The values thatthe shift registers store here are the histogram, analysis iteration value,mean, and standard deviation, in that order.LabVIEWTutorialManual 1-10 © National Instruments Corporation


Chapter 1Introduction to LabVIEWThe two main structures inside the While Loop are a For Loop and aCase structure. The acquisition of the data takes place inside the ForLoop. The For Loop takes 10 temperature readings at the rate specifiedby Update Period and plots each reading on the thermometer and thechart. The VI also compares the temperature to the high and low limits.The Case structure controls the temperature analysis. If the Analysisswitch is off, the VI performs no analysis. You can see this by clickingon one of the arrows next to the word True. In the False case, noanalysis takes place, and the histogram and analysis iteration value arereset to zero. Change back to the True case using the same method youused to change to the False case. Here, two subVIs analyze thedata—one keeps a running mean and standard deviation of thetemperatures, and the other keeps a running histogram of the acquiredtemperatures.You do not need to fully understand all of the structures at this point.The subsequent chapters in this tutorial discuss in greater detail eachelement that appears in this VI.HierarchyThe power of LabVIEW lies in the hierarchical nature of VIs. Afteryou create a VI, you can use it as a subVI in the block diagram of ahigher level VI. You can have an essentially unlimited number oflayers in the hierarchy.As an example, look at a VI that the Temperature System Demo VIuses as a subVI in its block diagram.© National Instruments Corporation 1-11 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEW1. Open the Temperature Status subVI by double-clicking on thesubVI icon. The following front panel appears.Icon/Connector PaneYou use the icon/connector pane to turn a VI into an object that youcan use in the block diagrams of other VIs as a subroutine or function.The icon and connector are located in the upper right corner of the VIIconConnectorfront panel. The icon graphically represents the VI in the block diagramof other VIs. The connector terminals determine where you must wirethe inputs and outputs on the icon. The terminals are analogous toparameters of a subroutine or function. They correspond to the controlsand indicators on the front panel of the VI. The icon hides theconnector until you choose to view it.2. Put the Operating tool on the icon pane in the upper right corner ofthe front panel and pop up. A pop-up menu appears.3. Select Show Connector from the pop-up menu. The cursorchanges to the Wiring tool, shown on the left.The squares on the connector are terminals that correspond to thecontrols and indicators on the front panel.4. Click on a terminal. It turns black. Notice that a control orindicator becomes highlighted on the front panel. When youwire the control or indicator (terminal), the data in it passesto (or is received from) the other end of the wire.LabVIEWTutorialManual 1-12 © National Instruments Corporation


Chapter 1Introduction to LabVIEW5. Place the Wiring tool on the connector in the front panel and popup. A pop-up menu appears.6. Select Show Icon. The Wiring tool changes back to the Operatingtool.7. Switch to the block diagram by selecting Windows»ShowDiagram. At this time, you do not need to understand what all theparts of the block diagram do. It is enough to notice that a subVIcan be complex or simple in itself.By creating subVIs, you can make your block diagrams modular. Thismodularity makes VIs easy to debug, understand, and maintain.8. Switch to the front panel (Windows»Show Panel).9. Select File»Close and do not save any changes you have made.© National Instruments Corporation 1-13 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWTools PaletteLabVIEW uses a floating Tools palette, which you can use to edit anddebug VIs. You use the key to tab through the commonly usedtools on the palette. If you have closed the Tools palette, selectWindows»Show Tools Palette to display the palette.The followingIllustration displays the Tools palette.Operating tool–Places Controls and Functions palette items on thefront panel and block diagramPositioning tool–Positions, resizes, and selects objectsLabeling tool–Edits text and creates free labelsWiring tool–Wires objects together in the block diagramObject pop-up menu tool–Brings up on a pop-up menu for an objectScroll tool–Scrolls through the window without using the scrollbarsBreakpoint tool–Sets breakpoints on VIs, functions, loops, sequences,and casesProbe tool–Creates probes on wiresColor copy tool–Copies colors for pasting with the Color toolColor tool–Sets foreground and background colorsLabVIEWTutorialManual 1-14 © National Instruments Corporation


Chapter 1Introduction to LabVIEWEditing TechniquesOBJECTIVETo learn LabVIEW editing techniques.To work on the Editing Exercise VI, select File»Open. The EditingExercise VI is located in examples\general\controls\smplctls.llb.The front panel of the Editing Exercise VI contains a number ofLabVIEW objects. Your objective is to change the front panel of the VIas the following illustration shows.1. If the Tools palette is not visible, select Windows»Show ToolsPalette to display it.2. Reposition the digital control.a. Choose the Positioning tool from the Tools palette.b. Click on the digital control and drag it to another location.Notice that the label follows the control. The control owns the label.3. Click on a blank space on the front panel to deselect the control,and then click on the label and drag it to another location.© National Instruments Corporation 1-15 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWNotice that the control does not follow the label. You can position anowned label anywhere relative to the control, but when the controlmoves, the label follows.4. Switch to the block diagram by selecting Windows»ShowDiagram.5. Move the block diagram so that you can see both windows.6. Click on the front panel to make it active.7. Copy the digital control to the block diagram to create acorresponding constant.a. Choose the Positioning tool from the Tools palette.b. Click on the digital control. While holding the mouse buttondown, drag the digital control to the block diagram. Thedigital control now appears as a corresponding constant on theblock diagram. You can also use the Copy and Paste optionsfrom the Edit menu to copy the control and then paste it to theblock diagram.Note:You can use this same process to drag or copy a constant from the blockdiagram to the front panel to create a corresponding control.8. Reposition the four slide switches as a group.a. Using the Positioning tool, click in an open area near the fourswitches, hold down the mouse button, and drag until all theswitches lie within the selection rectangle.b. Click on the selected switches and drag them to a differentlocation.9. Duplicate the free label. Using the Positioning tool, hold down (Windows); (Macintosh); (Sun); or (HP-UX), click on the free label, and drag the duplicate ofthe free label to a new location. For UNIX, you can use the middlemouse button to drag the label. This creates a duplicate copy of thelabel.10. Change the font size of the free label.a. Select the text by using the Labeling tool. You can triple-clickon the text, or click on the first letter in the label and drag thecursor to the end of the label.b. Change the selected text size to 12 points by choosing Sizefrom the Font ring, located in the toolbar.11. Create an owned label for the digital indicator.LabVIEWTutorialManual 1-16 © National Instruments Corporation


Chapter 1Introduction to LabVIEWa. Pop up on the digital indicator and choose Show»Label fromthe pop-up menu.b. Type Digital Indicator inside the bordered box and click themouse button outside the label. You can also end text entry bypressing on the numeric keypad.12. Resize the round LED. Place the Positioning tool over a corner ofthe LED until the tool becomes the Resizing cursor. Click and dragthe cursor outward to enlarge the LED. If you want to maintain thecurrent ratio of horizontal to vertical size of the LED, hold downthe key while resizing the LED.13. Change the color of the round LED.a. Using the Color tool, pop up on the LED.b. Choose a color from the selection palette. When you releasethe mouse button, the object assumes the last color youselected.14. Place the four button switches so they are aligned horizontally andevenly spaced.a. Using the Positioning tool, click in an open area near the fourswitches and drag until all the switches lie within the selectionrectangle.b. Align the switches horizontally by clicking on the Alignmentring in the toolbar and choosing the Vertical Centersalignment.c. Space the switches evenly by clicking on the Distribution ringand choosing the Horizontal Centers distribution. The frontpanel should now look similar to the following illustration.© National Instruments Corporation 1-17 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWControls Palette15. Close the VI by selecting File»Close. Do not save any changes.The Controls palette consists of a graphical, floating palette thatautomatically opens when you launch LabVIEW. You use this paletteto place controls and indicators on the front panel of a VI. Eachtop-level icon contains subpalettes. If the Controls palette is notvisible, you can open the palette by selecting Windows»Show ControlsPalette from the front panel menu. You can also pop up on an open areain the front panel to access a temporary copy of the Controls palette.LabVIEWTutorialManual 1-18 © National Instruments Corporation


Chapter 1Introduction to LabVIEWThe following illustration displays the top-level of the Controlspalette.Controls and IndicatorsNumeric Controls and IndicatorsYou use numeric controls to enter numeric quantities, while numericindicators display numeric quantities. The two most commonly usednumeric objects are the digital control and the digital indicator.LabelIncrement ButtonsDigital ControlLabelDigital Indicator© National Instruments Corporation 1-19 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWBoolean Controls and IndicatorsYou use Boolean controls and indicators for entering and displayingBoolean (True/False) values. Boolean objects simulate switches,buttons, and LEDs. The most commonly used Boolean objects are thevertical switch and the round LED.Configuring Controls and IndicatorsYou can configure nearly all the controls and indicators using optionsfrom their pop-up menus. Popping up on individual components ofcontrols and indicators displays menus for customizing thosecomponents. An easy way to access the pop-up menu is to click theObject pop-up menu tool, shown at left, on any object that has apop-up menu. The following picture illustrates this display method fora digital control.Pop up on the label forits pop-up menuPop up on the digital displayfor its pop-up menuLabVIEWTutorialManual 1-20 © National Instruments Corporation


Chapter 1Introduction to LabVIEWFunctions PaletteThe Functions palette consists of a graphical, floating palette thatautomatically opens when you switch to the block diagram. You usethis palette to place nodes (constants, indicators, VIs, and so on) on theblock diagram of a VI. Each top-level icon contains subpalettes. If theFunctions palette is not visible, you can select Windows»ShowFunctions Palette from the block diagram menu to display it. You canalso pop up on an open area in the block diagram to access a temporarycopy of the Functions palette. The following illustration displays thetop-level of the Functions palette.Building a VIOBJECTIVETo build a VI that simulates acquisition of a temperature reading.You will use the Demo Voltage Read VI to measure the voltage, andthen multiply the reading by 100.0 to convert the voltage into atemperature (in degrees F).© National Instruments Corporation 1-21 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWImagine that you have a transducer or sensor that converts temperatureto voltage.(Windows, Macintosh, and Sun) The sensor connects to ananalog-to-digital converter (A/D) board, as shown in the followingillustration, which converts voltage to digital data.A/D BoardPCSensor(HP-UX) The sensor could also be connected to an analog-to-digitalconverter that is connected to the computer through GPIB, as shown inthe following illustration. This also converts voltage to digital data.GPIBBoardhpGPIB-basedADCHP WorkstationSensorLabVIEWTutorialManual 1-22 © National Instruments Corporation


Chapter 1Introduction to LabVIEWFront PanelNote:1. Open a new front panel by selecting File»New. For Windows andUNIX, if you have closed all VIs, select New VI from theLabVIEW dialog box.If the Controls palette is not visible, select Windows»Show ControlsPalette to display the palette. You can also access the Controls palette bypopping up in an open area of the front panel.2. Select a Thermometer indicator from Controls»Numeric, andplace it on the front panel.3. Type Temp inside the label text box and click on the enter buttonon the toolbar.Note:If you click outside the text box without entering text, the label disappears.You can show the label again by popping up on the control and selectingShow»Label.Remember, to pop up, use right-click (-click on Macintosh).4. Rescale the thermometer control to display the temperaturebetween 0.0 and 100.0.a. Using the Labeling tool, double-click on 10.0 in thermometerscale to highlight it.b. Type 100.0 in the scale and click the mouse button anywhereoutside the display window. LabVIEW automatically scalesthe intermediary increments.The temperature control shouldnow look like the following illustration.© National Instruments Corporation 1-23 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWBlock Diagram1. Open the block diagram by choosing Windows»Show Diagram.Select the block diagram objects from the Functions palette. Foreach object that you want to insert, select the icon and then theobject from the top-level of the palette, or choose the object fromthe appropriate subpalette. When you position the mouse on theblock diagram, LabVIEW displays an outline of the object. This isyour opportunity to place the object where you want on the blockdiagram.Note:If the Functions palette is not visible, select Windows»Show FunctionsPalette to display the palette. You can also access the Functions palette bypopping up in an open area of the block diagram.The Demo Voltage Read VI (Functions»Tutorial) simulates reading avoltage from a plug-in data acquisition board.Multiply function (Functions»Numeric). In this exercise, the functionmultiplies the voltage returned by the Demo Voltage Read VI by 100.0.Numeric Constant (Functions»Numeric). You need two numericconstants: one for the scaling factor of 100 and one for the deviceconstant. For the first numeric constant, type 100.0 when the constantfirst appears on the block diagram.LabVIEWTutorialManual 1-24 © National Instruments Corporation


Chapter 1Introduction to LabVIEW2. Create the second numeric constant using a shortcut toautomatically create and wire the constant to the Demo VoltageRead VI.a. Using the Wiring tool, pop up on the input marked Board IDon the Demo Voltage Read VI and select Create Constantfrom the pop-up menu. This option automatically creates anumeric constant and wires it to the Demo Voltage Read VI.b. Type 1 when the constant first appears on the block diagram.This changes the default value of zero to one. Notice that youdo not have to change to the Labeling tool to insert the valuewhen using this feature.c. Using the Labeling tool, change the default label (Board ID)to Device.In this example, the two numerics represent the constant 100.0 and thedevice for the multiply function.String Constant (Functions»String).3. Pop up on the input marked Channel, at the bottom left of theDemo Voltage Read VI and select Create Constant from thepop-up menu. This option automatically creates a string constantand wires it to the Demo Voltage Read VI.4. Type 0 when the constant first appears on the block diagram.Notice that in this instance, Channel appears in the default labelso you do not have to change the label.In this example, you use the string constant to represent the channelnumber.Note:You can create and wire controls, constants and indicators with mostfunctions. If these options are not available for a particular function, theCreate Control, Create Constant and Create Indicator options aredisabled on the pop-up menu. For more information on this feature, seethe Create & Wire Controls, Constants, and Indicators section later in thischapter.© National Instruments Corporation 1-25 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEW5. Using the Wiring tool, wire the remaining objects together asexplained in the Wiring Techniques section later in this chapter.Blue wire (integer)Orange wire (floating-point numbers)Pink wire (string)LabVIEW color keys wires to the kind of data each wire carries. Bluewires carry integers, orange wires carry floating-point numbers, greenwires carry Booleans, and pink wires carry strings.You can activate the Help window by choosing Help»Show Help.Placing any of the editing tools on a node displays the inputs andoutputs of that function in the Help window. As you pass an editingtool over the VI icon, LabVIEW highlights the wiring terminals in boththe block diagram and the Help window. When you begin to wire yourown diagrams, this flashing highlight can help you to connect yourinputs and outputs to the proper terminals.The Demo Voltage Read VI simulates reading the voltage at Channel0 of a plug-in board. The VI then multiplies the voltage by 100.0 toconvert it to a temperature in °F.LabVIEWTutorialManual 1-26 © National Instruments Corporation


Chapter 1Introduction to LabVIEWWiring TechniquesIn the wiring illustrations in this section, the arrow at the end of thismouse symbol shows where to click and the number printed on themouse button indicates how many times to click the mouse button.The hot spot of the tool is the tip of the unwound wiring segment.Hot SpotTo wire from one terminal to another, click the Wiring tool on the firstterminal, move the tool to the second terminal, and click on the secondterminal. It does not matter at which terminal you start.When the Wiring tool is over a terminal, the terminal area blinks, toindicate that clicking connects the wire to that terminal. Do not holddown the mouse button while moving the Wiring tool from oneterminal to another. You can bend a wire once by moving the mouseperpendicular to the current direction. To create more bends in thewire, click the mouse button. To change the direction of the wire, pressthe spacebar. Click with the mouse button, to tack the wire down andmove the mouse perpendicularly.© National Instruments Corporation 1-27 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWTip StripsWhen you move the Wiring tool over the terminal of a node, a tip stripfor that terminal pops up. Tip strips consist of small, yellow textbanners that display the name of each terminal. These tip strips shouldhelp you to wire the terminals. The following illustration displays thetip strip (Measured Voltage) that appears when you place the Wiringtool over the output of the Demo Voltage Read VI.Note:When you place the Wiring tool over a node, LabVIEW displays wire stubsthat indicate each input and output. The wire stub has a dot at its end if itis an input to the node.Showing TerminalsIt is important that you wire the correct terminals of a function. Youcan show the icon connector to make correct wiring easier. To do this,pop up on the function and choose Show»Terminals. To return to theicon, pop up on the function and again select Show»Terminals.LabVIEWTutorialManual 1-28 © National Instruments Corporation


Chapter 1Introduction to LabVIEWWire StretchingYou can move wired objects individually or in groups by dragging theselected objects to a new location with the Positioning tool.Selecting and Deleting WiresYou may accidentally wire nodes incorrectly. If you do, select the wireyou want to delete and then press . A wire segment is asingle, horizontal or vertical piece of wire. The point where three orfour wire segments join is called a junction. A wire branch contains allthe wire segments from one junction to another, from a terminal to thenext junction, or from one terminal to another if there are no junctionsin between. You select a wire segment by clicking on it with thePositioning tool. Double-clicking selects a branch, and triple-clickingselects the entire wire.segmentjunctionsegmentbendSelects a segment Selects a branch Selects anentire wire© National Instruments Corporation 1-29 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWBad WiresA dashed wire represents a bad wire. You can get a bad wire for anumber of reasons, such as connecting two controls, or connecting asource terminal to a destination terminal when the data types do notmatch (for instance, connecting a numeric to a Boolean). You canremove a bad wire by clicking on it with the Positioning tool andpressing . Choosing Edit»Remove Bad Wires deletes allbad wires in the block diagram. This is a useful quick fix to try if yourVI refuses to run or returns the Signal has loose ends errormessage.Note:Do not confuse a dashed wire with a dotted wire. A dotted wire representsa Boolean data type, as the following illustration shows.Dashed Wire (Bad)Dotted Wire (Good)Create & Wire Controls, Constants, and IndicatorsFor terminals acting as inputs on the block diagram, LabVIEW has twofeatures that you can use to create and wire a control or constant. Youaccess these features by popping up on the terminal and choosingCreate Control or Create Constant. LabVIEW automatically createsLabVIEWTutorialManual 1-30 © National Instruments Corporation


Chapter 1Introduction to LabVIEWand wires the correct control or constant type to the terminal input. Thefollowing illustration shows an example pop-up menu.For a terminal acting as an output on the block diagram, you can choosethe Create Indicator feature to create and then wire an indicator to theterminal. You access this feature by popping up on the terminal andchoosing Create Indicator. LabVIEW automatically creates and wiresthe correct indicator type to the output of a terminal.Run the VI1. For Windows and Macintosh, make the front panel active byclicking anywhere on it. In UNIX, make the front panel active byclicking on the window title bar or by choosing Windows»ShowPanel.2. Run the VI by clicking on the run button in the toolbar of the frontpanel.Notice that you have to rerun the VI each time. If you want torepeatedly run the VI, you must click on the continuous run button.3. Click on the continuous run button in the toolbar.4. Click on the continuous run button again to deselect it. The VI thencompletes execution and quits.Note:The continuous run button is not the preferred method for repeating blockdiagram code. You should use a looping structure. This is covered inChapter 3, Loops and Charts, of this tutorial.© National Instruments Corporation 1-31 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWDocumenting the VIYou can document the VI by choosing Windows»Show VI Info....Type the description of the VI in the VI Information dialog box. Youcan then recall the description by again selecting Windows»Show VIInfo....1. Document the VI. Select Windows»Show VI Info.... Type thedescription for the VI, as shown in the following illustration, andclick on OK.You can view the descriptions of objects on the front panel (or theirrespective terminals on the block diagram) by popping up on the objectand choosing Description.... The location of this choice differs betweenthe front panel and block diagram.front panel:block diagram:Pop up on the object and choose DataOperations»Description....Pop up on the object and choose Description....Note:You cannot change the description while running a VI.LabVIEWTutorialManual 1-32 © National Instruments Corporation


Chapter 1Introduction to LabVIEWThe following illustration is an example pop-up menu that appearswhile you are running a VI. You cannot add to or change thedescription while running the VI, but you can view any previouslyentered information.2. Document the thermometer indicator.a. On the front panel, pop up on the thermometer indicator andchoose Data Operations»Description....b. Type the description for the indicator, as shown in thefollowing illustration, and click on OK.© National Instruments Corporation 1-33 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEW3. Show the description you created again by popping up on thethermometer indicator and selecting Data Operations»Description....Saving and Loading VIsAs with other applications, you can save your VI to a file in a regulardirectory. With LabVIEW, you can also save multiple VIs in a singlefile called a VI library. The tutorial.llb library is an example of aVI library.If you are using Windows 3.1, you should save your VIs into VIlibraries because you can use long file names (up to 255 characters)with mixed cases.Otherwise, you should not use VI libraries unless you need to transferyour VIs to Windows 3.1. Saving VIs as individual files is moreeffective because you can copy, rename, and delete files more easilythan if you are using a VI library. For a list of the advantages anddisadvantages of using VI libraries and individual files, see the SavingVIs section in Chapter 2, Creating VIs, of the LabVIEW User Manual.Even though you may not save your own VIs in VI libraries, youshould be familiar with how they work. For that reason, you shouldsave all VIs that you create during this tutorial into VI libraries tobecome familiar with using these libraries.Save your VI in a VI library.1. Select File»Save As.... If you are using UNIX, specify a location inthe file system where you have write privileges. For example, youmight select your home directory.2. Do not save your files in the examples directory. Instead, createyour own directory and label it Tutorial VIs.3. Create the VI library.(Windows) Select New... or the New VI Library button to create theVI Library.(Macintosh) If you use the native file dialog box, Edit»Preferences...,select Use LLBs to access LabVIEW’s file dialogbox. To create the VI library, click on Save»New....(UNIX) Select Save»New....LabVIEWTutorialManual 1-34 © National Instruments Corporation


Chapter 1Introduction to LabVIEW4. Enter mywork as the name of the new library in the dialog box andclick on the VI Library button. The library name must be followedby an .llb extension. For Windows 3.1, you must limit yourlibrary names to eight characters or less. LabVIEW appendsthe .llb extension if you do not include it.VI libraries have the same load, save, and open capabilities asdirectories. VI libraries, however, are not hierarchical. That is, youcannot create a VI library inside of another VI library. You cannotcreate a new directory inside a VI library, either. There is no wayto list the VIs in a VI library outside of the LabVIEWenvironment.After you create a VI library, it appears in LabVIEW’s file dialog boxas a folder with VI on the folder icon. Regular directories appear as afolder without the VI label.DirectoryVI LibraryfileVI5. Name the VI and save it in your new library. Look at the name inthe ring control at the top of the dialog box. Make sure it ismywork.llb. If it is not, click on mywork.llb in the directorylist to make sure you save your VI in the right place.a. Type My Thermometer.vi in the dialog box.b. Click on OK.6. Close the VI by selecting File»Close.© National Instruments Corporation 1-35 LabVIEWTutorialManual


Chapter 1Introduction to LabVIEWSummaryVirtual instruments (VIs) have three main parts: the front panel, theblock diagram, and the icon/connector. The front panel specifies theinputs and outputs of the VI. The block diagram consists of theexecutable code that you create using nodes, terminals, and wires. Withthe icon/connector, you can use a VI as a subVI in the block diagramof another VI.The Tools palette consists of a graphical, floating palette. On the frontpanel and block diagram, you use tools from the Tools palette to build,edit, and debug VIs. You use the key to tab through thecommonly used tools on the palette. The most commonly used toolsare:Operating toolPositioning toolLabeling toolWiring toolColor toolYou use the Operating tool to manipulate front panel controls andindicators. You use the Positioning tool to position, resize, and selectobjects. You use the Labeling tool to create free labels and to enter textin labels. You use the Wiring tool to wire objects together in the blockdiagram. You use the Color tool to set the foreground and backgroundcolor of windows, controls, indicators, and so on.The front panel and block diagram contain toolbars, which display therun button along with other buttons that control the execution of the VI.In the front panel, you place controls and indicators to denote theinputs and outputs of the VI. You use the Controls palette to addcontrols and indicators to the front panel. The Controls paletteautomatically pops up on the front panel when you launch LabVIEW.You can also access the Controls palette by selecting Windows»ShowControls Palette. Controls and indicators have different options thatare configured from their pop-up menus. See the LabVIEW UserManual for more information regarding front panel controls andindicators.LabVIEWTutorialManual 1-36 © National Instruments Corporation


Chapter 1Introduction to LabVIEWThe block diagram contains buttons, which also include features thatyou can use for execution debugging and single-stepping through VIs.On the block diagram, you develop your source diagram by connectingnodes and terminals using the Wiring tool. You use the Functionspalette to place nodes (structures, functions, and subVIs) on the blockdiagram. The Functions palette automatically pops up on the blockdiagram when you open the block diagram. You can also open theFunctions palette by selecting Windows»Show Functions Palette.LabVIEW automatically places terminals, which are associated withthe front panel controls and indicators on the block diagram. See theLabVIEW User Manual for more information concerning blockdiagram programming.You can modify nearly all LabVIEW objects through their own pop-upmenus. You access the pop-up menu by popping up on the object or byusing the Object pop-up menu tool.Popping up on individual components of an object accesses their ownpop-up menus. So remember—when in doubt, pop up!© National Instruments Corporation 1-37 LabVIEWTutorialManual


Creating a SubVIChapter2You Will Learn:Understanding HierarchyCreating the SubVI• What a subVI is.• How to create the icon and connector.• How to use a VI as a subVI.One of the keys to creating LabVIEW applications is understandingand using the hierarchical nature of the VI. After you create a VI, youcan use it as a subVI in the block diagram of a higher-level VI.Therefore, a subVI is analogous to a subroutine in C. Just as there is nolimit to the number of subroutines you can use in a C program, there isno limit to the number of subVIs you can use in a LabVIEW program.You can also call a subVI inside another subVI.When creating an application, you start at the top-level VI and definethe inputs and outputs for the application. Then, you construct subVIsto perform the necessary operations on the data as it flows through theblock diagram. If a block diagram has a large number of icons, groupthem into a lower-level VI to maintain the simplicity of the blockdiagram. This modular approach makes applications easy to debug,understand, and maintain.OBJECTIVETo make an icon and connector for the My Thermometer VI youcreated in Chapter 1 and use the VI as a subVI.To use a VI as a subVI, you must create an icon to represent it on theblock diagram of another VI, and a connector pane to which you canconnect inputs and outputs.© National Instruments Corporation 2-1 LabVIEWTutorialManual


Chapter 2Creating a SubVIIconCreate the icon, which represents the VI in the block diagram of otherVIs. An icon can be a pictorial representation of the purpose of the VI,or it can be a textual description of the VI or its terminals.1. If you have closed the My Thermometer VI, open it by selectingFile»Open....2. Select My Thermometer.vi from mywork.llb.3. Invoke the Icon Editor by popping up in the icon pane in the upperright corner of the front panel and choosing Edit Icon. As ashortcut, you can also double-click on the icon pane to edit theicon.Icon Editor Tools and ButtonsThe tools to the left of the editing area perform the following functions:Pencil toolLine toolDropper toolFill bucket toolRectangle toolFilled rectangle toolSelect toolText toolDraws and erases pixel by pixel.Draws straight lines. Press andthen drag this tool to draw horizontal,vertical, and diagonal lines.Copies the foreground color from an elementin the icon.Fills an outlined area with the foregroundcolor.Draws a rectangular border in the foregroundcolor. Double-click on this tool to frame theicon in the foreground color.Draws a rectangle bordered with theforeground color and filled with thebackground color. Double-click to frame theicon in the foreground color and fill it withthe background color.Selects an area of the icon for moving,cloning, or other changes.Enters text into the icon design.LabVIEWTutorialManual 2-2 © National Instruments Corporation


Chapter 2Creating a SubVIForeground/ BackgroundDisplays the current foreground andbackground colors. Click on each to get acolor palette from which you can choose newcolors.The buttons at the right of the editing screen perform the followingfunctions:UndoOKCancelCancels the last operation you performed.Saves your drawing as the VI icon and returns to the front panel.Returns to the front panel without saving any changes.4. Erase the default icon.a. With the Select tool, select the interior section of the defaulticon, shown at left.a. Press to erase the interior of the default icon.5. Draw the thermometer with the Pencil tool.6. Create the text with the Text tool. To change the text font,double-click on the Text tool. Experiment with the editor.Your icon should look similar to the following illustration.7. Close the Icon Editor by clicking on OK once you complete youricon. The new icon appears in the icon pane in the upper rightcorner of the front panel.© National Instruments Corporation 2-3 LabVIEWTutorialManual


Chapter 2Creating a SubVIConnectorNow, you can create the connector.1. Define the connector terminal pattern by popping up in the iconpane on the front panel and choosing Show Connector, as thefollowing illustration shows.single terminalconnector paneBecause LabVIEW selects a terminal pattern based on the number ofcontrols and indicators on the front panel, there is only oneterminal—the thermometer indicator.2. Assign the terminal to the thermometer.a. Click on the terminal in the connector. The cursor automaticallychanges to the Wiring tool, and the terminal turns black.LabVIEWTutorialManual 2-4 © National Instruments Corporation


Chapter 2Creating a SubVIb. Click on the thermometer indicator. A moving dashed line framesthe indicator, as the following illustration shows.connectorcontrolIf you click in an open area on the front panel, the dashed linedisappears and the selected terminal dims, indicating that you haveassigned the indicator to that terminal. If the terminal is white, youhave not made the connection correctly. Repeat the previous steps ifnecessary.3. Save the VI by choosing File»Save. On the Macintosh, if you areusing the native file dialog box to save into a VI library, you mustclick on the Use LLBs button before selecting the VI library.This VI is now complete and ready for use as a subVI in other VIs. Theicon represents the VI in the block diagram of the calling VI. Theconnector (with one terminal) outputs the temperature.Note:The connector specifies the inputs and outputs to a VI when you use it asa subVI. Remember that front panel controls can be used as inputs only;front panel indicators can be used as outputs only.4. Close the VI by choosing File»Close.© National Instruments Corporation 2-5 LabVIEWTutorialManual


Chapter 2Creating a SubVIUsing a VI as a SubVIYou can use any VI that has an icon and a connector as a subVI in theblock diagram of another VI. You select VIs to use as subVIs fromFunctions»Select a VI.... Choosing this option produces a file dialogbox, from which you can select any VI in the system. If you open a VIthat does not have an icon and a connector, a blank, square box appearsin the calling VI’s block diagram. You cannot wire to this node.A subVI is analogous to a subroutine. A subVI node (icon/connector)is analogous to a subroutine call. The subVI node is not the subVIitself, just as a subroutine call statement in a program is not thesubroutine itself. A block diagram that contains several identical subVInodes calls the same subVI several times.OBJECTIVETo build a VI that uses the My Thermometer VI as a subVI.The My Thermometer VI you built returns a temperature in degreesFahrenheit. You will take that reading and convert the temperature todegrees Centigrade.Front Panel1. Open a new front panel by selecting File»New.LabVIEWTutorialManual 2-6 © National Instruments Corporation


Chapter 2Creating a SubVI2. Choose the thermometer from Controls»Numeric. Label it Tempin deg C.3. Change the range of the thermometer to accommodate thetemperature values. With the Operating tool, double-click on thelower limit, type 20, and press on the numeric keypad.You do not have to type the decimal and trailing zeroes. LabVIEWadds them automatically when you enter the value. Similarly,change the upper limit of the thermometer to 40 and press on the numeric keypad. LabVIEW automaticallyadjusts the intermediate values.Each time you create a new control or indicator, LabVIEW creates thecorresponding terminal in the block diagram. The terminal symbolssuggest the data type of the control or indicator. For example, a DBLterminal represents a double-precision, floating-point number.Block Diagram1. Select Windows»Show Diagram.2. Pop up in a free area of the block diagram and chooseFunctions»Select a VI....A dialog box appears. Locate and openthe mywork.llb library. Double-click on My Thermometer.vior highlight it and click on Open in the dialog box. LabVIEWplaces the My Thermometer VI on the block diagram.3. Add the other objects to the block diagram as shown in thefollowing illustration.© National Instruments Corporation 2-7 LabVIEWTutorialManual


Chapter 2Creating a SubVINumeric Constant (Functions»Numeric). Add three numeric constantsto the block diagram. Assign the values of 32.0, 5.0, and 9.0 to theconstants by using the Labeling tool.Note:Remember, you can use the pop up on functions and choose CreateConstant to automatically create and wire the correct constant to afunction.The Subtract function (Functions»Numeric) subtracts 32 from theFahrenheit value for the conversion to Centigrade.The Divide function (Functions»Numeric) computes the value of 5/9for the temperature conversion.The Multiply function (Functions»Numeric) returns the Centigradevalue from the conversion process.4. Wire the diagram objects as shown in the previous block diagramillustration.Note:A broken wire between the Thermometer icon and the Temp in deg Cterminal might indicate that you have assigned the subVI connectorterminal to the front panel indicator incorrectly. Review the instructionsin the Creating the SubVI section earlier in this chapter. When you havemodified the subVI, you may need to select Relink to SubVI from the iconpop-up menu. If necessary, choose Edit»Remove Bad Wires.5. Return to the front panel and click on the run button in the toolbar.Block DiagramToolbarThe block diagram contains additional options not included on thefront panel toolbar.Block Diagram Toolbar:The block diagram toolbar contains the following buttons that you canuse for debugging VIs.Hilite execute button–Displays data as it passes through wiresLabVIEWTutorialManual 2-8 © National Instruments Corporation


Chapter 2Creating a SubVIStep into button–Steps into loops, subVIs, and so onStep over button–Begins single stepping, steps over a loop, subVI, andso onStep out button–Completes execution of loops, VIs, block diagrams,and so onSome Debugging TechniquesThe thermometer should display a value in the selected range.However, suppose you want to see the Fahrenheit value for comparisonand debugging. LabVIEW contains some tools that can help you. Inthis exercise, you examine the probe and execution highlightingfeatures. These techniques and other debugging tools and tips arediscussed in greater detail in Chapter 9, Programming Tips andDebugging Techniques, of this tutorial.1. Select Windows»Show Diagram.2. Select the Probe tool from the Tools palette. Click with the Probetool on the temperature value (wire) coming out of the MyThermometer subVI. A Probe window pops up with the titleTemp 1 and a yellow glyph with the number of the probe, asshown in the following illustration. The Probe window alsoappears on the front panel.© National Instruments Corporation 2-9 LabVIEWTutorialManual


Chapter 2Creating a SubVI3. Return to the front panel. Move the Probe window so you can viewboth the probe and thermometer values as shown in the followingillustration. Run the VI. The temperature in degrees Fahrenheitappears in the Probe window.4. Close the Probe window by clicking in the close box in the top-leftcorner of the Probe window title bar.Another useful debugging technique is to examine the flow of data inthe block diagram using LabVIEW’s execution highlighting feature.5. Return to the block diagram of the VI by choosingWindows»Show Diagram.6. Begin execution highlighting by clicking on the hilite executebutton, in the toolbar, shown at left. The hilite execute buttonchanges to an illuminated light bulb.7. Run the VI and notice that execution highlighting animates the VIblock diagram execution. Moving bubbles represent the flow ofdata through the VI. Also notice that data values appear on thewires and display the values contained in the wires at that time, asshown in the following block diagram, just as if you had probedthe wire.LabVIEWTutorialManual 2-10 © National Instruments Corporation


Chapter 2Creating a SubVIPath 1Path 3Path 2Notice the order in which the different nodes in LabVIEW execute. Inconventional text-based languages, the program statements execute inthe order in which they appear. LabVIEW, however, uses data flowprogramming. In data flow programming, a node executes when data isavailable at all of the node inputs, not necessarily in a top-to-bottom orleft-to-right manner.The preceding illustration shows that LabVIEW can multitask betweenpaths 1 and 2 because there is no data dependency, that is, nothing inpath 1 depends on data from path 2, and nothing in path 2 depends ondata from path 1. Path 3 must execute last, however, because themultiply function is dependant upon the data from the Subtract andDivide functions.Execution highlighting is a useful tool for examining the data flownature of LabVIEW and is discussed further in Chapter 9,Programming Tips and Debugging Techniques, of this tutorial.You can also use the single stepping buttons if you want to have morecontrol over the debugging process.8. Begin single stepping by clicking on the step over button, in thetoolbar. Clicking on this button displays the first executionsequence in the VI. After LabVIEW completes this portion of thesequence, it highlights the next item that executes in the VI.9. Step over the divide function by clicking on the step over button,in the toolbar. Clicking on this button executes the Dividefunction. After LabVIEW completes this portion of the sequence,it highlights the next item that executes in the VI.© National Instruments Corporation 2-11 LabVIEWTutorialManual


Chapter 2Creating a SubVI10. Step into the My Thermometer subVI by clicking on the step intobutton, in the toolbar. Clicking on this button opens the front paneland block diagram of your thermometer subVI. You can nowchoose to single step through or run the subVI.11. Finish executing the block diagram by clicking on the step outbutton, in the toolbar. Clicking on this button completes allremaining sequences in the block diagram. After LabVIEWcompletes this portion of the sequence, it highlights the next itemthat executes in the VI. You can also hold down the mouse buttonwhen clicking on the step out button to access a pop-up menu. Onthis pop-up menu, you can select how far the VI executes beforepausing. The following illustration shows your finish executionoptions in the pop-up menu of the step out button.12. Save the VI in mywork.llb. Name it Using MyThermometer.vi, and close the VI.Opening, Operating, and Changing SubVIsYou can open a VI used as a subVI from the block diagram of thecalling VI. You open the block diagram of the subVI bydouble-clicking on the subVIs icon or by selecting Project»This VI’sSubVIs. You then open the block diagram by selectingWindows»Show Diagram.Any changes you make to a subVI alter only the version in memoryuntil you save the subVI. Notice that the changes affect all calls to thesubVI and not just the node you used to open the VI.LabVIEWTutorialManual 2-12 © National Instruments Corporation


Chapter 2Creating a SubVIHierarchy WindowYou use the Hierarchy window (Project»Show VI Hierarchy) tovisually display the dependencies of VIs by providing information onVI callers and subVIs. This window contains a toolbar that you can useto configure several types of settings for displayed items. Thefollowing illustration shows an example of the VI hierarchy toolbar.You can use buttons on the Hierarchy window toolbar or the VIEWmenu, or pop up on an empty space in the window to access thefollowing options.• Redraw–Rearranges nodes after successive operations onhierarchy nodes if you need to minimize line crossings andmaximize symmetric aesthetics. If a focus node exists, you thenscroll through the window so that the first root that shows subVIsis visible.• Switch to vertical layout–Arranges the nodes from top-to-bottom,placing roots at the top.• Switch to horizontal layout–Arranges the nodes from left-to-right,placing roots on the left side.• Include/Exclude VIs in VI libraries–Toggles the hierarchy graphto include or exclude VIs in VI libraries.• Include/Exclude global variables–Toggles the hierarchy graph toinclude or exclude global variables.• Include/Exclude typedefs–Toggles the hierarchy graph to includeor exclude typedefs.In addition, the View menu and pop-up menus include Show all VIsand Full VI Path in Label options that you cannot access on thetoolbar.As you move the Operating tool over objects in the Hierarchy window,LabVIEW displays the name of the VI below the VI icon.Use the key toggle between the Positioning and Scroll windowtools. This feature is useful for moving nodes from the Hierarchywindow to the block diagram.© National Instruments Corporation 2-13 LabVIEWTutorialManual


Chapter 2Creating a SubVIYou can drag a VI or subVI node to the block diagram or copy it to theclipboard by clicking on the node. -click on a VI or subVIsnode to select multiple selections for copying to other block diagramsor front panels. Double-clicking on a VI or subVI node opens the frontpanel of that node.Any VIs that contain subVIs have an arrow button next to the VI thatyou can use to show or hide the VI’s subVIs. Clicking on the red arrowbutton or double-clicking on the VI itself opens the VI’s subVIs. Ablack arrow button on a VI node means that all subVIs are displayed.You can also pop up on a VI or subVI node to access a menu withoptions, such as showing or hiding subVIs, open the VI or subVI frontpanel, edit the VI icon, and so on.Search HierarchyYou can also search currently visible nodes in the Hierarchy windowby name. You initiate the search by typing in the name of the node,anywhere on the window. As you type in the text, a search windowappears, which displays the text as you type it in and concurrentlysearches through the hierarchy. The following illustration shows thesearch hierarchy.After finding the correct node, you can press to search forthe next node that matches the search string, or you can press (Windows); (Macintosh); (Sun); or (HP-UX) to find theprevious node that matches the search string.LabVIEWTutorialManual 2-14 © National Instruments Corporation


Chapter 2Creating a SubVIOnline Help for SubVI NodesWhen you place one of the tools on a subVI node, the Help windowshows the icon for the subVI with wires attached to each terminal. Thefollowing illustration shows an example of online help. This is theDigital Thermometer VI from Functions»Tutorial. Your thermometerVI also contains the text you typed in the VI Information dialog box.First select Help»Show Help. Then place the Positioningtool on the subVI to display its wiring diagram.Simple/Complex Help ViewIn the Help window, you can specify whether you want to display thesimple or complex view for block diagram objects.Note:When you open the Help window, LabVIEW automatically defaults to thesimple help view.In simple help view, LabVIEW displays only the required andrecommended inputs for VIs and functions. In complex help view,LabVIEW displays the required, recommended, and optional inputs forVIs and functions. It also displays the full path name of a VI. To accessthe simple help view, press the Simple/Complex Diagram Help switch,© National Instruments Corporation 2-15 LabVIEWTutorialManual


Chapter 2Creating a SubVIor choose Help»Simple Diagram Help. The following illustrationshows both views of the Simple/Complex Diagram Help switch.Simple HelpComplex HelpIn the Help window, required inputs appear in bold text, recommendedinputs appear in plain text, and optional inputs appear in gray text.When designing your own VIs, you can specify which inputs arerequired, recommended, or optional by popping up on an input oroutput on the connector pane and selecting the correct option from theThis Connection is submenu.Links to Online Help FilesIn the Help Window, you can click on the online help button to accessLabVIEW’s online help as well as help files that you have createdusing a help compiler. If you want to create your own help file, youmust specify the link to the help file by clicking on the icon pane andselecting VI Setup.... When the VI Setup dialog box opens, chooseDocumentation from the ring control at the top of the box, and thenenter the path of the help file in the Help Path box. The followingillustration shows the options that appear in the VI Setup dialog box.You select Browse... to associate the help file and topic with your VI.LabVIEWTutorialManual 2-16 © National Instruments Corporation


Chapter 2Creating a SubVIFor more information on creating help files, see the Creating Your OwnHelp Files section, in Chapter 25, Managing Your Applications, in theLabVIEW User Manual.SummaryLabVIEW’s ability to call VIs as subVIs within higher-level VIsfacilitates modular block diagrams. Modularization, in turn, makesyour block diagrams more understandable and simplifies debugging.A VI used as a subVI must have an icon and connector. The connectorterminals pass data to the subVI code and receive the results from thesubVI.You create the icon using the Icon Editor. You define the connector bychoosing the number of terminals you want for the VI and thenassigning a front panel control or indicator to each of those terminals.Once you have created the icon and connector for a VI, you can thenuse the VI as a subVI. You select subVIs using Functions»Select aVI....LabVIEW contains several tools for debugging VIs. You can placeprobes on any wire and display the value that passes through that wireas the VI runs. Execution highlighting animates a block diagram bydisplaying the data flow as moving bubbles and autoprobes. You canuse single stepping to debug VIs and examine data flow in VIs andsubVIs. These debugging techniques and more are described further inChapter 9, Programming Tips and Debugging Techniques, of thistutorial.You use the Hierarchy window to graphically display dependencies ofVIs and subVIs. With the Hierarchy window, you can choose betweenVI layout, including information about typedefinitions, globalvariables, and so on. You access the Hierarchy window by selectingProject»Show VI Hierarchy.LabVIEW also includes online help for subVIs. You can use the onlinehelp to wire subVIs correctly. You can also use online help to show thesimple or complex view of a VI or subVI.© National Instruments Corporation 2-17 LabVIEWTutorialManual


Loops and ChartsChapter3You Will Learn:• How to use a While Loop.• How to display data in a chart.• What a shift register is and how to use it.• How to use a For Loop.Structures control the flow of data in a VI. LabVIEW has fourstructures: the While Loop, the For Loop, the Case structure, and theSequence structure. This chapter introduces the While Loop and ForLoop structures along with the chart and the shift register. The Caseand Sequence structures are explained in Chapter 5, Case and SequenceStructures and the Formula Node.For examples of structures, see examples\ general\structs.llb.For examples of charts, see examples\ general\graphs\charts.llb.Using While Loops and ChartsOBJECTIVETo use a While Loop and a chart for acquiring and displaying data inreal time.You will build a VI that generates random data and displays it on achart. A knob control on the front panel will adjust the loop ratebetween 0 and 2 seconds and a switch will stop the VI. You will learnto change the mechanical action of the switch so you do not have to turnon the switch each time you run the VI. Use the front panel in thefollowing illustration to get started.© National Instruments Corporation 3-1 LabVIEWTutorialManual


Chapter 3Loops and ChartsFront Panel1. Open a new front panel.2. Place a vertical switch (Controls»Boolean) in the front panel.Label the switch Enable. You use this switch to stop theacquisition.3. Use the Labeling tool to create the free label for ON and OFF. Usethe Color tool to make the free label border transparent. The T inthe bottom left corner of the color palette makes an objecttransparent.4. Place a waveform chart (Controls»Graph) in the front panel.Label the chart Random Signal. The chart displays random datain real time.5. Pop up on the chart and choose Show»Digital Display. The digitaldisplay shows the latest value.6. Using the Labeling tool, double-click on 10.0 in the chart,type 1.0, and click outside the label area. The click enters thevalue. You can also press (Windows); (Macintosh); (Sun); or (HP-UX) to inputyour change to the scale.LabVIEWTutorialManual 3-2 © National Instruments Corporation


Chapter 3Loops and Charts7. Place a knob (Controls»Numeric) in the front panel. Label theknob Loop Delay (sec). This knob controls the timing of theWhile Loop later in this exercise. Pop up on the knob and deselectShow»Digital Display to hide the digital display that shows bydefault.8. Using the Labeling tool, double-click on 10.0 in the scale aroundthe knob, type 2.0, and click outside the label area to enter the newvalue.Block Diagram1. Open the block diagram.2. Place the While Loop in the block diagram by selecting it fromFunctions»Structures. The While Loop is a resizable box that isnot dropped on the diagram immediately. Instead, you have thechance to position and resize it. To do so, click in an area aboveand to the left of all the terminals. Continue holding down themouse button, and drag out a rectangle that encompasses theterminals. A While Loop is then created with the specified locationand size.© National Instruments Corporation 3-3 LabVIEWTutorialManual


Chapter 3Loops and ChartsconditionalterminaliterationterminalThe While Loop, shown in the following illustration, is a resizable boxyou use to execute the diagram inside it until the Boolean value passedto the conditional terminal (an input terminal) is FALSE. The VIchecks the conditional terminal at the end of each iteration; therefore,the While Loop always executes at least once. The iteration terminal isan output numeric terminal that contains the number of times the loophas executed. However, the iteration count always starts at zero, so ifthe loop runs once, the iteration terminal outputs 0.iterationterminalconditionalterminalThe While Loop is equivalent to the following pseudo-code:DoExecute Diagram Inside the Loop (which sets the condition)While Condition is TRUE3. Select the Random Number (0-1) function fromFunctions»Numeric.4. Wire the diagram as shown in the opening illustration of this BlockDiagram section, connecting the Random Number (0-1) functionto the Random Signal chart terminal, and the Enable switch to theconditional terminal of the While Loop. Leave the Loop Delayterminal unwired for now.5. Return to the front panel and turn on the vertical switch by clickingon it with the Operating tool. Run the VI.The While Loop is an indefinite looping structure. The diagramwithin its border executes as long as the specified condition is true. Inthis example, as long as the switch is on (TRUE), the diagramcontinues to generate random numbers and display them on the chart.LabVIEWTutorialManual 3-4 © National Instruments Corporation


Chapter 3Loops and Charts6. To stop the loop, click on the vertical switch. Turning the switchoff sends the value FALSE to the loop conditional terminal andstops the loop.7. The chart has a display buffer that retains a number of points afterthey have scrolled off the display. Give the chart a scrollbar bypopping up on the chart and selecting Show»Scrollbar. You canuse the Positioning tool to adjust the size and position of thescrollbar.To scroll through the chart, click and hold down the mouse button oneither arrow in the scrollbar.To clear the display buffer and reset the chart, pop up on the chart andchoose Data Operations»Clear Chart.Note:The display buffer default size is 1,024 points. You can increase ordecrease this buffer size by popping up on the chart and choosing ChartHistory Length....© National Instruments Corporation 3-5 LabVIEWTutorialManual


Chapter 3Loops and ChartsMechanical Action of Boolean SwitchesYou may notice that each time you run the VI, you first must turn onthe vertical switch and then click on the run button, in the toolbar. WithLabVIEW, you can modify the mechanical action of Boolean controls.There are six possible choices for the mechanical action of a Booleancontrol–Switch When Pressed, Switch When Released, Switch UntilReleased, Latch When Pressed, Latch When Released, and LatchUntil Released. LabVIEW contains an example that demonstrates thesebehaviors called Mechanical Action of Booleans.vi located inexamples\general\controls\booleans.llb. As an example,consider the following vertical switch. The default value of the switchis off (FALSE).Switch When Pressed action changes the control value each time youclick on the control with the Operating tool. The action is similar to thatof a ceiling light switch, and is not affected by how often the VI readsthe control.Switch When Released action changes the control value only after yourelease the mouse button, during a mouse click, within the graphicalboundary of the control. The action is not affected by how often the VIreads the control. This action is similar to what happens when you clickon a check mark in a dialog box; it becomes highlighted but does notchange until you release the mouse button.Switch Until Released action changes the control value when you clickon the control. It retains the new value until you release the mousebutton, at which time the control reverts to its original value. Theaction is similar to that of a doorbell, and is not affected by how oftenthe VI reads the control.LabVIEWTutorialManual 3-6 © National Instruments Corporation


Chapter 3Loops and ChartsLatch When Pressed action changes the control value when you clickon the control. It retains the new value until the VI reads it once, atwhich point the control reverts to its default value. (This actionhappens whether or not you continue to press the mouse button.) Thisaction is similar to that of a circuit breaker and is useful for stoppingWhile Loops or having the VI do something only once each time youset the control.Latch When Released action changes the control value only after yourelease the mouse button. When your VI reads the value once, thecontrol reverts to the old value. This action guarantees at least one newvalue. As with Switch When Released, this action is similar to thebehavior of buttons in a dialog box; clicking on this action highlightsthe button, and releasing the mouse button latches a reading.Latch Until Released action changes the control value when you clickon the control. It retains the value until your VI reads the value once oruntil you release the mouse button, depending on which one occurslast.1. Modify the vertical switch so it is used only to stop the VI. That is,change the switch so that you need not turn on the switch each timeyou run the VI.a. Turn on the vertical switch.b. Pop up on the switch and choose Data Operations»MakeCurrent Value Default. This makes the ON position thedefault value.c. Pop up on the switch and choose Mechanical Action»LatchWhen Pressed.2. Run the VI. Click on the vertical switch to stop the acquisition.The switch moves to the OFF position and changes back after theWhile Loop condition terminal reads the value.Adding TimingWhen you ran the VI, the While Loop executed as quickly as possible.However, you may want to take data at certain intervals, such as onceper second or once per minute.LabVIEW’s timing functions express time in milliseconds (ms),however, your operating system may not maintain this level of timing© National Instruments Corporation 3-7 LabVIEWTutorialManual


Chapter 3Loops and Chartsaccuracy. The following list contains guidelines for determining theaccuracy of LabVIEW’s timing functions on your system.• (Windows 3.1) The timer has a default resolution of 55 ms. Youcan configure LabVIEW to have 1 ms resolution by selectingEdit»Preferences..., selecting Performance and Disk from thePaths ring, and unchecking the Use Default Timer checkbox.LabVIEW does not use the 1 ms resolution by default because itplaces a greater load on your operating system. Read thedescription of the Use Default Timer option in the Performanceand Disk Preferences section in Chapter 8, Customizing YourLabVIEW Environment, in the LabVIEW User Manual to decide ifyou should use this option.• (Windows 95/NT) The timer has an resolution of 1 ms. However,this is hardware dependent, so on slower systems, such asan 80386, you may have lower resolution timing.• (Macintosh) For 68K systems without the QuickTime extension,the timer has an resolution of 16 2/3 ms (1/60th of a second). If youhave a Power Macintosh or have QuickTime installed, timerresolution is 1 ms.• (UNIX) The timer has a resolution of 1 ms.You can control loop timing using the Wait Until Next ms Multiplefunction (Functions»Time & Dialog). This function ensures that noiteration is shorter than the specified number of milliseconds.1. Modify the VI to generate a new random number at a time intervalspecified by the knob, as shown in the preceding diagram.LabVIEWTutorialManual 3-8 © National Instruments Corporation


Chapter 3Loops and ChartsWait Until Next ms Multiple function (Functions»Time & Dialog ). Inthis exercise, you multiply the knob terminal by 1000 to convert theknob value in seconds to milliseconds. Use this value as the input to theWait Until Next ms Multiple function.Multiply function (Functions»Numeric). In this exercise, the multiplyfunction multiplies the knob value by 1000 to convert seconds tomilliseconds.Numeric Constant (Functions»Numeric).The numeric constant holdsthe constant by which you must multiply the knob value to get aquantity in milliseconds. Thus, if the knob has a value of 1.0, the loopexecutes once every 1000 milliseconds (once a second).2. Run the VI. Rotate the knob to get different values for the numberof seconds.3. Save and close the VI in mywork.llb. Name it My RandomSignal.vi.For LoopLoop CountNumerical InputNumericalOutputYou place the For Loop on the block diagram by selecting it fromFunctions»Structures. A For Loop (see preceding illustration) is aresizable box, like the While Loop. Like the While Loop, it is notdropped on the diagram immediately. Instead, a small iconrepresenting the For Loop appears in the block diagram, and you havethe opportunity to size and position it. To do so, first click in an areaabove and to the left of all the terminals. While holding down themouse button, drag out a rectangle that encompasses the terminals youwant to place inside the For Loop. When you release the mouse button,© National Instruments Corporation 3-9 LabVIEWTutorialManual


Chapter 3Loops and ChartsLabVIEW creates a For Loop of the correct size and in the position youselected.The For Loop executes the diagram inside its border a predeterminednumber of times. The For Loop has two terminals:the count terminal (an input terminal) The count terminal specifies thenumber of times to execute the loop.the iteration terminal (an output terminal). The iteration terminalcontains the number of times the loop has executed.The For Loop is equivalent to the following pseudo-code:For i = 0 to N-1Execute Diagram Inside The LoopThe example in the following illustration shows a For Loop thatgenerates 100 random numbers and displays the points on a chart.Numeric ConversionUntil now, all the numeric controls and indicators that you have usedhave been double-precision, floating-point numbers. LabVIEW,however, can represent numerics as integers (byte, word, or long) orfloating-point numbers (single-, double-, or extended-precision). Thedefault representation for a numeric is a double-precision,floatingpoint.LabVIEWTutorialManual 3-10 © National Instruments Corporation


Chapter 3Loops and ChartsIf you wire two terminals together that are of different data types,LabVIEW converts one of the terminals to the same representation asthe other terminal. As a reminder, LabVIEW places a gray dot, calleda coercion dot, on the terminal where the conversion takes place.For example, consider the For Loop count terminal. The terminalrepresentation is a long integer. If you wire a double-precision,floating-point number to the count terminal, LabVIEW converts thenumber to a long integer. Notice the gray dot in the count terminal ofthe first For Loop.GrayDotNote:When the VI converts floating-point numbers to integers, it rounds to thenearest integer. If a number is exactly halfway between two integers, it isrounded to the nearest even integer. For example, the VI rounds 6.5 to 6,but rounds 7.5 to 8. This is an IEEE Standard method for readingnumbers. See the IEEE Standard 754 for details.© National Instruments Corporation 3-11 LabVIEWTutorialManual


Chapter 3Loops and ChartsUsing a For LoopOBJECTIVETo use a For Loop and shift registers to calculate the maximum valuein a series of random numbers. You will use a For Loop (N = 100)instead of a While Loop.Front Paneldigital indicatorWaveform chartwith scrollbarand digital displayshowing1. Open a new front panel and add the objects shown in the precedingillustration to it.a. Place a digital indicator on the front panel and label itMaximum Value.b. Place a waveform chart on the front panel and name itRandom Data. Change the scale of the chart to rangefrom 0.0 to 1.0.c. Pop up on the chart and choose Show»Scrollbar andShow»Digital Display.LabVIEWTutorialManual 3-12 © National Instruments Corporation


Chapter 3Loops and ChartsBlock Diagram1. Open the block diagram.2. Add the For Loop (Functions»Structures).3. Add the shift register by popping up on the right or left border ofthe For Loop and choosing Add Shift Register.4. Add the other objects to the block diagram.Random Number (0-1) function (Functions»Numeric) to generate therandom data.Numeric Constant (Functions»Numeric). The For Loop needs to knowhow many iterations to make. In this case, you execute the ForLoop 100 times.Numeric Constant (Functions»Numeric). You set the initial value ofthe shift register to zero for this exercise because you know that theoutput of the random number generator is from 0.0 to 1.0.You must know something about the data you are collecting toinitialize a shift register. For example, if you initialize the shift registerto 1.0, then that value is already greater than all the expected datavalues, and is always the maximum value. If you did not initialize theshift register, then it would contain the maximum value of a previousrun of the VI. Therefore, you could get a maximum output value that isnot related to the current set of collected data.© National Instruments Corporation 3-13 LabVIEWTutorialManual


Chapter 3Loops and ChartsMax & Min function (Functions»Comparison) takes two numericinputs and outputs the maximum value of the two in the top right cornerand the minimum of the two in the bottom right corner. Because youare only interested in the maximum value for this exercise, wire onlythe maximum output and ignore the minimum output.5. Wire the terminals as shown. If the Maximum Value terminal wasinside the For Loop, you would see it continuously updated, butbecause it is outside the loop, it contains only the last calculatedmaximum.Note:Updating indicators each time a loop iterates is time-consuming and youshould try to avoid it when possible to increase execution speed.Shift Registers6. Run the VI.7. Save the VI. Name the VI My Calculate Max.vi.Shift registers (available for While Loops and For Loops) transfervalues from one loop iteration to the next. You create a shift registerby popping up on the left or right border of a loop and selecting AddShift Register.The shift register contains a pair of terminals directly opposite eachother on the vertical sides of the loop border. The right terminal storesthe data upon the completion of an iteration. That data shifts at the endof the iteration and appears in the left terminal at the beginning of theLabVIEWTutorialManual 3-14 © National Instruments Corporation


Chapter 3Loops and Chartsnext iteration (see the following illustration). A shift register can holdany data type–numeric, Boolean, string, array, and so on. The shiftregister automatically adapts to the data type of the first object that youwire to the shift register.Before Loop BeginsFirst IterationInitialValueInitialValueNewValueSubsequent IterationsPreviousValueNewValuePreviousValueLast IterationNewValueNewValueYou can configure the shift register to remember values from severalprevious iterations. This feature is useful for averaging data points.You create additional terminals to access values from previousiterations by popping up on the left or right terminal and choosing AddElement. For example, if a shift register contains three elements in theleft terminal, you can access values from the last three iterations.© National Instruments Corporation 3-15 LabVIEWTutorialManual


Chapter 3Loops and ChartsContains i-1Contains i-2Contains i-3Pop up on leftterminal to addnew elements oruse Positioningtool to resize theleft terminal toexpose moreelementsPrevious values areavailable at the leftterminalsLatest valuepasses toright terminalPop up onborder fornew shift registerUsing Shift RegistersOBJECTIVEYou will build a VI that displays two random plots on a chart. The twoplots should consist of a random plot and a running average of the lastfour points of the random plot.Front Panel1. Open a new front panel and create the front panel shown in thepreceding illustration.LabVIEWTutorialManual 3-16 © National Instruments Corporation


Chapter 3Loops and Charts2. After you add the waveform chart to the front panel, change thescale to range from 0.0 to 2.0.3. After adding the vertical switch, set the ON state to be the defaultand set the mechanical action to Latch When Pressed.Block Diagram1. Add the While Loop (Functions»Structures) in the block diagramand create the shift register.a. Pop up on the left or right border of the While Loop andchoose Add Shift Register.b. Add an extra element by popping up on the left terminal of theshift register and choosing Add Element. Add a third elementin the same manner as the second.2. Build the block diagram shown in the previous illustration.Random Number (0-1) function (Functions»Numeric) generates rawdata.Compound Arithmetic function (Functions»Numeric). In this exercise,the compound arithmetic function returns the sum of random numbersfrom two iterations. To add more inputs, pop up on an input and chooseAdd Input from the pop-up menu.© National Instruments Corporation 3-17 LabVIEWTutorialManual


Chapter 3Loops and ChartsDivide function (Functions»Numeric). In this exercise, the dividefunction returns the average of the last four random numbers.Numeric Constant (Functions»Numeric). During each iteration of theWhile Loop, the Random Number (0-1) function generates one randomvalue. The VI adds this value to the last three values stored in the leftterminals of the shift register. The Random Number (0-1) functiondivides the result by four to find the average of the values (the currentvalue plus the previous three). The average is then displayed on thewaveform chart.Wait Until Next ms Multiple function (Functions»Time & Dialog),ensures that each iteration of the loop occurs no faster than themillisecond input. The input is 500 milliseconds for this exercise. Ifyou pop up on the icon and choose Show»Label, the label Wait UntilNext ms Multiple appears.3. Pop up on the input of the Wait Until Next ms Multiple functionand select Create Constant. A numeric constant appears and isautomatically wired to the function.4. Use the Labeling tool to enter 500. The numeric constant wired tothe Wait Until Next ms Multiple function specifies a waitof 500 milliseconds (one half-second). Thus, the loop executesonce every half-second.Notice that the VI initializes the shift registers with a random number.If you do not initialize a shift register terminal, it contains the defaultvalue or the last value from the previous run. In this case, the first fewaverages would be meaningless.5. Run the VI and observe the operation. LabVIEW only plots theaverage on the graph.Note:Remember to initialize shift registers to avoid incorporating old or defaultdata into your current data measurementsLabVIEWTutorialManual 3-18 © National Instruments Corporation


Chapter 3Loops and ChartsMultiplot ChartsCharts can accommodate more than one plot. You must bundle the datatogether in the case of multiple scalar inputs.You should modify the block diagram to display both the average andthe current random number on the same chart.1. Modify the block diagram as shown in the previous illustration.Bundle function (Functions»Cluster). In this exercise, the Bundlefunction bundles, or groups, the average and current value for plottingon the chart. The bundle node appears as shown at left when you placeit in the block diagram. If you pop up on the bundle and chooseShow»Label, the word Bundle appears in the label. You can addadditional elements by using the Resizing cursor (accessed by placingthe Positioning tool at the corner of the function) to enlarge the node.Note:The order of the inputs to the Bundle function determines the order of theplots on the chart. For example, if you wire the raw data to the top inputof the Bundle and the average to the bottom, the first plot corresponds tothe raw data and the second plot corresponds to the average.© National Instruments Corporation 3-19 LabVIEWTutorialManual


Chapter 3Loops and Charts2. Run the VI. The VI displays two plots on the chart. The plots areoverlaid. That is, they share the same vertical scale. Try runningthe VI with execution highlighting turned on to see the data in theshift registers. Remember to turn off the hilite execute button, inthe toolbar, when you finish so the VI can execute at full speed.Customizing ChartsYou can customize charts to match your data display requirements orto display more information. Features available for charts include: ascrollbar, a legend, a palette, and a digital display.On the chart, the digital display has been enabled. Notice that aseparate digital display exists for each trace on the chart.1. If the scrollbar is present, hide it by popping up on the chart anddeselecting Show»ScrollBar.2. Customize the Y axis.a. Use the Labeling tool to double-click on 2.0 in the Y scale.Type in 1.2 and press (Windows); (Macintosh); (Sun); or (HP-UX).b. Again using the Labeling tool, click on the second numberfrom the bottom on the Y axis. Change this numberto 0.2, 0.5, or something other than the current number. Thisnumber determines the numerical spacing of the Y axisdivisions.LabVIEWTutorialManual 3-20 © National Instruments Corporation


Chapter 3Loops and ChartsNote:The chart size has a direct effect on the display of axis scales. Increase thechart size if you have trouble customizing the axis.3. Show the legend by popping up on the chart, and choosingShow»Legend. Move the legend if necessary.You can place the legend anywhere relative to the chart. Stretch thelegend to include two plots using the Resizing cursor. The Positioningtool changes to the Resizing cursor to indicate that you can resize thelegend. Rename 0 to Current Value by double-clicking on the labelwith the Labeling tool and typing in the new text. You can changeplot 1 to Running Avg in the same way. If the text disappears, enlargethe legend text box by resizing from the left corner of the legend withthe Resizing cursor. You can set the plot line style and the point styleby popping up on the plot in the legend.You can set the plot line width by popping up on the plot in the legend.Using this pop-up menu, you can change the default line setting to onethat is larger than 1 pixel. You can also select a hairline width, whichis not displayed on the computer screen, but is printed if your printersupports hairline printing.If you have a color monitor, you can also color the plot background,traces, or point style by popping up on what you want to change in thelegend with the Color tool. Choose the color you want from the colorpalette that appears.4. Show the chart pop-up palette by popping up on the chart andchoosing Show»Palette.With the palette, you can modify the chart display while the VI isrunning. You can reset the chart, scale the X or Y axis, and change thedisplay format at any time. You can also scroll to view other areas orzoom into areas of a graph or chart. Like the legend, you can place thepalette anywhere relative to the chart.5. Run the VI. While the VI is running, use the buttons from thepalette to modify the chart.You can use the X and Y buttons to rescale the X and Y axes,respectively. If you want the graph to autoscale either of the scalescontinuously, click on the lock switch to the left of each button to lockon autoscaling.© National Instruments Corporation 3-21 LabVIEWTutorialManual


Chapter 3Loops and ChartsYou can use the other buttons to modify the axis text precision or tocontrol the operation mode for the chart. Experiment with these buttonsto explore their operation, scroll the area displayed, or zoom in on areasof the chart.Note:Modifying the axis text format often requires more physical space thanwas originally set aside for the axis. If you change the axis, the text maybecome larger than the maximum size that the waveform can correctlypresent. To correct this, use the Resizing cursor to make the display areaof the chart smaller.Different Chart ModesThe following illustration shows the three chart display optionsavailable from the Data Operations»Update Mode: strip chart, scopechart, and sweep chart. The default mode is strip chart. (If the VI is stillrunning, the Data Operations submenu is the pop-up menu for thechart.)LabVIEWTutorialManual 3-22 © National Instruments Corporation


Chapter 3Loops and ChartsThe strip chart mode scrolling display is similar to a paper tape stripchart recorder. As the VI receives each new value, it plots the value atthe right margin, and shifts old values to the left.1. Make sure the VI is still running, pop up on the chart, and selectData Operations»Update Mode»Scope Chart.The scope chart mode has a retracing display similar to anoscilloscope. As the VI receives each new value, it plots the value tothe right of the last value. When the plot reaches the right border of theplotting area, the VI erases the plot and begins plotting again from theleft border. The scope chart is significantly faster than the strip chartbecause it is free of the overhead processing involved in scrolling.2. Make sure the VI is still running, pop up on the chart, and selectData Operations»Update Mode»Sweep Chart.The sweep chart mode acts much like the scope chart, but it does notgo blank when the data hits the right border. Instead, a moving verticalline marks the beginning of new data and moves across the display asthe VI adds new data.3. Stop the VI, and save it. Name it My Random Average.vi.SummaryLabVIEW has two structures to repeat execution of a subdiagram—theWhile Loop and the For Loop. Both structures are resizable boxes. Youplace the subdiagram to be repeated inside the border of the loopstructure. The While Loop executes as long as the value at theconditional terminal is TRUE. The For Loop executes a set number oftimes.You can control the loop timing by using the Wait Until Next msMultiple function. This function ensures that no iteration is shorterthan a specified number of milliseconds (1000 ms equals one second).Shift registers (available for While Loops and For Loops) transfervalues from one iteration to the beginning of the next. You canconfigure shift registers to access values from previous iterations. Foreach iteration you want to recall, you must add a new element to theleft terminal of the shift register.© National Instruments Corporation 3-23 LabVIEWTutorialManual


Chapter 3Loops and ChartsAdditional TopicsWhen LabVIEW must force the numeric representation of one terminalto match the numeric representation of another terminal, a graycoercion dot appears. This dot is located at the terminal where the VIconverts the data.The rest of this chapter discusses more advanced topics. Feel free toexplore this material now, or to go on to the next chapter and refer backto these topics as necessary.Customizing ChartsFor more information on charts, refer to Chapter 15, Graph and ChartControls and Indicators, in your LabVIEW User Manual.Using LoopsFaster Chart UpdatesYou can pass an array of multiple values to the chart. The chart treatsthese inputs as new data for a single plot. Refer to the charts.viexample located in examples\general\graphs\charts.llb.Stacked Versus Overlaid PlotsEarlier in this chapter you made a multiplot chart that had the plotsoverlaid. You can also stack plots on a chart. Refer to the charts.viexample located in examples\general\graphs\charts.llbWhile and For Loops are basic structures for programming withLabVIEW, so you can find them in most of the LabVIEW examples aswell as the exercises in this tutorial. You can also find moreinformation on loops in Chapter 19, Structures, in the LabVIEW UserManual.Testing a While Loop before ExecutionThe While Loop always executes at least once, because LabVIEWperforms the loop test for continuation after the diagram executes. Youcan construct a While Loop that pretests its conditional terminal byincluding a Case structure inside the loop. You wire a Boolean input tothe Case structure selector terminal so the subdiagram for the FALSEcondition executes if the While Loop is not supposed to execute. TheLabVIEWTutorialManual 3-24 © National Instruments Corporation


Chapter 3Loops and Chartssubdiagram for the TRUE condition contains the work of the WhileLoop. The test for continuation occurs outside the Case structure, andits results are wired to both the conditional terminal of the While Loopand the selector terminal of the Case structure. In the followingillustration, labels represent the pretest condition and the actual workperformed by the While Loop.This example has the same result as the following pseudocode.While (pretest condition)Do actual work of While LoopLoop© National Instruments Corporation 3-25 LabVIEWTutorialManual


Chapter 3Loops and ChartsUsing Uninitialized Shift RegistersYou initialize a shift register by wiring a value from outside a While orFor Loop to the left terminal of the shift register. Sometimes, however,you want to repeatedly execute a VI with a loop and shift register, sothat each time the VI executes, the initial output of the shift register isthe last value from the previous execution. To do that, you must leavethe left, shift register terminal unwired from outside the loop.You can use uninitialized shift registers, for example, to avoidreprogramming the function, range, and trigger parameters ininstrument driver VIs every time they execute. This can improveperformance in instruments slow to execute commands.The following version of a Fluke 8840A multimeter driver uses twouninitialized shift registers to remember the last state of the driver sothat you have to reprogram the instrument only when you first use it orwhen a control parameter changes.LabVIEWTutorialManual 3-26 © National Instruments Corporation


Chapter 3Loops and ChartsThe first time this VI executes after you load or compile it, the valueof the bottom shift register is FALSE, the default for an uninitializedBoolean. The True case executes and programs the function, range, andtrigger parameters and sets the meter to use slow measurements. TheTrue case also executes if the current value of any of the threeparameter controls differs from the last value; that is, when any of thecontrols changes. You can modify the operation to program thechanged control only by using separate Case structures for eachcontrol.Case structures are discussed in greater detail in Chapter 5, Case andSequence Structures and the Formula Node.© National Instruments Corporation 3-27 LabVIEWTutorialManual


Arrays, Clusters, and GraphsChapter4You Will Learn:• About arrays.• How to generate arrays on loop boundaries.• What polymorphism is.• About clusters.• How to use graphs to display data.• How to use some basic array functions.ArraysAn array consists of a collection of data elements that are all the sametype. An array has one or more dimensions and up to 2 31 – 1 elementsper dimension, memory permitting. Arrays in LabVIEW can be anytype (except array, chart, or graph). You access each array elementthrough its index. The index is in the range 0 to n-1, where n is thenumber of elements in the array. The following one-dimensional arrayof numeric values illustrates this structure. Notice that the first elementhas index 0, the second element has index 1, and so on.index 0 1 2 3 4 5 6 7 8 910-element array 1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7Array Controls, Constants, and IndicatorsYou create array controls, constants, and indicators on the front panelor block diagram by combining an array constant with a numeric,Boolean, string, or cluster. The array element cannot be another array,chart, or graph.For examples of arrays, see examples\ general\ arrays.llb.© National Instruments Corporation 4-1 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsGraphsA graph indicator consists of a two-dimensional display of one ormore data arrays called plots. LabVIEW has three types of graphs:XY graphs, waveform graphs, and intensity graphs (see the AdditionalTopics section at the end of this chapter for information onintensity graphs).The difference between a graph and a chart (discussed in Chapter 3,Loops and Charts, in this tutorial) is that a graph plots data as a block,whereas a chart plots data point by point or array by array.For examples of graph VIs, see examples\ general\graphs.Creating an Array with Auto-IndexingOBJECTIVETo create an array using the auto-indexing feature of a For Loop andplot the array in a waveform graph.You will build a VI that generates an array using the GenerateWaveform VI and plots the array in a waveform graph. You will alsomodify the VI to graph multiple plots.Front Panel*digital indicator array**waveform graph*Autoscale Y disabledMin Y axis -0.5Max Y axis 1.51. Open a new front panel.2. Place an array shell from Controls»Array & Cluster in the frontpanel. Label the array constant Waveform Array.LabVIEWTutorialManual 4-2 © National Instruments Corporation


Chapter 4Arrays, Clusters, and Graphs3. Place a digital indicator from Controls»Numeric inside theelement display of the array constant, as the following illustrationshows. This indicator displays the array contents.As stated previously, a graph indicator is a two-dimensional display ofone or more data arrays called plots. LabVIEW has three types ofgraphs: XY graphs, waveform graphs, and intensity graphs.4. Place a waveform graph from Controls»Graph in the front panel.Label the graph Waveform Graph.The waveform graph plots arrays with uniformly spaced points, suchas acquired time-varying waveforms.5. Enlarge the graph by dragging a corner with the Resizing cursor.By default, graphs autoscale their input. That is, they automaticallyadjust the X and Y axis scale limits to display the entire input data set.6. Disable autoscaling by popping up on the graph and deselectingY Scale»Autoscale Y.7. Modify the Y axis limits by double-clicking on the scale limitswith the Labeling tool and entering the new numbers. Changethe Y axis minimum to -0.5 and the maximum to 1.5.© National Instruments Corporation 4-3 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsBlock Diagram1D array1. Build the block diagram shown in the preceding illustration.The Generate Waveform VI (Functions»Tutorial) returns one point ofa waveform. The VI requires a scalar index input, so wire the loopiteration terminal to this input. Popping up on the VI and selectingShow»Label displays the word Generate Waveform in the label.Notice that the wire from the Generate Waveform VI becomes thickeras it changes to an array at the loop border.The For Loop automatically accumulates the arrays at its boundary.This is called auto-indexing. In this case, the numeric constant wiredto the loop count numeric input has the For Loop create a 100-elementarray (indexed 0 to 99).Bundle function (Functions»Cluster) assembles the plot componentsinto a cluster. You need to resize the Bundle function icon before youcan wire it properly. Place the Positioning tool on the lower rightcorner of the icon. The tool transforms into the Resizing cursor shownat left. When the tool changes, click and drag down until a third inputterminal appears. Now, you can continue wiring your block diagram asshown in the first illustration in this section.A cluster consists of a data type that can contain data elements ofdifferent types. The cluster in the block diagram you are building heregroups related data elements from multiple places on the diagram,reducing wire clutter. When you use clusters, your subVIs requirefewer connection terminals. A cluster is analogous to a record in PascalLabVIEWTutorialManual 4-4 © National Instruments Corporation


Chapter 4Arrays, Clusters, and Graphsor a struct in C. You can think of a cluster as a bundle of wires, muchlike a telephone cable. Each wire in the cable would represent adifferent element of the cluster. The components include the initial Xvalue (0), the delta X value (1), and the Y array (waveform data,provided by the numeric constants on the block diagram). InLabVIEW, use the Bundle function to assemble a cluster.Note:Be sure to build data types that the graphs and charts accept.As you build your block diagram, be sure to check your data types bytaking the following steps:• Open the Help window by choosing Help»Show Help.• Move the Wiring tool over the graph terminal.• Check the data type information that appears in the Help window.For an example, see the following illustration.Numeric Constant (Functions»Numeric). Three numeric constantsset the number of For Loop iterations, the initial X value, and thedelta X value. Notice that you can pop up on the For Loop countterminal, shown at left, and select Create Constant to automaticallyadd and wire a numeric constant for that terminal.© National Instruments Corporation 4-5 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsEach iteration of the For Loop generates one point in a waveform thatthe VI stores in the waveform array created automatically at the loopborder. After the loop finishes execution, the Bundle function bundlesthe initial value of X (Xo), the delta value of X, and the array forplotting on the graph.2. Return to the front panel and run the VI. The VI plots theauto-indexed waveform array on the waveform graph. Theinitial X value is 0 and the delta X value is 1.3. Change the delta X value to 0.5 and the initial X value to 20. Runthe VI again.Notice that the graph now displays the same 100 points of data with astarting value of 20 and a delta X of 0.5 for each point (see the X axis).In a timed test, this graph would correspond to 50 seconds worth ofdata starting at 20 seconds. Experiment with several combinations forthe initial and delta X values.4. You can view any element in the array by entering the index of thatelement in the index display. If you enter a number greater than thearray size, the display dims, indicating that you have not defined avalue for that index.If you want to view more than one element at a time, you can resize thearray indicator. Place the Positioning tool on the lower right corner ofthe array. The tool transforms into the Resizing cursor shown at left.When the tool changes, drag to the right or straight down. The arraynow displays several elements in ascending index order, beginningwith the element corresponding to the specified index, as the followingillustration shows.678index6 7 8indexIn the previous block diagram, you specified an initial X and a delta Xvalue for the waveform. Often, however, the initial X value is zero andthe delta X value is 1. In these instances, you can wire the waveformLabVIEWTutorialManual 4-6 © National Instruments Corporation


Chapter 4Arrays, Clusters, and Graphsarray directly to the waveform graph terminal, as the followingillustration shows.5. Return to the block diagram. Delete the Bundle function and thenumeric constants wired to it. To delete the function and constants,select the function and constants with the Positioning tool thenpress . Select Edit»Remove Bad Wires. Finish wiringthe block diagram as shown in the previous illustration.6. Run the VI. Notice that the VI plots the waveform with aninitial X value of 0 and a delta X value of 1.Multiplot GraphsYou can create multiplot waveform graphs by building an array of thedata type normally passed to a single-plot graph.2D array© National Instruments Corporation 4-7 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and Graphs1. Continue building your block diagram as shown in the precedingdiagram.Sine function from (Functions»Numeric»Trigonometric). In thisexercise, you use the function in a For Loop to build an array of pointsthat represents one cycle of a sine wave.Build Array function (Functions»Array). In this exercise, you use thisfunction to create the proper data structure to plot two arrays on awaveform graph, which in this case is a two-dimensional array.Enlarge the Build Array function to create two inputs by dragging acorner with the Positioning tool.Pi constant (Functions»Numeric»Additional Numeric Constants).Remember that you can find the Multiply and Divide functions inFunctions»Numeric.2. Switch to the front panel. Run the VI.Notice that the two waveforms plot on the same waveform graph. Theinitial X value defaults to 0 and the delta X value defaults to 1 for bothdata sets.Note:You can change the appearance of a plot on the graph by popping up inthe legend for a particular plot. For example, you can change from a linegraph to a bar graph by choosing Common Plots»Bar Graph.3. Save and close the VI. Name it My Graph WaveformArrays.vi. Be sure to save your work in mywork.llb.PolymorphismPolymorphism is the ability of a function to adjust to input data ofdifferent types, dimensions, or representations. Most LabVIEWfunctions are polymorphic. The previous block diagram is an exampleof polymorphism. Notice that you use the Multiply function in twolocations, inside and outside the For Loop. Inside the For Loop, thefunction multiplies two scalar values; outside the For Loop, thefunction multiplies an array by a scalar value.LabVIEWTutorialManual 4-8 © National Instruments Corporation


Chapter 4Arrays, Clusters, and GraphsThe following example shows some of the polymorphic combinationsof the Add function.In the first combination, the two scalars are added together, and theresult is a scalar. In the second combination, the scalar is added to eachelement of the array, and the result is an array. In the third combination,each element of one array is added to the corresponding element of theother array. You can also use other combinations, such as clusters ofnumerics, arrays of clusters, and so on.These principles can be applied to other LabVIEW functions and datatypes. LabVIEW functions may be polymorphic to different degrees.Some functions may accept numeric and Boolean inputs, others mayaccept a combination of any data types. For more information aboutpolymorphism, see Online Reference»Function and VIReference»Introduction to Functions.Using Auto-Indexing on Input ArraysOBJECTIVEYou will open and operate a VI that uses auto-indexing in a For Loopto process an array.1. Open the Separate Array Values.vi by selectingFile»Open.... The VI is located in examples\general\arrays.llb.2. Open the block diagram. You can pop up on the array and chooseShow Case True or Show Case False to view the true and falsecases of the array.© National Instruments Corporation 4-9 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsThe following illustration shows the block diagram with both Trueand False cases visible.Notice that the wire from Input Array changes from a thick wireoutside the For Loop, indicating it is an array, to a thin wire inside theloop, indicating it is a single element. The i th element of the array isautomatically indexed from the array during each iteration.Using Auto-Indexing to Set the For Loop CountNotice that the count terminal is left unwired. When you useauto-indexing on an array entering a For Loop, LabVIEWautomatically sets the count to the array size, eliminating the need towire a value to the count terminal. If you use auto-indexing for morethan one array, or if you set the count, the count becomes the smallestof the possibilities.LabVIEWTutorialManual 4-10 © National Instruments Corporation


Chapter 4Arrays, Clusters, and Graphs1. Run the VI and experiment with different array sizes. Create adigital control on the front panel, wire it to the count terminal, andcheck the output arrays to see how different counts affect theoutput arrays.2. Close the VI and do not save changes. You may not be familiarwith some of the structures used in this example. They arediscussed in greater detail later in this tutorial.Note:LabVIEW automatically enables Auto-indexing for every array wired to aFor Loop. You can disable auto-indexing by popping up on the tunnel(entry point of the input array) and selecting Disable Indexing.tunnelLabVIEW automatically disables auto-indexing for every array wiredto a While Loop. Pop up on the array tunnel of a While Loop to enableauto-indexing.Using the Initialize Array FunctionNotice that the two shift registers are initialized using the InitializeArray function, located in Functions»Array. Use this function to createan array whose elements all have the same value. In the followingillustration, this function creates a one-dimensional array.© National Instruments Corporation 4-11 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsThe element input determines the data type and the value of eachelement. The dimension size input determines the length of the array.For example, if element is a long integer with the value of five anddimension size has a value of 100, the result is a one-dimensionalarray of 100 long integers all set to five. You can wire the inputs fromfront panel control terminals, as shown in the preceding illustration,from block diagram constants, or from calculations on other parts ofyour diagram.To create and initialize an array that has more than one dimension, popup on the lower-left side of the function and select Add Dimension.You can also use the Resizing cursor to enlarge the Initialize Arraynode and add more dimension size inputs, one for each additionaldimension. You can remove dimensions by shrinking the node byselecting Remove Dimension from the function pop-up menu or withthe Resizing cursor.The following block diagram shows how to initialize a threedimensionalarray.As you saw in the previous example, if all the dimension size inputs arezero, the function creates an empty array of the specified type anddimension.Using the Graph and Analysis VIsOBJECTIVEYou will build a VI that measures temperature every 0.25 secondsfor 10 seconds. During the acquisition, the VI displays themeasurements in real time on a strip chart. After completing theacquisition, the VI plots the data on a graph and calculates the average,maximum, and minimum temperatures.For examples of analysis VIs, see examples\analysis.LabVIEWTutorialManual 4-12 © National Instruments Corporation


Chapter 4Arrays, Clusters, and GraphsFront Panel1. Open a new front panel and build the front panel shown in thepreceding illustration. You can modify the point styles of thewaveform chart and waveform graph by popping up on theirlegends.The Temperature waveform chart displays the temperature as it isacquired. After acquisition, the VI plots the data in Temp Graph. TheMean, Max, and Min digital indicators display the average, maximum,and minimum temperatures.Block Diagram© National Instruments Corporation 4-13 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and Graphs1. Build the block diagram shown in the previous illustration, usingthe following elements:The Digital Thermometer VI (Functions»Tutorial, or you can use theVI you built in Chapter 2 by choosing Functions»Select a VI... andselecting My Thermometer VI. Returns one temperature measurement.Wait Until Next ms Multiple function (Functions»Time & Dialog ). Inthis exercise, this function ensures the For Loop executes every 0.25seconds (250 milliseconds).Numeric constant (Functions»Numeric). You can also pop up on theWait Until Next ms Multiple function and select Create Constant toautomatically create and wire the numeric constant.Array Max & Min function (Functions»Array). In this exercise, thisfunction returns the maximum and minimum temperature measuredduring the acquisition.The Mean VI (Functions»Analysis»Probability and Statistics) returnsthe average of the temperature measurements.Bundle function (Functions»Cluster) assembles the plot componentsinto a cluster. The components include the initial X value (0), thedelta X value (0.25), and the Y array (temperature data). Use thePositioning tool to resize the function by dragging one of the corners.The For Loop executes 40 times. The Wait Until Next ms Multiplefunction causes each iteration to take place every 250 milliseconds.The VI stores the temperature measurements in an array created at theFor Loop border (auto-indexing). After the For Loop completesexecution, the array passes to various nodes.The Array Max & Min function returns the maximum and minimumtemperature. The Mean VI returns the average of the temperaturemeasurements.Your completed VI bundles the data array with an initial X valueof 0 and a delta X value of 0.25. The VI requires a delta X valueof 0.25 so that the VI plots the temperature array points every 0.25seconds on the waveform graph.2. Return to the front panel and run the VI.3. Save the VI in mywork.llb as My TemperatureAnalysis.vi.LabVIEWTutorialManual 4-14 © National Instruments Corporation


Chapter 4Arrays, Clusters, and GraphsUsing ArraysLabVIEW has many functions to manipulate arrays located inFunctions»Array. Some common functions are discussed here.Creating and Initializing ArraysIf you need an array as a source of data in your block diagram, you canchoose Functions»Array and then select and place the array constanton your block diagram. Using the Operating tool, you can then choosea numeric constant, boolean constant, or string constant to place insidethe empty array. The following illustration shows an example arrayconstant with a numeric constant inserted into the array shell.Note:You can also create an array and its corresponding control on the frontpanel and then copy or drag the array control to the block diagram tocreate a corresponding constant.For information on how to create array controls and indicators on thefront panel, see Chapter 15, Array and Cluster Constants and Indicators,in the LabVIEW User Manual.There are several ways to create and initialize arrays on the blockdiagram. You have already seen how to create arrays at loopboundaries and how to use the Initialize Array function. Some blockdiagram functions also produce arrays, as the following illustrationshows.String To Byte ArraySine Patternx[i]=ASCII codeof i th characterx[i]=cos(2πi /N)© National Instruments Corporation 4-15 LabVIEWTutorialManual


Chapter 4Arrays, Clusters, and GraphsUsing the Build Array FunctionBuild Array function (Functions»Array). You can use it to create anarray from scalar values or from other arrays. Initially, the Build Arrayfunction appears with one scalar input.You can add as many inputs as you need to the Build Array function,and each input can be either a scalar or an array. To add more inputs,pop up on the left side of the function and select Add Element Input orAdd Array Input. You can also enlarge the Build Array node with theResizing cursor (place the Positioning tool at the corner of an object totransform it into the Resizing cursor). You can remove inputs byshrinking the node with the Resizing cursor, or by selecting RemoveInput.The following examples show two ways to create and initialize arrayswith values from block diagram constants. On the left, five stringconstants are built into a one-dimensional array of strings. On the right,three groups of numeric constants are built into three, one-dimensionalnumeric arrays. The three arrays are then combined into atwo-dimensional numeric array. The result is a 3 x 3 array with therows 3, 4, 7; -1, 6, 2; and 5, -2, 8.LabVIEWTutorialManual 4-16 © National Instruments Corporation


Chapter 4Arrays, Clusters, and GraphsYou can also create an array by combining other arrays along withscalar elements. For example, suppose you have two arrays and threescalar elements that you want to combine into a new array with theorder array 1, scalar 1, scalar 2, array 2, and scalar 3. First, create aBuild Array node with five inputs. Pop up on the first (top) input in theBuild Array node and select Change to Array, as the followingillustration shows. Do the same for the fourth, or next-to-last input.Next, wire the arrays and scalars to the node. The output array isa 1D array composed of the elements of array 1 followed by scalar 1,scalar 2, the elements of array 2, and scalar 3, as the followingillustration shows.The dimension of the output array is always one dimension higher thanthe elements you wire to element inputs, and equal to the dimension ofarrays you wire to array inputs. Element and array inputs can varyby no more than one dimension. For instance, if you wire a seriesof 1D arrays to element inputs, the output array consists of a 2D array© National Instruments Corporation 4-17 LabVIEWTutorialManual


Sours: https://www.yumpu.com/en/document/view/51133401/labview-tutorial-manual

Communication commands manual and LabVIEW 2019 driver for LR8450, LR8416, LR8410, LR8400, LR8401, LR8402 and 8423

V1.03 Jun 07, 2021

The copyright to the executable program file and associated documents is owned by HIOKI E.E. CORPORATION. This utility may not be bundled with software or other publications which are sold for profit without the express written permission of the copyright owner.
Further, this product may not be modified without the express written permission of the copyright owner.

HIOKI disclaims any and all responsibility for any consequences arising out of use of this software.

LabVIEW driver (LV_LR8450s_E2019.zip)

Specifications

1.This is the LabVIEW 2019 driver for the HEAT FLOW LOGGER LR8416,WIRELESS LOGGING STATION LR8410, MEMORY HiLOGGER LR8450,LR8400,LR8401,LR8402,8423.
2.This LabVIEW driver can control and collect data. However,
3.It is not capable of controlling all functions. For details, refer to the Function Manual.
4.This driver can use it at LabVIEW 2019  SP1 and other ones.

Version Upgrade History

V1.03 (June 2021) Newest Version
 Resolved bugs

 1. The issue of sending :MEMORY:POINT in HIOKI 84series Memo Apoint_LR8450.vi has been fixed.

V1.02  (May 2020)
 Compatibility to Model LR8450.

V1.01
 Compatibility to Model LR8512,LR8513,LR8514,LR8515,LR8520 for LR8410,LR8416.

V1.00
 Release

 

Operating Environment

LabVIEW Driver OperatingnEnvironment
Windows 10(64bit) LabVIEW2019 SP1


Communication Command Operating Environment
WindowsXP(32bit),Vista(32bit),7(32bit),8/8.1(32bit),Windows10(64bit)
Visual Basic 6,2005,2008,2010,2012

Sours: https://www.hioki.com/global/support/download/software/versionup/detail/id_605
  1. How to use brute forcer
  2. X570 mobo
  3. Skylanders online
  4. Skyrim memes
  5. Craigslist owensboro

XIMEA LabVIEW Demo Application Manual¶

XIMEA Virtual Instruments (VIs).¶

OpenDevice¶


Parameters:

device id index of the device
hDevice handle to device

C Prototype:
int OpenDevice(UINT32 device_id, UINT32 * hDevice);
Description:
This function initializes the device and returns a device handle.

CloseDevice¶


Parameters:

C Prototype:
int CloseDevice(UINT32 hDevice);
Description:
This function uninitializes the specified device, closes its handle and releases allocated resources.

SetMode¶

This VI was replaced in V2_10 of XIMEA API Software Package with VI - SetDownsampling.

GetNumberDevices¶


Parameters:

pNumberDevices number of connected devices

C Protopype:
int GetNumberDevices(UINT32 * pNumberDevices);
Description:
This function returns the number of devices connected to PC.

StartAcquisition¶


Parameters:

C Prototype:
int StartAcquisition(UINT32 hDevice);
Description:
This function starts the data acquisition on the devices specified by the handle.

StopAcquisition¶


Parameters:

C Prototype:
int StopAcquisition(UINT32 hDevice);
Description:
This function stops the work cycle and data acquisition on the device.

GetImage¶


Parameters:

hDevice handle to device
timeout maximum time to wait new image in milliseconds
ImageData pointer to image array
buffer_size size of image array(in bytes)

C Prototype:
int GetImage(UINT32 hDevice, UINT32 timeout, void * ImageData, UINT32 buffer_size);
Description:
This function acquires image and copies it to ImageData array.

SetDownsampling¶


Parameters:

hDevice handle to device
ds downsampling factor

C Prototype:
int SetDownsampling(UINT32 hDevice, UINT32 ds);
Description:
This function sets downsampling factor (binning or skipping).

Example: When sensor gives 1024x640 pixels, then with downsampling factor 2 the result image will have 512x320 pixels.

SetExposure¶


Parameters:
hDevice handle to device
exposure integration time (in microseconds)

C Prototype:
int SetExposure(UINT32 hDevice, UINT32 exposure);
Description:
This function sets integration time.

SetGain¶


Parameters:

hDevice handle to device
gain gain (in dB)

C Prototype:
int SetGain(UINT32 hDevice, double gain);
Description:
This function sets gain.

SetROI¶


Parameters:

hDevice handle to device
x0 x (horizontal) coordinate of the top-left origin of ROI, used for image clipping
y0 y (vertical) coordinate of the top-left origin of ROI, used for image clipping
cx width of the ROI image area
cy height of the ROI image area

C Prototype:
int SetROI(UINT32 hDevice, UINT32 x0, UINT32 y0, UITN32 cx, UINT32 cy);
Description:
This function sets position and size of region of interest.

GetImageAttributes¶


Parameters:

hDevice handle to device
width current mode width
height current mode height

C Prototype:
int GetImageAttributes(UINT32 hDevice, UINT32 width, UINT32 height);
Description:
This function returns current mode width and height.

GetGainInfo¶


Parameters:

hDevice handle to device
fLow lower bound gain value in dB
fHigh upper bound gain value in dB

C Prototype:
int GetGainInfo(UINT32 hDevice, double fLow, double fHigh);
Description:
This function retrieves the gain information of the device.

SetTrigger¶


Parameters:

hDevice handle to device
mode trigger mode (0=free run, 1=hardware trigger “positive edge”, 2=hardware trigger ‘negative edge”, 3=software trigger)

C Prototype:
int SetTrigger(UINT32 hDevice, UINT32 mode);
Description:
This function sets the trigger mode.

PingTrigger¶


Parameters:

C Prototype:
int PingTrigger(UINT32 hDevice);
Description:
This function performs a software trigger event.

DoBadPixelCorrection¶


Parameters:
hDevice handle to device
bpl on/off bad pixel correction

C Prototype:
int DoBadPixelCorrection(UINT32 hDevice, int bpl);
Description:
This function performs bad pixel correction.

TakeWhiteBalance¶


Parameters:

hDevice handle to device
Kr red coefficient
Kg green coefficient
Kb blue coefficient

C Prototype:
int TakeWhiteBalance(UINT32 hDevice, double * Kr, double * Kg, double * Kb);
Description:
This function calculates white balance coefficients.

SetCooling¶


Parameters:

hDevice handle to device
temperature temperature
bOn On/Off cooling

C Prototype:
int SetCooling(UINT32 hDevice, float temp, UINT32 bOn);
Description:
Allows the user to cool device to specific tagt temperature.

SetDataFormat¶


Parameters:

hDevice handle to device
format output data format(0=mono8,1=mono16,
2=RGB32).

C Prototype:
int SetDataFormat(UINT32 hDevice, UINT32 format);
Description:
Sets output data format.

SetGPIO¶


Parameters:

hDevice handle to device
gpio #gpio
state gpio state
gpi1 = trigger, gpi2 = external event, gpi3 = off, gpi4 = off
gpo1 = 0, gpo2 = 1, gpo3 = 1, gpo4 = strobe out (0 - gpo zero, 1 – gpo one, 2 – gpi external event, 3 – gpo strobe out, 4 – gpi trigger, 5 – gpo strobe out inv., 6 – gpo integration time, 7 – gpo integration time inv., 8 – gpi off)

C Prototype:
int SetGPIO(UINT32 hDevice, UINT32 gpio, UINT32 state);
Description:
Sets GPIO state.

SetLED¶


Parameters:

hDevice handle to device
gpio #led
state led functionality
led1 = busy, led2 = heartbeat
(0-HB,1-trigger,2-ext_event,3-data streaming,4-integration,5-busy,6-link ok,7-off,8-on)

C Prototype:
int SetLED(UINT32 hDevice, UINT32 gpio, UINT32 state);
Description:
Sets LED functionality.

EnableHDR¶


Parameters:

hDevice handle to device
hdr enables HDR feature

C Prototype:
int EnableHDR(UINT32 hDevice, UINT32 hdr);
Description:
Enables/Disables HDR feature.

EnableLUT¶


Parameters:

hDevice handle to device
lut enables LUT feature

C Prototype:
int EnableLUT(UINT32 hDevice, UINT32 lut);
Description:
Enables/Disables LUT feature.

SetLUT¶


Parameters:

hDevice handle to device
input input LUT parameter(max 4095)
output output(max 256)

C Prototype:
int SetLUT(UINT32 hDevice, UINT32 input, UINT32 output);
Description:
Sets LUT values (12bit or 10bit LUt to 8 bit).

Error codes¶

0 Function call succeeded
1 Invalid handle
2 Register read error
3 Register write error
4 Freeing resiurces error
5 Freeing channel error
6 Freeing bandwith error
7 Read block error
8 Write block error
9 No image
10 Timeout
11 Invalid arguments supplied
12 Not supported
13 Attach buffers error
14 Overlapped result
15 Memory allocation error
16 DLL context is NULL
17 DLL context is non zero
18 DLL context exists
19 Too many devices connected
20 Camera context error
21 Unknown hardware
22 Invalid TM file
23 Invalid TM tag
24 Incomplete TM
25 Bus reset error
26 Not implemented
27 Shading too bright
28 Shading too dark
29 Gain is too low
30 Invalid bad pixel list
31 Bad pixel list realloc error
32 Invalid pixel list
33 Invalid Flash File System
34 Invalid profile
35 Invalid calibration
36 Invalid buffer
38 Invalid data
39 Timing generator is busy
40 Wrong operation open/write/read/close
41 Acquisition already started
42 Old version of device driver installed to the system.
43 To get error code please call GetLastError function.
44 Data can't be processed
45 Error occured and acquisition has been stoped or didn't start.
46 Acquisition has been stoped with error.

Sours: https://www.ximea.com/support/wiki/vision-libraries/XIMEA_LabVIEW_Demo_Application_Manual

LINX 3.0 Target Manual Install Process

This is the manual install process for adding support for running LabVIEW VIs on BeagleBone Black and Raspberry Pi 2/3 targets.

The process described below is the same process that the Target Configuration wizard performs. The wizard is available in LabVIEW from Tools»MakerHub»LINX»Target Configuration

All of the steps below are performed on the command line using an SSH terminal connected to the target.

Pre-install Checks


The Target Configuration Wizard performs a number of checks before installation. These checks are made to ensure that the installation is successful and that the post-install experience is good.

  1. Ensure that the target has internet access. If you're not sure, you can check by running: ping google.com
  2. Check the operating system version by running: cat /etc/debian_version

    If the file does not exist or has a value other than 7.0 to 8.9 then you should consider upgrading your operating system to the most recent image for your device. Follow one of these tutorials for more information: BeagleBone Black OS Update, Raspberry Pi OS Update

  3. Expand file system. If you just installed an operating system image and have not yet expanded the file system to use all of the available disk space on your system, you may consider one of the following tutorials: BeagleBone Black Expand File System, Raspberry Pi Expand File System

  4. BeagleBone Black Only:Remove led_aging.sh. On BBB, there is sometimes a startup script which can cause problems when installing additional software to the system. You can safely remove this file, if it exists, by running: rm /etc/init.d/led_aging.sh
  5. Raspberry Pi Only: Enable UART. See this tutorial for more information.

  6. Raspberry Pi Only: Enable SPI and I2C so it can be used from the LINX library:

    1. Use arrow keys to move to “Advanced Options” and hit Enter

    2. Go to “SPI” and hit Enter

    3. Select yes to enable SPI

    4. Select yes to load the kernel module automatically

    5. Repeat steps 2-5 for I2C

    6. Use arrow keys to select “Finish”

    7. Select yes when asked to reboot

Installation Steps


  1. Add the MakerHub software repository address to the target: sudo sh -c 'echo "deb http://feeds.labviewmakerhub.com/debian/ binary/" >> /etc/apt/sources.list'
  2. Get the list of available software from the MakerHub repository: sudo apt-get update
  3. Install the LabVIEW target support: sudo apt-get install -y --force-yes lvrt-schroot
  4. You should be ready to go!

Sours: https://www.labviewmakerhub.com/doku.php?id=learn:libraries:linx:misc:target-manual-install

Manuales labview

LabView Resources

Emergency Notification

COVID-19: Visit the Health Advisories website for the latest updates, FAQs, vaccination information, and to Report a Case.

Site Navigation

Learn LabView

LabView VI's

  • Read Voltage VI - Reads a single analog input from the device and channel specified
  • Spreadsheet Writer VI - Generates 3 columns (with headers) x 100 rows and stores in a file compatible with Excel
  • Spreadsheet Reader VI - Reads a text file (or spreadsheet file saved as a text file) consisting of a column of data and calculates the mean and standard deviation
  • PID VI - PID temperature controller for lab experiment
  • ME120WaveformAcq VI - For use with the Waveform Logger Experiment. Acquires a waveform from the DAQ Signal Accessory box
  • Waveform Logger Simulator VI - Simulates the sinewave generator on the DAQ Signal Accessory box and a data acquisition card

How-to's

  • Getting Started With LabView [PDF] - A quick start guide to get you going
  • Basic TCP/IP Using LabView - A brief intro on how to use TCP/IP in LabView
  • Using Fast Fourier Transforms and Power Spectra in LabVIEW - Describes the basics of FFT analysis using LabView

Other

Week 1

Week 2

Week 3

 

Sours: https://www.sjsu.edu/people/burford.furman/courses/me120/labview/

You start stroking my penis with your hands. I cant stand it. I release a white flame right on your face. uh. how am I This story happened when people met in person more often than called each other on the phone and talked on Skype, went to visit.

You will also like:

There was a knock on the door. I put on my robe. I do not know. The security chief might know, I said.



4288 4289 4290 4291 4292