Вы находитесь на странице: 1из 296

Online LabVIEW Core 3

ni.com/training

What You Need To Get Started

LabVIEW Core 3 Course Manual


LabVIEW Core 3 Exercise Manual
LabVIEW Core 3 Course CD

Computer running
LabVIEW Professional
Development System 2009 and
Windows 2000/XP

ni.com/training

File Locations
The course installer places the course files in the following
location:

ni.com/training

Instructional Methods
Lecture gives a foundation
in the topic
Instructor reinforces
foundation through
demonstrations and quizzes
Use concept exercises to further explore a topic
Watch a simulation, experiment with example VIs

Use development exercises to gain hands-on experience


Demonstration of a finished development exercise further
reinforces the learning process
ni.com/training

Getting The Most Out Of This Course


Experiment with hands-on exercises to understand the
methods used
Implementations explore a possible solutionyou may find
a better one
Do not come to class prepared to develop an outside
application; concentrate on the exercises given to build a
good foundation

ni.com/training

New User
LabVIEW Core 1

Experienced User
LabVIEW Core 3

LabVIEW Core 2

Managing Software
Engineering in LabVIEW
LabVIEW OOP System
Design

Advanced Architectures
in LabVIEW

Certifications

Certified LV Associate
Developer Exam

Certified LabVIEW
Developer Exam

Certified LabVIEW
Architect Exam

ni.com/training

Course Learning Map

ni.com/training

Course Goals
This course prepares you to:
Establish a software lifecycle for future project development
Communicate with customers during project definition
Develop professional user interfaces
Develop applications that are scalable, readable, and
maintainable
Investigate and implement techniques for timing a VI
Handle errors that may occur during code execution
Document Vis effectively
ni.com/training

Lesson 1:
Successful Development Practices
(Pre-Course Work)
TOPICS
A. Scalable, Readable, and Maintainable VIs
B. Successful Development Practices
C. Course Project Overview

ni.com/training

Lesson 2:
Analyzing the Project
TOPICS
A.
B.
C.
D.

Evaluating the Needs of the Customer


Communicating with the Customer
Developing the Requirements Document
Defining the Application

ni.com/training

A. Evaluating the Customers Needs


Read customer specifications carefully

Identify any areas that are lacking


Develop questions to ask your customer to clarify any issues
ni.com/training

Demonstration Theatre Light Controller

Study the execution of the Theater Light Controller.


DEMONSTRATION

B. Communicating with the Customer

The expectations of the customer and the programmer are


different. It is your responsibility to determine what
expectations the customer has and how to relate to him or her.

ni.com/training

Customer: Expectations of the Programmer


The Programmer:
Understands what he or she has been told
Communicates design ideas
Communicates any problems
Asks the right questions
Keeps to schedule
Keeps promises

ni.com/training

Programmer: Expectations of the Customer


The Customer:
Knows what he or she wants
Communicates his or her requirements
Is aware of any pitfalls
Is consistent in stating views

ni.com/training

C. Developing the Requirements Document


The Requirements Document provides a common ground
from which you and the customer work.
Write it in a language that you both understand.

ni.com/training

Exercise 2-1: Analyze a Requirements Document

Assess a requirements document that is based on a software


requirements document specification.
GOAL

Exercise 2-1: Analyze a Requirements Document

Refer to this document as you implement code in later


exercises
This document provides a high-level overview of the course
project
DISCUSSION

D. Defining the Application


Create a diagram of the application
Improves your ability to design the application
Conveys ideas to your customer
The first step in creating a diagram is to determine the
abstract components of each requirement

ni.com/training

Abstracting Components

Two Forms of Abstraction


Procedural Abstraction
Data Abstraction

ni.com/training

Procedural Abstraction
Procedure

Abstracted
Implementation

Open datalog file


Get frequency information for data
Display all data points that satisfy
the search parameter
ni.com/training

Data Abstraction
Separates what data will be stored from how the data will be
stored physically
Provides a more logical view of the data
For example, group related data together as a cluster

ni.com/training

Example of Procedural Abstraction


1. Start with a requirements document
2. Identify nouns and organize them into abstract
components
3. Identify verbs and assign them to the abstract
components that perform each action
4. Improve the readability of the verbs; for each abstract
object, pair verbs with specific nouns to create phrases

ni.com/training

Completed Parse for Course Project


Hardware Display

Cue

Timing

Error

File

Write Color
Initialize Front
and Intensity Panel

Add Cue

Wait Time

Report
Errors

Save
Cues

Update Front
Panel

Get Cue Values

Fade Time

Handle
Errors

Read
Cues

Select Cue

Set Cue Values

Follow Time

Enable/Disable Get Number of


Front Panel
Cues
Update Cue
List

Get Empty Cue

ni.com/training

Object-Oriented Design
Procedural abstraction creates:
List of abstracted components
List of verbs associated with each component (methods)

This abstraction lends itself to the development of objects

ni.com/training

What Is Object-Oriented Design?


Task-Oriented design

Object-Oriented design

Breaks a problem into step-bystep instructions


Produces a sequence of tasks

Groups tasks into areas of


responsibility
Produces a set of objects
formed around each area of
responsibility

ni.com/training

Two Descriptions of the Same Problem


We want to test each board at the end of an assembly line to
make sure each is functional. We want to send an e-mail to
management for any failed tests.
vs.
We want the assembly line to produce boards. Each board
should test itself for functionality and report any problem. The
log should send an e-mail to management for any failed tests.

ni.com/training

Coupling

The goal of any hierarchical architecture is to ensure that the


implementation uses low or loose coupling.
If one module does not function correctly, coupled modules may not function
correctly
Higher coupling makes debugging difficult
Low coupling allows more changes in the code without breaking other modules
ni.com/training

Cohesion

The goal of any hierarchical architecture is to ensure that the


implementation has one goal per modulehigh cohesion.
When a module tries to accomplish multiple goals, the block
diagram becomes harder to read
High cohesion decreases overall development time
ni.com/training

Drawing Abstracted Components


Two powerful methods
Flowcharts
Data flow diagrams

ni.com/training

Flowcharts: Play Function


Provides good
understanding of
application flow
Divides task into
manageable pieces at
logical places
Nodes are functions
that are performed

ni.com/training

Dataflow Diagrams
Data Store Files or repositories in the system
Process Accepts incoming data, processes the
data, and generates outgoing data
External Entity Items outside the system that
the system communicates with
Data Flow Pipes that indicate the flow of data
ni.com/training

Dataflow Diagram: Play Function


Focus is on data
Conceptually easier to realize with LabVIEW because
LabVIEW is a dataflow language

ni.com/training

Summary Quiz
1. Match each document to its purpose.
Requirements Document
Flowchart
Data Flow Diagram

a. Provides a common ground


for the programmer and the
customer to work from
b. Represents the flow of data
through an application
c. Provides good understanding
of application flow

ni.com/training

Summary Quiz Answers


1. Match each document to its purpose.
Requirements Document
Flowchart
Data Flow Diagram

a. Provides a common ground


for the programmer and the
customer to work from
c. Provides good understanding
of application flow
b. Represents the flow of data
through an application

ni.com/training

Summary Quiz
2. Match each application design concept with its definition
Coupling
Cohesion
Abstraction

a.

b.
c.

Describes an application by
generalizing it and removing
details
Reliance of a code module on
other code modules
Focus of a code module on a
single goal

ni.com/training

Summary Quiz Answers


2. Match each application design concept with its definition
Coupling

b.

Cohesion

c.

Abstraction

a.

Reliance of a code module on


other code modules
Focus of a code module on a
single goal
Describes an application by
generalizing it and removing
details

ni.com/training

Lesson 3:
Designing the User Interface
TOPICS
A.
B.
C.
D.
E.

User Interface Design Issues


User Interface Layout Issues
Front Panel Prototyping
User Interface Examples
Localizing User Interfaces
ni.com/training

A. User Interface Design Issues


Fonts and Text
Colors
Graphics

ni.com/training

Fonts and Text


Limit VI to the three standard fontsapplication, system,
and dialog
Standard fonts vary depending on the platform
Leave room for font to expand or contract
ExampleLabel is right-justified;
leave some space to left of label
for expansion

ni.com/training

Colors
Color can distract the user from important information
Use complementary colors that vary primarily in brightness
Grayscale Spectrum
Muted Color Spectrum
Highlight Color Spectrum

Transparency Box

ni.com/training

Graphics
Import bitmaps, Macintosh PICTs, Windows Enhanced
Metafiles, and text objects to use as front panel
backgrounds
Imported graphics slow down screen updates
Do not place indicators and controls on top of a graphic
object
Split large graphics into smaller ones

ni.com/training

B. User Interface Layout Issues


Keep front panels simple to avoid confusing the user
Place most important controls in the most prominent
positions
Keep inputs on the left and outputs on the right

ni.com/training

Run-Time Menus

ni.com/training

Tools for Improving User Interface Layout


Organizing the User Interface
Decorations
Tab controls
Subpanel controls
Tree controls
Splitter bars and panes

ni.com/training

Demonstration NI Example Finder

Open and explore the NI Example Finder


What tools can you identify that organize the user interface
of the NI Example Finder?
DEMONSTRATION

Sizing and Positioning


Make front panels as small as possible without crowding
controls or sacrificing a clear layout
Place front panel in the center of the screen
Use the Window Run-Time Position page of the VI
Properties dialog box
Front Panel:Run-Time Position methods
Centered
Custom

ni.com/training

Labels and Captions

ni.com/training

Paths versus Strings


Use path controls and
indicators rather than
string controls and
indicators
Formats paths using
standard syntax for platform
Allows user to browse for file

ni.com/training

Default Values and Ranges


Use Data Range to coerce values into the desired range
(Minimum, Maximum, and Increment)
Use reasonable default values
Show default values in parentheses in the control label

ni.com/training

Key Navigation

ni.com/training

Front Panel Object Styles


Modern Controls, Classic Controls, System Controls

ni.com/training

C. Front Panel Prototyping


Design VI front panels with the controls and indicators you
need
Leave the block diagram empty and figure out how the
controls work and how various actions require other front
panels
For more extensive prototypes, tie the front panels together

ni.com/training

D. User Interface Example

ni.com/training

User Interface Example

ni.com/training

E. Localizing User Interfaces


The process of creating an application used in a different
locale and culture
Leave space for localization
Do not hardcode user interface strings on the block diagram
Avoid using non-international symbols and icons
Avoid using text in icons
Use captions for labels

ni.com/training

Exercise 3-1: User Interface Design Techniques

Learn techniques you can use to create professional user


interfaces in LabVIEW.
GOAL

Exercise 3-1: User Interface Design Techniques

This exercise demonstrates additional techniques for UI


development that you can add to your developers toolbox
DISCUSSION

Summary - Quiz
1. Which of the following control types does not specifically
improve front panel organization?
a. Subpanel control
b. Tab control
c. Boolean button

2. Adding extra space between front panel controls makes which


of the following easier?
a.
b.
c.
d.

Adding key navigation to controls


Porting the application from Windows XP to Windows Vista
Localizing the application into German
Modifying the default values in the controls
ni.com/training

Summary - Quiz Answers


1. Which of the following control types does not specifically
improve front panel organization?
a. Subpanel control
b. Tab control
c. Boolean button

2. Adding extra space between front panel controls makes which


of the following easier? (Multiple answers)
a.
b.
c.
d.

Adding key navigation to controls


Porting the application from Windows XP to Windows Vista
Localizing the application into German
Modifying the default values in the controls
ni.com/training

Lesson 4:
Designing the Project
TOPICS
A. Design Patterns
B. Event-Based Design
Patterns
C. Advanced Event-Based
Design Patterns
D. Creating a Hierarchical
Architecture

E. Working with LabVIEW


Projects
F. Choosing Data Types
G. Information Hiding
H. Designing Error Handling
Strategies
ni.com/training

A. Design Patterns
State Machine
Parallel Loops
Producer/Consumer (Data)

ni.com/training

State Machine Design Pattern


1. While LoopContinually executes the various states
2. Shift RegisterContains state transition information
3. Case StructureContains a case for each state, and the
code to execute for each state

ni.com/training

Demonstration State Machine Design Pattern

Observe the functionality and design of the state machine


design pattern
DEMONSTRATION

Parallel Loop Design Pattern

ni.com/training

Producer/Consumer (Data) Design Pattern


Benefits
Acquire multiple sets of data
that must be processed in order
Queues data in the consumer
loop

Considerations
Timing the producer
Sending data from the
consumer to the producer

ni.com/training

Demonstration Producer/Consumer (Data)


Design Pattern

Observe the functionality and design of the


producer/consumer (data) design pattern.
DEMONSTRATION

B. Event-Based Design Patterns


Event-Driven Programming
Event-Based Design Patterns

ni.com/training

Event-Driven Programming
Events influence block diagram execution
Events are asynchronous notification that something has
occurred
Events originate from the user interface, external I/O, or
other parts of the program
Configure events by right-clicking the Event structure border
and selecting Edit Events Handled by This Case from the
shortcut menu
Event registration ensures no events are missed or
processed out of order
ni.com/training

Event-Based Design Patterns


User Interface Event Handler
Producer/Consumer(Events)

ni.com/training

User Interface Event Handler


1. Event structureConfigured to have one frame for each
category of event you want to detect
2. While Loop
3. Timeout terminalControls when the Timeout event
executes
4. Event Data Node

ni.com/training

Demonstration: User Interface Event Handler

Observe the functionality and design of the user interface


event handler design pattern
DEMONSTRATION

Producer/Consumer (Events)

Benefits:
Efficiently responds asynchronously to the user interface
Queues can transfer any data type
ni.com/training

Demonstration Producer/Consumer (Events)

Observe the functionality and design of the


producer/consumer (events) design pattern
DEMONSTRATION

C. Advanced Event-Based Design Patterns


How can we send messages from the consumer to the
producer?
Local Variable?
Global Variable?
Synchronization Techniques?
Events?
Take advantage of the Event structure in the producer loop by
defining user events
ni.com/training

Producer/Consumer (Events) with User Events

Producer
User
Event

Queue
Consumer

ni.com/training

User Events
Create
& Register
User Event

Generate
User Event

Unregister
User Event

Destroy
User Event

ni.com/training

Creating and Registering User Events

ni.com/training

Creating and Registering User Events

ni.com/training

Generating User Events


Generate User Event function:
Sends the user event and associated event data to
each Event structure registered to handle the event

ni.com/training

Unregistering User Events


Unregister and destroy user events when
you no longer need them

ni.com/training

Producer/Consumer (Events) with User Events

ni.com/training

Exercise 4-1: User Event Techniques

Complete a VI that contains a static user interface event and a


user event
GOAL

Exercise 4-1: User Event Techniques

User events give you the ability to programmatically generate


events
User events provide a method for communicating between loops
A reference is created for the Event Fired indicator and modifies
that indicator in the Flash LED subVI

DISCUSSION

Design
Pattern
Guide

ni.com/training

Course Project Select a Design Pattern


Refer to the requirements document for the Theatre Light
Controller project and answer the following questions to select
a design pattern for the project.

ni.com/training

Course Project Select a Design Pattern


Will the application contain a
sequence?

ni.com/training

Course Project Select a Design Pattern


Will the application need to
respond to the user
interface?

ni.com/training

Course Project Select a Design Pattern


Will the application need to
be capable of intensive
processing?

ni.com/training

Course Project Select a Design Pattern


Because the application must
respond to the user interface
and certain cases require
time-intensive processing, the
best design pattern choice is:
Producer/Consumer (events)
with user events.

ni.com/training

D. Creating a Hierarchical Architecture


Designing a hierarchical architecture involves designing
individual VIs that perform specific functions
Evaluate design quality using the following criteria:
CouplingConnection that exists among modules (ideal:
low coupling)
CohesionHow well a single module focuses on a single
goal (ideal: high cohesion)

ni.com/training

E. Working with LabVIEW Projects


Using the LabVIEW Project
Using Project Folders
Using Project Libraries

ni.com/training

Using the LabVIEW Project


Use Project Explorer to create and edit LabVIEW Projects
Project Explorer window includes the Project root, My
Computer, Dependencies, and Build Specifications

ni.com/training

Project Explorer Window


Items page

Files page

ni.com/training

Saving a Project
You must save new, unsaved files in a project before you
can save the project
When you save a project, LabVIEW does not save items
under Dependencies as part of the project file
Select FileSave Project to save a project

ni.com/training

Using Project Folders


Virtual folder
Organizes project items and does not represent files on disk

Auto-populating folder
Adds a directory on disk to the project
LabVIEW continuously monitors and updates the folder
according to changes made in the project and on disk

ni.com/training

Project Dependencies
Select Dependencies to open the list of subVIs that VIs
under a given target require
Right-click Dependencies and select Refresh from the
shortcut menu to update the list

ni.com/training

Using Project Libraries


Collections of VIs, type definitions, shared variables, palette
menu files, and other files
Organize files into a single hierarchy of items
Avoid potential VI name duplications
Limit public access to certain files
Do not contain the actual files they own
Maintain a two-way link with VIs

ni.com/training

Configuring Access Options in Project Libraries


Items in a library can be:
Public
Community
Private

Public items are visible when users view the project library.
Other VIs and applications can call public VIs
Private items do not appear visible when users view the
project library or palettes. Other VIs and applications that the
project library does not own cannot call a private VI
ni.com/training

Organizing Project Libraries


Create each project library within a separate LabVIEW
project that contains only files related to that project library
Create a separate directory of files for each project library
you create
If you move files on disk that a project library owns, reopen
and save the project library.
Make sure that you save the files that a project library owns
on the same drive as the project library
The hierarchy of a project library trumps the hierarchy of an
auto-populating folder
ni.com/training

LabVIEW Classes
A LabVIEW class is a special type of project library where
the member VIs collectively define a new data type
Consider classes as a more
powerful cluster type
Consists of:
A data control (cluster)
Member VIs to access that data

ni.com/training

Exercise 4-2: Using the LabVIEW Project

Create a LabVIEW project for the application


GOAL

Exercise 4-2: Using the LabVIEW Project

Throughout this course, you will use the LabVIEW project file that
you created in this exercise to build the TLC application
LabVIEW projects are not necessary for every application, but
they are required for any application that you want to build into an
executable

DISCUSSION

Project Explorer Tools

Find SubVIs
Find Callers
Find Project Items
Resolve Conflicts

ni.com/training

Find SubVIs
Finds all subVIs of a specific item in the project

ni.com/training

Find Callers
Finds all callers of a specific item in the project

ni.com/training

Find Project Items


Finds all callers of a specific item in the project
Select EditFind Project Items or press <Ctrl-F>

ni.com/training

Resolve Conflicts
Projects can contain items that conflict with other items in the
project

ni.com/training

Examples of Conflicts
Two VIs within a project have the same name
A VI in the project is calling a subVI outside the project that
has the same name as a VI in the project

ni.com/training

Show Item Paths


View the full path to items to determine if cross-linking exists
In the menu bar, select ProjectShow Item Paths

ni.com/training

Methods for Resolving Conflicts


Renaming files with unique names
Project Explorer updates all referencing items with new names

Using the Resolve Conflicts tools


Click the Resolve Conflicts button in the Project Explorer to
display the Resolve Project Conflicts dialog box

ni.com/training

Resolve Project Conflicts Dialog Box

ni.com/training

Exercise 4-3: Using Project Explorer Tools

Use the Project Explorer tools to resolve conflicts and


manage files in a project.
GOAL

Exercise 4-3: Using Project Explorer Tools

Conflicts can arise from using multiple files with the same name
Always be as specific as possible when naming your files

Auto-populating folders help ensure that your project hierarchy


matches your file structure on disk

DISCUSSION

F. Choosing Data Types

Scalar Data
Arrays
Clusters
LabVIEW Class

ni.com/training

Scalar Data
Most basic data structure in LabVIEW
Examplesa number, a Boolean value
Use scalar data only if future modifications will not require a
more complex data structure

ni.com/training

Arrays of Data
Arrays group data elements of the same type
Use arrays when:
Data includes more than one element of the same data type
Each data element is associated with the others

ni.com/training

Clusters of Data
Data structures that contain any type of data
A cluster is very useful for storing data about objects
Use clusters when you need to group data into an individual
data type

ni.com/training

Type Definitions
For any data type that controls execution of your application,
save the data type as a type definition
Type-defined data types are more scalable
Modifications to the type definition are propagated to each
instance of that data type in your applications

Always create a type definition for complex data types to


ensure consistency
Clusters
Enumerated type control
ni.com/training

LabVIEW Classes
A LabVIEW class is a more powerful cluster data type
Class file (.lvclass) stores class information
Data control definition (the data stored as part of the cluster)
List of member VIs
Properties for each member VI
Properties of the class itself (such as wire appearance)

ni.com/training

Exercise 4-4: Choose Data Types

Design and create the data types that you need for this
application.
GOAL

Exercise 4-4: Choose Data Types

You can use the type-defined cluster created in this exercise


throughout the TLC project
Type-defined data types improve the scalability and
maintainability of a project
DISCUSSION

G. Information Hiding
In this example, it is possible for any module to access the
global variable and change its value without any other module
knowing that the global variable has changed.

First VI accesses data in


a global variable

Second VI accesses the same data


in a global variable

ni.com/training

Information Hiding
Implement information hiding by creating a VI that accesses
the global data
Read and write to the global data by calling the VI
Information hiding protects the global data
Good
Information
Hiding:

ni.com/training

Functional Global Variables


Control access to data in a shift register
Eliminates the possibility
of a race condition

ni.com/training

Functional Global Variables


Common applicationperform
timing
Measures elapsed
time between
each call to the
subVI

ni.com/training

Encapsulation

A LabVIEW class restricts access to the data stored within it


Member VI Diagram

Non-Member VI Diagram
Illegal
Legal

ni.com/training

Exercise 4-5: Information Hiding

Design a VI that provides an interface to the data


GOAL

Exercise 4-5: Information Hiding

tlc_Cue Module.vi can perform a wide range of functions

Each time this module executes, it retains data from the previous
execution
This is a clean, efficient method for passing data throughout an
application

DISCUSSION

H. Designing Error Handling Strategies


Three primary strategies:
Design a system that is proactive in determining if an error
will occur.
Design corrective error processing that determines the error
and fixes the error
Design a system that simply passes errors through the
system

ni.com/training

Designing Error Handling Strategies


By default, LabVIEW automatically handles errors by suspending
execution
You can program other error handling methods
VIs and functions return errors in one of two wayswith numeric
error codes (functions) or with an error cluster (VIs)
Error codes reserved for defining custom error messages:
8999 through 8000
5000 through 9999
500,000 through 599,999

Use the General Error Handler VI to define custom error codes


ni.com/training

Define Custom Error Codes


Use the General Error Handler VI to define custom error
codes

ni.com/training

Define Custom Error Codes


Error Code File Editor creates an XML-based text file in the
<labview>\user.lib\errors directory
Useful when
Using the same custom error codes with several VIs
Distributing custom error codes with an application or shared
library

ni.com/training

Exercise 4-6: Design an Error Handling Strategy

HOMEWORK:
Develop a strategy to handle errors in the application
GOAL

Exercise 4-6: Design an Error Handling Strategy

In this exercise, you identified a possible error, defined a custom error


code for that error, and developed code to handle that problem
Identify potential sources of errors early in development
Place custom error code files in <labview>\user.lib\errors

DISCUSSION

Summary Quiz
1. Which of the following describes good module hierarchy?
a.
b.
c.
d.

High cohesion and high coupling


High cohesion and low coupling
Low cohesion and high coupling
Low cohesion and low coupling

ni.com/training

Summary Quiz Answer


1. Which of the following describes good module hierarchy?
a.
b.
c.
d.

High cohesion and high coupling


High cohesion and low coupling
Low cohesion and high coupling
Low cohesion and low coupling

ni.com/training

Summary Quiz
2. Which design pattern is best suited for an application that
can be described using a state transition diagram?
a.
b.
c.
d.

State machine
Master/slave
User interface event handler
Producer/consumer (data)

ni.com/training

Summary Quiz Answer


2. Which design pattern is best suited for an application that
can be described using a state transition diagram?
a.
b.
c.
d.

State machine
Master/slave
User interface event handler
Producer/consumer (data)

ni.com/training

Summary Quiz
3. Which design pattern is best suited for a non-sequential
application that requires that the user interface events and
updates be separated from processor-intensive code?
a.
b.
c.
d.

Queued message handler


Master/slave
Parallel loop
Producer/consumer (events)

ni.com/training

Summary Quiz Answer


3. Which design pattern is best suited for a non-sequential
application that requires that the user interface events and
updates be separated from processor-intensive code?
a.
b.
c.
d.

Queued message handler


Master/slave
Parallel loop
Producer/consumer (events)

ni.com/training

Lesson 5:
Implementing the User Interface
TOPICS
A. Implementing User Interface-Based Data Types
B. Implementing Meaningful Icons
C. Implementing Appropriate Connector Panes

ni.com/training

A. Implementing User Interface-Based


Data Types
Text-based programming languagesDeclare variables
LabVIEWStores data as it flows through the VI
User interface-based data types
Block diagram constants

ni.com/training

User Interface-Based Data TypesScalar Data


Ring ControlsAssociate numeric values with strings or pictures
You can change string labels programmatically
Use a ring control instead of a Boolean control for scalability

Enumerated Type ControlsInclude information about the


numeric values and the string labels in the control
Cannot change string labels programmatically at run time
Make a type definition to ease code redevelopment

Numeric Scalar Data


Choose data types that provide a more accurate range for the data
that you want to store
Example: Range of values = 0 to 10 integers => Choose a U8

ni.com/training

User Interface-Based Data TypesArrays


Output arrays to a graphEasier to view the array data in a graph
Array restrictions: You CANNOT create
An array of arrays
An array of subpanel controls
An array of tab controls
An array of ActiveX controls
An array of charts
An array of multiplot XY graphs
ni.com/training

User Interface-Based Data TypesClusters


Group data elements of mixed types
Create a type definition of the cluster for future additions
Advantages:
Eliminates wire clutter on the block diagram
Reduces the number of connector pane terminals
Creates specific, organized data objects
ni.com/training

Exercise 5-1: Implement User Interface-Based


Data Types

HOMEWORK:
Implement user interface-based data types
GOAL

Exercise 5-1: Implement User Interface-Based


Data Types

In this exercise, you:

Created a VI from a design pattern template


Created the user interface for the TLC Main VI
Created custom controls for the TLC Main VI
Used the type-defined control that you previously built

You will focus on this VI for most of the remaining exercises in the course

DISCUSSION

B. Implementing Meaningful Icons


An icon represents a VI on a palette and a block diagram
Suggestions:
Create a meaningful icon for every VI
Avoid colloquialisms when making an icon
Create a unified icon style for related VIs
Use standard size (32 32 pixel) icons
Enclose the icon with a border to ensure the subVI is visible
on the block diagram
Use project libraries to apply an icon template
ni.com/training

Implementing Meaningful Icons


Disk, printer, pencil, and
trash can images represent
action
Paper with text represents
a reportCommon
element unifies the icon
designs
No language dependency

ni.com/training

Exercise 5-2: Implement a Meaningful Icon

HOMEWORK:
Implement a meaningful icon for the VI
GOAL

Exercise 5-2: Implement a Meaningful Icon

Are there any disadvantages to the icon you created?


DISCUSSION

C. Implementing Appropriate Connector Panes


Connector PaneSet of terminals that correspond to the
controls and indicators of a VI
Suggestions for creation:
Include extra terminals
Use the 4 2 2 4 pattern, shown at right
Inputs on the left and outputs on the right
Choose the same connector pane pattern for related VIs
ni.com/training

Implementing Appropriate Connector Panes


Suggestions, continued:
Use connector patterns with 16 or fewer terminals. If you
need to pass more data, use clusters
When assigning terminals, keep in mind how the VIs will be
wired together
Use the Required, Recommended, and Optional settings
for every terminal

ni.com/training

Implementing Appropriate Connector Panes


Suggestions, continued:
Include error in and error out clusters on all subVIs, even if
the subVI does not process errors
Strive for similar arrangements between front panel and
connector pane layouts

ni.com/training

Implementing Appropriate Connector Panes

ni.com/training

Implementing Appropriate Connector Panes

ni.com/training

Exercise 5-3: Implement an Appropriate


Connector Pane

HOMEWORK:
Implement an appropriate connector pane for the TLC Main VI
GOAL

Exercise 5-3: Implement an Appropriate


Connector Pane

A VI that is called by other VIs must have the connector


pane wired if you want to pass data to it from the calling VI
Consistent connector panes help to keep your block
diagrams cleaner and minimize wire bends
DISCUSSION

Summary Quiz
1. Which of the following array types can you create in
LabVIEW? (Multiple answers)
a.
b.
c.
d.

An array of Boolean arrays


An array of two clusters, with each cluster containing an array
of Boolean values
An array of tab controls
An array of tree controls

ni.com/training

Summary Quiz Answer


1. Which of the following array types can you create in
LabVIEW? (Multiple answers)
a. An array of Boolean arrays
b. An array of two clusters, with each cluster containing an
array of Boolean values
c. An array of tab controls
d. An array of tree controls

ni.com/training

Summary Quiz
2. Which of the following methods helps create a unified
icon style among a group of VIs? (Multiple answers)
a.
b.
c.
d.

Place the VIs into the same project


Place inputs on the left side of the front panel and outputs on
the right side
Place the VIs into a project library
Place a common image on the icon for each VI

ni.com/training

Summary Quiz Answer


2. Which of the following methods helps create a
unified icon style among a group of VIs? (Multiple
answers)
a.
b.

Place the VIs into the same project


Place inputs on the left side of the front panel and outputs on
the right side
c. Place the VIs into a project library
d. Place a common image on the icon for each VI

ni.com/training

Summary Quiz
3. Which connector pane terminal setting should you use for
inputs that users must wire for a calling VI to run properly?
a.
b.
c.
d.

Required
Recommended
Optional
None of the above

ni.com/training

Summary Quiz Answer


3. Which connector pane terminal setting should you use for
inputs that users must wire for a calling VI to run properly?
a.
b.
c.
d.

Required
Recommended
Optional
None of the above

ni.com/training

Lesson 6: Implementing Code


TOPICS
A.
B.
C.
D.
E.

Implementing a Design Pattern


Practicing LabVIEW Style Guidelines
Timing a Design Pattern
Developing Scalable and Maintainable Modules
Implementing an Error Handling Strategy
ni.com/training

A. Implementing a Design Pattern


When you implement scalable architecture, consider how you
want to handle the following items:
Initializing a design pattern
Selecting data types for passing data

ni.com/training

Initializing a Design Pattern

Single Frame
Sequence Structure

ni.com/training

Initializing a Design Pattern

Initialization
State

ni.com/training

Initializing a Design Pattern


Initialize shift registers or feedback nodes
Wire any value from outside the loop to the left shift register
terminal to initialize the shift register

ni.com/training

Selecting Data Types for Passing Data


Two data types in LabVIEW that can adapt to any other data
type
Variants
Strings

A cluster containing a variant and an enum provides


flexibility

ni.com/training

Variant Data
Use To Variant to convert
any data type in LabVIEW
to a variant
Use Variant to Data to
convert a variant into any
LabVIEW data type
Variants are not supported
on LabVIEW Real-Time
Use strings or LabVIEW
classes
ni.com/training

Selecting Data Types for Passing Data

ni.com/training

Exercise 6-1: Implement the Design Pattern

ni.com/training

Exercise 6-1: Implement the Design Pattern

Use LabVIEW to implement a design pattern as the basis for


the application architecture.
GOAL

Exercise 6-1: Implement the Design Pattern

This exercise establishes the code architecture you will use for the rest of the
course project
Design patterns are only starting points for developing an architecture
Using type-defined data, events, and Case structures help make an
application more scalable
Custom menus help to remove functionality from the user interface

DISCUSSION

B. Practicing LabVIEW Style Guidelines


Following style guidelines as you develop code helps prevent bugs or
errors
Use the following suggestions to maintain consistent style and quality:

Maintain appropriate block diagram size


Use proper wiring techniques
Document your code
Develop self-documenting code
Organize the file structure

Refer to the LabVIEW Style Checklist topic of the LabVIEW Help for
more guidelines.
ni.com/training

Maintain Appropriate Size of Block Diagram


Affects readability of LabVIEW code
Make block diagram windows no larger than
1024 x 768 pixels
LabVIEW code in the window should not be too large
Forces user to scroll through the window
If necessary, require user to scroll in only one direction,
horizontal or vertical

ni.com/training

Use Proper Wiring Techniques


Avoid placing any wires under block diagram objects such as
subVIs or structures; draw your wires so that you can clearly see
if a wire correctly connects to a terminal
Add as few bends in the wires as possible and keep the wires
short
Delete any extra wires
Avoid the use of local variables when you can use a wire to
transfer data
Do not wire through structures if the data in the wire is not used
in the structure
Space parallel wires evenly in straight lines and around corners
ni.com/training

Document Your Code


Use comments on block diagrams to explain what the code is
doing
Use free labels on wires to identify their use
Use labels on structures to specify the main functionality
Use labels on constants to specify the nature of the constant
Use labels on Call Library Function Nodes to specify what
function the node is calling and the path to the library being
called
Use comments to document algorithms that you use on the block
diagrams
ni.com/training

Document Your Code


Express VIs hide functionality
that can be viewed in the
Context Help
Improve readability by
documenting this information on
the block diagram

ni.com/training

Develop Self-Documenting Code

ni.com/training

Organize the File Structure

Organize VIs to reflect the hierarchical nature of the software


Make top-level VIs directly accessible
Project hierarchy should be similar to the file organization of the
files on the system
ni.com/training

C. Timing a Design Pattern


Two forms of timing you can implement with a scalable
architecture:
Execution timingControls how quickly a scalable
architecture executes on the processor
Software control timingTimes a real-world operation to
perform within a set time period

ni.com/training

Execution Timing
Design patterns where the
timing is based on the
occurrence of events do not
need execution timing

ni.com/training

Software Control Timing


Using Wait (ms) or Wait Until Next ms Multiple allows
execution to occur after the wait function finishes
Software control timing must allow the design pattern to run
continuously without stopping

ni.com/training

Get Date/Time in Seconds

Note: Always use Get Date/Time in Seconds instead of Tick


Count, because the Tick Count function can rollover to 0.
ni.com/training

Software Control Timing


Using Get Date/Time In Seconds in a functional global
variable for software control timing

ni.com/training

Software Control Timing


Functional global variable can make a VI more readable and
easier to understand.

ni.com/training

Synchronization Timeout

Consumer executes every 50 ms even if the queue is empty


Allows a function to be executed in the consumer loop
ni.com/training

Event Structure Timeout


Wiring a millisecond value to the timeout terminal of an Event
structure wakes the Event structure and executes the code in
the Timeout case

ni.com/training

Timed Structures
Use timed structures on the block diagram to repeat blocks
of code and to execute code in a specific order with time
bounds and delays
Two timed structures
Timed Sequence Structure
Timed Loop

ni.com/training

Exercise 6-2: Timing

Create a functional global variable that uses the Get


Date/Time In Seconds function to provide accurate software
controlled timing.
GOAL

Exercise 6-2: Timing

Implement software control timing to ensure the application


responds to the user within 100ms
A functional global variable implements the software control
timing
How else could you implement software control timing?

DISCUSSION

D. Developing Scalable and Maintainable Modules


Develop with loose coupling and strong cohesion
Functional global variable design pattern is the basis for
each module
Each VI has a user
interface that clearly
indicates the Input,
Local Data and
Output parameters
of the VI
ni.com/training

Recommendations for Module Development

Module inputs and outputs are self-verifying


Each module handles its own errors
Modules are easy to modify without affecting other modules
Each module has a simple interface for accessing its data
Each module stores its own state locally and persistently

ni.com/training

Developing Modules Using Organized SubVIs


Create a set of related subVIs that perform each of the
functions required of the module
Use a consistent style when implementing each VI in your
module
Create a directory on disk for each module to organize the
files on the disk
Use LabVIEW Project Libraries to organize the VIs into a
module

ni.com/training

Developing Modules Using a Multi-Functional VI


Uses a Case structure controlled by an enumerated control
Command the module using an enumerated type
Store data in the module by using a shift register on a single
iteration While Loop

ni.com/training

Exercise 6-3: Implement Code

Observe and implement the VIs that you identified as modules


for the application
GOAL

Exercise 6-3: Implement Code

A display loop further separates the user interface from the processing of commands
Producer loopmonitors user activity
Consumer loopprocesses data that the user generates
Display loophandles all updates to the user interface

Functional global variable used for display module


You will use the display, file, and hardware modules in later exercises

DISCUSSION

E. Implementing an Error Handling Strategy


Purpose of an error handling strategy:
Determine if an error occurs
Determine what should happen if a VI generates an error

Typical strategies for handling an error include:


Passing the error outside the VI
Displaying a dialog box that informs the user of the error

ni.com/training

Implementing an Error Handling Strategy


Passing the error outside the VI
Can be ineffective for code with loose coupling because the
error is handled by an external routine
Commonly used for VIs that are part of an API

Displaying a dialog box that informs the user of the error


Indicates the error to the user and provide a meaningful
description and a resolution to the error
Uses the General Error Handler VI to create an error handler
specific to the application
ni.com/training

Exercise 6-4: Implement Error Handling Strategy

ni.com/training

Exercise 6-4: Implement Error Handling Strategy

HOMEWORK:
Develop a module that handles the errors in the application
GOAL

Exercise 6-4: Implement Error Handling Strategy

This module handles errors for the entire application


When an error is being handled, this module:
Flushes the consumer and display loop queues
Sends a command to each loop to stop execution

DISCUSSION

Summary Quiz
1. Which of the following LabVIEW data types can adapt to any
other data type? (Multiple answers)
a.
b.
c.
d.

Numeric
String
Variant
Boolean

2. Where can you find the LabVIEW Style Checklist?


a.
b.
c.
d.

Searching the LabVIEW Help


Browsing the NI Example Finder
Selecting FileLabVIEW Style Checklist from the menu
Searching the <labview>\Manuals folder on disk
ni.com/training

Summary Quiz Answers


1. Which of the following LabVIEW data types can adapt to any
other data type? (Multiple answers)
a.
b.
c.
d.

Numeric
String
Variant
Boolean

2. Where can you find the LabVIEW Style Checklist?


a.
b.
c.
d.

Searching the LabVIEW Help


Browsing the NI Example Finder
Selecting FileLabVIEW Style Checklist from the menu
Searching the <labview>\Manuals folder on disk
ni.com/training

Summary Quiz
3. You need to connect two terminals that are at opposite
ends of a block diagram that contains a large Event
structure in a While Loop. Which is the preferred wiring
technique?
a.
b.
c.
d.

Use a local variable to avoid long wires


Hide the long wire by wiring under the While Loop
Minimize bends by wiring through the While Loop
Wire around the While Loop

ni.com/training

Summary Quiz Answers


3. You need to connect two terminals that are at opposite
ends of a block diagram that contains a large Event
structure in a While Loop. Which is the preferred wiring
technique?
a.
b.
c.
d.

Use a local variable to avoid long wires


Hide the long wire by wiring under the While Loop
Minimize bends by wiring through the While Loop
Wire around the While Loop

ni.com/training

Lesson 7:
Implementing a Test Plan
TOPICS
A.
B.
C.
D.

Verifying the Code


Implementing a Test Plan for Individual VIs
Implementing a Test Plan for Integrating VIs
Implementing a Test Plan for the System

ni.com/training

A. Verifying the Code


During the code review, discuss quality goals and consider the
following questions:
Does the design incorporate testing?
Is error handling built-in?
Are there any assumptions in the system that might be
invalid?

ni.com/training

Code Reviews
During the code review, discuss quality goals and consider the
following questions:
What happens if a specific VI or function returns an error?
Are there any race conditions?
Is the block diagram implemented well?
Are the algorithms efficient in terms of speed and/or memory
usage?
Is the block diagram easy to maintain?
Does the developer adhere to established guidelines?
ni.com/training

B. Implementing a Test Plan for Individual VIs


Test each VI as you complete it
Develop test cases that can identify the largest number of
errors in the application
Goal of a test plan is to find the majority of errors

ni.com/training

Creating a Test Plan for Individual VIs


Use the following list to help identify what you need to test:
Requirements in the requirements document
Error handling and reporting capabilities of the VI

ni.com/training

Functional Tests
Determine whether a VI functions as expected
Boundary Conditions Values above or below a set
maximum
Hand Checks Pass a set of data with a known return value

ni.com/training

Boundary Conditions
Requirements state a maximum value
Sample test parameters:
maximumvalue+1
maximumvalue1
maximumvalue

ni.com/training

Hand Checking
If you know the value that a VI should return when run with a
certain set of inputs, use those values as a test
Sin(253.4569)= Difficult to know the answer
Sin(3.14159)= Answer is known and exercises the VI
the same way as 253.4569 because the values are of the
same data type

ni.com/training

Error Tests
Test the error handling codecreate test plans that force
errors
Verify that the proper errors are reported and recovered
Verify that the error handling code handles errors gracefully

ni.com/training

C. Implementing a Test Plan for Integrating VIs


Use integration testing to test the individual VIs as you
integrate them into a larger system
Top-down
Bottom-up
Sandwich Testing

Perform regression testing at each step to verify that


previously tested features still work

ni.com/training

Top-Down Integration Testing

Build stub VIs to represent undeveloped modules


Replace stub VIs as you develop components
Test as you replace each stub VI

AdvantageIdentifies major control errors earlier


DisadvantageRequires time and effort to develop stub VIs
ni.com/training

Bottom-Up Integration Testing

Test the lowest-level VIs first, using driver VIs or control programs
As you proceed, replace control programs with VIs that are higher in
the hierarchy

AdvantageInteraction with lower-level components early in


testing
DisadvantageTop-level control and decision algorithms are not
tested until the very end of the testing process
ni.com/training

Sandwich Testing

Uses top-down tests to test upper-level control


Uses bottom-up tests to test low-level hardware and system
functionality

ni.com/training

Exercise 7-1: Integrate Initialize and Shutdown


Functions

ni.com/training

Exercise 7-1: Integrate Initialize and Shutdown


Functions

HOMEWORK:
Initialize and shutdown a set of code modules
GOAL

Exercise 7-1: Integrate Initialize and Shutdown


Functions

Each code module requires initialization and shutdown


You can expand integration VIs as needed for future
development
What type of integration testing is performed?
DISCUSSION

Exercise 7-2: Integrate Display Module

HOMEWORK:
Update the front panel controls
GOAL

Exercise 7-2: Integrate Display Module

The display loop separates programmatic UI updates from the


producer loop and the intensive processing of the consumer loop
Either the producer loop or the consumer loop can send UI updates
How can you implement a subVI to handle updating the user
interface?

DISCUSSION

Exercise 7-3: Integrate Record Function

ni.com/training

Exercise 7-3: Integrate Record Function

HOMEWORK:
Pass data from the user interface to the rest of the application.
Use an Event structure to create a dialog box
GOAL

Exercise 7-3: Integrate Record Function

Testing the integration of this function uses all three loops


User interaction in the producer loop triggers processing of
data in the consumer loop
The display loop handles front panel updates
DISCUSSION

Exercise 7-4: Integrate Play Function

ni.com/training

Exercise 7-4: Integrate Play Function

HOMEWORK:
Execute a state machine design pattern in a
producer/consumer (events) design pattern
GOAL

Exercise 7-4: Integrate Play Function

TLC application architecture consists of:


TLC Main: producer/consumer with user events
tlc_Play: state machine

Applications often require the use of multiple design patterns to develop the overall
architecture
tlc_Play works with the timing module to calculate new intensity and color values and
works with the display loop to update the UI as it executes

DISCUSSION

Exercise 7-5: Integrate Error Module

ni.com/training

Exercise 7-5: Integrate Error Module

HOMEWORK:
Integrate an error handling module into the design pattern
GOAL

Exercise 7-5: Integrate Error Module

An error in any of the three loops of the TLC Main VI halts


execution in all three loops
The Simple Error Handler VI reports all errors to the user
DISCUSSION

D. Implementing a Test Plan for the System


Your company may have its own method for testing a system
System tests focus on the following areas
Configuration
Performance
Stress/Load
Functionality
Reliability
Usability

ni.com/training

Configuration Tests
Test variations in system and software configurations
Test on multiple operating systems, as stated by
requirements document
Test on different screen resolutions (minimum and
maximum) for proportionality and distortion

ni.com/training

Performance Tests
System responds to the user within the predefined limits
The software performs well with external hardware and
interfaces
Define and verify performance benchmarks for features of
the VI
Includes tests for:
Execution Time
Memory Usage
File Sizes
ni.com/training

Stress/Load Tests
Push a VI beyond the required limits in the specifications
Examples:
Large quantities of data
Extended time testing
Running a large number of applications concurrently

ni.com/training

Functionality Tests
Check functionality to the level stated in the requirements
document
Must involve the customer

ni.com/training

Reliability
Pilot testing (alpha and beta) to test system in nondevelopment environment
Alpha and beta testing are not substitutes for other forms of
testing that rigorously test each component

ni.com/training

Usability
Measures the potential of a system to accomplish the
goals of the user
A usable VI has the following characteristics:
Easy to learn
Easy to remember
Enjoyable to use
Efficient to use
Provides quick recovery
Visually pleasing
from errors

ni.com/training

Exercise 7-6: Stress and Load Testing

Perform stress and load testing on the application


GOAL

Exercise 7-6: Stress and Load Testing

Example of the type of testing that should occur before


shipping a finished product
What are the advantages of performing these tests prior to
creating an executable?
DISCUSSION

Summary Quiz
1. Top-down, bottom-up, big-bang, and sandwich are all
methods of performing what kind of test?
a.
b.
c.
d.

Regression
Integration
Performance
Usability

ni.com/training

Summary Quiz Answer


1. Top-Down, bottom-up, and sandwich are all methods of
performing what kind of test?
a.
b.
c.
d.

Regression
Integration
Performance
Usability

ni.com/training

Summary Quiz
2. Which type of test involves testing at each step of
integration to verify that previously tested features still
work?
a.
b.
c.
d.

Regression
Stress/load
Performance
Configuration

ni.com/training

Summary Quiz Answer


2. Which type of test involves testing at each step of
integration to verify that previously tested features still
work?
a.
b.
c.
d.

Regression
Stress/load
Performance
Configuration

ni.com/training

Summary Quiz
3. Which of the following are foci of system testing? (Multiple
answers)
a.
b.
c.
d.
e.

Performance
Stress/load
Functionality
Code style
Usability

ni.com/training

Summary Quiz Answer


3. Which of the following are foci of system testing? (Multiple
answers)
a.
b.
c.
d.
e.

Performance
Stress/load
Functionality
Code style
Usability

ni.com/training

Lesson 8:
Evaluating VI Performance
TOPICS
A. Identifying Performance Problems
B. Using VI Metrics to Identify VI Issues
C. Fixing Performance Problems

ni.com/training

A. Identifying Performance Problems


Make it Right, Then Make It FastAnonymous
Cost of Developer > Cost of Computer
Development Goals:
Use good design principles to create a VI that works
correctly
Improve performance
ni.com/training

The 80/20 Rule

Certain parts of code use more execution time than others


Little benefit to optimizing code that is not part of this 20%

Identify which portions of code are part of this 20%


Profile Performance and Memory window

ni.com/training

Profile Performance and Memory Window

ni.com/training

B. Using VI Metrics to Identify VI Issues


Use the VI metrics tool to identify the following issues:
Inappropriate use of local variables
Deep nesting of the
block diagram and
overuse of structures
Oversized block
diagrams

ni.com/training

Exercise 8-1: Identify VI Issues with VI Metrics

Determine the complexity of the VI


GOAL

Exercise 8-1: Identify VI Issues with VI Metrics

In this exercise, VI Metrics measures the complexity of the VI


Use the information on VI complexity to estimate development
effort for future development projects
Use the statistics to identify a variety of problems

DISCUSSION

C. Fixing Performance Problems


Performance Issues:
Memory: Reallocation buffers and coercion
Speed of execution: Input/output and screen display

ni.com/training

Memory Reallocation Buffers


LabVIEW tries to minimize the reallocation of memory
Functions that are likely to cause memory reallocation:
Build Array function
Concatenate Strings function

Large Number of Reallocations

Low Number of Reallocations


ni.com/training

Memory Reallocation Buffers


Preallocate an array if you:
Conditionally add values to an
array
Can determine an upper limit on
the array size

ni.com/training

Coercion
To improve memory use:
Minimize coercion
Eliminate coercion entirely

ni.com/training

VI Execution Speed
Examine the following items to determine the causes of slow
performance:
Input/Output (I/O) (files, GPIB, data acquisition, networking)
Screen Display (large controls, overlapping controls, too many
displays)

Other factors, such as execution overhead and subVI call


overhead, can have an effect but these are usually minimal

ni.com/training

Input/Output
For examplefiles, GPIB, data acquisition, networking
Reduce the number of I/O calls you make
Structure application to transfer large amounts of data with
each call, rather than multiple I/O calls with smaller amounts
of data

ni.com/training

Screen Display
Reduce number of controls
Keep displays as simple as possible
For charts and graphs, turn off autoscaling, scale markers,
and grids
Do not overlap controls
Pass larger amounts of data to a chart at a time
Leave asynchronous display as the default setting for
controls
ni.com/training

Defer Front Panel Updates on Property Nodes

ni.com/training

Reentrant Execution and SubVI Memory Use


Multiple instances of a subVI can execute in parallel
Each instance uses distinct and separate data storage

ni.com/training

Methods of Updating the User Interface


Three primary methods for updating a value on the user
interface
Wire data directly to an indicator
Wire data to a local variable
Wire data to a Value Property Node

ni.com/training

Exercise 8-2: Methods of Updating Indicators

Compare the performance of different methods for updating


indicators
GOAL

Exercise 8-2: Methods of Updating Indicators

Which method for updating the user interface was the


fastest? Was this what you expected?
Which method was the slowest?
When is the best use of each method?
DISCUSSION

Summary Quiz
1. What are possible reasons for the VI Metric tool to report
a high number of structures and a high number of
diagrams? (Multiple answers)
a.
b.
c.
d.

Deep nesting of Case structures


Too many reentrant subVI calls
Overuse of Sequence structures
Oversized block diagram

ni.com/training

Summary Quiz Answer


1. What are possible reasons for the VI Metric tool to report
a high number of structures and a high number of
diagrams? (Multiple answers)
a.
b.
c.
d.

Deep nesting of Case structures


Too many reentrant subVI calls
Overuse of Sequence structures
Oversized block diagram

ni.com/training

Summary Quiz
2. Which of the following function(s) can slow VI execution
by causing memory reallocation?
a.
b.
c.
d.

Build Array
Initialize Array
Replace Array Subset
Transpose 2D Array

ni.com/training

Summary Quiz Answer


2. Which of the following function(s) can slow VI execution
by causing memory reallocation?
a.
b.
c.
d.

Build Array
Initialize Array
Replace Array Subset
Transpose 2D Array

ni.com/training

HOMEWORK: Lesson 9:
Implementing Documentation
TOPICS
A.
B.
C.
D.

Designing Documentation
Developing User Documentation
Describing VIs, Controls, and Indicators
Creating Help Files

ni.com/training

Lesson 10:
Deploying the Application
TOPICS
A. Implementing Code for Stand-Alone Applications
B. Building a Stand-Alone Application
C. Building an Installer

ni.com/training

A. Implementing Code for Stand-Alone


Applications
Consider the following when building a stand-alone
application:
Paths used by stand-alone applications can change
The behavior of stand-alone applications is similar to
standard applications that the user launches directly from
the operating system
Users of stand-alone applications need not recognize that
the applications are LabVIEW VIs

ni.com/training

Relative File Path Handling


Set paths relative to Application Directory VI path:
If called from a stand-alone application, returns the path to
the folder containing the application executable
If called from a LabVIEW Project (.lvproj) in the LabVIEW
Development Environment, returns the path to the project
folder

ni.com/training

About Dialog Box


Displays information about the application and the developer or
company that designed it
A VI that LabVIEW runs when a user selects HelpAbout.
There can only be one About VI per application.
If you do not supply an About VI, LabVIEW displays a default
dialog box similar to the one that appears for the LabVIEW
Development System.
Must include a National Instruments copyright notice.
Must be saved at the same level of the file hierarchy as the toplevel VI for the application
ni.com/training

About Dialog Box

ni.com/training

Exercise 10-1: Implementing Code for Stand-Alone


Applications

Create an About dialog box that you can use in your own
applications
GOAL

Exercise 10-1: Implementing Code for Stand-Alone


Applications

Use an About dialog box to provide corporate information or links to support


web pages
Use a Case structure with the App.Kind property to conditionally execute the
Quit LabVIEW function
What changed about the appearance of the VI when you set the Window
style to Top-level application window?

DISCUSSION

B. Building a Stand-Alone Application


Create build specifications for source distributions and other
types of LabVIEW builds
Create build specifications from the Project Explorer
window

ni.com/training

Configuring Application Properties


Configure settings for a stand-alone application
Application information
Source Files
Destinations
Source File Settings
Icon
Use the Preview page to view a preview of the stand-alone
application build
ni.com/training

Exercise 10-2: Create a Stand-Alone Application

Create a build specification and build a stand-alone


application (EXE) in LabVIEW
GOAL

Exercise 10-2: Create a Stand-Alone Application

For each LabVIEW application that you want to create build


specifications for, a LabVIEW project must exist
You must manually include any necessary files that are not part
of the LabVIEW project , such as error code files, in the build
specification

DISCUSSION

C. Building an Installer
Caveats and Recommendations
You must include or exclude build specifications and project
libraries as a whole to be included with the installer
Verify that the project does not include files on a network
When you add an NI product installer to the installer build,
you are adding only the components that are installed on the
computer where the build was made
Include custom error codes with the installer

ni.com/training

Summary - Quiz
1. Which of the following code changes should you consider
before building a VI into an executable? (Multiple
answers)
a.
b.
c.
d.

Removing relative file paths


Including an About dialog box
Adding code to quit LabVIEW upon code completion
Creating custom run-time menus

ni.com/training

Summary Quiz Answer


1. Which of the following code changes should you consider
before building a VI into an executable? (Multiple
answers)
a.
b.
c.
d.

Removing relative file paths


Including an About dialog box
Adding code to quit LabVIEW upon code completion
Creating custom run-time menus

ni.com/training

Summary - Quiz
2. Which of the following can you include when building an
installer for your executable?
a.
b.
c.
d.

LabVIEW Run-Time Engine


Custom error file
NI-DAQmx
All of the above

ni.com/training

Summary Quiz Answer


2. Which of the following can you include when building an
installer for your executable?
a.
b.
c.
d.

LabVIEW Run-Time Engine


Custom error file
NI-DAQmx
All of the above

ni.com/training

Continuing Your LabVIEW Education


Instructor Led Training
Managing Software Engineering in LabVIEWThis course
builds upon the software engineering process
Hardware courses such as Data Acquisition and Signal
Processing
Online courses such as Machine Vision and LabVIEW RealTime

Self-Paceda variety of instructional packages and tools


designed to educate you at your own pace
ni.com/training

Continuing Your LabVIEW Education


Training and Certification Membership upgrade
Includes access to all our regional and online classes plus all
certifications from 1 yr of purchase
Please contact Customer Education at (866) 337-5918 to
receive a quote for Training and Certification Membership
Apply the cost of this course to your membership if you
purchase within 30 days

ni.com/training

Continue Your Learning


ni.com/support
On Demand training modules: ni.com/src
Access product manuals, KnowledgeBase, example code,
tutorials, application notes, and discussion forums

User Groups: ni.com/usergroups


Alliance Program: ni.com/alliance
Publications: ni.com/reference/books/
Practice!
ni.com/training

New User

Experienced User

LabVIEW Core 1

LabVIEW Core 3

LabVIEW Core 2

Managing Software
Engineering in LabVIEW
LabVIEW OOP
System Design

Advanced Architectures
in LabVIEW

Certifications

Certified LV Associate
Developer Exam

Certified LabVIEW
Developer Exam

Certified LabVIEW
Architect Exam

ni.com/training

Please complete the course survey


and retrieve your course CD.

Thank you!

ni.com/training