LabVIEWTM Basics II
Development
Course Manual
Course Software Version 8.0
October 2005 Edition
Part Number 320629N-01
LabVIEW Development Course Manual
Copyright
© 1993–2005 National Instruments Corporation. All rights reserved.
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including
photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent
of National Instruments Corporation.
In regards to components used in USI (Xerces C++, ICU, and HDF5), the following copyrights apply. For a listing of the conditions and
disclaimers, refer to the USICopyrights.chm.
This product includes software developed by the Apache Software Foundation (http:/www.apache.org/).
Copyright
Copyright © 1995–2003 International Business Machines Corporation and others. All rights reserved.
NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities
Copyright 1998, 1999, 2000, 2001, 2003 by the Board of Trustees of the University of Illinois. All rights reserved.
© 1999 The Apache Software Foundation. All rights reserved.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section
on ni.com/legal for more information about National Instruments trademarks.
Other product and company names mentioned herein are trademarks or trade names of their respective companies.
Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have
no agency, partnership, or joint-venture relationship with National Instruments.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software,
the patents.txt file on your CD, or ni.com/legal/patents.
Worldwide Technical Support and Product Information
ni.com
National Instruments Corporate Headquarters
11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599, Canada 800 433 3488,
China 86 21 6555 7838, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00, Finland 385 0 9 725 725 11,
France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, India 91 80 51190000, Israel 972 0 3 6393737, Italy 39 02 413091,
Japan 81 3 5472 2970, Korea 82 02 3451 3400, Lebanon 961 0 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793,
Netherlands 31 0 348 433 466, New Zealand 0800 553 322, Norway 47 0 66 90 76 60, Poland 48 22 3390150,
Portugal 351 210 311 210, Russia 7 095 783 68 51, Singapore 1800 226 5886, Slovenia 386 3 425 4200,
South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51,
Taiwan 886 02 2377 2222, Thailand 662 278 6777, United Kingdom 44 0 1635 523545
For further support information, refer to the Additional Information and Resources appendix. To comment on National Instruments
documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback.
Contents
Student Guide
A. Course Description ...............................................................................................vi
B. What You Need to Get Started .............................................................................vii
C. Installing the Course Software..............................................................................vii
D. Course Goals.........................................................................................................viii
E. Course Conventions..............................................................................................ix
Lesson 1
Common Design Techniques
A. Single Loop Architectures ....................................................................................1-2
B. Parallelism ............................................................................................................1-6
Exercise 1-1 Concept: Evaluate Parallelism..........................................................1-8
C. Multiple Loop Architectures.................................................................................1-9
D. Timing a Design Pattern .......................................................................................1-13
Lesson 2
Communicating Among Multiple Loops
A. Variables ...............................................................................................................2-2
B. Functional Global Variables .................................................................................2-11
Exercise 2-1 Variables VI......................................................................................2-14
C. Race Conditions....................................................................................................2-23
Exercise 2-2 Concept: Bank VI .............................................................................2-30
D. Synchronizing Data Transfer ................................................................................2-33
Exercise 2-3
Project: Queue Data..........................................................................2-37
Exercise 2-4 Optional: Global Data Project ..........................................................2-52
Lesson 3
Improving an Existing VI
A. Refactoring Inherited Code...................................................................................3-2
Exercise 3-1
Project: Refactor...............................................................................3-5
B. Typical Issues .......................................................................................................3-23
Exercise 3-2 Concept: Typical Issues....................................................................3-27
© National Instruments Corporation
iii
LabVIEW Development Course Manual
Contents
Lesson 4
Controlling the User Interface
A. VI Server Architecture..........................................................................................4-2
B. Property Nodes .....................................................................................................4-3
Exercise 4-1
Temperature Limit VI.......................................................................4-5
C. Control References ...............................................................................................4-9
Exercise 4-2
Set Plot Names .................................................................................4-13
D. Invoke Nodes ........................................................................................................4-23
Front Panel Properties VI .................................................................4-24
Exercise 4-3
Lesson 5
Advanced File I/O Techniques
A. File Formats ..........................................................................................................5-2
B. Binary Files...........................................................................................................5-5
Exercise 5-1 Bitmap File Writer VI ......................................................................5-12
C. TDM Files.............................................................................................................5-20
TDM Logger VI ...............................................................................5-32
Exercise 5-2
Exercise 5-3
TDM Query ......................................................................................5-47
Lesson 6
Creating and Distributing Applications
A. LabVIEW Features for Project Development.......................................................6-2
Exercise 6-1 Concept: LabVIEW Project Management Tools..............................6-5
B. Preparing the Application .....................................................................................6-7
C. Building the Application and Installer..................................................................6-8
Exercise 6-2 Concept: Creating a Stand-Alone Application .................................6-10
Appendix A
Additional Information and Resources
Index
Course Evaluation
LabVIEW Development Course Manual
iv
ni.com
Student Guide
Thank you for purchasing the LabVIEW Basics II: Development course
kit. You can begin developing an application soon after you complete
the exercises in this manual. This course manual and the accompanying
software are used in the two-day, hands-on LabVIEW Basics II:
Development course.
You can apply the full purchase of this course kit toward the corresponding
course registration fee if you register within 90 days of purchasing the kit.
Visit ni.com/training for online course schedules, syllabi, training
centers, and class registration.
Note For course manual updates and corrections, refer to ni.com/info and enter the
info code rdlvc2.
The LabVIEW Basics II: Development course is part of a series of courses
designed to build your proficiency with LabVIEW and help you prepare for
exams to become an NI Certified LabVIEW Developer and NI Certified
LabVIEW Architect. The following illustration shows the courses that are
part of the LabVIEW training series. Refer to ni.com/training for more
information about NI Certification.
Courses
New User
Experienced User
Advanced User
Begin
Here
LabVIEW Basics I*
LabVIEW Basics II*
Skills learned:
Skills learned:
LabVIEW environment
LabVIEW environment
navigation
navigation
Basic application creation
Basic application creation
using LabVIEW
using LabVIEW
Certifications
LabVIEW Intermediate I*
LabVIEW Intermediate II*
Skills learned:
Modular application development
Structured design and
development practices
Memory management and VI
performance improvement
LabVIEW Advanced
LabVIEW Advanced
Application Development
Application Development
Skills learned:
Large application design
Code reuse maximization
Object-oriented programming
in LabVIEW
Certified LabVIEW
Associate Developer Exam
Certified LabVIEW
Developer Exam
Skills tested:
LabVIEW environment
knowledge
Skills tested:
• LabVIEW application
development expertise
Certified LabVIEW
Architect Exam
Skills tested:
LabVIEW application
development mastery
Hardware-Based Courses:
Data Acquisition and Signal Conditioning Modular Instruments Instrument Control Machine Vision
Motion Control LabVIEW Real-Time
*Core courses are strongly recommended to realize maximum productivity gains when using LabVIEW.
© National Instruments Corporation
v
LabVIEW Development Course Manual
Student Guide
A. Course Description
Use this manual to learn about LabVIEW programming concepts,
techniques, features, VIs, and functions you can use to create test and
measurement, data acquisition, instrument control, datalogging,
measurement analysis, and report generation applications.
This course manual assumes that you are familiar with Windows,
Macintosh, or UNIX; that you have experience writing algorithms in the
form of flowcharts or block diagrams; and that you have taken the LabVIEW
Basics I: Introduction course or have equivalent experience.
The course manual is divided into lessons, each covering a topic or a set of
topics. Each lesson consists of the following:
• An introduction that describes the purpose of the lesson and what you
will learn
A description of the topics in the lesson
A set of exercises to reinforce those topics
A set of additional exercises to complete if time permits
A summary that outlines important concepts and skills taught in the
lesson
Several exercises in this manual use a plug-in multifunction data acquisition
(DAQ) device connected to a DAQ Signal Accessory containing a
temperature sensor, function generator, and LEDs.
Exercises that explicitly require hardware are indicated with an icon, shown
at left. You also can substitute other hardware for those previously
mentioned. For example, you can use another National Instruments
DAQ device connected to a signal source, such as a function generator.
LabVIEW Development Course Manual
vi
ni.com
B. What You Need to Get Started
Student Guide
Before you use this course manual, make sure you have all of the following
items:
❑ Windows 2000 or later installed on your computer; this course is
optimized for Windows XP
❑ Multifunction DAQ device configured as device 1 using Measurement
& Automation Explorer (MAX)
❑ DAQ Signal Accessory, wires, and cable
❑ LabVIEW Professional Development System 8.0 or later
❑ LabVIEW Basics II: Development course CD, from which you install the
following files:
Filename
Description
Exercises
Folder containing VIs used in the course
Solutions
Folder containing completed course exercises
C. Installing the Course Software
Complete the following steps to install the course software.
1.
Insert the course CD in your computer. The LabVIEW Basics Course
Material Setup dialog box appears.
2. Click the Next button.
3. Choose Typical setup type and click the Install button to begin the
installation.
4. Click the Finish button to exit the Setup Wizard.
5. The installer places the Exercises and Solutions folders at the top
level of the C:\ directory.
Exercise files are located in the C:\Exercises\LabVIEW Basics II
directory.
© National Instruments Corporation
vii
LabVIEW Development Course Manual
Student Guide
Repairing or Removing Course Material
You can repair or remove the course material using the Add or Remove
Programs feature on the Windows Control Panel. Repair the course
material to overwrite existing course material with the original, unedited
versions of the files. Remove the course material if you no longer need the
files on your machine.
D. Course Goals
This course prepares you to do the following:
Understand the VI development process
Understand some common VI programming architectures
Design effective user interfaces (front panels)
Efficiently transfer data among parallel processes
Use advanced file I/O techniques
Use LabVIEW to create applications
Use property nodes and invoke nodes in your VI
You will apply these concepts as you build a project that uses VIs you create
throughout the course. While these VIs individually illustrate specific
concepts and features in LabVIEW, they constitute part of a larger project
built throughout the course.
This course does not describe any of the following:
LabVIEW programming methods covered in the LabVIEW Basics I:
Introduction course
Every built-in VI, function, or object; refer to the LabVIEW Help for
more information about LabVIEW features not described in this course
Developing a complete application for any student in the class; refer to
the NI Example Finder, available by selecting Help»Find Examples,
for example VIs you can use and incorporate into VIs you create
LabVIEW Development Course Manual
viii
ni.com