0% found this document useful (0 votes)
160 views50 pages

LabVIEW Workshop Presentation

This document provides an overview and review of topics covered in Workshop 4, and introduces new topics for Workshop 5. The review questions cover sequence structures, state machines, multiple loop design patterns, notifiers vs queues, and file input/output data types. Modularity, subVIs, documentation best practices, and high-level vs low-level file I/O functions are then introduced as the main topics for Workshop 5.

Uploaded by

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

LabVIEW Workshop Presentation

This document provides an overview and review of topics covered in Workshop 4, and introduces new topics for Workshop 5. The review questions cover sequence structures, state machines, multiple loop design patterns, notifiers vs queues, and file input/output data types. Modularity, subVIs, documentation best practices, and high-level vs low-level file I/O functions are then introduced as the main topics for Workshop 5.

Uploaded by

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

Welcome!

Workshop
5 of 7
Today's Topics

Review from Workshop 4

Modularity & subVIs

Documentation

File Input/Output Introduction


Review Question 1
True or False?

A sequence structure can be aborted in the


middle of the sequence.
Review Question 1
True or False?

A sequence structure can be aborted in the


middle of the sequence.

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) Execute multiple tasks concurrently


b) Execute different states in a state machine
c) Execute tasks at different rates
d) Execute start up code, main loop, and shutdown code
Review Question 2
The major difference between Notifiers and Queues is:

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 2
The major difference between Notifiers and Queues is:

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

It is desirable to section code into reusable parts


that can be edited without having to change a
bunch of other parts too.
18
Modularity and SubVIs

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

SubVI Block Diagram Calling VI Block Diagram

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

Select a different pattern by


right-clicking the connector
pane and selecting Patterns
from the shortcut menu

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

The control/indicator and


connector pane terminal
are now linked
The terminal will display
the color of the data type of
the linked control/indicator

24
Connector Pane: Standards
Use this connector pane layout as a standard

Top terminals are usually reserved for references,


such as a file reference
Bottom terminals are
usually reserved for
error clusters

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

To create a free label:


Double-click and begin typing
Place a free label form the Functions palette

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:

LVM The LabVIEW measurement data file (.lvm) is a tab-


delimited text file you can open with a spreadsheet
application or a text-editing application

ASCIISpecific type of binary file that is a standard used by


most programs

TDMSType of binary file created for NI products consisting


of two separate files: a binary file and a binary index file

BinaryUnderlying file format of all other file formats

35
File Input/Output

At their lowest level, all files written to your


computers hard drive are a series of bits

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

Read From Spreadsheet File


Reads a specified number of lines or rows from a numeric
text file and outputs a 2D array of double-precision numbers

Write to/Read from Measurement File


Express VIs that write data to or read data
from an LVM or TDMS file format

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

TDMS file format internal structure is publicly documented


File I/O: TDMS

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

Use the TDM Streaming API


Total control over organization, more involved set-up

Use the TDM Excel Add-In Tool


Allows you to read TDMS files in Microsoft Excel

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

Study for the CLAD

You might also like