0% found this document useful (0 votes)
75 views10 pages

LabVIEW TM Core 2 Course Manual-1-10

Uploaded by

陳彥勳
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views10 pages

LabVIEW TM Core 2 Course Manual-1-10

Uploaded by

陳彥勳
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

TM

LabVIEW Core 2
Course Manual

Course Software Version 2012


August 2012 Edition
Part Number 325292D-01
LabVIEW Core 2 Course Manual
Copyright
© 1993–2012 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 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.
End-User License Agreements and Third-Party Legal Notices
You can find end-user license agreements (EULAs) and third-party legal notices in the following locations:
• Notices are located in the <National Instruments>\_Legal Information and <National Instruments>
directories.
• EULAs are located in the <National Instruments>\Shared\MDF\Legal\License directory.
• Review <National Instruments>\_Legal Information.txt for more information on including legal information
in installers built with NI products.
Trademarks
CVI, 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.
The mark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft
Corporation in the United States and other countries. 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.
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
A. NI Certification .....................................................................................................v
B. Course Description ...............................................................................................v
C. What You Need to Get Started .............................................................................vi
D. Installing the Course Software..............................................................................vii
E. Course Goals.........................................................................................................vii
F. Course Conventions ..............................................................................................vii

Lesson 1
Moving Beyond Dataflow
A. Asynchronous Communication.............................................................................1-2
B. Queues ..................................................................................................................1-2
C. Event-Driven Programming..................................................................................1-5

Lesson 2
Implementing Design Patterns
A. Design Patterns .....................................................................................................2-2
B. Simple Design Patterns .........................................................................................2-2
C. Multiple Loop Design Patterns .............................................................................2-8
D. Error Handlers.......................................................................................................2-14
E. Generating Error Codes and Messages .................................................................2-17
F. Timing a Design Pattern .......................................................................................2-19
G. Functional Global Variable Design Pattern ..........................................................2-24

Lesson 3
Controlling the User Interface
A. VI Server Architecture..........................................................................................3-2
B. Property Nodes .....................................................................................................3-3
C. Invoke Nodes ........................................................................................................3-4
D. Control References ...............................................................................................3-5

Lesson 4
File I/O Techniques
A. Compare File Formats ..........................................................................................4-2
B. Create File and Folder Paths .................................................................................4-4
C. Write and Read Binary Files.................................................................................4-5
D. Work with Multichannel Text Files and Headers .................................................4-11
E. Access TDMS Files in LabVIEW and Excel........................................................4-16

© National Instruments | iii


Contents

Lesson 5
Improving an Existing VI
A. Refactoring Inherited Code...................................................................................5-2
B. Typical Refactoring Issues....................................................................................5-4

Lesson 6
Deploying an Application
A. Preparing the Files ................................................................................................6-2
B. Build Specifications ..............................................................................................6-3
C. Create and Debug an Application .........................................................................6-4

Appendix A
Additional Information and Resources

Glossary

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 course manual and the accompanying
software are used in the two-day, hands-on LabVIEW Core 2 course.

You can apply the full purchase of this course kit toward the corresponding course registration fee
if you register within 90 days of purchasing the kit. Visit ni.com/training for online course
schedules, syllabi, training centers, and class registration.

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 courses that are part of the LabVIEW training series. Refer to
ni.com/training for more information about NI Certification.

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
Object-Oriented Design
and Programming
in LabVIEW

LabVIEW Performance
Certifications

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


LabVIEW FPGA LabVIEW DAQ and Signal Conditioning Modular Instruments Series

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

B. Course Description
The LabVIEW Core 2 course teaches you programming concepts, techniques, features, VIs, and
functions you can use to create test and measurement, data acquisition, instrument control,
datalogging, measurement analysis, and report generation applications. This course assumes that
you are familiar with Windows, that you have experience 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 course and exercise manuals are divided into lessons, described as
follows.

© National Instruments | v
Student Guide

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


• An introduction that describes the purpose of the lesson and what you will learn
• A description of the topics in the lesson
• A summary or 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 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.

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. Alternate instructions are
provided for completing the exercises without hardware. You also can substitute other hardware
for those previously mentioned. For example, you can use another National Instruments DAQ
device connected to a signal source, such as a function generator.

C. What You Need to Get Started


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

 Computer running Windows 7/Vista/XP

 Multifunction DAQ device configured as Dev1 using Measurement & Automation Explorer
(MAX)

 DAQ Signal Accessory or BNC-2120, wires, and cable

 LabVIEW Professional Development System 2012 or later

 DAQmx 9.5.5 or later

 LabVIEW Core 2 course CD, from which you install the following folders:

Directory Description
Exercises Contains VIs used in the course
Solutions Contains completed course exercises

vi | ni.com
LabVIEW Core 2 Course Manual

D. Installing the Course Software


Complete the following steps to install the course software.
1. Insert the course CD in your computer. The LabVIEW Core 2 Course Setup dialog box
appears.
2. Click Install the course materials.
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 directory of your computer.

E. Course Goals
This course prepares you to do the following:
• Apply common design patterns that use queues and events
• Use event programming effectively
• Programmatically control user interface objects
• Evaluate file I/O formats and use them in applications
• Modify existing code for improved usability
• Prepare, build, debug, and deploy stand-alone applications

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 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

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

» 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
Instrumentation item, and finally select the Find Instrument Drivers
option.

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

© National Instruments | vii


Student Guide

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.

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.

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

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.

Platform Text in this font denotes a specific platform and indicates that the text
following it applies only to that platform.

viii | ni.com
Moving Beyond Dataflow
1
As you learned in LabVIEW Core 1, LabVIEW is a dataflow language where the flow of data
determines the execution order of block diagram elements. A block diagram node executes when
it receives all required inputs. When a node executes, it produces output data and passes the data
to the next node in the dataflow path. The movement of data through wires and nodes determines
the execution order of the VIs and functions on the block diagram. This type of communication
between nodes is referred to as synchronous communication.

Topics
A. Asynchronous Communication
B. Queues
C. Event-Driven Programming

© National Instruments | 1-1


Lesson 1 Moving Beyond Dataflow

A. Asynchronous Communication
Although LabVIEW is a dataflow language that uses wires to transfer data between functions, there
are situations where communicating asynchronously, or without wires, is desirable. In this lesson
you learn two important techniques for communicating asynchronously—queues for
communicating between parallel loops and events for communicating between the user interface
and the block diagram.

B. Queues
Use queues to communicate data between parallel loops in LabVIEW. A queue can hold data of
any type and can store multiple pieces of data. By default, queues work in a first in, first out (FIFO)
manner. Therefore, the first piece of data inserted into the queue is the first piece of data that is
removed from the queue. Use a queue when you want to process all data placed in the queue.

Variables are useful in LabVIEW for passing data between parallel processes. However, when
using variables it is often difficult to synchronize data transfers, which may cause you to read
duplicate data or to miss data. Further more, you must take care to avoid race conditions. This
lesson introduces queues as alternative methods for passing data between parallel processes.
Queues have advantages over using variables because of the ability to synchronize the transfer
of data.

Queue Operations
Use the queue operations functions to create and use queues for communicating data between
different sections of a VI and different VIs.

Table 1-1 describes the queue operations functions you use in this course.

Table 1-1. Queue Operations Functions

Function Description
Dequeue Element Removes an element from the front of a queue and returns
the element.

Enqueue Element Adds an element to the back of a queue.

Enqueue Element at Opposite Adds an element to the front of a queue.


End

1-2 | ni.com

You might also like