LabVIEW Basics II Slides
LabVIEW Basics II Slides
Computer running
LabVIEW 8.6 or later
and Windows 2000 or later
ni.com/training
File Locations
Instructional Methods
Root Directory
e c ses
Exercises
<or>
Solutions
LabVIEW
Basics II
Demonstrations
Quizzes
Concept
Exercise
Development
Exercise
ni.com/training
Courses
New User
Experienced User
Advanced User
LabVIEW Basics I
LabVIEW Intermediate I
LabVIEW Advanced I
LabVIEW Basics II
Skills learned:
LabVIEW environment
navigation
Basics application creation
using LabVIEW
Basics of data acquisition and
instrument control
Skills learned:
Large application design
Advanced development
techniques
Implementing multideveloper
projects
Certifications
Certified LV Associate
Developer Exam
Skills tested:
LabVIEW environment
knowledge
ni.com/training
LabVIEW Intermediate II
Skills learned:
Modular application
development
Structured design and
development practices
Inter-application
communication and
connectivity techniques
Certified LabVIEW
Developer Exam
Skills tested:
LabVIEW application
development expertise
Certified LabVIEW
Architect Exam
Skills tested:
LabVIEW application
development mastery
ni.com/training
6
Course Goals
Lesson 1
Lesson 5
Lesson 2
Lesson 6
Lesson 3
Lesson 7
Event Programming
Lesson 4
Improving an Existing VI
ni.com/training
ni.com/training
Lesson 1
Common Design Techniques
TOPICS
A.
B.
C.
D.
E.
ni.com/training
10
General VI
Three phases: Start-up, Main Application, and Shut-down
General VI
ni.com/training
ni.com/training
11
12
State Machine
Usually has a start-up and shut-down state, but also
contains other states
State Machine
ni.com/training
ni.com/training
13
14
B. Parallelism
B. Parallelism
ni.com/training
ni.com/training
15
16
B. Parallelism
B. Parallelism
ni.com/training
ni.com/training
17
18
Parallel Loop
ni.com/training
ni.com/training
19
D. Events
20
D. Events
ni.com/training
D. Events
Event Programming
Execution Timing
Provides the design pattern with a function that specifically
allows the processor time to complete other tasks
In some cases, a function is not necessaryy
Execution
ni.com/training
ni.com/training
23
24
ni.com/training
ni.com/training
25
26
SummaryQuiz
Execution Timing
ni.com/training
27
28
SummaryQuiz Answers
Are the following statements True or False?
False. Software control timing is a method for monitoring a
real-time clock.
True. Execution timingg allows the pprocessor time to
complete other tasks.
False. If you pass data between two loops with a wire, the
loops no longer run in parallel.
ni.com/training
29
Lesson 2
Communicating Among Multiple Loops
A. Variables
Cannot pass data between parallel loops with a wire
Variables allow you to circumvent normal dataflow by
passing data from one place to another without connecting
the two places with a wire
TOPICS
A.
B.
C.
D.
Variables
Functional Global Variables
Race Conditions
Synchronizing Data
ni.com/training
ni.com/training
2
A. Variables
ni.com/training
3
GOAL
ni.com/training
ni.com/training
5
GOAL
GOAL
ni.com/training
ni.com/training
7
ni.com/training
ni.com/training
9
A. Variables Initializing
10
A. Variables Initializing
ni.com/training
11
12
ni.com/training
ni.com/training
13
14
GOAL
ni.com/training
ni.com/training
15
GOAL
16
C. Race Conditions
A race condition is a situation where the timing of events or
the scheduling of tasks may unintentionally affect an output
or data value
Race conditions are a common problem for programs that
execute multiple tasks in parallel and share data between
the tasks
OPTIONAL
Create a project containing multiple VIs that share data
using a single process shared variable.
ni.com/training
ni.com/training
17
18
C. Race Conditions
Race conditions are very difficult to identify and debug
Often, code with a race condition can return the same
result thousands of times in testing, but still be capable of
returning a different result
Avoid race conditions by:
GOAL
ni.com/training
ni.com/training
20
19
ni.com/training
ni.com/training
21
22
ni.com/training
ni.com/training
23
24
ni.com/training
ni.com/training
25
26
GOAL
ni.com/training
ni.com/training
28
27
Demo: Notifiers
GOAL
ni.com/training
ni.com/training
29
30
Notifier disadvantages:
A notifier does not buffer data
If the master loop sends another piece of data before the
first ppiece of data has been read byy the slave loops,
p that
data is overwritten and lost
ni.com/training
ni.com/training
31
32
ni.com/training
ni.com/training
33
GOAL
GOAL
Demo: Queues
34
ni.com/training
ni.com/training
35
36
SummaryQuiz
GOAL
ni.com/training
38
37
SummaryQuiz Answer
SummaryQuiz
ni.com/training
ni.com/training
39
40
SummaryQuiz Answer
SummaryQuiz
ni.com/training
ni.com/training
41
42
SummaryQuiz Answer
SummaryQuiz
ni.com/training
ni.com/training
43
44
SummaryQuiz Answer
4. Which cannot be used to pass data between multiple VIs?
a) Local variable
b) Global variable
c) Functional global variable
d) Single-process
Si l
shared
h d variable
i bl
ni.com/training
45
TOPICS
A. Event Driven Programming
B. Event Based Design Patterns
ni.com/training
ni.com/training
ni.com/training
ni.com/training
ni.com/training
2. Event Sources
GOAL
3. Events
Concept
Experiment with the operation of the Event Structure in a
VI.
ni.com/training
ni.com/training
ni.com/training
You can turn off locking, but only for Notify Events
ni.com/training
Producer/Consumer (Events)
SummaryQuiz Answer
Benefits
Efficiently
responds
asynchronously
to the user
interface
Queues can
transfer any
data type
ni.com/training
ni.com/training
16
GOAL
SummaryQuiz
2. Which of the following are examples of user interface
events?
a) Mouse click
b)) Keystroke
y
c) Event Filter Node
d) Value change of a control
Concept
Observe the functionality and design of event-based
LabVIEW design patterns
ni.com/training
ni.com/training
17
SummaryQuiz
SummaryQuiz Answer
ni.com/training
ni.com/training
15
18
SummaryQuiz
3. True or False? Using user interface events allows you to
synchronize user actions on the front panel with block
diagram execution.
ni.com/training
19
SummaryQuiz Answer
3. Using user interface events allows you to synchronize
user actions on the front panel with block diagram
execution. True.
ni.com/training
20
Lesson 4
Controlling the User Interface
A. VI Server Architecture
VI Server performs many functions; however, this lesson
concentrates on using VI Server to control front panel objects
and edit the properties of a VI
TOPICS
A.
B.
C.
D.
VI Server Architecture
Property Nodes
Control References
Invoke Nodes
ni.com/training
ni.com/training
2
A. VI Server Architecture
Terminology:
An object is a member of a class
A class defines what an object is able to do, what
operations it can perform ((methods),
) and what properties it
has
Control
Boolean
Boolean Sub-Class
S b Class
Property: Boolean Text
Control Class
Property: Visible
Method: Reinitialize to Default
Array
Array Sub
Class
Sub-Class
Property: Number of Rows
Stop
Stop Object
Visible: Yes
Reinitialize to Default: No
Boolean Text: Stop
ni.com/training
ni.com/training
3
A. VI Server Architecture
B. Property Nodes
Control Classes
VI Class
Your VI belongs to the VI Class and has its own properties and
methods associated with it
Example Methods: abort your VI, adjust the position of the front
panel, get an image of the block diagram
Example Properties: change the title of your front panel
window, retrieve the size of the block diagram, hide the abort
button
ni.com/training
ni.com/training
5
GOAL
ni.com/training
ni.com/training
8
GOAL
Main VI
VI
Main VI
VI
ni.com/training
SubVI
ni.com/training
9
C. Control References
ni.com/training
ni.com/training
11
12
S bVI F
SubVI
Frontt Panel
P l
S bVI Bl
SubVI
Blockk Di
Diagram
S bVI F
SubVI
Frontt Panel
P l
S bVI Bl
SubVI
Blockk Diagram
Di
Ctl Refnum
ni.com/training
ni.com/training
13
14
For example, you can select Digital as the class, and the
subVI can only accept references
to numeric controls of the class Digital
ni.com/training
15
D. Invoke Nodes
Invoke Nodes access the methods of an object
Use the Invoke Node to perform actions, or methods, on an
application or VI
Unlike the Property
p y Node, a single
g Invoke Node executes
only a single method on an application or VI
Set Plots.vi
GOAL
16
ni.com/training
ni.com/training
17
18
Invoke Nodes
GOAL
ni.com/training
ni.com/training
19
20
SummaryQuiz
SummaryQuiz Answer
a.
b.
c.
d.
a.
b.
c.
d.
ni.com/training
ni.com/training
21
22
SummaryQuiz
SummaryQuiz Answer
a.
b.
c.
d.
a.
b.
c.
d.
ni.com/training
ni.com/training
23
24
Lesson 5
Advanced File I/O Techniques
A. File Formats
At their lowest level, all files written to your computers hard
drive are a series of bits
TOPICS
A. File Formats
B. Binary Files
C. TDMS Files
ASCII
TDMS
Binary
ni.com/training
ni.com/training
2
A. File Formats
B. Binary Files
ASCII
TDMS
Direct Binary
Numeric
Precision
Good
Best
Best
Share
data
Efficiency
Good
Best
Best
Ideal Use
ni.com/training
ni.com/training
4
B. Binary FilesBits/Bytes?
0
00000000
bit
byte
ni.com/training
ni.com/training
5
File Contents
Method A
00000001 00000001
00000000 00000001
00000000 00000001
Binary Value
00000000
00000001
00000010
11111111
U8 Value
0
1
2
255
Method B
00101011
ni.com/training
ni.com/training
7
U32 Value
Little-endian Value
Big-endian Value
00000001
00000000
00000000
00000000
00000000
00000000
00000000
00000001
ni.com/training
ni.com/training
9
10
ni.com/training
ni.com/training
11
12
Use the Set Position VI to set the read offset to the point in
the file you want to begin reading
The offset is in bytes; therefore, you must calculate the
offset based upon the layout of the file
ni.com/training
ni.com/training
13
B. Binary FilesDatalog
14
ni.com/training
ni.com/training
15
16
C. TDMS Files
TDMS
Technical Data Management Streaming
Use TDMS files for the following purposes:
To store test or measurement data
To create a structure for grouping your data
To store information about your data
To read and write data at high speeds
GOAL
ni.com/training
ni.com/training
17
18
C. TDMS Files
Channel
Stores measurement signals or raw data in a TDMS file
Each channel can have properties describing the data
The data stored in the signal is stored as binary data on disk to
conserve di
diskk space andd iimprove efficiency
ffi i
TDMS_Index file
Channel Group
ni.com/training
19
C. TDMS Files
20
ni.com/training
21
22
Reads the specified TDMS file and returns data from the
specified channel and/or channel group
ni.com/training
23
ni.com/training
24
ni.com/training
ni.com/training
25
26
ni.com/training
ni.com/training
27
28
SummaryQuiz
1. You need to store test results and organize the data into
descriptive groups. In the future, you need to efficiently view the
test results by group. Which file storage format should you use?
a) Tab-delimited ASCII
b) Custom binary format
c) TDMS
d) Datalog
GOAL
ni.com/training
ni.com/training
29
30
SummaryQuiz Answer
SummaryQuiz
1. You need to store test results and organize the data into
descriptive groups. In the future, you need to efficiently view the
test results by group. Which file storage format should you use?
a) Tab-delimited ASCII
b) Custom binary format
c) TDMS
d) Datalog
ni.com/training
ni.com/training
31
32
SummaryQuiz Answer
SummaryQuiz
3. You need to store data that other engineers will later analyze with
Microsoft Excel. Which file storage format should you use?
a) Tab-delimited ASCII
b) Custom binary format
c) TDMS
d) Datalog
ni.com/training
ni.com/training
33
34
SummaryQuiz Answer
SummaryQuiz
3. You need to store data that other engineers will later analyze with
Microsoft Excel. Which file storage format should you use?
a) Tab-delimited ASCII
b) Custom binary format
c) TDMS
d) Datalog
ni.com/training
c) 00001010
d) 01010000
00000000
00000000
00000000
ni.com/training
35
SummaryQuiz Answer
SummaryQuiz
a) 00001010
00000000
00000000
00000000
b) 00000000
00000000
00000000
00001010
c) 00001010
d) 01010000
00000000
00000000
00000000
ni.com/training
ni.com/training
38
SummaryQuiz Answer
SummaryQuiz
ni.com/training
ni.com/training
39
40
SummaryQuiz Answer
6. TDMS Files store properties only at the channel or
channel group level. False.
ni.com/training
41
Lesson 6
Improving an Existing VI
TOPICS
A. Refactoring Inherited Code
B. Typical Issues
ni.com/training
ni.com/training
2
ni.com/training
ni.com/training
3
A. When to Refactor
versus
ni.com/training
ni.com/training
5
B. Typical Issues
When you refactor to improve the
block diagram, make small
cosmetic changes before tackling
larger issues
B. Typical Issues
The following issues can make it difficult to work with an
inherited VI:
Too disorganized
Uses incorrect object
j names and ppoor icons
Uses unnecessary logic
Has duplicated logic
Does not use data flow programming
Has complicated algorithms
Is too big
Test VI
Is VI Acceptable?
No
Yes
Add Features or Use VI
ni.com/training
ni.com/training
7
B. Typical Issues
Better
Best
Good
10
ni.com/training
ni.com/training
9
B. Typical Issues
B. Typical Issues
ni.com/training
ni.com/training
11
12
B. Typical Issues
B. Typical Issues
Simplify:
ni.com/training
ni.com/training
13
B. Typical Issues
14
GOAL
The block diagram is too big (larger than the screen size)
Refactor the VI to make it smaller
Create subVIs for sections of code within the block diagram
ni.com/training
Concept Exercise
Improve an existing VI that is poorly designed.
ni.com/training
15
16
SummaryJob Aid
Use the following refactoring checklist to help determine if you
should refactor a VI:
ni.com/training
17
Lesson 7
Creating and Distributing Applications
TOPICS
A. LabVIEW Features for Managing Project Development
B. Preparing the Application
C. Building the Application and Installer
ni.com/training
ni.com/training
VI Hierarchy
Comparing VIs
ni.com/training
GOAL
Concept Exercise
Examine some of the built-in LabVIEW features for project
management.
ni.com/training
ni.com/training
ni.com/training
System Requirements
Applications that you create with Build Specifications
generally have the same system requirements as the
LabVIEW development system used to create the VI or
application
Memory requirements vary depending on the size of the
application created
ni.com/training
ni.com/training
Summary
The Application Builder enables you to create stand-alone
applications and installers
GOAL
Concept Exercise
Create a stand-alone application with LabVIEW.
ni.com/training
Courses
ni.com/training
New User
Experienced User
Advanced User
LabVIEW Basics I
LabVIEW Intermediate I
LabVIEW Advanced I
LabVIEW Basics II
Skills learned:
LabVIEW environment
navigation
Basics application creation
using LabVIEW
Basics of data acquisition and
instrument control
LabVIEW Intermediate II
Skills learned:
Modular application
development
Structured design and
development practices
Inter-application
communication and
connectivity techniques
Skills learned:
Large application design
Advanced development
techniques
Implementing multideveloper
projects
Certifications
Certified LV Associate
Developer Exam
Skills tested:
LabVIEW environment
knowledge
12
Certified LabVIEW
Developer Exam
Skills tested:
LabVIEW application
development expertise
Certified LabVIEW
Architect Exam
Skills tested:
LabVIEW application
development mastery
ni.com/training
Info-LabVIEW: www.info-labview.org
Alliance Program: ni.com/alliance
Publications: ni.com/reference/books/
Practice!
13
THANK YOU!
ni.com/training
ni.com/training