LabVIEW Workshop Presentation
LabVIEW Workshop Presentation
Workshop
5 of 7
Today's Topics
Documentation
FALSE
Review Question 2
Which is best to use when monitoring the passage
of time over a period of 24 or more hours?
a)Tick Count
b)Get Date/Time in Seconds
c) Elapsed Time Express VI
Review Question 2
Which is best to use when monitoring the passage
of time over a period of 24 or more hours?
a)Tick Count
b)Get Date/Time in Seconds
c) Elapsed Time Express VI
Review Question 3
If you have a Wait Until Next Millisecond Multiple in a
while loop with a 20 wired to it and the other code
within the loop take 25ms to execute, how long will one
iteration of the loop take?
a) 25 ms
b) 40 ms
c) 45 ms
d) unknown
7
Review Question 3
If you have a Wait Until Next Millisecond Multiple in a
while loop with a 20 wired to it and the other code
within the loop take 25ms to execute, how long will one
iteration of the loop take?
a) 25 ms
b) 40 ms
c) 45 ms
d) unknown
8
Review Question 4
1. Which of the following is a state machine?
Review Question 4
1. Which of the following is a state machine?
Review Question 5
Which block diagram objects compose a state machine?
a) While loop
b) Enum
c) Sequence structure
d) Case structure
e) Shift register
f) Numeric constants
11
Review Question 5
Which block diagram objects compose a state machine?
a) While loop
b) Enum (optional, although often used)
c) Sequence structure
d) Case structure
e) Shift register
f) Numeric constants
12
Review Question 1
Which of the following are reasons for using a
multiple loop design pattern?
a) Notifiers cannot send data with the notification, but queues can.
b) Notifiers cannot buffer data that is sent, but queues buffer data.
a) Notifiers cannot send data with the notification, but queues can.
b) Notifiers cannot buffer data that is sent, but queues buffer data.
c) Notifiers will make the slave loop wait on the notification, a queue
does not make the slave loop wait.
Review Question 3
Which of the following are valid data types for
queues and notifiers?
a) String
b) Numeric
c) Enum
d) Array of Booleans
e) Cluster of a String and a Numeric
Review Question 3
Which of the following are valid data types for
queues and notifiers?
a) String
b) Numeric
c) Enum
d) Array of Booleans
e) Cluster of a String and a Numeric
Modularity and SubVIs
Modularity - The degree to which a program is
composed of discrete modules such that a
change to one module has minimal impact on
other modules
Module = subVI
19
Modularity and SubVIs
20
Modularity and SubVIs
Function Code Calling Program Code
function average (in1, in2, main
out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }
21
SubVI Icon
Conveys the functionality of the VI using:
Relevant graphics
Descriptive text
Create template for related subVIs
i.e. DAQmx
Icon and Connector Pane:
Setting up the Connector
Pane
Right-click the icon in the
upper right corner of the front
panel and select Show
Connector
Each rectangle on the connector
pane represents a terminal
23
Icon and Connector Pane:
Setting up the Connector
Pane
Once the connector pane pattern is selected,
1. Click on a terminal in the connector pane
2. Click on a control/indicator on the front panel
24
Connector Pane: Standards
Use this connector pane layout as a standard
25
Connector Pane: Terminal
Settings
Bold: Required terminal
Plain: Recommended
terminals
Dimmed: Optional terminals
26
Using SubVIs: Handling Errors
Use a Case structure to handle errors passed into the
subVI
27
Creating SubVIs
1. You can use an existing VI as a subVI after making the appropriate
connections in the connector pane.
Drag the VI from the project to the block diagram of another VI
Drag the VI icon (top right corner of the VI) to the block diagram of another
VI
2. LabVIEW will create a subVI from selected code on the block
diagram
Edit Create SubVI
Edit Create
SubVI
28
Demonstration:
Creating a subVI
Documentation
Free labels
(standard) labels
Descriptions
Captions
Tip Strips
30
Documentation: Description and
Tip Strips
Descriptions- appear in the
Context Help window when you
move the cursor over the object
VIs: VI Properties Description
Controls, indicators, and constants:
Properties Description
Tip Strips
Brief description of the object to
display when you move the cursor
over a front panel object while a VI
runs. (controls, indicators, and
constants)
31
Documentation- Labels and
Captions
Labels (including free labels) are available on the
front panel and block diagram
Captions are only available on the front panel use
when you want to be more descriptive and
dont want to take as much space on the block diagram
programmatically use the label and dont want to break
your VI
Be descriptive!
For example,
Does Temp mean temporary or temperature?
What are the units of Temp?
32
Documentation- Block Diagram
Use block diagram comments to:
Describe algorithms
Explain the data contents of
wires
LabVIEW 2010 and later: right-click
on wire select VisibleLabel
LabVIEW 2009 and earlier: use a
free label to label wires
Using Unbundle/Bundle By Name
creates self-documenting code
33
Demonstration:
Adding a VI Description and Free
Labels
File Input/Output: File Formats
LabVIEW can use or create the following file formats:
35
File Input/Output
36
File Formats
ASCII TDMS Direct Binary
Numeric Good Best Best
Precision
Share data Best (Any program Better (NI Good (only with
easily) Programs easily) detailed
metadata)
Efficiency Good Best Best
Ideal Use Share data with Share data with Store numeric
other programs programs when data compactly
when file space and storing simple with ability to
numeric precision array data and random access
are not important metadata
High-Level vs. Low-Level File I/O
Functions
High-level VIs
Perform all three steps (open,
read/write, close) for common file
I/O operations
Might not be as efficient as the
functions configured or designed
for individual operations
Low-level VIs
Individual VI for each step
If you are writing to a file in a loop,
use low-level file I/O functions
38
High-Level File I/O Functions
Write to Spreadsheet File
Converts an array of double-precision numbers to a text
string and writes the string to an ASCII file
39
Low-level File I/O
File I/O writes to or reads from a file
A typical file I/O operation involves the following
process:
Open/ Read
Close Check for
Create/ and/or
File Errors
Replace File Write to File
40
File I/O: Writing (Binary)
- Boolean - Strings
LabVIEW represents Boolean series of unsigned 8-bit integers, each of
values as 8-bit values in a which has a value in the ASCII Character
binary file Code Equivalents Table
Eight zeroes represents False - Arrays
[00000000] represented as a sequential list of the
Any other value represents True elements (representation dependent on
[00000001], [01000110], [11111111], data type of element)
etc
a header contains a 32-bit integer
representing the size of each dimension
- Integers
Binary Value U8 Value
00000000 0
00000001 1
00000010 2
11111111 255
File I/O: Reading (Binary)
Two methods of accessing data:
Sequential AccessRead each item in order, starting at the
beginning of a file
Random AccessAccess data at an arbitrary point within the
file
Random
Sequential
File I/O: TDMS
(Technical Data Management
Streaming)
TDMS file
Binary file (.tdms) that contains data and stores properties
about the data
TDMS_Index file
Binary index file (*.tdms_index) that provides consolidated
information on all the attributes and pointers in the TDMS file
Speeds up access to the data while reading
Automatically regenerated if lost
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 disk space and improve efficiency
Channel Group
Segment of a TDMS file that contains properties and one or
more channels
Use channel groups to organize your data and to store
information that applies to multiple channels
File I/O: TDMS
Properties
You can assign properties to
entire file
Channel Groups
individual Channels
Examples:
File: Date/Time of logging, user signed into system
Channel Groups: Location of sensor group (top of the
bridge), types of sensors (strain, temperature, etc.)
Channel: Sensor ID, max/min readings
File I/O: TDMS Functions
Use the Express VIs :
quick, but little control of organization
--- Write to Measurement File
--- Read from Measurement File
46
File I/O: TDMS
Data subset to read/write is determined by group
name and channel name(s) inputs
47
File I/O: TDMS
Setting/getting the properties of the TDMS file, channel
group, or channel is dependent on if the group or channel
name is specified
48
File I/O: TDMS File Viewer
Opens TDMS file and presents the file data
in the TDMS File Viewer dialog box
49
Homework
Homework 5 email to
[email protected]
LabVIEW Game