Download presentation
Presentation is loading. Please wait.
1
1 Lesson 5 Clusters TOPICS Introduction to Clusters Cluster Functions Error Clusters
2
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
3 1. Select a Cluster shell from the Array & Cluster subpalette Cluster Controls and Indicators 2.Place objects inside the shell
4
4 Creating Cluster Constants 1. Select Cluster Constant shell from the Cluster subpalette 2. Place objects in the Cluster shell
5
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
6 Using Clusters to Pass Data to SubVIs Use clusters to pass several values to one terminal Overcomes 28-terminal limit Simplifies wiring
7
7 Cluster Functions - Bundle Bundle Bundle By Name Create new clusterModify existing cluster Must have an existing cluster to use this function.
8
8 Cluster Functions - Unbundle UnbundleUnbundle By Name
9
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 Controls»Array & Cluster palette include the components of information shown
10
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
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
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 Functions»All Functions»Time and Dialog palette. Wire the error cluster to the Error In (no error) input.
13
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
14 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. Summary
15
15 Lesson 6 Plotting Data TOPICS Waveform Charts Waveform and XY Graphs Intensity Graphs
16
16 Waveform Charts Selected from the Controls»Graphs and Charts palette
17
17 Wiring to Charts Single-Plot Chart Multiple-Plot Chart
18
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
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 Scale Legend Zoom Subpalette
20
20 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 Graphs
21
21 Uniform X axis I nitial X = 0.0 Delta X = 1.0 Uniform X axis you specify point spacing Single-Plot Waveform Graphs
22
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
23 Non-uniform X axis Separate X and Y arrays define data points XY Graphs
24
24 Chart and Graph Use Summary Use the Context Help window with charts and graphs
25
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
26 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
27
27 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. Summary, cont.
28
28 Lesson 7 Making Decisions in a VI TOPICS Decision making with the Select function Case Structures Formula Nodes
29
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
30 Boolean Case Structure Example: If Temp Scale is TRUE, execute True case; if temp scale is FALSE, execute False case. Case Structures
31
31 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 Case Structures
32
32 Boolean and Numeric Cases Wire all possible outputs of the case structure
33
33 String, Enum, and Error Cases String Case Enum Case Error Case
34
34 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 Formula Node
35
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
36 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 2 31 –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. Summary
37
37 Lesson 8 Strings 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
38 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 Strings
39
39 String Display Modes Normal display Password display \ code display Hex display
40
40 Concatenate Strings (spaces here) String Length String Functions
41
41 String Functions String Subset Match Pattern
42
42 Converting Numerics to Strings: Build String
43
43 Converting Strings to Numerics: Scan From String
44
44 Edit Format String Scan From String Function
45
45 File Input and Output Four Hierarchy Levels: High-level File VIs Intermediate File VIs and Functions Advanced File Functions subpalette Express VIs
46
46 Write to Spreadsheet File Read from Spreadsheet File Write Characters to File Read Characters from File Read Lines from File High-level File I/O VIs
47
47 File I/O Programming Model - Intermediate Open/ Create/ Replace File Read and/or Write to File Close File Check for Errors
48
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
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
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 TabEnd of Line A spreadsheet yields:
51
51 Creating a Spreadsheet File Can replace Format Into String and Write File with Format Into File in above example
52
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
53 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
54
54 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 Summary, cont.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.