The media on which you receive National Instruments software are warranted not to fail to execute programming
instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced
by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not
execute programming instructions if National Instruments receives notice of such defects during the warranty period.
National Instruments does not warrant that the operation of the software shall be uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside
of the package before any equipment will be accept ed for warranty work. National Instru ments will pay the shippi ng costs
of returning to the owner parts which are covered by warranty.
National Instruments believes that the informatio n in this manual is accurate. The docume nt has been ca refully review ed
for technical accurac y. In th e even t that te ch nical o r typograp hic al errors exis t, Nation al Inst ruments rese rves th e right to
make changes to subsequent editions of this document without prior notice to holders of this edition. The reader should
consult National Instruments if errors are suspected. In no event shall National Instruments be liable for any damages
arising out of or related to this document or the information contained in it.
XCEPT AS SPECIFIED HEREIN
E
ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE
CUSTOME R
OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF
National Instruments will apply regardless of the form of action, whether in contract or tort, including negligence.
Any action against National Instruments must be brought within one year after the cause of action accrues. National
Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty
provided herein does not cover damages, defects, malfunctions, or service failures caused by owner’s failure to follow
the National Instruments installation, operation, or maintenance instructions; owner’s modification of the product;
owner’s abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or
other events outside reasonable control.
ATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS
. N
ATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS
, N
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical,
including photocopyi ng, recordi ng, st oring in an info rmation ret riev al syste m, or translating , in whole or in part, wit hout
the prior written consent of National Instruments Corporation.
USTOMER’S RIGHT TO RECOVER DAMAGES CAUSED
. C
. This limitation of the liability of
,
Trademarks
CVI™, LabVIEW™, National Instruments™, natinst.com™, NI-488™, NI-488.2™, NI-DAQ™, NI-VISA™, NI-VXI™,
™
, and VXI pc™, are trademarks of National Instruments Corporation.
SCXI
Product and company names listed are trademarks or trade names of their respective companies.
WARNING REGARDING MEDICAL AND CLINICAL USE OF NATIONAL INSTRUMENTS PRODUCTS
National Instruments products are not designed with components and testing intended to ensure a level of reliability
suitable for use in treatment and diagnosis of humans. Applications of National Instruments products involving medical
or clinical treatment can create a potential for accidental injury caused by product failure, or by errors on the part of the
user or application des igner. Any us e or ap plica tion of Na tiona l Instrum ents pr oducts for or inv olving m edi cal or clin ica l
treatment must be performed by properly trai ned and qualifi ed medic al pe rsonne l, and al l tra ditiona l medic al safegu ards,
equipment, and procedu res that are appropriate in the particula r situation to prevent serious injury or dea th should al ways
continue to be used when Natio nal Instrume nts products are being use d. National In struments prod ucts are N OT intended
to be a substitute for any form of establis hed process, procedure, or e quipment us ed to monit or or safeguard human heal th
and safety in medical or clinical treatment.
Contents
About This Manual
Organization of This Manual................................................ ...... .....................................xxiii
Part I, Introduction to G Programming..............................................................xxiii
Part II, I/O Interfaces.........................................................................................xxiv
Part III, Analysis................................................................................................xxiv
Part IV, Network and Interapplication Communication....................................xxv
Part V, Advanced G Programming....................................................................xxvi
Appendices, Glossary, and Index......................................................................xxvi
Conventions Used in This Manual...................................................................................xxvii
Related Documentation....................................................................................................xxviii
National Instruments CorporationxxiLabVIEW User Manual
About This Manual
The LabVIEW User Manual provides information about creating virtual
instruments (VIs). This manual also includes information about the
interfaces to which you can input and output data, using LabVIEW VIs to
perform analysis operations, and how LabVIEW handles network and
interapplication communication. Please read the LabVIEW Release Notes
before you use the LabVIEW User Manual.
Organization of This Manual
The LabVIEW User Manual is organized as follows.
•Chapter 1, Introduction, introduces the unique LabVIEW approa ch to
programming. It also e xplains ho w to start us ing LabVIEW to de v elop
programs.
Part I, Introduction to G Programming
This section contains basic information ab out creating virtual instruments
(VIs), using VIs in other VIs, programming structures such as loops, and
data structures such as arrays and strings.
Part I, Introduction to G Programming, contains the following chapters.
•Chapter 2, Creating VIs, explains how to create a VI including the
front panel, which is the user interface, and the block diagram, which
is the source code. Once you create a VI, you can use it in other VIs.
•Chapter 3, Loops and Charts, shows you how to rep eat portio ns of the
block diagram using a While Loop and a For Loop. This chapter also
explains how to display graphically multiple points, one at a time, on
a chart.
•Chapter 4, Case and Sequence Structures and the Formula Node,
explains how to use the Case structure, which is a conditional structure,
the Sequence structure, which aids in establishing ex ecution order , and
the Formula Node, which aids in executing mathematical formulas.
•Chapter 5, Arrays, Cl usters, and Gr aphs, shows how to display a
group or array of data points on a graph. You can pass scale parameters
as well as an array of data points to a graph by creating a cluster, which
is a group of data different data types.
•Chapter 6, Strings and File I/O, introduces string controls and
indicators and file i npu t and out pu t operat io ns .
National Instruments CorporationxxiiiLabVIEW User Manual
About This Manual
Part II, I/O Interfaces
This section contains basic information on the interfaces to which you can
input and output data, which are data acquisition, GPIB, serial, and VXI.
Refer to the Data Acquisition Basics Manual for basic information on
real-time data acquisition. VISA (Virtual Instrument Software
Architecture) is a single software library that interfaces with GPIB, serial,
and VXI instruments. LabVIEW applications developed especially for a
specific instrument are called instrument drivers. National Instruments
provides several instrument drivers using the VISA library , but you can also
build your own instrument drivers.
Part II, I/O Interfaces, contains the following chapters.
•Chapter 7, Getting Started with a LabVIEW Instrument Driver,
•Chapter 8, LabVIEW VISA Tutorial, shows you how to implement
•Chapter 9, Introduction to LabVIEW GPIB Functions, explains how
•Chapter10, Serial Port VIs, explains the important factors that affect
explains how to create and use National Instruments instrument
drivers.
common VISA applications using message-based and register-based
communication as well as events and locking.
the GPIB operates and the difference between the IEEE 488 and
IEEE 488.2 interface.
serial communication.
Part III, Analysis
This section contains basic information on analysis of data, signal
processing, signal generation, linear algebra, curve fitting, probability, and
statistics.
Part III, Analysis, contains the following chapters.
•Chapter11, Introduction to Analysis in LabVIEW, introduces concepts
that apply to all analysis applications, including supported
functionality, notation and naming conventions, and sampling signal
methods.
•Chapter12, Signal Generation, explains how to produce signals using
the normalized frequency and how to build a simulated function
generator.
•Chapter13, Digital Signal Processing, shows the difference
between the Fast Fourier Transform (FFT) and the Discrete Fourier
Transform (DFT).
•Chapter14, Smoothing Wind ow s, explains how using windows
prevents spectral leakage and improves the analysis of acquired
signals.
•Chapter15, Spectrum Analysis and Measurement, shows how to
determine the amplitude and phase sp ectrum, develop a spectrum
analyzer, and determine the total harmonic distortion (THD).
•Chapter16, Filtering, explains how to filter unnecessary frequencies
from signals using infinite impulse response filters (IIR), finite
impulse response filters (FIR), and nonlinear filters.
•Chapter17, Curve Fitting, shows how to extract information from a
data set to create a data trend description.
•Chapter18, Linear Algebra, explains how to perform matrix
computation and analysis.
•Chapter19, Probability and Statistics, explains some fundamental
concepts of probability and statistics, and shows how to use these
concepts in solving real-world problems.
Part IV, Network and Interapplication Communication
This section contai ns basic inform ation abou t network an d interapp lication
communication.
About This Manual
Part IV, Network and Interapplication Communication, contains the
following chapters.
•Chapter20, Introduction to Communication, introduces the way
LabVIEW handles networking and interapplication communication.
•Chapter21, TCP and UDP, explains basic concepts of Transmission
Control Protocol (TCP), Internet Protocol (IP ), and internet addres ses.
•Chapter22, Acti veX Support, shows how LabVIEW can be an ActiveX
server and client. ActiveX is the same as OLE Automation
communication.
•Chapter23, Using DDE, explains ho w to use Dynamic Data Exchange
(DDE) to communicate between Windows applications. DDE can be
used in a client, a server, and across a network.
•Chapter24, AppleEvents, shows how AppleEvents are used to
communicate between LabVIEW and other Macintosh applications.
LabVIEW can be an AppleEvents server and client.
•Chapter25, Program-to-Program Communication, explains how
LabVIEW can communicate to other Macintosh applications using
Program-to-Program Communication (PPC).
National Instruments CorporationxxvLabVIEW User Manual
About This Manual
Part V, Advanced G Programming
This section contains information on VI customization; programmatic
control of front panel objects, VIs, and LabVIEW; and tips on how to
design complex applications.
Part V, Advanced G Programming, contains the following chapters.
•Chapter26, Customizing VIs, shows how to use VI Setup… and
VI Node Setup… to customize the appearance and execution behavior
of a VI when it is running.
•Chapter27, Front Panel Object Attributes, describes objects called
attribute nodes, which are special block diagram nodes that control the
appearance and functional characteristics of controls and indicators.
•Chapter28, Program Design, explains techniques to use when
creating programs and offers programming-style guidelines.
•Chapter29, Where to Go from Here, provides information about
resources you can use to create your applications successfully.
Appendices, Glossary, and Index
•AppendixA, Analysis References, lists the reference material used to
produce the Analysis VIs in LabVIEW . These references contain more
information on the theories and algorithms implemented in the
analysis library.
•AppendixB, Common Questions, answers common questions about
LabVIEW networking communications and Instrument I/O ,
specifically GPIB and serial I/O.
•AppendixC, Customer Communication, contains forms to help you
gather the information necessary to help us solve your technical
problems and a form you can use to comment on the product
documentation.
•The Glossary contains an alphabetical list of terms used in this manual,
including abbreviations, acronyms, metric prefixes, mnemonics, and
symbols.
•The Index contains an alphabetical list of key terms and topics in this
manual, including the page where you can find each one.
The following conventions are used in this manual:
< >Angle brackets enclose the name of a key on the keyboard—for example,
<shift>. Angle brackets containing numbers separated by an ellipsis
represent a range of values associated with a bit or signal name—
for example, DBIO<3..0>.
-A hyphen between two or more key names enclosed in angle brackets
denotes that you should simultaneously press the named keys—
for example, <Control-Alt-Delete>.
»The » symb ol leads you throu gh nested menu ite ms and dialog box op tions
to a final action. The sequence File»Page Setup»Options» Substitute Fonts directs you to pull down the File menu, select the Page Setup item,
select Options, and finally select the Substitute Fonts options from the
last dialog box.
This icon to the left of bold te xt denotes the be ginning of an acti vity, which
contains step-by-step instructions you can follow to learn more about
LabVIEW.
This icon to the left of bold text denotes the end of an activity, which
contains step-by-step instructions you can follow to learn more about
LabVIEW.
This icon to the left of bold italicized text denotes a note, which alerts you
to important information.
!
boldBold text denotes the names of menus, menu items, parameters, dialo g
bold italicBold italic text denotes an activity objective, note, caution, or warning.
bold monospaceBold monospace text denotes messages and responses that the computer
italicItalic text denotes variables, emphasis, a cross reference, or an introduction
National Instruments CorporationxxviiLabVIEW User Manual
This icon to the left of bold italicized text denotes a caution, which advises
you of precautions to take to avoid injury, data loss, or a system crash.
boxes, dialog box buttons or options, icons, windows, Windows 95 tabs,
or LEDs.
automatically prints to the screen.
to a key concept. This font also denotes text from which you supply the
appropriate word or value, as in Windows 3.x.
About This Manual
monospaceText in this font denotes text or characters that you should literally enter
from the keyboard, sections of code, programming examples, and syntax
examples. This font is also used for the proper n ames of disk d ri ves, p aths,
directories, progr ams, su bprog rams, s ubrouti nes, d e vice n ames, functio ns,
operations, variables, filenames and extensions, and for statements and
comments taken from programs.
pathsPaths in this manual are denoted using backslashes (\) to separate drive
names, director i es, fol ders, and files.
PlatformText in this font denotes information related to a specific platform.
Related Documentation
•G Programming Reference Manual
•LabVIEW Data Acquisition Basics Manual
•LabVIEW Function and VI Reference Manual
•LabVIEW QuickStart Guide
•LabVIEW Online Reference, available by selecting
Help»Online Reference
•LabVIEW Online Tutorial
LabVIEW dialog box
•G Programming Quick Reference Card
•LabVIEW Getting Starte d Card
•LabVIEW Release Notes
•LabVIEW Upgrade Notes
(Windows only), which you launch f rom t he
Customer Communication
National Instruments wants to receive your comments on our products
and manuals. We are interested in the applications you develop with our
products, and we want to help if you have problems with them. To make it
easy for you to contact us, this manual contains comment and configuration
forms for you to complete. These forms are in Appendix C, Customer
This chapter introduces the unique LabVIEW approach to programming.
It also explains how to start using LabVIEW to develop programs. The
chapter refers you to other chapters or manuals for more information.
What Is LabVIEW?
LabVIEW is a program development enviro nment, much like modern C
or BASIC development environments, and National Instr uments
LabWindows/CVI. However, LabVIEW is different from those
applications in one important respect. Other programming systems use
text-based languages to create lines of code, while LabVIEW uses a
graphical programming language, G, to create programs in block diagram
form.
LabVIEW, like C or BASIC, is a general-purpose programming system
with extensive libraries of functions for any programming task. LabVIEW
includes libraries for data acquisition, GPIB and serial instrument control,
data analysis, data presentation, and data storage. LabVIEW also includes
conventional program development tools, so you can set breakpoints,
animate the execution to see how data passes through the program, and
single-step through the program to make debugging and program
development easier.
1
How Does LabVIEW Work?
LabVIEW is a general-purpose programming system, but it also includes
libraries of functions and devel opment tool s designed specifically fo r data
acquisition and instrument control. LabVIEW programs are called virtual instruments (VIs) because their appearance and operation can imitate actual
instruments. However, VIs are similar to the functions of conventional
language programs.
A VI consists of an interactive user interface, a dataflow diagram that
serves as the source code, and icon connections that allow the VI to be
National Instruments Corporation1-1LabVIEW User Manual
Chapter 1Introduction
called from higher level VIs. More specifically, VIs are structured as
follows:
•The interactive user interface of a VI is called the front panel,
because it simulates the pane l o f a physica l instru ment. T he fr ont
panel can contain knobs, push buttons, graphs, and othe r controls
and indicators. Yo u ente r data using a m ouse and k eyboa rd , and
then view th e re su lt s o n t h e co mpu ter sc re en .
•The VI receives instructions from a block diagram, which you
construct in G. The block diagram is a pictorial solution to a
programming problem. The block diagram is also the sourc e code
for the VI.
•VIs are hierarchical and modular. You can use them as top-level
programs, or as sub pro gram s within o the r p rogra ms. A VI w ithin
another VI is called a su bVI. The icon and connector of a VI work
like a graphical parameter list so that other VIs can pass data to a
subVI.
With these features, LabVIEW promotes and adheres to the concept of
modular programming. You divide an application into a series of tasks,
which you can divide again until a complicated application becomes a
series of simple subtasks. You build a VI to accomplish each subtask and
then combine those VIs on another block diagram to accomplish the larger
task. Finally, your top-level VI contains a collection of subVIs that
represent application functions.
Because you can execute each subVI by itself, apart from the rest of the
application, debugging is much easier. Furthermore, many low-level
subVIs often perform tas ks common to sev eral applications, s o that you can
develop a specialized set of subVIs well-suited to applications you are
likely to construct.
G Programming
G is the easy to use graphical data flow programming language on which
LabVIEW is based. G simplifies scientific computation , process
monitoring and control, and test and measurement applications, and you
also can use it for a wide variety of other applications.
Part I, Introduction to G Programming, covers the functionality of G that
you need to get started with most LabVIEW applications . For a more
extensive explanation of LabVIEW functionality, see the G Programming Reference Manual.
The basic concepts of G that are covered in this manual are described in the
following list.
•VIs—Virtual instruments (VIs) have three main parts: the front panel,
the block diagram, and the icon/connector. The front panel specifies
the user interface of the VI. The block diagram consists of the
executable code that you create using nodes, terminals, and wires.
With the icon/connector, you can use a VI as a subVI in the block
diagram of another VI. For more information about VIs, refer to
Chapter 2, Creating VIs and Chapter 26, Customizing VIs.
•Loops and Charts—G has two structures to repeat execution of a
sub-diagram—the While Loop and the For Loop. Both structures are
resizable boxes. You place the subdiagram to be repeated inside the
border of the loop structure. The While Loop executes as long as the
value at the conditional terminal is TRUE. The For Loop executes a set
number of times. Charts are used to d isplay real-time trend information
to the operator. For more information about loops and charts, refer to
Chapter 3, Loops and Charts.
•Case and Sequence Structures—The Case structure is a co nditional
branching control structure, which executes a subdiagram based on
certain input. A Sequence structure is a program control structure that
executes its subdiagrams in numeric order. For more information about
Case or Sequence structures, refer to Chapter 4, Case and Sequence
Structures and the Formula Node.
•Attribute Nodes—Attribute nodes are special block diagra m nodes
that you can use to control the appearance and functional
characteristics of controls and indicators. For mor e info rmation abo ut
attribute nodes, refer to Chapter 27, Front Panel Object Attributes.
•Arrays, Clusters and Graphs—An array is a resizable collection of
data elements of the same type. A cluster is a statically sized collection
of data elements of the same or different types. Graphs commo nly are
used to display data. For more informa tion about arrays, clusters, and
graphs, refer to Chapter 5, Arrays, Clusters, and Graphs.