Lesson 5 clusters
1 / 54

Lesson 5 Clusters - PowerPoint PPT Presentation

  • Uploaded on

Lesson 5 Clusters. TOPICS Introduction to Clusters Cluster Functions Error Clusters. 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

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Lesson 5 Clusters' - ashton

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Lesson 5 clusters l.jpg
Lesson 5Clusters


Introduction to Clusters

Cluster Functions

Error Clusters

Clusters l.jpg

  • 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

Cluster controls and indicators l.jpg
Cluster Controls and Indicators

1. Select a Cluster shell from the Array & Cluster subpalette

2. Place objects inside the shell

Creating cluster constants l.jpg
Creating Cluster Constants

1. Select Cluster Constant shell from the Cluster subpalette

2. Place objects in the Cluster shell

Cluster order l.jpg
Cluster Order

  • Elements have a logical order (start with 0)

  • To change order, right-click the border and select Reorder Controls in Cluster...

Using clusters to pass data to subvis l.jpg
Using Clusters to Pass Data to SubVIs

Use clusters to pass several values to one terminal

Overcomes 28-terminal limit

Simplifies wiring

Cluster functions bundle l.jpg
Cluster Functions - Bundle

Create new cluster

Modify existing cluster


Bundle By Name

Must have an existing cluster to use this function.

Cluster functions unbundle l.jpg
Cluster Functions - Unbundle


Unbundle By Name

Error cluster l.jpg
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 Controls»Array & Cluster palette include the components of information shown

Error cluster details l.jpg
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.

Error handling with clusters l.jpg
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

Simple error handler l.jpg
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 Functions»All Functions»Time and Dialog palette. Wire the error cluster to the Error In (no error) input.

Using while loops for error handling l.jpg
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.

Summary l.jpg

  • 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 Controls»Array & Cluster palette, place it on the front panel, and drag controls or indicators into the cluster shell.

  • Use the Cluster functions located on the Functions»All Functions»Cluster 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.

Lesson 6 plotting data l.jpg
Lesson 6Plotting Data


Waveform Charts

Waveform and XY Graphs

Intensity Graphs

Slide16 l.jpg

Waveform Charts

Selected from the Controls»Graphs and Charts palette

Wiring to charts l.jpg
Wiring to Charts

Single-Plot Chart

Multiple-Plot Chart

Modifying chart properties l.jpg
Modifying Chart Properties

  • Change the appearance

  • Set the format and precision of the axis

  • Choose the plot type

  • Edit the scales

  • Document the chart

Customizing charts and graphs l.jpg
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

Graphs l.jpg

• 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

Single plot waveform graphs l.jpg
Single-Plot Waveform Graphs

Uniform X axisInitial X = 0.0

Delta X = 1.0

Uniform X axis

you specify point


Multiple plot waveform graphs l.jpg
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

Xy graphs l.jpg
XY Graphs

  • Non-uniform X axis

  • Separate X and Y arrays define data points

Chart and graph use summary l.jpg
Chart and Graph Use Summary

Use the Context Help window with charts and graphs

Intensity plots and graphs l.jpg
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

Summary26 l.jpg

  • 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.

Summary cont l.jpg
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.

Lesson 7 making decisions in a vi l.jpg
Lesson 7Making Decisions in a VI


Decision making with the Select function

Case Structures

Formula Nodes

Simple decision select function l.jpg
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.

Case structures l.jpg
Case Structures

Boolean Case Structure Example:

If Temp Scale is TRUE, execute True case; if temp scale is FALSE, execute False case.

Case structures31 l.jpg
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

Boolean and numeric cases l.jpg
Boolean and Numeric Cases

Wire all possible outputs of the case structure

String enum and error cases l.jpg
String, Enum, and Error Cases

String Case Enum Case Error Case

Formula node l.jpg
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

Decision making with formula nodes l.jpg
Decision Making with Formula Nodes

Two different ways of using an if-then statement in a Formula Node

Both structures produce the same result

Summary36 l.jpg

  • 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 231–1 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.

Lesson 8 strings and file i o l.jpg
Lesson 8Strings and File I/O


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

Strings l.jpg

  • 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 Controls»String subpalette

String display modes l.jpg

\ code display

Hex display

Normal display

Password display

String Display Modes

String functions l.jpg
String Functions

String Length

Concatenate Strings

(spaces here)

String functions41 l.jpg

String Subset

String Functions

Match Pattern

Edit format string l.jpg
Edit Format String

Scan From String Function

File input and output l.jpg
File Input and Output

Four Hierarchy Levels:

High-level File VIs

Intermediate File VIs and Functions

Advanced File Functions subpalette

Express VIs

High level file i o vis l.jpg
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

Slide47 l.jpg

File I/O Programming Model - Intermediate

Open/Create/Replace File


and/orWrite to File



Check for


Write to file example l.jpg
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

Reading data from a file l.jpg
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

Formatting a spreadsheet string l.jpg
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:


End of Line

Creating a spreadsheet file l.jpg
Creating a Spreadsheet File

Can replace Format Into String and Write File with Format Into File in above example

Write labview measurement file l.jpg
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

Summary53 l.jpg

  • Strings group sequences of ASCII characters. Use the string control and indicator located on the Controls»String & Path palette to simulate text entry boxes and labels.

  • Use the String functions located on the Functions»String 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.

Summary cont54 l.jpg
Summary, cont.

  • Use the File I/O VIs and functions located on the Functions»File 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