LabVIEW TM Core 2 Course Manual-1-10
LabVIEW TM Core 2 Course Manual-1-10
LabVIEW Core 2
Course Manual
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
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.
LabVIEW Performance
Certifications
Other Courses
*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
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.
Multifunction DAQ device configured as Dev1 using Measurement & Automation Explorer
(MAX)
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
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
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.
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.
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
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.
Function Description
Dequeue Element Removes an element from the front of a queue and returns
the element.
1-2 | ni.com