You are on page 1of 102

uti ts

LabVIEW Core 2 TM

rib en
Exercises

on
ist um
r D str
Course Software Version 2011
August 2011 Edition
Part Number 325293C-01
LabVIEW Core 2 Exercises
t fo l In
Copyright
© 1993–2011 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.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by
copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to
No na

others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable
license or other legal restriction.
For components used in USI (Xerces C++, ICU, HDF5, b64, Stingray, and STLport), the following copyright stipulations apply. For a
listing of the conditions and disclaimers, refer to either the USICopyrights.chm or the Copyrights topic in your software.
Xerces C++. This product includes software that was developed by the Apache Software Foundation (http://www.apache.org/).
tio

Copyright 1999 The Apache Software Foundation. All rights reserved.


ICU. Copyright 1995–2009 International Business Machines Corporation and others. All rights reserved.
HDF5. 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.
b64. Copyright © 2004–2006, Matthew Wilson and Synesis Software. All Rights Reserved.
Na

Stingray. This software includes Stingray software developed by the Rogue Wave Software division of Quovadx, Inc.
Copyright 1995–2006, Quovadx, Inc. All Rights Reserved.
STLport. Copyright 1999–2003 Boris Fomitchev

Trademarks
LabVIEW, National Instruments, NI, ni.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National
Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other 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/technology, refer to the appropriate location: Help»Patents in your software,
the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.
uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

Worldwide Technical Support and Product Information


ni.com
Worldwide Offices
Visit ni.com/niglobal to access the branch office Web sites, which provide up-to-date contact information, support phone
numbers, email addresses, and current events.
National Instruments Corporate Headquarters
11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100

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

uti ts
A. NI Certification .....................................................................................................v
B. Course Description ...............................................................................................vi
C. What You Need to Get Started .............................................................................vii
D. Installing the Course Software..............................................................................vii

rib en
E. Course Goals.........................................................................................................viii
F. Course Conventions ..............................................................................................ix

on
Lesson 2

ist um
Synchronization Techniques
Exercise 2-1 Concept: Comparing Queues With Local Variables ........................2-1

Lesson 3
Event Programming
r D str
Exercise 3-1 Concept: Experiment with Event Structures ....................................3-1
Exercise 3-2 Create a Print Queue Console...........................................................3-4

Lesson 4
t fo l In
Error Handling
Exercise 4-1 Updating the Print Console With Error Handling ............................4-1

Lesson 5
Controlling the User Interface
No na

Exercise 5-1 Display Temperature and Limits ......................................................5-1


Exercise 5-2 Customizing the VI Window............................................................5-5
Exercise 5-3 Set Plot Names .................................................................................5-10

Lesson 6
tio

File I/O Techniques


Exercise 6-1 Bitmap File Writer VI ......................................................................6-1
Exercise 6-2 Read TDMS Files .............................................................................6-8
Na

Lesson 7
Improving an Existing VI
Exercise 7-1 Concept: Refactoring a VI................................................................7-1

Lesson 8
Creating and Distributing Applications
Exercise 8-1 Preparing Files for Distribution........................................................8-1
Exercise 8-2 Creating a Stand-Alone Application ................................................8-7

© National Instruments Corporation iii LabVIEW Core 2 Exercises


Contents

Appendix A
Setting Up Your Hardware

Appendix B

uti ts
Additional Information and Resources

rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises iv ni.com


Student Guide

Thank you for purchasing the LabVIEW Core 2 course kit. You can begin
developing an application soon after you complete this course. This exercise

uti ts
manual and the accompanying software are used in the two-day, hands-on
LabVIEW Core 2 course.

rib en
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.

on
Visit ni.com/training for online course schedules, syllabi, training
centers, and class registration.

ist um
A. NI Certification
The LabVIEW Core 2 course is part of a series of courses designed to build
your proficiency with LabVIEW and help you prepare for the NI Certified
LabVIEW Associate Developer exam. The following illustration shows the
r D str courses that are part of the LabVIEW training series. Refer to ni.com/
training for more information about NI Certification.
t fo l In
New User Experienced User Advanced User
Courses

LabVIEW Core 1* LabVIEW Core 3* Managing Software


Engineering in LabVIEW
LabVIEW Core 2*
LabVIEW Connectivity Advanced Architectures
in LabVIEW
No na

Object-Oriented Design
and Programming
in LabVIEW

LabVIEW Performance
Certifications
tio

Certified LabVIEW Certified LabVIEW Certified LabVIEW


Associate Developer Exam Developer Exam Architect Exam

Other Courses

LabVIEW Instrument Control LabVIEW Real-Time 1 LabVIEW Real-Time 2


Na

LabVIEW FPGA LabVIEW DAQ and Signal Conditioning Modular Instruments Series

*Core courses are strongly recommended to realize maximum productivity gains when using LabVIEW.

© National Instruments Corporation v LabVIEW Core 2 Exercises


Student Guide

B. Course Description
The LabVIEW Core 2 course teaches you programming concepts,
techniques, features, VIs, and functions you can use to create test

uti ts
and measurement, data acquisition, instrument control, datalogging,
measurement analysis, and report generation applications. This course
assumes that you are familiar with Windows; that you have experience

rib en
writing algorithms in the form of flowcharts or block diagrams; and that you
have taken the LabVIEW Core 1 course or have equivalent experience. The

on
course and exercise manuals are divided into lessons, described as follows.

In the course manual, each lesson consists of the following:

ist um
• An introduction that describes the purpose of the lesson and what
you will learn
• A description of the topics in the lesson
r D str • A summary quiz that tests and reinforces important concepts and
skills taught in the lesson

In the exercise manual, each lesson consists of the following:


• A set of exercises to reinforce those topics
• Some lessons include optional and challenge exercise sections or
t fo l In
a set of additional exercises to complete if time permits

Note For course and exercise manual updates and corrections, refer to ni.com/info
and enter the Info Code core2.
No na

Several exercises use a plug-in multifunction data acquisition (DAQ) device


connected to a DAQ Signal Accessory or BNC 2120 containing a
temperature sensor, function generator, and LEDs.

If you do not have this hardware, you still can complete the exercises.
tio

Alternate instructions are provided for completing the exercises without


hardware. 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
Na

Instruments DAQ device connected to a signal source, such as a function


generator.

LabVIEW Core 2 Exercises vi ni.com


Student Guide

C. What You Need to Get Started


Before you use this course manual, make sure you have all of the following
items:

uti ts
❑ Windows XP or later installed on your computer; this course is
optimized for Windows XP

rib en
❑ Multifunction DAQ device configured as Dev1 using Measurement &
Automation Explorer (MAX)

on
❑ DAQ Signal Accessory or BNC-2120, wires, and cable

ist um
❑ LabVIEW Professional Development System 2011 or later

❑ DAQmx 9.3.5 or later


r D str ❑ LabVIEW Core 2 course CD, from which you install the following
folders:

Directory Description
Exercises Contains VIs used in the course
t fo l In

Solutions Contains completed course exercises

D. Installing the Course Software


Complete the following steps to install the course software.
No na

1. Insert the course CD in your computer. The LabVIEW Core 2 Course


Setup dialog box appears.
2. Click Install the course materials.
tio

3. Follow the onscreen instructions to complete installation and setup.

Exercise files are located in the <Exercises>\LabVIEW Core 2\ folder.

Note Folder names in angle brackets, such as <Exercises>, refer to folders on the root
Na

directory of your computer.

© National Instruments Corporation vii LabVIEW Core 2 Exercises


Student Guide

E. Course Goals
This course prepares you to do the following:
• Apply common design patterns that use notifiers, queues, and events

uti ts
• Use event programming effectively
• Programmatically control user interface objects

rib en
• Evaluate binary file I/O formats and use them in applications
• Modify existing code for improved usability

on
• Prepare, build, and deploy stand-alone applications

ist um
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.
r D str This course does not describe any of the following:
• LabVIEW programming methods covered in the LabVIEW Core 1
course
• Every built-in VI, function, or object; refer to the LabVIEW Help for
t fo l In
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
No na
tio
Na

LabVIEW Core 2 Exercises viii ni.com


Student Guide

F. Course Conventions
The following conventions appear in this course manual:

uti ts
» The » symbol leads you through nested menu items and dialog box
options to a final action. The sequence Tools»Instrumentation»Find
Instrument Drivers directs you to drop down the Tools menu, select the

rib en
Instrumentation item, and finally select the Find Instrument Drivers
option.

on
This icon denotes a tip, which alerts you to advisory information.

ist um
This icon denotes a note, which alerts you to important information.

This icon denotes a caution, which advises you of precautions to take to


avoid injury, data loss, or a system crash.
r D str This icon indicates that an exercise requires a plug-in DAQ device.

bold Bold text denotes items that you must select or click in the software, such as
menu items and dialog box options. Bold text also denotes sections of dialog
boxes and hardware labels.
t fo l In
italic Italic text denotes variables, emphasis, a cross-reference, or an introduction
to a key concept. Italic text also denotes text that is a placeholder for a word
or value that you must supply.

monospace Text in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
No na

This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames, and extensions.
tio

monospace bold Bold text in this font denotes the messages and responses that the computer
automatically prints to the screen. This font also emphasizes lines of code
that are different from the other examples.
Na

© National Instruments Corporation ix LabVIEW Core 2 Exercises


Na
tio
No na
t fo l In
r D str
ist um
rib en
uti ts
on
Synchronization Techniques
2

uti ts
Exercise 2-1 Concept: Comparing Queues With Local

rib en
Variables

on
Goal
In this exercise, you run and examine a prebuilt producer/consumer design

ist um
pattern VI that transfers data generated by the producer loop to each of the
consumer loops using local variables and queues.

Description
1. Open Queues vs Local Variables.vi in the <Exercises>\
r D str LabVIEW Core 2\Queues versus Local Variables directory.
The front panel of this VI is shown in Figure 2-1.
t fo l In
No na
tio
Na

Figure 2-1. Front Panel of the Queues vs Local Variables VI

© National Instruments Corporation 2-1 LabVIEW Core 2 Exercises


Lesson 2 Synchronization Techniques

2. Run the VI. The producer loop generates data and transfers it to each
consumer loop using a local variable and a queue.

3. Display and examine the block diagram for this VI.

uti ts
rib en
on
ist um
r D str
t fo l In

Figure 2-2. Block Diagram of the Queues vs Local Variables VI

Creating a Queue
The Obtain Queue function, placed to the left of the Producer Loop, creates
No na

the queue.

The My Data string constant, wired to the name (unnamed) input of the
Obtain Queue function, assigns a name to the queue you want to obtain or
create.
tio

The Data Type numeric constant, wired to the element data type input of the
Obtain Queue function, specifies the type of data that you want the queue to
contain.
Na

Queuing Data Generated by the Producer Loop


The Enqueue Element function inside the Producer Loop adds each data
element generated by the Sine Wave subVI to the back of the queue.

LabVIEW Core 2 Exercises 2-2 ni.com


Lesson 2 Synchronization Techniques

Dequeuing Data from the Producer Loop inside the Queue’s


Consumer Loop
The Dequeue Element function inside the Queue’s Consumer Loop removes
an element from the front of the queue and outputs the data element to the

uti ts
Queue’s Consumer Loop waveform graph.

The Get Queue Status function inside the Queue’s Consumer Loop indicates

rib en
how many elements remain in the queue. In order to process these data
elements, you must execute the Queue’s Consumer Loop faster than the

on
Producer Loop, or continue to process after the Producer Loop has stopped.

Waiting for the Queue to Empty

ist um
The While Loop inside the Flat Sequence structure waits for the queue to
empty before stopping the VI. Refer to this While Loop as the Queue Wait
Loop.

The Get Queue Status function inside the Queue Wait Loop returns
r D str information about the current state of the queue, such as the number of data
elements currently in the queue.

The Equal To 0? function wired to the stop condition of the Queue Wait
Loop checks if the queue is empty.
t fo l In

The Release Queue function to the right of the Queue Wait Loop releases
and clears reference to the queue.

The Simple Error Handler to the right of the Release Queue function reports
any error at the end of execution.
No na

Local Variable’s Consumer Loop


The Producer Loop generates sine wave data and writes it to a local variable
while the Local Variable’s Consumer Loop periodically reads out the sine
tio

wave data from the same local variable. The Points Difference VI inside the
Local Variable’s Consumer Loop outputs the number of missed points or
number of duplicate points read out.

Switch to the front panel of this VI.


Na

1. Select the loop time speed of the Local Variable’s Consumer Loop and
observe the Local Variable’s Consumer Loop waveform graph and the
results generated on the Duplicate Points indicator.

❑ Ensure that the Loop Speed selected is Same as Producer Loop and
observe the waveform graphs for both the Producer Loop and the
Local Variable’s Consumer Loop. A race condition may occur
resulting in missed points or duplicated data.

© National Instruments Corporation 2-3 LabVIEW Core 2 Exercises


Lesson 2 Synchronization Techniques

❑ Select Maximum Speed from the pull-down menu of the Loop


Speed control and observe the waveform graph of the Local
Variable’s Consumer Loop. A race condition occurs because data is
consumed faster than it is produced, allowing the local variable to

uti ts
read the same value multiple times.

❑ Select 1/2 as Producer from the pull-down menu of the Loop Speed
control and observe the waveform graph of the Local Variable’s

rib en
Consumer Loop. A race condition occurs because data is produced
faster than it is consumed. The data changes before the local variable

on
has a chance to read it.

ist um
❑ Select the remaining options available from the pull-down menu of
the Loop Speed control and observe the data retrieval.

2. Stop the VI.


r D str Data transfer between two non-synchronized parallel loops using local
variables causes a race condition. This occurs when the Producer Loop
is writing a value to a local variable while the Local Variable’s
Consumer Loop is periodically reading out the value from the same
local variable. Because the parallel loops are not synchronized, the value
can be written before it has actually been read or vice versa resulting in
t fo l In
data starvation or data overflow.

Queue’s Consumer Loop


1. Run the VI. Select the loop time speed of the Queue’s Consumer Loop
and observe the Queue’s Consumer Loop waveform graph and the
No na

results generated on the # of elements in queue indicator.

❑ Ensure that the Loop Speed selected is Same as Producer and


observe the value of the # of elements in queue indicator. The value
should remain zero. Hence with queues, you will not lose data when
tio

the producer and consumer loops are executing at the same rate.

❑ Select Maximum Speed from the pull-down menu of the Loop


Speed control and observe the value of # of elements in queue. The
value should remain zero. Hence with queues, you will not lose data
Na

if the consumer loop is executing much faster than the producer


loop.

LabVIEW Core 2 Exercises 2-4 ni.com


Lesson 2 Synchronization Techniques

❑ Select 1/2 as Producer from the pull-down menu of the Loop Speed
control and observe the value of # of elements in queue. The data
points will accumulate in the queue. You will need to process the
accumulated elements in the queue before reaching the maximum

uti ts
size of the queue to avoid data loss.

❑ Select the remaining options available from the pull-down menu of


the Loop Speed control and observe the synchronization of data

rib en
transfer between the producer loop and the consumer loop using
queues.

on
2. Stop the VI.

ist um
When the Producer Loop and Queue’s Consumer Loop run at the same
speed, the number of elements in the queue remains unchanged. When
the Queue’s Consumer Loop runs slower, the queue quickly backs up
and the Producer Loop must wait for the Queue Consumer Loop to
remove the elements. When the Queue’s Consumer Loop runs faster,
r D str the queue is quickly emptied and the consumer loop must wait for the
Producer loop to insert elements. Hence queues synchronize the data
transfer between the two independent parallel loops and thus avoid loss
or duplication of data.
t fo l In
3. Close the VI. Do not save changes.

End of Exercise 2-1


No na
tio
Na

© National Instruments Corporation 2-5 LabVIEW Core 2 Exercises


Lesson 2 Synchronization Techniques

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 2-6 ni.com


Event Programming
3

uti ts
Exercise 3-1 Concept: Experiment with Event Structures

rib en
Goal

on
Experiment with the operation of the Event structure in a VI.

ist um
Description
Use and modify a VI that contains an Event structure.

1. Open the NI Example Finder.

❑ Select Help»Find Examples.


r D str 2. Open the New Event Handler VI example.

❑ Navigate to Building User Interfaces»Acquiring User Input»


General and double-click New Event Handler.vi.
t fo l In

3. Close the NI Example Finder.

4. Enable execution highlighting on the block diagram.

5. Run the VI.


No na

6. Observe the operation of the VI when you click the buttons on the front
panel.

7. Stop the VI.


tio

8. Disable execution highlighting.

9. Modify the VI to respond to a Value Change event with a new control on


the front panel.
Na

❑ Switch to the front panel of the VI.

❑ Create a copy of the Boolean button on the front panel.

❑ Change the button text and label of the button to New Button.

❑ Right-click the new button and verify that the Mechanical Action is
set to Latch When Released.

© National Instruments Corporation 3-1 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

❑ Switch to the block diagram of the VI.

❑ Right-click the border of the Event structure and select Add Event
Case from the shortcut menu to open the Edit Events dialog box.

uti ts
❑ Select New Button in the Event Sources section and select Value
Change in the Events section as shown in Figure 3-1.

rib en
on
ist um
r D str
t fo l In
No na

Figure 3-1. New Button Value Change Event


tio

❑ Click OK to create the new Event case structure.

❑ Place the New Button control in the New Button event case.
Na

❑ Add a One Button Dialog function in the New Button event case
and wire a string constant to the message input. Set the string
constant to New Event Case.

❑ Wire the Time Waveform data through the case.

❑ Wire a False constant to the Boolean tunnel.

LabVIEW Core 2 Exercises 3-2 ni.com


Lesson 3 Event Programming

❑ Run the VI and click New Button. A dialog box should open and
display the New Event Case message.

❑ Stop the VI.

uti ts
10. Modify the Event structure to add a Filter Event to discard the Panel
Close event.

rib en
❑ Right-click the Event structure and select Add Event Case from
the shortcut menu to open the Edit Events dialog box.

on
❑ Select <This VI> in the Event Sources section.

ist um
❑ Select Panel Close? from the Events section and click the OK
button.

❑ Wire a True constant to the Discard? Event Filter Node in the Panel
r D str Close? case.

❑ Wire the Time Waveform data through the case.

❑ Wire a False constant to the Boolean tunnel.


t fo l In
11. Run the VI.

12. Attempt to close the VI by closing the front panel.

13. Click the STOP button to stop the VI.

14. Open the NI Example Finder.


No na

15. Open the Old Event Handler VI example.

❑ Navigate to Building User Interfaces»Acquiring User Input»


tio

General and double-click Old Event Handler.vi.

16. Enable execution highlighting on the block diagram.

17. Run the VI.


Na

18. Observe the operation of the Old Event Handler VI and compare and
contrast the operation with the New Event Handler VI.

19. Close all VIs without saving changes.

End of Exercise 3-1

© National Instruments Corporation 3-3 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

Exercise 3-2 Create a Print Queue Console


Goal

uti ts
Use the Producer/Consumer (Event) template to create a print queue
console that submits print jobs to a printer and monitors the print queue.

Scenario

rib en
You must create a print console VI that controls print job submissions and

on
monitors the processing status of the print jobs. Each time the user clicks on
the Queue Event button, a print job will be sent to the printer. You will
monitor the number of print jobs in the queue using a vertical bar. LEDs will

ist um
indicate the print processing status.

The print process for each job includes two steps—an initialization stage
with a fixed duration of 300 ms and a print stage with a varying duration
r D str based on the size of the job.

Design
The controls and type definition enums necessary for this project are already
created. Your task is to use the Producer/Consumer design pattern template
that ships with LabVIEW to create the print console VI. Table 3-1 lists the
t fo l In
controls and indicators used in the front panel of the print console VI.

Table 3-1. Front Panel Controls/Indicators and Descriptions

Controls/Indicators Description
No na

Queue Event button Each time the user clicks on this button, a print job is sent to the printer.
Queued Print Jobs bar This bar displays the number of print jobs that are currently in the print
queue. Each time a print job is sent to the printer, a new job is added to
the queue. When the printer starts a new job, the print job is removed
tio

from the queue.


Waiting LED This LED is turned on only when there are no print jobs in the queue.
Initializing LED This LED is turned on for the duration of the setup stage for each print job.
Na

Printing LED This LED is turned on for the duration of the print stage for each print
job.
Stop Button This button stops the VI.

LabVIEW Core 2 Exercises 3-4 ni.com


Lesson 3 Event Programming

Table 3-2 lists the Event cases you will implement in the producer loop.

Table 3-2. Producer Loop Event Cases

Event Case Case Description

uti ts
Enqueue Element10: In this case, you use the Enqueue Element function to queue a
Value Change string constant with the value of print job.

rib en
Stop: Value Change In this case, you stop the While Loop.

on
Timeout In this case, you use the Get Queue Status function to get the
number of elements in the queue. You pass the value to the

ist um
Queued Print Jobs bar.

Table 3-3 lists the states you will implement in the consumer loop state
machine.
r D str Table 3-3. Consumer Loop States

State State Description


Wait You perform the following tasks in this state.
• Use the Dequeue Element function to wait for a queued print job.
t fo l In
• Set the Dequeue Element function to timeout for 100 ms.
• Set the next state to be the Wait state, if the Dequeue Element function
times out. Set the next state to be Initialize Setup, if the Dequeue
Element function does not time out.
• Set the Waiting LED to True.
No na

Initialize Setup You perform the following tasks in this state.


• Set the Waiting LED to False.
• Set the Initializing LED to True.
tio

• Transition to the Setup state.


Setup You perform the following tasks in this state.
• Simulate print setup with a 300 ms wait.
Na

• Set the Initializing LED to False.


• Transition to the Initialize Print state.

© National Instruments Corporation 3-5 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

Table 3-3. Consumer Loop States (Continued)

State State Description


Initialize Print You perform the following tasks in this state.

uti ts
• Set the Printing LED to True.
• Transition to the Print state.

rib en
Print You perform the following tasks in this state.
• Simulate the print job using a variable wait time.

on
• Set the Printing LED to False.

ist um
• Transition to the Wait state.

Implementation
Note To reinforce the development skills you have learned so far, you are given limited
instructions to create the application.
r D str
Create a New VI From a Template
1. Open Print Console.lvproj in the <Exercises>\
LabVIEW Core 2\Print Console directory.
t fo l In

2. Create a new VI using the Producer/Consumer Design Pattern (Events)


design pattern.

❑ Select File»New to open the New dialog box.


No na

❑ Select From Template»Frameworks»Design Patterns»


Producer/Consumer Design Pattern (Events) and click OK.

3. Select File»VI Properties»Documentation. In the VI description


section, replace the template documentation with a concise description
tio

of your application.

4. Create a meaningful icon for the VI.

5. Save the VI as Print Console.vi in the <Exercises>\


Na

LabVIEW Core 2\Print Console directory. Confirm that the new


VI is added to the Print Console.lvproj project.

6. Save the Print Console.lvproj project.

LabVIEW Core 2 Exercises 3-6 ni.com


Lesson 3 Event Programming

Create the Front Panel


Create the front panel as shown in Figure 3-2 using the Queued Print
Jobs.ctl and the Print LEDs.ctl available in the Print
Console.lvproj project.

uti ts
1

rib en
on
ist um
r D str 1 Already created in Print Console.lvproj
Figure 3-2. Print Console Front Panel
t fo l In
Producer Loop
Complete the block diagram by first modifying the producer loop and then
modifying the consumer loop.

The producer loop responds to front panel events. Each time the user clicks
the Enqueue Element button, a print job is added to the queue. The producer
No na

loop is also responsible for updating the Queued Print Jobs bar with the
number of elements in the queue.
tio
Na

© National Instruments Corporation 3-7 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

Figure 3-3 and Figure 3-4 are examples of the completed producer loop.

uti ts
rib en
on
ist um
r D str Figure 3-3. Producer Loop—Enqueue Element Case

1. In the Enqueue Element case, replace the element string with print
job in the Enqueue Element function.
t fo l In
2. Add a Timeout case to the Event structure. The Timeout case updates the
Queued Print Jobs bar by reading the number of elements in the queue.

❑ Select <Application> in the Event Sources section and select


Timeout in the Events section.
No na

Note If the Event Data Node label is invalid (black text), right-click the label and select
a valid one.

Note Because the Timeout case is an application event, the Event Selector label at the
tio

top of the Timeout case differs from other events associated objects. The label name only
specifies the event and does not include the associated object.
Na

LabVIEW Core 2 Exercises 3-8 ni.com


Lesson 3 Event Programming

uti ts
rib en
on
ist um
Figure 3-4. Producer Loop—Timeout Event Case

❑ Add a Get Queue Status function to read the number of elements in


r D str the queue.

❑ Set the Event structure to time out every 100 ms by wiring a constant
value of 100 to the Timeout terminal.
t fo l In
Note You do not need to make any changes to the Stop case as it already exists in the
template.

Consumer Loop
The consumer loop simulates the print process and updates the LEDs.
No na

Implement the print process using a state machine. The Wait state receives
print jobs. When a print job is received, the state machine initiates a series
of steps to simulate the print process. The Print LEDs update after each
state. Therefore, the Initializing LED turns on after the Initialize Setup state
tio

and turns off after the Setup state. Similarly, the Printing LED turns on after
the Initialize Print state and turns off after the Print state.
Na

© National Instruments Corporation 3-9 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

Figures 3-5 through 3-9 are examples of the completed consumer loop.

1. Create a state machine in the consumer loop by starting with the Wait
state. The Wait state receives print jobs using the Dequeue Element

uti ts
function. If the Dequeue Element function receives a queue element
within the specified 100 ms timeout the state machine transitions to the
Initialize Setup state. If the Dequeue Element function times out, the
state machine stays in the Wait state.

rib en
on
ist um
1
r D str
1 Already created in Print Console.lvproj
t fo l In
Figure 3-5. Consumer Loop—Wait Case

❑ The print processing states type definition enum is created for you.
Select and drag the Print Processing States.ctl from the Project
Explorer window onto the block diagram.
No na

❑ Wire the Print Processing States.ctl to the Case selector to


associate the Case structure with the enum values.

❑ Move the Dequeue Element function into the Case structure.


tio

❑ Use the timed out? output of the Dequeue Element function to


determine if the next state is the Wait state or the Initialize Setup
state.
Na

❑ Add a Bundle by Name function to set the Boolean state of the


Waiting LED.

❑ Drag the Print LEDs.ctl from the Project Explorer window onto the
block diagram to create a Print LEDs cluster constant on the block
diagram.

LabVIEW Core 2 Exercises 3-10 ni.com


Lesson 3 Event Programming

2. Refer to Figure 3-6 to create the Initialize Setup case.

uti ts
rib en
on
ist um
Figure 3-6. Consumer Loop—Initialize Setup Case

r D str ❑ To create cases associated with each of the enum values, right-click
the edge of the Case structure and select Add Case for Every
Value.

Tip Alternatively, you can also create new cases by duplicating existing cases.
To duplicate a case, right-click the edge of the Case structure and select Duplicate Case.
t fo l In
Be careful when duplicating cases that include front panel terminals as this will result in
duplicated front panel objects.

❑ Right-click on the error tunnel and select Use Default if Unwired.

3. Refer to Figure 3-7 to create the Setup state.


No na
tio
Na

Figure 3-7. Consumer Loop—Setup Case

❑ Simulate the initialization duration with a 300 ms wait.

© National Instruments Corporation 3-11 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

4. Refer to Figure 3-8 to create the Initialize Print state.

uti ts
rib en
on
ist um
Figure 3-8. Consumer Loop—Initialize Print Case

r D str 5. Refer to Figure 3-9 to create the Print state.


t fo l In
No na

Figure 3-9. Consumer Loop—Print Case


tio

❑ To simulate a varying print duration, generate a random wait time


between 300 ms and 1500 ms. Use the Random Number in Range
VI found in your Print Console.lvproj to set a random wait
duration for a print job.
Na

6. Save the VI and save the Print Console.lvproj project.

LabVIEW Core 2 Exercises 3-12 ni.com


Lesson 3 Event Programming

Test
1. Run the VI to confirm that it behaves correctly. Each time you click the
Queue Event button, a new print job is submitted to the print queue. If
you submit several print jobs in succession, you will see a backlog of

uti ts
print jobs in the Queued Print Jobs bar.

❑ Notice that after you stop queueing the print jobs, the print process

rib en
continues to execute.

❑ Notice that the consumer loop stops only when there is an error. This

on
occurs when the producer loop stops and the Release Queue function
destroys the queue reference. Without a valid queue reference, the

ist um
Dequeue Element function in the consumer loop returns error code
1122 with an explanation of Refnum became invalid while
node waited for it or an error code 1 with an explanation of
An input parameter is invalid (if there are elements left in
r D str the queue when you press stop).

Stopping a consumer loop on error is relatively easy to implement


but is not recommended when creating professional applications that
are scalable and maintainable. A better approach is to shut down
gracefully and report all errors to the user.
t fo l In
2. Close the VIs and project. Save any changes.

End of Exercise 3-2


No na
tio
Na

© National Instruments Corporation 3-13 LabVIEW Core 2 Exercises


Lesson 3 Event Programming

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 3-14 ni.com


Error Handling
4

uti ts
Exercise 4-1 Updating the Print Console With Error Handling

rib en
Goal

on
Update a VI to report errors and include a shutdown state.

ist um
Scenario
You begin with a Print Console VI that simulates the control of print job
submissions and monitors the status of the print jobs being processed. Each
time you click the Queue Event button, you send a print job to the printer.
r D str You monitor the number of print jobs in the queue using a vertical bar. You
use LEDs and a numeric indicator to monitor the process of the print jobs.

The Print Console VI does not report errors. You must update the VI to
report potential errors and warnings.
t fo l In
You must also complete a shutdown procedure after the last print job.

Design
To implement error reporting, you must do the following.

❑ Use shift registers to monitor and track errors and warnings for all loop
No na

iterations.

❑ Use the Merge Errors function to obtain error information from both the
producer and consumer loops.
tio

❑ Use the Simple Error Handler VI to display both errors and warnings.

❑ Use an error handling VI that causes the state machine to execute the
shutdown case when an error occurs or when the producer loop sends a
Na

shutdown message.

© National Instruments Corporation 4-1 LabVIEW Core 2 Exercises


Lesson 4 Error Handling

Implementation
1. Open Print Console with Error Handling.lvproj in the
<Exercises>\LabVIEW Core 2\Error Handling directory.

uti ts
rib en
on
ist um
r D str
Figure 4-1. Front Panel of Print Console
t fo l In
2. Open and run the Print Console VI. The front panel of this VI is shown
in Figure 4-1.

❑ Each time you click the Queue Event button, you add a print job to
the queue. The Queued Print Jobs bar displays the backlog of print
jobs.
No na

❑ When there are no print jobs in the queue, the Waiting LED is turned
on. When each print job is processed the Job Number indicator is
updated to show the number of print jobs that have been processed.
tio

The Initializing LED is turned on during print initialization and the


Printing LED is turned on during the print operation.

❑ Click the Stop button.


Na

3. Examine the block diagram.

❑ Notice that none of the errors are reported to the user.

❑ Notice that the consumer loop stops only when there is an error. This
occurs when the producer loop stops and the Release Queue function
destroys the queue reference. Without a valid queue reference, the
Dequeue Element function in the consumer loop returns error code
1122 with an explanation of Refnum became invalid while
node waited for it.

LabVIEW Core 2 Exercises 4-2 ni.com


Lesson 4 Error Handling

Error Handling in Consumer Loop


1. Modify the block diagram as shown in Figure 4-2 to report errors.

uti ts
rib en
on
ist um
r D str
t fo l In
No na

Figure 4-2. Block Diagram with Error Handling in Consumer Loop

❑ Wire the error cluster of the Obtain Queue function to the consumer
While Loop.
tio

❑ Replace the error tunnel on the While Loop with a shift register.

❑ Wire the error cluster from the left shift register to the error in input
of the Dequeue Element function.
Na

❑ Wire the right-side error tunnel to the right shift register.

2. In the Initialize Setup case, wire the left-side error cluster tunnel to the
error in terminal of the Scan from String function.

3. For all the remaining cases, wire the left-side error cluster tunnel to the
right-side error cluster tunnel.

© National Instruments Corporation 4-3 LabVIEW Core 2 Exercises


Lesson 4 Error Handling

Merge and Report Errors


1. Add a Merge Errors function.

2. Add a Simple Error Handler VI.

uti ts
❑ Right-click on the type of dialog terminal of the Simple Error
Handler VI and select Create»Constant.

rib en
❑ Select OK Message + warnings.

on
Note By default, the Simple Error Handler VI only displays a dialog when an error
occurs. To report both warnings and errors, change the dialog selection to OK Message +

ist um
warnings.

3. Complete wiring the Merge Errors function and the Simple Error
Handler VI as shown in Figure 4-3.
r D str
t fo l In
No na
tio
Na

Figure 4-3. Block Diagram with Merge Errors Function and Simple Error Handler VI

LabVIEW Core 2 Exercises 4-4 ni.com


Lesson 4 Error Handling

4. Run the VI.

❑ Notice that the VI does not stop when you click the Stop button.
You must stop the VI using the Abort button.

uti ts
5. Examine the block diagram.

❑ Notice that the Merge Errors function cannot execute until both the

rib en
producer and consumer loops terminate. Therefore, the Release
Queue function cannot destroy the queue reference that the

on
consumer loop relies on to stop the loop. Moving the Release Queue
function before the Merge Errors function will cause the consumer

ist um
loop to stop. However, relying on an error to stop the loop will cause
the Simple Error Handler VI to report an error every time the VI
runs. You will fix this when you modify the Shutdown state in the
consumer loop.

Add an Error Handler VI


r D str 1. Modify the diagram as shown in Figure 4-4 so that the consumer loop
executes the Shutdown case when the producer loop stops or when there
is an error in the consumer loop.
t fo l In
No na
tio
Na

Figure 4-4. Block Diagram with Printer Error Handler VI

© National Instruments Corporation 4-5 LabVIEW Core 2 Exercises


Lesson 4 Error Handling

❑ Modify the producer loop to include a shutdown element at the front


of the queue when the user clicks on the Stop button.

– In the Stop event case, add an Enqueue Element At Opposite

uti ts
End function.

– Right-click the element input of the Enqueue Element At


Opposite End function and select Create»Constant from the

rib en
shortcut menu.

on
– Type Shutdown in the string constant.

ist um
Note The text in this string constant is case sensitive.

– Wire the Stop event case as shown in Figure 4-4.

❑ Modify the consumer loop to stop after executing the Shutdown


case.
r D str – Delete the error wire from the right-side error tunnel to the While
Loop conditional terminal.

– Add a True constant to the Shutdown case diagram.


t fo l In

– Wire the True Constant to the While Loop conditional terminal.

– Right-click on the Boolean tunnel and select Use Default if


Unwired.
No na

❑ Modify the consumer loop to execute the Shutdown case when it


receives the Shutdown element in the queue.

– Drag the Printer Error Handler VI from the subvis folder of


tio

the Print Console with Error Handling LabVIEW project and


place it in the consumer loop.

– Wire the consumer loop as shown in Figure 4-4.


Na

2. Double-click the Printer Error Handler VI to open the VI.

3. Examine the block diagram of the Printer Error Handler VI.

❑ Notice that the Next State is the same as the State In, except when
the error in cluster contains an error or the Queue Data value is equal
to Shutdown. If there is an error or a Shutdown match, the next state
is Shutdown.

LabVIEW Core 2 Exercises 4-6 ni.com


Lesson 4 Error Handling

4. Close the Printer Error Handler VI.

5. Switch to the front panel of the Print Console VI.

uti ts
6. Save and run the Print Console VI.

❑ Notice that the VI stops when you click the Stop button and no error
is reported.

rib en
❑ Although the VI appears to work as you expect, you should force

on
errors and warnings to test your error handling.

ist um
Test (Optional)
Time permitting, try inserting errors and warnings in your code and running
the VI to test the error handling. You can force errors by breaking one of the
error wires and replacing it with an Error Code Constant that has the status
r D str and code values set for an error or warning.

Do not save your VIs with forced errors.

End of Exercise 4-1


t fo l In
No na
tio
Na

© National Instruments Corporation 4-7 LabVIEW Core 2 Exercises


Lesson 4 Error Handling

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 4-8 ni.com


Controlling the User Interface
5

uti ts
Exercise 5-1 Display Temperature and Limits

rib en
Goal

on
Use Property Nodes to change the properties of front panel objects
programmatically.

ist um
Scenario
Complete a VI that records temperature to a waveform chart. During
execution, the VI performs the following tasks:

Set the Δx value of the chart to the user-defined value.


r D str •

• Clear the waveform chart so it initially contains no data.

• Change the color of a plot if the data exceeds a certain value.


t fo l In
• Blink an alarm indicator if the data exceeds a certain value.

Design
Add the following Property Nodes to an existing VI:
No na

Type Name Property


Waveform Chart Temperature XScale.Multiplier
Waveform Chart Temperature History
tio

Waveform Chart Temperature Active Plot 0»Plot.Color


Boolean Indicator (LED) Over Limit Blinking
Na

© National Instruments Corporation 5-1 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

Implementation
1. Open Temperature Limit.vi located in the <Exercises>\
LabVIEW Core 2\Temperature Limit directory. The front panel is
already created for you.

uti ts
rib en
on
ist um
r D str Figure 5-1. Temperature Limit Front Panel

2. Open the block diagram of the VI. A portion has been created for you.
Figure 5-2 shows an example of the final block diagram.
t fo l In
No na
tio
Na

Figure 5-2. Temperature Limit Block Diagram

3. Modify the VI so that it sets the Δx value of the chart to the Δt (ms) value
input by the user.

❑ Right-click the Temperature indicator and select Create»


Property Node»X Scale»Offset and Multiplier»Multiplier
from the shortcut menu to create a Property Node.

LabVIEW Core 2 Exercises 5-2 ni.com


Lesson 5 Controlling the User Interface

❑ Place the new Property Node to the left of the While Loop.

❑ Right-click the Temperature Property Node and select Change All


To Write from the shortcut menu.

uti ts
❑ Divide delta t (ms) by 1000 to determine the X-Scale Multiplier,
as shown in Figure 5-2.

rib en
4. Modify the VI to clear old data from the Temperature chart before
starting the temperature acquisition.

on
Tip To clear a waveform chart from the block diagram, send an empty array of data to

ist um
the History Data property.

❑ Resize the Property Node to two terminals.

r D str ❑ Select the History Data property in the second terminal.

❑ Verify that the History Data property is set to Write.

❑ Right-click the History Data property and select Create»Constant


from the shortcut menu.
t fo l In
❑ Wire the Property Node as shown in Figure 5-2.

5. Modify the VI so that when the VI acquires data, it turns the Data trace
red and the Over Limit LED blinks when the temperature exceeds the
limit value.
No na

❑ Right-click the Temperature indicator and select Create»


Property Node»Active Plot from the shortcut menu to create
another Property Node.

❑ Place the new Property Node in the True case of the Case structure.
tio

❑ Resize the Property Node to show two terminals.

❑ Click the second terminal and select Plot»Plot Color.


Na

❑ Right-click the Property Node and select Change All To Write


from the shortcut menu.

❑ Wire a numeric constant with a value of 0 to the Active Plot


property to select the first plot on the Temperature chart.

❑ Wire the Red color box constant to the Plot Color property to set the
plot color to red when the data rises above the High Limit.

© National Instruments Corporation 5-3 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

❑ Create a copy of the Property Node by pressing <Ctrl> while


selecting and dragging the Property Node.

Tip Do not use the clipboard (Edit»Copy or <Ctrl-C>) to create a copy of the Property

uti ts
Node. This creates a different type of Property Node that you learn about in the Control
References section of Lesson 5, Controlling the User Interface, in the LabVIEW Core 2
Course Manual.

rib en
❑ Place the copy of the Property Node in the False case of the Case

on
structure, as shown in Figure 5-3.

❑ Wire a numeric constant with a value of 0 to the Active Plot

ist um
property to select the first plot on the Temperature chart.

❑ Wire the Green color box constant to the Plot Color property to set
the plot color to green when the data is below the High Limit.
r D str
t fo l In
Figure 5-3. False Case in the Temperature Limit VI

6. Modify the VI so that when the VI acquires data, the Over Limit LED
blinks when the temperature exceeds the limit value.

❑ Right-click the Over Limit indicator and select Create»Property


No na

Node»Blinking from the shortcut menu.

❑ Place the new Property Node inside the While Loop.

❑ Right-click the Property Node and select Change All To Write


tio

from the shortcut menu.

❑ Wire the Property Node as shown in Figure 5-2.

7. Save the VI.


Na

Test
1. Run the VI to confirm that it behaves correctly.

2. Close the VI.

End of Exercise 5-1

LabVIEW Core 2 Exercises 5-4 ni.com


Lesson 5 Controlling the User Interface

Exercise 5-2 Customizing the VI Window


Goal

uti ts
Affect the attributes of a VI by using Property Nodes and Invoke Nodes.

Scenario

rib en
You can set the appearance properties of a VI statically by using the VI
properties page. However, robust user interfaces often must modify the

on
appearance of a front panel while the program runs.

You must create a VI that can perform the following tasks on demand:

ist um
• Show or hide its title bar
• Show or hide its menu bar
• Become transparent so that objects behind the VI can be seen
r D str • Move to the center of the screen

Design
Inputs and Outputs
t fo l In
Type Name Default Value
Push Button Show Menu Bar? True
Push Button Show Title Bar? True
No na

Push Button Make VI Transparent? True


OK Button Center False
Stop Button Stop False
tio

TipUse the Push Button controls because their default mechanical action is Switch
When Pressed. Use the OK button because its default action is Latch When Released.
Na

© National Instruments Corporation 5-5 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

Properties
Use the following properties and methods on the VI class:

• ShowMenuBar—When this property is true, the menu bar of the VI is

uti ts
visible.

rib en
Figure 5-4. VI Menu Bar

on
• TitleBarVisible—When this property is true, the title bar of the VI is
visible.

ist um
Figure 5-5. VI Title Bar

• RunVITransparently—When this property is true, the transparency of


r D str the VI can vary. The default value of this property is false, so you must
write a true value to this property before varying the transparency of
the VI.

• Transparency—This property varies the transparency of the VI. The


t fo l In
property accepts any value between 0 and 100. A value of 0 makes the
VI completely opaque (normal behavior), and a value of 100 makes the
VI completely transparent (invisible). For this exercise, you set the value
to 50 when the Make VI Transparent? button is clicked.
No na

Methods
Unlike properties, a method has an effect every time you call it. Therefore,
you should call methods only when you want to perform an action. For
example, if you call the Fp.Center method during each iteration of a loop,
tio

the VI is continually centered, thereby preventing the user from moving it.
You can use a Case structure to control calling the method in a given
iteration of a loop. Use the following method on the VI class:

• Center—Each time this method is called, the VI moves to the center of


Na

the screen.

Tip Use the Context Help window to view descriptions of each property and method.

VI Structure
The VI polls the front panel controls every 50 ms and sets the value of the
properties based on the current value of the controls. A Case structure
controls the execution of the Center method.

LabVIEW Core 2 Exercises 5-6 ni.com


Lesson 5 Controlling the User Interface

Implementation
1. Open the Customize VI Window VI from <Exercises>\LabVIEW
Core 2\Customize VI Window directory. The front panel of this VI
is shown in Figure 5-6.

uti ts
rib en
on
ist um
Figure 5-6. Customize VI Window VI Front Panel

Complete the following steps to create the block diagram as shown in


Figure 5-7.
r D str
t fo l In
No na

Figure 5-7. Customize VI Window Block Diagram


tio
Na

Figure 5-8. False Case for Center Method

2. Add a While Loop around the terminals.

3. Create a reference to the VI.

❑ Add a VI Server Reference to the block diagram to the left of the


While Loop.

❑ Set the VI Server Reference to This VI if it is not already.

© National Instruments Corporation 5-7 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

Note Using the This VI reference you can access all the methods and properties of the
current VI without having to explicitly open and close a reference.

4. Create a Property Node with the RunTransparently property.

uti ts
❑ Right-click the This VI reference and select Create»Property for
VI Class»Front Panel Window»Run VI Transparently from the
shortcut menu to create a Property Node.

rib en
❑ Move the Property Node to the right of the This VI reference,

on
outside of the While Loop.

❑ Right-click the Property Node and select Change All to Write from

ist um
the shortcut menu.

❑ Right-click the FP:RunTransparently property and select Create»


Constant from the shortcut menu.

❑ Change the value of the constant to True.


r D str 5. Create a Property Node with the ShowMenuBar, TitleBarVis, and
Transparency properties.

❑ Right-click the This VI reference and select Create»Property for


t fo l In
VI Class»Front Panel Window»Show Menu Bar from the
shortcut menu to create another Property Node.

❑ Expand the Property Node to show three elements.

❑ Click the second item in the Property Node and select Front Panel
Window»Title Bar Visible.
No na

❑ Click the third item in the Property Node and select Front Panel
Window»Transparency.

❑ Right-click the Property Node and select Change All to Write from
tio

the shortcut menu.

❑ Move the Property Node inside the While Loop.

❑ Add a Select function inside the While Loop.


Na

❑ Add two numeric constants with values 0 and 50 to the left of the
Select function.

❑ Wire the 0 numeric constant to the f input of the Select function.

❑ Wire the 50 numeric constant to the t input of the Select function.

❑ Wire the Boolean controls to the appropriate properties, as shown in


Figure 5-7.

LabVIEW Core 2 Exercises 5-8 ni.com


Lesson 5 Controlling the User Interface

6. Create an Invoke Node with the Center method.

❑ Right-click the This VI reference and select Create»Method for VI


Class»Front Panel»Center from the shortcut menu to create an

uti ts
Invoke Node.

7. Add a Case structure around the FP.Center Invoke Node.

rib en
8. Add a 50 ms wait to the loop.

on
❑ Add a Wait (ms) function to the While Loop.

❑ Right-click the milliseconds to wait input and select Create»

ist um
Constant from the shortcut menu.

❑ Enter 50 in the constant.

r D str 9. Set the While Loop to stop when the user clicks the Stop button or when
an error occurs.

❑ Add an Unbundle By Name function to the While Loop.

❑ Add an Or function to the While Loop.


t fo l In
10. Wire the diagram as shown in Figure 5-7 and Figure 5-8. Make sure to
replace the error cluster tunnel with a shift register.

11. Display any errors that may occur to the user.

❑ Add a Simple Error Handler VI to the right of the While Loop.


No na

❑ Wire the Simple Error Handler VI to the error cluster output shift
register from the While Loop.
tio

12. Save the VI.

Test
1. Switch to the front panel window of the VI.
Na

2. Run the VI.

3. Try each of the buttons and observe the results.

End of Exercise 5-2

© National Instruments Corporation 5-9 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

Exercise 5-3 Set Plot Names


Goal

uti ts
Use control references to create a subVI that modifies graph or chart
properties.

Scenario

rib en
Create a subVI that allows you to assign a list of plot names to a chart or

on
graph. The subVI should resize the plot legend as necessary to display all of
the plots.

ist um
Design
Inputs and Outputs

r D str Type Name Default Value


Control Reference to a GraphChart Graph N/A
object Reference

1-D Array of Strings Control Plot Names Empty Array


t fo l In
Error Cluster Control Error In No Error
Error Cluster Indicator Error Out No Error

Control References
No na

Both the Waveform Chart and the Waveform Graph are objects in the
GraphChart class. To write a subVI that can accept references to both
charts and graphs you must use a weakly typed control reference of the
GraphChart class. However, this class also contains other charts and graphs,
such as the XY Graph. This subVI generates an error if the user wires any
tio

type of graph other than a Waveform Chart or a Waveform Graph. You can
determine if the user has wired the correct type by using the ClassName
property to control a Case structure. If the correct class is wired, use the
To More Specific Class function to get a reference to the appropriate
Na

subclass. After you have a reference to a WaveformChart or a


WaveformGraph you can set the properties to modify plot names.

LabVIEW Core 2 Exercises 5-10 ni.com


Lesson 5 Controlling the User Interface

Properties
Graphs and charts do not have a single property to set all of the plot names.
Instead you must use a combination of properties to set each plot name.
In this exercise, use the following properties:

uti ts
• ClassName—This property returns a string indicating the control class
of the object that the property is called on. You can access this property

rib en
for any control.

• LegAutosize—This property controls whether the Graph Legend

on
automatically resizes to accommodate the plot names within it. Before
modifying the plot names you should set this property to False.

ist um
Otherwise, the legend may resize in such a way that it is separated from
the graph or covers the graph or other controls.

• LegNumRows—This property controls the number of rows visible on


the Graph Legend. When adding your legend to the front panel,
remember to leave room for the legend to expand when you set this
r D str property. The legend expands downwards.

• ActPlot—Properties affecting a plot act on one plot at a time. This


property controls the active plot. Any time a plot property is set or read
t fo l In
it applies to the active plot. The plots are numbered sequentially as they
are created, starting with zero.

• Plot.Name—This property sets the name of the active plot.

Implementation
No na

1. Open a blank VI.

2. Save the VI as Set Plot Names.vi in the <Exercises>\


LabVIEW Core 2\Set Plot Names directory.
tio

3. Create the front panel window.

❑ Add a control refnum to the front panel window.

❑ Name the control refnum Graph Reference.


Na

❑ Right-click Graph Reference and choose Select VI Server Class»


Generic»GObject»Control»GraphChart»GraphChart from the
shortcut menu.

❑ Add an array to the front panel window.

❑ Name the array Plot Names.

© National Instruments Corporation 5-11 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

❑ Place a string control to the empty Plot Names array.

❑ Add an error in cluster.

uti ts
❑ Add an error out cluster.

❑ Arrange the controls as shown in Figure 5-9.

rib en
on
ist um
r D str
Figure 5-9. Set Plot Names Front Panel
t fo l In
Tip Because the front panel of this subVI is not displayed to the user, you do not have
to put as much effort into making it visually appealing. You should always organize your
front panels logically. However, you should not spend too much time on panels that the
user does not see.

4. Switch to the block diagram.


No na

5. Identify the class of the control reference and generate an error if it has
an invalid class.

❑ Use the Class Browser to find and drop the ClassName Property
tio

Node.

– Open the Class Browser dialog by selecting View»Class


Browser.
Na

– Select VI Server for the Object Library.

– Select Generic»Generic for the Class.

– Click the Search button to open the Class Browser Search


dialog box.

LabVIEW Core 2 Exercises 5-12 ni.com


Lesson 5 Controlling the User Interface

uti ts
rib en
on
ist um
r D str
t fo l In

Figure 5-10. Class Browser Search Dialog

– Type Class Name in the search field. Class Name should be the
only item in the Search results.
No na

– Select Generic class in the Search Scope section.


tio
Na

© National Instruments Corporation 5-13 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

– Click OK to return to the Class Browser dialog box. Class Name


is highlighted in the Properties and Methods tree.

uti ts
rib en
on
ist um
r D str
t fo l In

Figure 5-11. Class Browser Dialog Box

– Click the Create button and then move your mouse to an empty
area on the block diagram. Click on the block diagram to drop
the ClassName Property Node.
No na

– Close the Class Browser dialog box.


tio
Na

LabVIEW Core 2 Exercises 5-14 ni.com


Lesson 5 Controlling the User Interface

❑ Wire Graph Reference to the reference input of the Property Node.

uti ts
rib en
on
ist um
Figure 5-12. Default Case

❑ Add a Case structure to the block diagram, as shown in


Figure 5-12.
r D str
❑ Wire the ClassName output of the Property Node to the case
selector of the Case structure.

❑ Switch to the False case of the Case structure.


t fo l In

❑ Delete the False text in the case name so that the case name
resembles Figure 5-12.

The Default case of the Case structure is selected if the class of the
control reference does not match one of the other cases. In this case,
No na

if the default case executes, then the control reference passed to this
subVI is not a WaveformGraph or a WaveformChart. Remember for
a Case structure, the case selector label is case sensitive.
tio

❑ Add an Error Cluster From Error Code VI to the Case structure.

❑ Right-click the error code input of the Error Cluster From Error
Code VI and select Create»Constant from the shortcut menu.
Na

❑ Enter 1057 in the constant.

Error code 1057 corresponds to the message Object cannot be


typecast to the specified type. This is the appropriate
error to generate if the caller of the subVI passes a control reference
of the wrong class.

❑ Wire the block diagram as shown in Figure 5-12.

© National Instruments Corporation 5-15 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

6. Handle the WaveformGraph references.

uti ts
rib en
on
ist um
Figure 5-13. WaveformGraph Case

r D str ❑ Switch to the True case of the Case structure.

❑ Change the True text in the case name to WaveformGraph so that


the case name resembles Figure 5-13.

Caution The text entered the case selector label must exactly match the input string,
t fo l In
including spaces and case. For this example, enter WaveformGraph.

❑ Add a To More Specific Class function to the Case structure.

❑ Right-click the target class input of the To More Specific Class


function and select Create»Constant from the shortcut menu.
No na

❑ Click the constant you created in the previous step and select the
Generic»GObject»Control»GraphChart»WaveformGraph»
WaveformGraph class.
tio

❑ Use the Class Browser window to find and drop the Legend:
Autosize Property Node inside the Case structure.

– Object library: VI Server


Na

– Class: Generic»Generic

– Select All classes in the VI Server library in the Search Scope


section

– Search string: Legend: Autosize

– Select the Legend: Autosize entry with class type of


WaveformGraph

LabVIEW Core 2 Exercises 5-16 ni.com


Lesson 5 Controlling the User Interface

❑ Wire the specific class reference output of the To More Specific


Class function to the reference input of the Property Node.

❑ Expand the Property Node to display two properties.

uti ts
❑ Click the second property in the Property Node and select Legend»
Number of Rows.

rib en
❑ Right-click the Property Node and select Change All To Write
from the shortcut menu.

on
❑ Right-click the LegAutosize property and select Create»Constant

ist um
from the shortcut menu. Verify that the value of the constant is
False.

❑ Add an Array Size function to the Case structure.

r D str ❑ Add a For Loop to the Case structure.

7. Add a Property Node to the For Loop.

❑ Use the Class Browser window to find and drop the Active Plot
Property Node inside the For Loop.
t fo l In
– Object library: VI Server

– Class: Generic»Generic

– Select All classes in the VI Server library in the Search Scope


section
No na

– Search string: Active Plot

– Select the Active Plot entry with class type of


tio

WaveformGraph

❑ Wire the reference out output of the second Property Node through
the border of the For Loop to the reference input of the third
Property Node.
Na

❑ Expand the third Property Node to display two properties.

❑ Click the second property in the Property Node and select Plot»
Plot Name from the list.

© National Instruments Corporation 5-17 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

❑ Right-click the third Property Node and select Change All To


Write from the shortcut menu.

❑ Wire the block diagram as shown in Figure 5-13. Use shift registers

uti ts
when wiring the error wires through the For Loop. Confirm that auto
indexing is enabled on the Plot Names tunnel on the For Loop.

8. Handle WaveformChart references.

rib en
on
ist um
r D str
Figure 5-14. WaveformChart Case
t fo l In
❑ Right-click the border of the Case structure and select Duplicate
Case from the shortcut menu.

❑ Enter WaveformChart in the case name.


No na

Caution The text entered in the case selector label must exactly match the input string,
including spaces and case. For this example, enter WaveformChart.

❑ Click the WaveformGraph reference constant and select Generic»


tio

GObject»Control»GraphChart»WaveformChart.

Note When you change the class of a control reference, all Property Nodes and Invoke
Nodes using the reference become invalid because the properties refer to a class that does
not match the reference. Notice that all the property names change to black when you
Na

change the class reference and that the run arrow is broken. Leave the broken wires alone,
because the wires reconnect as you reselect the properties.

❑ Click each of the four properties and select the correct property
again. The four properties are Legend»Autosize, Legend»
Number of Rows, Active Plot, and Plot»Plot Name. The resulting
block diagram appears as shown in Figure 5-14.

LabVIEW Core 2 Exercises 5-18 ni.com


Lesson 5 Controlling the User Interface

9. Create the icon and connector pane for the subVI. Figure 5-15 shows an
example icon and connector pane.

uti ts
rib en
Connections Connector Pane

on
Figure 5-15. Connector Pane Connections for Set Plot Names VI

❑ Switch to the front panel of the VI.

ist um
❑ Right-click the connector pane and select Patterns from the
shortcut menu to choose a pattern.

r D str ❑ Wire the connector pane.

❑ Right-click the icon and select Edit Icon from the shortcut menu.

❑ Use the tools in the Icon Editor to create an icon.

❑ Close the Icon Editor when you are finished.


t fo l In

10. Save the VI.

Test
1. Test the VI using a Waveform Graph.
No na
tio
Na

Figure 5-16. Set Plot Names Test

❑ Create a blank VI.

❑ Add a Waveform Graph to the front panel window.

© National Instruments Corporation 5-19 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

❑ Open the block diagram.

❑ Right-click the Waveform Graph indicator and select Create»


Reference from the shortcut menu.

uti ts
❑ Add the Set Plot Names VI to the block diagram of the new VI.

Tip If the Set Plot Names VI is open, you can drag the icon from upper right corner of

rib en
its front panel to the block diagram of the new VI.

on
❑ Wire the WaveformGraph reference to the Graph Reference input
of the Set Plot Names VI.

ist um
❑ Right-click the Plot Names input of the Set Plot Names VI and
select Create»Control from the shortcut menu. The block diagram
should resemble Figure 5-16.

❑ Switch to the front panel window of the new VI.


r D str ❑ Type One and Two as items in the Plot Names array.

❑ Move the Plot Legend to the right of the graph so that you can
expand the legend.
t fo l In

❑ Run the VI. One and Two appear in the legend.

2. Test the VI using a Waveform Chart.

❑ Right-click the waveform graph and select Replace»Graph»


No na

Waveform Chart from the shortcut menu.

❑ Type Three as another item in the Plot Names array.

❑ Run the VI. Three appears in the legend of the chart.


tio

3. Test the VI with an XY Graph.

❑ Right-click the waveform chart and select Replace»Graph»


XY Graph from the shortcut menu.
Na

❑ Add Four as another item in the Plot Names array.

❑ Run the VI. A typecasting error occurs.

LabVIEW Core 2 Exercises 5-20 ni.com


Lesson 5 Controlling the User Interface

Note The error is displayed because the control reference of the XY Graph is not
supported in the subVI.

4. Close the VI. You do not need to save the VI used for testing the Set Plot

uti ts
Names VI.

End of Exercise 5-3

rib en
on
ist um
r D str
t fo l In
No na
tio
Na

© National Instruments Corporation 5-21 LabVIEW Core 2 Exercises


Lesson 5 Controlling the User Interface

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 5-22 ni.com


File I/O Techniques
6

uti ts
Exercise 6-1 Bitmap File Writer VI

rib en
Goal

on
Use Binary File I/O to write to a file using a specified format.

ist um
Scenario
Write a file storage routine to store image files for an existing
LabVIEW-based Drawing Pad. The drawing pad VI returns a drawing as a
2D array of red, green, and blue (RGB) values. Save the data as a 24-bit
r D str bitmap file.

Design
You can use binary file I/O to write or read data in any file format, assuming
that you have a specification that tells you the file layout for that format. The
following section describes the format for a 24-bit Windows bitmap file.
t fo l In

24-bit Bitmap File Layout


Bitmaps (.bmp) files are a format for storing image data. Bitmaps come in
multiple varieties, with differences such as the number of bits used to
represent a pixel and the level of image compression used. The easiest type
No na

of bitmap file to understand and create is a 24-bit uncompressed bitmap file.


Table 6-1 describes the format of a 24-bit uncompressed bitmap file.

Table 6-1. 24-Bit Bitmap File Layout


tio

Section Name Size (bytes) Notes


BITMAPFILEHEADER 14 Data is provided.
Write data to the file.
Na

BITMAPINFOHEADER 40 Data is provided.


Write data to the file.
Image Data 3 × Number of Pixels Stored in BGR order.
Image is inverted.

BITMAPFILEHEADER—Contains information about the file such as the


file type and file size. A subVI calculates the data for this segment. The
subVI returns an array of U8 numerics that you must write to the file.

© National Instruments Corporation 6-1 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

BITMAPINFOHEADER—Contains information about the image such as


the height, width, compression level, and number of bits per pixel. A subVI
calculates the data for this segment. The subVI returns an array of
U8 numerics that you must write to the file.

uti ts
Image Data—For a 24-bit image, three bytes represent each pixel in the
image. The three bytes represent the RGB values for the pixel and are stored
in reverse order, BGR. The pixel array you are given is a 2D array of

rib en
clusters. Each cluster has an RGB value in it. The rows in the Image Data
are stored from bottom to top, and the first pixel stored is the lower left

on
corner of the image.

ist um
Inputs and Outputs
The main VI for this program contains no inputs or outputs. Dialog boxes
control all user interaction. The Drawing Pad VI displays a dialog box that
allows the user to draw a picture. When the user clicks Save, the application
r D str prompts the user to enter a save location by using a File Dialog VI.

Program Flow
1. Call the Drawing Pad VI to create a picture.
t fo l In
Note The Drawing Pad VI returns the picture as a 2D array of clusters, each containing
RGB values. The 2D array has a width that is a multiple of four and is inverted in
preparation for writing to file.

2. Display a file dialog box to the user to select a location and filename and
open the selected file for writing.
No na

3. Call the BITMAPFILEHEADER VI and pass the dimensions of the


pixel array to it.

4. Write the 1D array of unsigned integers returned by the


tio

BITMAPFILEHEADER VI to the open file.

Note Disable the prepend array or string size option when you call the Write to
Binary File function, otherwise LabVIEW inserts the array size at the beginning of the
Na

data, which invalidates the file layout.

5. Call the BITMAPINFOHEADER VI and pass the dimensions of the


pixel array to it.

6. Write the 1D array of unsigned integers returned by the


BITMAPINFOHEADER VI to the open file.

LabVIEW Core 2 Exercises 6-2 ni.com


Lesson 6 File I/O Techniques

7. Process each pixel in the array by using a pair of For Loops to remove
the values from the cluster in BGR order and build them into an array.

Note Use a 3D array to store the processed pixel data, because it allows you to use For

uti ts
Loop auto-indexing and simplify the program. The number of dimensions in the array is
not important, because the File I/O functions automatically reformat the array to write to
the file.

rib en
8. Write the processed pixel array to the open file.

on
9. Close the file and handle any errors.

ist um
Implementation
1. Display the drawing pad.

❑ Open a blank VI.


r D str ❑ Save the VI as Bitmap File Writer.vi in the <Exercises>\
LabVIEW Core 2\Bitmap File Writer directory.

❑ Open the block diagram.


t fo l In
❑ Add the Drawing Pad VI, located in the <Exercises>\LabVIEW
Core 2\Bitmap File Writer directory, to the block diagram.

❑ Right-click the Drawing Pad VI and select SubVI Node Setup


from the shortcut menu.

❑ Check the Show Front Panel when called and Close afterwards if
No na

originally closed boxes.

❑ Click OK to exit the SubVI Node Setup dialog box.


tio

Note The subVI node setup lets you specify how to call a subVI. Checking the
Show Front Panel when called box instructs the VI to show its front panel, even if the
VI properties would otherwise prevent it from doing so.
Na

❑ Run the VI and observe the drawing pad. Click the Save button to
exit. Currently, the program ends when you click Save, because you
have not yet implemented the file I/O.

2. Open a new binary file.

❑ Add a File Dialog Express VI to the block diagram.

❑ Click OK to exit the Configure File Dialog dialog box. The default
values allow the user to select a single new or existing file.

© National Instruments Corporation 6-3 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

❑ Expand the File Dialog Express VI to show the selected path,


error out, error in, prompt, pattern label, and pattern (all files)
terminals by expanding the node and then clicking each terminal to
select an input or output.

uti ts
❑ Right-click the prompt input of the File Dialog Express VI and
select Create»Constant from the shortcut menu.

rib en
❑ Enter Select File to Save in the string constant.

on
❑ Right-click the pattern label input of the File Dialog Express VI
and select Create»Constant from the shortcut menu.

ist um
❑ Enter Bitmap Files in the string constant.

❑ Right-click the pattern (all files) input of the File Dialog Express VI
and select Create»Constant from the shortcut menu.

❑ Enter *.bmp in the string constant.


r D str
❑ Add an Open/Create/Replace File function to the block diagram.

❑ Right-click the operation input of the Open/Create/Replace File


t fo l In
function and select Create»Constant from the shortcut menu.

❑ Select replace or create as the value of the constant.

❑ Wire the block diagram as shown in Figure 6-1.


No na
tio
Na

Figure 6-1. Open Binary File

3. Create bitmap headers.

❑ Add the BITMAPFILEHEADER VI located in the


<Exercises>\LabVIEW Core 2\Bitmap File Writer
directory to the block diagram.

LabVIEW Core 2 Exercises 6-4 ni.com


Lesson 6 File I/O Techniques

❑ Add the BITMAPINFOHEADER VI located in the


<Exercises>\LabVIEW Core 2\Bitmap File Writer
directory to the block diagram.

❑ Add an Array Size function to the block diagram.

uti ts
❑ Add two Write to Binary File functions to the block diagram.

rib en
❑ Right-click the prepend array or string size terminal of each Write
to Binary File function and select Create»Constant from the

on
shortcut menu.

❑ Set the constant values to False.

ist um
❑ Wire the block diagram as shown in Figure 6-2.

Note You do not need to specify little-endian or big-endian for the byte order input
r D str of the Write to Binary File function because the array data type is only one byte.
t fo l In
No na
tio

Figure 6-2. Write Bitmap Headers

4. Write image data.


Na

❑ Add a For Loop to the block diagram.

❑ Add a second For Loop inside the first For Loop.

❑ Add an Unbundle by Name function to the inner For Loop.

❑ Add a Build Array function to the For Loops.

❑ Wire the Image Data array through the For Loop borders to the
Unbundle By Name function.

© National Instruments Corporation 6-5 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

❑ Expand the Unbundle by Name function so that three elements are


shown.

❑ Choose Blue, Green, and Red, in order, for the elements.

uti ts
Note The bitmap file definition specifies that pixels must be stored in blue, green, red
order. Storing the pixels in another order causes the colors in your image to be incorrect.

rib en
❑ Add a Write to Binary File function to the block diagram.

on
❑ Right-click the prepend array or string size input of the Write to
Binary File function and select Create»Constant from the shortcut

ist um
menu.

❑ Set the constant value to False.

5. Close the file and handle the errors.

❑ Add a Close File function to the block diagram.


r D str
❑ Add a Simple Error Handler VI to the block diagram.

❑ Wire the block diagram as shown in Figure 6-3.


t fo l In

6. Save the VI.


No na
tio
Na

Figure 6-3. Completed Block Diagram

LabVIEW Core 2 Exercises 6-6 ni.com


Lesson 6 File I/O Techniques

Test
1. Run the VI.

❑ Switch to the VI front panel window.

uti ts
❑ Run the VI.

❑ Draw a picture in the drawing pad.

rib en
❑ Click Save.

on
❑ Select C:\Exercises\LabVIEW Core 2\Bitmap File

ist um
Writer\My Image.bmp as the file to save.

2. Open the image in an image viewer.

❑ Open the C:\Exercises\LabVIEW Core 2\Bitmap File


r D str Writer directory in Windows Explorer.

❑ Double-click the image to open it in your default image viewer.


Verify that the image displayed is the picture you created.

3. Close the VI.


t fo l In

End of Exercise 6-1


No na
tio
Na

© National Instruments Corporation 6-7 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

Exercise 6-2 Read TDMS Files


Goal

uti ts
Log data to a TDMS file and read the same TDMS file to access information
about a specific channel.

Scenario

rib en
You are given a TDMS Logger VI that generates measurement data for any

on
number of units under test (UUTs). The UUT measurement data consists of
a time domain waveform and the power spectrum of a waveform.

ist um
Run the TDMS Logger VI that accepts UUTs identified by serial numbers.
The TDMS Logger VI retrieves the measurement data from the Generate
Data VI, and logs the UUT data and additional properties to a TDMS file.

The TDMS file contains the author, timestamp, and two channel
groups—Time Data and Power Spectrum Data. Each group contains a
r D str channel for each UUT. The serial number of the UUT names each channel
and contains the matching signal data.

Saving data to a file serves no purpose unless you also can access the data.
Create a reader VI to access data from the TDMS file you generated. The
t fo l In
reader should return either time data or power spectrum data for a particular
UUT serial number.

Note Optionally, if you have Microsoft Excel installed on your system you can use the
the TDM Excel Add-In tool to load the TDMS file into Microsoft Excel.
No na

Design
TDMS File Reference Information
• File Level Information
tio

– Time Stamp—contains the current time.

– Author—contains the test operator name, acquired through a front


panel control.
Na

– The file contains two channel groups, one for time data and one for
the power spectrum data.

• Channel Group Level Information

– Name—contains Time Data or Power Spectrum Data. This


identifies the channel group.

– Each channel group should contain a channel for each UUT.

LabVIEW Core 2 Exercises 6-8 ni.com


Lesson 6 File I/O Techniques

• Channel Level Information

– Name—contains the UUT Serial Number, which associates the


numeric data with a particular unit.

uti ts
– Signal—contains an array of floating-point numeric data.

– Several other properties, such as the signal minimum and maximum

rib en
will automatically be calculated and added to the file.

on
TDMS Reader Inputs and Outputs

ist um
Table 6-2. TDMS Reader VI Inputs and Outputs

Type Name Properties


File Path Control TDMS File Path Default Value =
r D str <Exercises>\LabVIEW Core 2\
TDMS Logger\Test Data.TDMS

String Control Serial Number —


Combo Box Data Set Item 1 = “Time Data”
Item 2 = “Power Spectrum”
t fo l In

Waveform Graph Indicator Channel Data —


String Indicator Test Operator —
Time Stamp Indicator Time of Test —
No na

Your VI should begin by opening the TDMS file and reading the author and
time stamp file properties. Then read the time data or power spectrum data
for the specified UUT and display the data on the Channel Data waveform
graph.
tio
Na

© National Instruments Corporation 6-9 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

Implementation
TDMS Logger
1. Open TDMS Logger.vi in the <Exercises>\LabVIEW Core 2\

uti ts
TDMS Logger directory. This VI is pre-built for you as shown in
Figure 6-4.

rib en
on
ist um
r D str
t fo l In
No na

Figure 6-4. TDMS Logger Front Panel


tio

2. Run the TDMS Logger VI.

❑ Verify that the default value of the TDMS File Path control is
<Exercises>\LabVIEW Core 2\TDMS Logger\
Test Data.tdms.
Na

❑ Enter your name in the Test Operator field.

❑ Enter A001, A002, and A003 in the UUT Serial Numbers control.

❑ Run and test the TDMS Logger VI. View the logged data in the
TDMS File Viewer window. The graphs on the front panel of the
TDMS Logger VI should also display a plot for each serial number
you enter.

LabVIEW Core 2 Exercises 6-10 ni.com


Lesson 6 File I/O Techniques

❑ Click Quit to close the TDMS File Viewer window.

❑ Examine the block diagram.

❑ Close the TDMS Logger VI. Do not save any changes.

uti ts
TDMS Reader VI

rib en
1. Create a blank VI.

2. Save the VI as <Exercises>\LabVIEW Core 2\TDMS Reader\

on
TDMS Reader.vi.

ist um
3. Build the VI front panel.

r D str
t fo l In
No na

Figure 6-5. TDMS Reader Front Panel

❑ Create the TDMS File Path control with a default value of


tio

<Exercises>\LabVIEW Core 2\TDMS Logger\


Test Data.tdms.

❑ Create the Serial Number string control.


Na

❑ Create the Time of Test time stamp indicator.

❑ Create the Test Operator string indicator.

❑ Create the Channel Data waveform graph.

❑ Place a combo box control on the front panel. Label the combo box
Data Set.

© National Instruments Corporation 6-11 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

❑ Right-click the Data Set control and select Edit Items from the
shortcut menu.

❑ Click Insert.

uti ts
❑ Enter Power Spectrum in the Items list.

❑ Click Insert.

rib en
❑ Enter Time Data in the Items list.

on
❑ Deselect the Allow undefined values at run time box.

ist um
❑ Click OK.

❑ Select Time Data from the drop-down menu of the Data Set
control.

❑ Right-click the Data Set control and select Data Operations»Make


r D str Current Value Default from the shortcut menu.

❑ Arrange the front panel as shown in Figure 6-5.

4. Open the TDMS file.


t fo l In

❑ Add a TDMS Open function to the block diagram.

❑ Right-click the operation input of the TDMS Open function and


select Create»Constant from the shortcut menu.
No na

❑ Select open (read-only) as the value of the constant.

Note Opening a file with the open (read-only) option increases the speed of reads in the
file. Also, it does not lock the file so that other programs can use it at the same time.
tio

❑ Wire the TDMS File Path control to the file path input of the
TDMS Open function.

5. Read the Author file property.


Na

❑ Add a TDMS Get Properties function to the block diagram.

❑ Right-click the property name input of the TDMS Get Properties


function and select Create»Constant from the shortcut menu.

❑ Enter Author in the string constant.

LabVIEW Core 2 Exercises 6-12 ni.com


Lesson 6 File I/O Techniques

❑ Wire an empty string constant to the data type input of the TDMS
Get Properties function.

❑ Wire the property value output of the TDMS Get Properties

uti ts
function to the Test Operator string indicator.

6. Read the Time Stamp file property.

rib en
❑ Add a TDMS Get Properties function to the block diagram.

on
❑ Right-click the property name input of the TDMS Get Properties
function and select Create»Constant from the shortcut menu.

ist um
❑ Enter Time Stamp in the string constant.

❑ Wire a time stamp constant to the data type input of the TDMS Get
Properties function.

❑ Wire the property value output of the TDMS Get Properties


r D str function to the Time of Test indicator.

7. Read the time data or power spectrum data for the specified UUT and
display the data on the Channel Data waveform graph.
t fo l In
❑ Add a TDMS Read function to the block diagram.

❑ Wire the Data Set control to the group name in input of the TDMS
Read function.

❑ Wire the Serial Number control to the channel name(s) in input of


No na

the TDMS Read function.

❑ Wire the data output of the TDMS Read function to the Channel
Data indicator.
tio

8. Close the file and handle errors.

❑ Add a TDMS Close function to the block diagram.


Na

© National Instruments Corporation 6-13 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

❑ Add a Simple Error Handler VI to the block diagram.

❑ Wire the block diagram as shown in Figure 6-6.

uti ts
rib en
on
ist um
r D str Figure 6-6. TDMS Reader Block Diagram

9. Save the VI.

10. Set the attributes and time stamp properties of the waveform graph.

❑ On the front panel, right-click the Channel Data graph and select
t fo l In
Ignore Attributes.

Note You must ignore the attributes of the waveform, otherwise the waveform name
attribute would overwrite the labels you set. This option is available only after you wire
a waveform to the graph.
No na

Test
1. Read and display the time domain data.

❑ On the VI front panel, ensure that the default TDMS File Path
tio

matches Table 6-2 and the Data Set is set to Time Data.

❑ Enter A001 in the Serial Number control.

Note A001 was one of the serial numbers you entered when you ran the TDMS Logger VI.
Na

❑ Run the VI. A sine wave should display in the Channel Data graph.

❑ Change the Serial Number to A002.

❑ Run the VI. A different sine wave should display.

LabVIEW Core 2 Exercises 6-14 ni.com


Lesson 6 File I/O Techniques

2. Read and display the power spectrum data.

❑ Change the Data Set control to Power Spectrum.

❑ Run the VI. Power spectrum data should display in the Channel Data

uti ts
graph.

3. Close the VI.

rib en
TDM Excel Add-In (Optional)

on
Note This exercise requires Microsoft Excel version 2003 or 2007 and the TDM Add-in
Tool available on ni.com.

ist um
1. Launch Microsoft Excel.

2. Click the Add-Ins tab and select the TDM Importer : Import a
r D str TDM(S) File icon in the Custom Toolbars section.

3. Browse to find the TDMS file you created earlier: <Exercises>\


LabVIEW Core 2\TDMS Logger\Test Data.tdms. The property
information is displayed on the first worksheet. The Time data and
Power Spectrum data are displayed on separate worksheets.
t fo l In

4. Exit Microsoft Excel and return to LabVIEW.

End of Exercise 6-2


No na
tio
Na

© National Instruments Corporation 6-15 LabVIEW Core 2 Exercises


Lesson 6 File I/O Techniques

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 6-16 ni.com


Improving an Existing VI
7

uti ts
Exercise 7-1 Concept: Refactoring a VI

rib en
Goal

on
Improve an existing VI that is poorly designed.

ist um
Description
You receive a VI that is used as a subVI in a larger project. You must
improve the VI for readability and user friendliness.

r D str Evaluate the VI


1. Open the Determine Warning Bad One.vi located in the
<Exercises>\LabVIEW Core 2\Determine Warnings directory.
Figure 7-1 shows the block diagram of this VI.

❑ Run this VI with a variety of input values and observe the varying
t fo l In
warning text.

2. Use the following list to evaluate the VI. Place a checkmark for all issues
that apply.

❑ Disorganized block diagram


No na

❑ Overly large block diagram

❑ Poorly named objects and poorly designed icons


tio

❑ Unnecessary logic

❑ Duplicated logic

❑ Lack of dataflow programming


Na

❑ Complicated algorithms

© National Instruments Corporation 7-1 LabVIEW Core 2 Exercises


Lesson 7 Improving an Existing VI

uti ts
rib en
on
ist um
Figure 7-1. Poorly Designed Block Diagram
r D str Improve the VI
Improve the VI in stages. Begin with the first checkmark: The block
diagram is too disorganized.

1. Use the following tips to help you organize the block diagram:
t fo l In
No na
tio
Na

Figure 7-2. Reorganized Block Diagram

❑ Move all controls to the left of the block diagram.

❑ Move all indicators to the right of the block diagram.

❑ Use the Align Objects and Distribute Objects toolbar buttons to


arrange the controls and indicators.

LabVIEW Core 2 Exercises 7-2 ni.com


Lesson 7 Improving an Existing VI

❑ Rearrange wires so that they do not overlap.

❑ Rearrange wires so that no input wires are running from right to left.

❑ Reduce the number of bends in wires.

uti ts
❑ Do not allow wires to run under objects.

rib en
2. After the block diagram is better organized, rename controls and
indicators using names that are more descriptive.

on
• The purpose of this VI is to determine whether the current
temperature and wind speed are at a level requiring a warning to

ist um
generate. The VI also lights an LED if a warning occurs.

• Suggested input names are Current Temperature, Low Temp,


High Temp, Current Wind Speed, and High Wind Speed.
r D str • Suggested output names are Warning Text and Warning?.

3. Remove any unnecessary logic from the block diagram.

Figure 7-3 shows the last few functions in the block diagram.
t fo l In
No na
tio

Figure 7-3. Unnecessary Logic


Na

© National Instruments Corporation 7-3 LabVIEW Core 2 Exercises


Lesson 7 Improving an Existing VI

Notice that the Equal? function is followed by a Not function.


One approach is to replace this with a Not Equal? function as shown in
Figure 7-4.

uti ts
rib en
on
ist um
Figure 7-4. Unnecessary Logic Simplified

Notice you can reduce unnecessary logic even further by removing the
Not Equal? function and inverting the Boolean input of the Select
r D str function, as shown in Figure 7-5.
t fo l In
No na

Figure 7-5. Unnecessary Logic Simplified Further

Refer to Figure 7-6 for assistance with wiring this duplicated function
that occurs near the end of the VI.
tio

❑ Delete the Equal? function.

❑ Delete the input wire to the Not function.

❑ Wire the input of the Not function to the input wire of the Select
Na

function.

❑ Test the edited VI to be sure the functionality has not changed.

LabVIEW Core 2 Exercises 7-4 ni.com


Lesson 7 Improving an Existing VI

uti ts
rib en
on
ist um
Figure 7-6. Well-Named Controls and Unnecessary Logic Removed

4. Save the VI as Determine Warnings Good One.vi.


r D str
Optional
1. Replace duplicated logic on the block diagram with subVIs. Figure 7-7
shows an example of the algorithm in the VI that is repeated. You can
t fo l In
replace this algorithm with a subVI.
No na

Figure 7-7. Repeated Algorithm

❑ Select the repeated algorithm by drawing a selection box around the


tio

objects.

❑ Select Edit»Create SubVI.

❑ Double-click the new subVI to open it.


Na

❑ Edit the new subVI as necessary. Some things to consider: create an


appropriate icon, recreate the connector pane, and rename the
controls and indicators.

❑ Save the subVI.

❑ Close the subVI.

© National Instruments Corporation 7-5 LabVIEW Core 2 Exercises


Lesson 7 Improving an Existing VI

Note If the subVI is dimmed, right-click the subVI icon on the block diagram and select
Relink to SubVI from the shortcut menu.

❑ Delete the duplicated logic in other locations and replace with the

uti ts
new subVI.

❑ Test the edited VI.

rib en
2. Remove unnecessary local variables and wire to the appropriate control
or indicator instead.

on
ist um
r D str
t fo l In

Figure 7-8. Duplicated Logic Placed in a SubVI and Local Variables Removed

3. Save the VI as Determine Warnings Good One.vi.


No na
tio
Na

LabVIEW Core 2 Exercises 7-6 ni.com


Lesson 7 Improving an Existing VI

Challenge: Simplify Algorithm


If you have time remaining in this exercise, try to determine a way to
simplify the algorithm and rewrite the code so that is easier to modify later.

uti ts
An example solution is shown in Figure 7-9 using a state machine. The states
contained are: Heatstroke, Freeze, High Wind, and Generate Warning. You
can explore alternate solutions in the <Solutions>\LabVIEW Core 2\

rib en
Exercise 7-1 Challenge directory.

on
ist um
r D str
t fo l In
No na

Figure 7-9. Alternate Algorithm that is Readable and Maintainable

End of Exercise 7-1


tio
Na

© National Instruments Corporation 7-7 LabVIEW Core 2 Exercises


Lesson 7 Improving an Existing VI

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 7-8 ni.com


Creating and Distributing Applications
8

uti ts
Exercise 8-1 Preparing Files for Distribution

rib en
Goal

on
Review the Building Applications Checklist and prepare VIs to build a
standalone application.

ist um
Scenario
Review the Building Applications Checklist to assist you in the build
process before creating a standalone application or installer.
r D str Stand-alone applications in LabVIEW have the Window Appearance set to
Top-level application to enable the front panel to open when the VI runs.

A VI that is running as a stand-alone executable remains in memory when


the application finishes running. Therefore, it is necessary to call the Quit
t fo l In
LabVIEW function in order to close the application when the application
finishes executing. Placing the Quit LabVIEW function on the block
diagram can make editing the application more difficult in the future
because LabVIEW exits each time the application finishes. With the use of
the App.Kind property, you can specify that LabVIEW exits only when
executed within the run-time system.
No na

Design
• Modify the VI Properties to prepare to build a stand-alone application.
tio

• Modify the application to call the Quit LabVIEW function when the
code is executed in the run-time system.

• Modify the application to specify a log path relative to the standalone


executable.
Na

© National Instruments Corporation 8-1 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

Implementation
Before you build an application, you first prepare the code so that it executes
reliably when compiled into an application.

uti ts
Review the Building Applications Checklist
1. Select Help»LabVIEW Help to open the LabVIEW Help.

rib en
2. Select Fundamentals»Building and Distributing Applications»
Building Applications Checklist.

on
3. Review the Preparing Files checklist items.

ist um
Set Top-Level Application Window
Note If you have hardware installed and you have not already set up your hardware as
part of a LabVIEW Core 1 exercise, refer to Appendix A, Setting Up Your Hardware.
r D strNote If you do not have hardware installed, use the files located in the <Exercises>\
LabVIEW Core 2\Weather Station\No Hardware Required Version
directory.
t fo l In
1. Open the Weather Station UI VI.

❑ Open Weather Station.lvproj in the <Exercises>\


LabVIEW Core 2\Weather Station directory.

❑ In the Project Explorer window, double-click Weather Station


UI.vi.
No na
tio
Na

LabVIEW Core 2 Exercises 8-2 ni.com


Lesson 8 Creating and Distributing Applications

uti ts
rib en
on
ist um
r D str
t fo l In

Figure 8-1. Front Panel


No na

2. Select File»VI Properties to display the VI Properties dialog box.

3. Select Window Appearance from the top pull-down menu.


tio

4. Give the window a name, such as Weather Station.

5. Select Top-level application window. This gives the front panel a


professional appearance when it opens as an executable.
Na

6. Click OK.

7. Save the VI.

© National Instruments Corporation 8-3 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

Call the Quit LabVIEW Function


1. Open and modify the block diagram to call the Quit LabVIEW function
when the application finishes.

uti ts
rib en
on
Figure 8-2. Adding the Quit LabVIEW Function to the Block Diagram

ist um
❑ Add the Quit LabVIEW function to the block diagram so that it is
the last function that executes. This function quits LabVIEW and
quits the application after it has executed.

❑ Enclose the Quit LabVIEW function in a Case structure.


r D str
❑ Using the settings below in the Class Browser window create the
Application: Kind property.

– Object library: VI Server


t fo l In

– Class: Application

– Properties and Methods: Properties»Application»Kind

❑ Wire the Property Node as shown in Figure 8-2.


No na

❑ Use the labeling tool to replace the text in the case label with
Run Time System.
tio

Note Enum values that you wire to a case selector terminal are case sensitive.

2. In the Project Explorer window, select File»Save All to save all the VIs.
Na

LabVIEW Core 2 Exercises 8-4 ni.com


Lesson 8 Creating and Distributing Applications

Specify a File Path Relative to the Executable


1. Instead of prompting the user to specify a log file, modify your code to
specify a file path relative to the application executable.

uti ts
rib en
on
ist um
r D str
t fo l In
No na

Figure 8-3. Additional Build Path Function

❑ Open the Initialize Weather Station.vi from the Project Explorer


window.
tio

❑ Switch to the block diagram.

❑ Add a Build Path function to the block diagram.


Na

❑ Right-click the name or relative path input and select Create»


Constant from the shortcut menu.

❑ Type weather.txt in the string constant.

❑ Add an Application Directory VI to the block diagram.

❑ Wire the block diagram as shown in Figure 8-3.

© National Instruments Corporation 8-5 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

❑ Save and close the VI.

❑ From the Project Explorer window, open and run the Weather
Station UI.vi. When you click the Stop button, the VI stops but does

uti ts
not quit LabVIEW.

❑ Open the <Exercises>\LabVIEW Core 2\Weather Station


directory in the Windows Explorer. Verify that the weather.txt

rib en
file exists and contains the log information.

on
Note If you do not have hardware installed, the weather.txt file is located in the
<Exercises>\LabVIEW Core 2\Weather Station\No Hardware Required

ist um
Version directory.

End of Exercise 8-1


r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 8-6 ni.com


Lesson 8 Creating and Distributing Applications

Exercise 8-2 Creating a Stand-Alone Application


Goal

uti ts
Create a build specification and build a stand-alone application (EXE) in
LabVIEW.

Scenario

rib en
Creating a stand-alone application and an installer simplifies deploying an

on
application on multiple machines. After you have prepared your files, you
create an Application (.exe) Build Specification and then create an
Installer Build Specification.

ist um
Design
Use the Application (EXE) Build Specifications to create a stand-alone
application for the Weather Station application.
r D str Use the Installer Build Specifications to create an installer for the Weather
Station application.

Implementation
t fo l In
Application (EXE) Build Specification
1. Open Weather Station.lvproj in the <Exercises>\
LabVIEW Core 2\Weather Station directory.

2. Right-click Build Specifications in the Project Explorer window and


select New»Application (EXE) from the shortcut menu.
No na

3. Modify the filename of the target and destination directory for the
application in the Information category.

❑ Select the Information category.


tio

❑ Change the Target filename to WeatherStation.exe.

❑ Enter <Exercises>\LabVIEW Core 2\Weather Station\


Na

Executable in the Destination directory.

Tip You do not need to create the directory. LabVIEW creates any directories that you
specify.

© National Instruments Corporation 8-7 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

4. Specify the top-level VI.

❑ Select the Source Files category.

❑ Select the Weather Station UI.vi in the Project Files tree.

uti ts
❑ Click the right arrow next to the Startup VIs listbox to add the
selected VI to the Startup VIs listbox.

rib en
❑ Click OK.

on
5. In the Project Explorer window, right-click the My Application build
specification that you just created, and select Build from the shortcut

ist um
menu.

6. Click Done in the Build status window.

r D str 7. Navigate to <Exercises>\LabVIEW Core 2\Weather Station\


Executable in Windows Explorer and run WeatherStation.exe.
Stop when done.

8. Verify that the application closed when you stopped the application and
that the weather.txt was created next to the executable.
t fo l In

Review the Building Applications Checklist


1. Open the LabVIEW Help by selecting Help»LabVIEW Help.

2. Select Fundamentals»Building and Distributing Applications»


Building Applications Checklist.
No na

3. Review the Configuring Build Specifications checklist items.

Installer Build Specification


tio

1. Right-click Build Specifications in the Project Explorer window and


select New»Installer from the shortcut menu.

2. Modify the Installer destination in the Product Information category.


Na

❑ Select the Product Information category.

❑ Type <Exercises>\LabVIEW Core 2\Weather Station\


Installer as the Installer destination.

3. Specify the Executable Build Specification.

❑ Click the Source Files category.

❑ Select the My Application build specification.

LabVIEW Core 2 Exercises 8-8 ni.com


Lesson 8 Creating and Distributing Applications

❑ Select the Weather Station directory in the Program Files in the


Destination View tree.

❑ Click the right arrow next to the Project View tree to place the

uti ts
executable and the executable support files under the Program Files
in the Weather Station directory as shown in Figure 8-4.

rib en
on
ist um
r D str
t fo l In
No na

Figure 8-4. Installer Source Files Category

4. Add the NI LabVIEW Run-Time Engine to the installer by modifying


tio

the Additional Installers category.

❑ Select the Additional Installers category.

❑ Select the NI LabVIEW Run-Time Engine 2011 installer.


Na

❑ Click OK.

5. In the Project Explorer window, right-click the My Installer build


specification and select Build from the shortcut menu.

6. Click Done.

© National Instruments Corporation 8-9 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

Test
1. Run the setup.exe file in the <Exercises>\LabVIEW Core 2\
Weather Station\Installer\Volume directory. You are guided
through a setup process. The executable is created inside the <Program

uti ts
Files>\Weather Station directory.

2. To run the application, select Start»Programs»Weather Station»

rib en
Weather Station.

on
End of Exercise 8-2

ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 8-10 ni.com


Lesson 8 Creating and Distributing Applications

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

© National Instruments Corporation 8-11 LabVIEW Core 2 Exercises


Lesson 8 Creating and Distributing Applications

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises 8-12 ni.com


Setting Up Your Hardware
A

uti ts
This appendix contains instructions on setting up your hardware.

rib en
Note Complete this setup only if you have hardware installed and have not already

on
completed hardware setup on your system as part of a LabVIEW Core 1 course exercise.

ist um
1. Launch MAX by selecting Start»Programs»National Instruments»
Measurement & Automation or by double-clicking the MAX icon on
your desktop. MAX searches the computer for installed National
Instruments hardware and displays the information.
r D str 2. Create a custom scale for the temperature sensor on the DAQ Signal
Accessory. The sensor conversion is linear and uses the following the
formula Voltage x 100 = Celsius.
t fo l In
No na
tio
Na

Figure A-1. Temperature Scale

© National Instruments Corporation A-1 LabVIEW Core 2 Exercises


Appendix A Setting Up Your Hardware

❑ Right-click the Scales section and select Create New from the
shortcut menu.

❑ Select NI-DAQmx Scale.

uti ts
❑ Click Next.

❑ Select Linear.

rib en
❑ Name the scale Temperature.

on
❑ Click Finish.

ist um
❑ Change the Scaling Parameter Slope to 100.

❑ Under Units, enter Celsius in the Scaled field.

r D str ❑ Click the Save button on the toolbar to save the scale.

❑ Close MAX by selecting File»Exit.


t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises A-2 ni.com


Appendix A Setting Up Your Hardware

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

© National Instruments Corporation A-3 LabVIEW Core 2 Exercises


Appendix A Setting Up Your Hardware

Notes

uti ts
rib en
on
ist um
r D str
t fo l In
No na
tio
Na

LabVIEW Core 2 Exercises A-4 ni.com


Additional Information and Resources
B

uti ts
This appendix contains additional information about National Instruments

rib en
technical support options and LabVIEW resources.

National Instruments Technical Support Options

on
Visit the following sections of the award-winning National Instruments

ist um
Web site at ni.com for technical support and professional services:
• Support—Technical support at ni.com/support includes the
following resources:
– Self-Help Technical Resources—For answers and solutions,
visit ni.com/support for software drivers and updates,
r D str a searchable KnowledgeBase, product manuals, step-by-step
troubleshooting wizards, thousands of example programs, tutorials,
application notes, instrument drivers, and so on. Registered
users also receive access to the NI Discussion Forums at ni.com/
t fo l In
forums. NI Applications Engineers make sure every question
submitted online receives an answer.
– Standard Service Program Membership—This program entitles
members to direct access to NI Applications Engineers via phone
and email for one-to-one technical support, as well as exclusive
access to eLearning training modules at ni.com/eLearning.
No na

NI offers complementary membership for a full year after purchase,


after which you may renew to continue your benefits.
For information about other technical support options in your
area, visit ni.com/services or contact your local office at
tio

ni.com/contact.
• System Integration—If you have time constraints, limited in-house
technical resources, or other project challenges, National Instruments
Alliance Partner members can help. The NI Alliance Partners joins
Na

system integrators, consultants, and hardware vendors to provide


comprehensive service and expertise to customers. The program ensures
qualified, specialized assistance for application and system
development. To learn more, call your local NI office or visit ni.com/
alliance.

You also can visit the Worldwide Offices section of ni.com/niglobal


to access the branch office Web sites, which provide up-to-date contact
information, support phone numbers, email addresses, and current events.

© National Instruments Corporation B-1 LabVIEW Core 2 Exercises


Appendix B Additional Information and Resources

Other National Instruments Training Courses


National Instruments offers several training courses for LabVIEW users.
These courses continue the training you received here and expand it to other

uti ts
areas. Visit ni.com/training to purchase course materials or sign up for
instructor-led, hands-on courses at locations around the world.

rib en
National Instruments Certification

on
Earning an NI certification acknowledges your expertise in working with
NI products and technologies. The measurement and automation industry,
your employer, clients, and peers recognize your NI certification credential

ist um
as a symbol of the skills and knowledge you have gained through
experience. Visit ni.com/training for more information about the
NI certification program.

LabVIEW Resources
r D str This section describes how you can receive more information regarding
LabVIEW.

LabVIEW Publications
t fo l In

LabVIEW Books
Many books have been written about LabVIEW programming and
applications. The National Instruments Web site contains a list of all
the LabVIEW books and links to places to purchase these books.
Visit zone.ni.com/devzone/cda/tut/p/id/5389 for more
No na

information.
tio
Na

LabVIEW Core 2 Exercises B-2 ni.com

You might also like