Lesson 5 Clusters - PowerPoint PPT Presentation

About This Presentation
Title:

Lesson 5 Clusters

Description:

Lesson 5 Clusters TOPICS Introduction to Clusters Cluster Functions Error Clusters Clusters Data structure that groups data together Data may be of different types ... – PowerPoint PPT presentation

Number of Views:116
Avg rating:3.0/5.0
Slides: 55
Provided by: Cryst142
Category:

less

Transcript and Presenter's Notes

Title: Lesson 5 Clusters


1
Lesson 5Clusters
  • TOPICS
  • Introduction to Clusters
  • Cluster Functions
  • Error Clusters

2
Clusters
  • Data structure that groups data together
  • Data may be of different types
  • Analogous to struct in C or a record in Pascal
  • Elements must be either all controls or all
    indicators
  • Thought of as wires bundled into a cable

3
Cluster Controls and Indicators
1. Select a Cluster shell from the Array
Cluster subpalette
2. Place objects inside the shell
4
Creating Cluster Constants
1. Select Cluster Constant shell from the
Cluster subpalette
2. Place objects in the Cluster shell
5
Cluster Order
  • Elements have a logical order (start with 0)
  • To change order, right-click the border and
    select Reorder Controls in Cluster...

6
Using Clusters to Pass Data to SubVIs
  • Use clusters to pass several values to one
    terminal
  • Overcomes 28-terminal limit
  • Simplifies wiring

7
Cluster Functions - Bundle
Create new cluster
Modify existing cluster
Bundle
Bundle By Name
Must have an existing cluster to use this
function.
8
Cluster Functions - Unbundle
Unbundle
Unbundle By Name
9
Error Cluster
Use the error in and error out clusters in each
VI you use or build to handle errors in the
VI. The error clusters located on the
ControlsArray Cluster palette include the
components of information shown
10
Error Cluster Details
  • Status is a Boolean value that reports TRUE if an
    error occurred. Most VIs, functions, and
    structures that accept Boolean data also
    recognize this parameter.
  • Code is a signed 32-bit integer that identifies
    the error numerically. A non-zero error code
    coupled with a status of FALSE signals a warning
    rather than a fatal error.
  • Source is a string that identifies where the
    error occurred.

11
Error Handling with Clusters
  • LabVIEW does not handle errors automatically. In
    LabVIEW, you can make these error handling
    decisions on the block diagram of the VI.
  • Error handling in LabVIEW follows the dataflow
    model. Just as data flow through a VI, so can
    error information.
  • Wire the error information from the beginning of
    the VI to the end.

Error Cluster
12
Simple Error Handler
  • Use the Simple Error Handler to handle the error
    at the end of the execution flow.
  • The Simple Error Handler is located on the
    FunctionsAll FunctionsTime and Dialog palette.
    Wire the error cluster to the Error In (no error)
    input.

13
Using While Loops for Error Handling
You can wire an error cluster to the conditional
terminal of a While Loop to stop the iteration of
the While Loop. Only the TRUE or FALSE value of
the status parameter of the error cluster is
passed to the terminal. When an error occurs,
the While Loop stops.
14
Summary
  • Clusters group data elements of mixed types. A
    cluster cannot contain a mixture of controls and
    indicators.
  • To create a cluster control or indicator, select
    a cluster on the ControlsArray Cluster
    palette, place it on the front panel, and drag
    controls or indicators into the cluster shell.
  • Use the Cluster functions located on the
    FunctionsAll FunctionsCluster palette to create
    and manipulate clusters.
  • Error checking tells you why and where errors
    occur.
  • The error cluster reports the status, code and
    source of the error.
  • Use the error cluster controls and indicators to
    create error inputs and outputs in subVIs.

15
Lesson 6Plotting Data
  • TOPICS
  • Waveform Charts
  • Waveform and XY Graphs
  • Intensity Graphs

16
Waveform Charts
Selected from the ControlsGraphs and Charts
palette
17
Wiring to Charts
Single-Plot Chart Multiple-Plot Chart
18
Modifying Chart Properties
  • Change the appearance
  • Set the format and precision of the axis
  • Choose the plot type
  • Edit the scales
  • Document the chart

19
Customizing Charts and Graphs
  • Right-click and select Visible Items to view the
    following items
  • Plot Legend
  • Digital Display
  • Scrollbar
  • X and Y Scale
  • Graph Palette
  • Scale Legend

Graph Palette
Zoom Subpalette
Scale Legend
20
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)
Graph Palette
Scale Legend
21
Single-Plot Waveform Graphs
Uniform X axisInitial X 0.0 Delta X 1.0
Uniform X axis you specify point spacing
22
Multiple-Plot Waveform Graphs
Each row is a separate plot Initial X 0 Delta
X 1
Each row is a separate plot Bundle specifies
point spacing of the X axis
23
XY Graphs
  • Non-uniform X axis
  • Separate X and Y arrays define data points

24
Chart and Graph Use Summary
Use the Context Help window with charts and graphs
25
Intensity Plots and Graphs
  • Useful in displaying terrain, temperature
    patterns, spectrum analysis, and image processing
  • Data type is a 2D array of numbers each number
    represents a color
  • Use these options to set and display color
    mapping scheme
  • Cursor also adds a third dimension

26
Summary
  • The waveform chart is a special numeric indicator
    that displays one or more plots. The waveform
    chart has the following three update modes
  • A strip chart shows running data continuously
    scrolling from left to right across the chart.
  • A scope chart shows one item of data, such as a
    pulse or wave, scrolling partway across the chart
    from left to the right.
  • A sweep works similarly to a scope except it
    shows the old data on the right and the new data
    on the left separated by a vertical line.
  • Waveform graphs and XY graphs display data from
    arrays.
  • Right-click a waveform chart or graph or its
    components to set attributes of the chart and its
    plots.

27
Summary, cont.
  • You can display more than one plot on a graph
    using the Build Array function and the Bundle
    function for charts and XY graphs. The graph
    becomes a multiplot graph when you wire the array
    of outputs to the terminal.
  • When you wire data to charts and graphs, use the
    Context Help window to determine how to wire
    them.
  • You can use intensity charts and graphs to plot
    three-dimensional data. The third dimension is
    represented by different colors corresponding to
    a color mapping that you define. Intensity charts
    and graphs are commonly used in conjunction with
    spectrum analysis, temperature display, and image
    processing.

28
Lesson 7Making Decisions in a VI
  • TOPICS
  • Decision making with the Select function
  • Case Structures
  • Formula Nodes

29
Simple Decision Select Function
  • If Temp Scale is TRUE, pass top input if temp
    scale is FALSE, pass bottom input.
  • If the decision to be made is more complex than a
    Select function can execute, a Case Structure may
    be what is required.

30
Case Structures
Boolean Case Structure Example If Temp Scale is
TRUE, execute True case if temp scale is FALSE,
execute False case.
31
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 at a time
32
Boolean and Numeric Cases
Wire all possible outputs of the case structure
33
String, Enum, and Error Cases
  • String Case Enum Case
    Error Case

34
Formula Node
Note semicolon
  • 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

35
Decision Making with Formula Nodes
Two different ways of using an if-then statement
in a Formula Node Both structures produce the
same result
36
Summary
  • The Select function is used to choose between two
    inputs dependant on a boolean input.
  • A Case structure has two or more cases. Only one
    case is visible at a time, and the structure
    executes only one case at a time.
  • If the case selector terminal is Boolean, the
    structure has a TRUE case and a FALSE case. If
    the selector terminal is an integer, string, or
    enumerated type value, the structure can have up
    to 2311 cases.
  • Inputs are available to all cases, but cases do
    not need to use each input. If at least one
    output tunnel is not defined, all output tunnels
    on the structure appear as white squares.
  • Formula Nodes are useful for complicated
    equations and for using existing text-based
    code. A semicolon () must terminate each
    statement.

37
Lesson 8Strings and File I/O
  • TOPICS
  • How to create string controls and indicators
  • How to use several String functions
  • About file I/O operations
  • How to use the high-level File I/O VIs
  • How to use the low-level File I/O VIs
  • How to format text files for use in spreadsheets

38
Strings
  • A string is a sequence of displayable or -
    characters (ASCII)
  • Many uses displaying messages, instrument
    control, file I/O
  • String control/indicator is in the
    ControlsString subpalette

39
String Display Modes
\ code display Hex display
Normal display Password display
40
String Functions
String Length
Concatenate Strings
(spaces here)
41
String Functions
String Subset
Match Pattern
42
Converting Numerics to Strings Build String
43
Converting Strings to Numerics Scan From String
44
Edit Format String
Scan From String Function
45
File Input and Output
Four Hierarchy Levels High-level File
VIs Intermediate File VIs and Functions Advanced
File Functions subpalette Express VIs
46
High-level File I/O VIs
  • Write to Spreadsheet File
  • Read from Spreadsheet File
  • Write Characters to File
  • Read Characters from File
  • Read Lines from File

47
File I/O Programming Model - Intermediate
Open/Create/Replace File
Read and/orWrite to File
Close File
Check for Errors
48
Write to File Example
  • 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

49
Reading Data from a File
  • Open/Create/Replace opens the file
  • Read File reads the specified number of bytes
    from the file
  • Close File closes the file
  • Simple Error Handler checks for errors

50
Formatting a Spreadsheet String
  • Spreadsheets are popular tools for data handling
    and analysis
  • There are many formats for spreadsheet data. One
    of the most popular is tab-delimited
  • Columns are separated by a tab character
  • Rows are separated by an end-of-line character

A spreadsheet yields
Tab
End of Line
51
Creating a Spreadsheet File
Can replace Format Into String and Write File
with Format Into File in above example
52
Write LabVIEW Measurement File
  • Includes the open, write, close and error
    handling functions
  • Handles formatting the string with either a tab
    or comma delimiter
  • Merge Signals function is used to combine data
    into the dynamic data type

53
Summary
  • Strings group sequences of ASCII characters. Use
    the string control and indicator located on the
    ControlsString Path palette to simulate text
    entry boxes and labels.
  • Use the String functions located on the
    FunctionsString palette to edit and manipulate
    strings on the block diagram.
  • Use the Format Into String function and the Build
    String Express VI to convert a numeric to a
    string.
  • Use the Scan From String function to convert a
    string to a numeric.
  • Right-click the Format Into String or Scan From
    String function and select Edit Format String or
    Edit Scan String from the shortcut menu to create
    or edit a format string.

54
Summary, cont.
  • Use the File I/O VIs and functions located on the
    FunctionsFile I/O palette to handle all aspects
    of file I/O.
  • When writing to a file, you open, create, or
    replace a file, write the data, and close the
    file. Similarly, when you read from a file, you
    open an existing file, read the data, and close
    the file.
  • To access a file through a dialog box, do not
    wire file path in the Open/Create/Replace File
    VI.
  • To write data to a spreadsheet file, you must
    format the string as a spreadsheet string, which
    is a string that includes delimiters, such as
    tabs. Use the Format Into File function to format
    string, numeric, path, and Boolean data as text
    and write the text to a file
Write a Comment
User Comments (0)
About PowerShow.com