Professional Documents
Culture Documents
Arrays
Collection of data elements that are of same type
0 0
1 1
2 2
3 3
4 4
5 5
6 6
1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7
LV Basics I 3
LV Basics I 4
LV Basics I 5
Creating 2D Arrays
Inner loop creates column elements Outer loop stacks them into rows
LV Basics I 6
Array Size
Initialize Array
Array Subset
LV Basics I 7
Appending an element
Extracting an Element
Extracting a Row
LV Basics I 9
Polymorphism
Function inputs can be of different types All LabVIEW arithmetic functions are polymorphic
Combination Scalar + Scalar Array + Scalar Array + Array Array + Array
5 2 1 4 2 2 3 2 5 1 4 2 1 4 2 3 2 5 7 4 6 7 7
3 6 4
4 6 7
LV Basics I 10
LV Basics I 11
Graphs
Selected from the Graph subpalette Waveform Graph Plot an array of numbers against their indices XY Graph Plot one array against another
Plot Legend
(point and line styles)
Scale Legend
LV Basics I 12
Graph Palette
Each row is a separate plot (Bundle specifies point spacing of the X axis)
LV Basics I 14
XY Graphs
Non-uniform X axis Separate X and Y arrays define data points
LV Basics I 15
LV Basics I 16
LV Basics I 17
LV Basics I 18
LV Basics I 19
Clusters
Data structure that groups data together Data may be of different types Analogous to record in Pascal or struct in C Elements must be either all controls or all indicators Thought of as wires bundled into a cable
LV Basics I 20
LV Basics I 21
Cluster Constants
Select a Cluster Constant shell from the Cluster subpalette Right-click on existing cluster and select Create>>Constant
LV Basics I 22
Cluster Order
Elements have a logical order (start with 0) To change order, right-click on border and select Reorder Controls in Cluster...
LV Basics I 23
LV Basics I 24
Cluster Functions
In the Cluster subpalette of the Functions palette Can also be accessed by right-clicking on the cluster terminal
Bundle By Name
LV Basics I 25
Cluster Functions
Unbundle
Unbundle By Name
LV Basics I 28
LV Basics I 29
LV Basics I 30
Summary
An array is a collection of elements of same data type numeric, Boolean, string, etc. Creating array or cluster controls/indicators is a two-step process 1. Get array or cluster shell 2. Place desired control/indicator inside the shell Loops can accumulate arrays at boundaries auto-indexing Array functions are in Array subpalette of Functions palette LabVIEW arithmetic functions are polymorphic input different data types Plot data on graphs Many features to manipulate plotted graph Multiple plots can be plotted on one graph Clusters group data that can be different types The Bundle and Unbundle functions are used to create and disassemble clusters
LV Basics I 31
LV Basics I 33
Case Structures
In the Structures subpalette of Functions palette Enclose nodes or drag them inside the structure Stacked like a deck of cards, only one case visible
LV Basics I 34
LV Basics I 36
LV Basics I 37
Sequence Structures
In the Structures subpalette of Functions palette Executes diagrams sequentially, Frame 0 (0..x), where x is the total number of frames Stacked like a deck of cards, only one frame visible
LV Basics I 38
Sequence Locals
Pass data from one frame to future frames Created at the border of the Sequence structure
Data available
LV Basics I 39
LV Basics I 40
Formula Node
In the Structures subpalette Implement complicated equations Variables created at border Variable names are case sensitive Each statement must terminate with a semicolon (;) Context Help Window shows available functions
Note semicolon
LV Basics I 41
Condition
LV Basics I 42
True Condition
LV Basics I 43
LV Basics I 44
Summary
Two structures to control flow of data Case structure Sequence structure Case structure Boolean or numeric cases selector determines type Subdiagrams placed inside case structure Output from a Case structure must be defined for all cases Sequence structure executes subdiagrams sequentially Sequence locals pass data between frames Created at the border of Sequence structure Data available in subsequent frames Formula Nodes allow direct entry of equations in the block diagram Sequence structures can be replaced with a Case inside of a Loop
LV Basics I 45
Over Threshold.vi
Time to complete: 30 min.
LV Basics I 46
LV Basics I 47
Strings
A string is a sequence of displayable or nondisplayable characters (ASCII) Many uses displaying messages, instrument control, file I/O String control/indicator is in the Controls >> String subpalette
LV Basics I 48
Password display
Hex display
LV Basics I 49
String Functions
String Length
String
Length = 20
Concatenated String
LV Basics I 50
String Functions
LV Basics I 51
String Functions
Converting numbers to strings
LV Basics I 52
LV Basics I 53
LV Basics I 54
High Level File VIs Intermediate File VIs and Functions Advanced File Functions
LV Basics I 55
LV Basics I 56
Open/Create/Replace opens the existing file TEST1.DAT and generates refnum and error cluster Write File writes the data Close File closes the file Simple Error Handler checks for errors
LV Basics I 57
Open/Create/Replace opens the file Read File reads the specified number of bytes from the file
LV Basics I 59
LV Basics I 60
LV Basics I 61
A spreadsheet yields:
Tab
LV Basics I 62
End of Line
LV Basics I 63
LV Basics I 64
LV Basics I 65
LV Basics I 66
Summary
String is a collection of ASCII characters many uses Display messages Instrument control File I/O Many functions to manipulate strings Strings palette of Functions menu Three levels of File I/O hierarchy High-level VIs Intermediate VIs and functions Advanced functions Writing data in spreadsheet format Tab character separates columns End-of-line character separates rows Write/Read from spreadsheet high-level File I/O VIs
LV Basics I 67
More
Spreadsheets.vi
Time to complete: 25 min.
Converter.vi
Time to complete: 30 min.
7-9 Students modify Temperature Logger.vi (Ex. 7-4) and save the new VI as