You are on page 1of 95

LabVIEW Core 1

TOPICS

1

ni.com/training

Lesson 1
Navigating LabVIEW
TOPICS
A.
B.
C.
D.
E.

2

What Is LabVIEW?
Project Explorer
Parts of a VI
Front Panel
Block Diagram

F. Searching for Controls, VIs
and Functions
G. Selecting a Tool
H. Dataflow
I. Building a Simple VI

ni.com/training

H. Dataflow

3

ni.com/training

• A node supplies data to the output terminals only when the node finishes execution. 4 ni.Dataflow LabVIEW follows a dataflow model for running VIs. • A node executes only when data are available at all of its required input terminals.com/training .

Dataflow – Quiz Which node executes first? a) Add b) Subtract c) Random Number d) Divide e) Sine 5 ni.com/training .

com/training .Dataflow – Quiz Answers No single correct answer. Which node executes first? a) Add – Possibly b) Subtract – Definitely not c) Random Number – Possibly d) Divide – Possibly e) Sine – Definitely not 6 ni.

GOAL .Group Exercise 1-4 Concept: Dataflow Identify dataflow execution order in the following block diagrams.

Group Exercise 1-4 Concept: Dataflow Which node executes first? Last? Where are the data dependencies? DISCUSSION .

Group Exercise 1-4 Concept: Dataflow Which Express VI executes last? DISCUSSION .

Group Exercise 1-4 Concept: Dataflow Which Express VI executes last? DISCUSSION .

Group Exercise 1-4 Concept: Dataflow Which Tone Measurement executes last? DISCUSSION .

Building a Simple VI 12 ni.com/training .I.

Building a Simple VI 13 ni.com/training .

com/training .Acquire Express VIs • DAQ Assistant Express VI • Instrument I/O Assistant Express VI • Simulate Signal Express VI • Read from Measurement File Express VI 14 ni.

com/training .Analyze Express VIs • Amplitude and Level Measurements Express VI • Statistics Express VI • Spectral Measurements Express VI • Tone Measurements Express VI • Filter Express VI 15 ni.

com/training .Present Express VIs and Indicators • Display Message Express VI • Play Waveform Express VI • Report Express VI • Write Measurement File Express VI • DIAdem Report Express VI 16 ni.

Save and run the VI. Configure the dialog box that opens. Place Express VI on the block diagram.Building and Running a VI 1. The Run button appears broken when the VI you are creating or editing contains errors. Wire Express VIs together. 3. 17 ni.com/training . 4. 2.

• Display the data to a graph.Exercise 1-5.1 seconds. • Determine the average value of the waveform. • Log the data. Analyze. 18 GOAL . Part A – Group Exercise Simple Acquire. and Present Design Scenario: • Acquire a sine waveform 0.

Exercise 1-5. and Present Design DISCUSSION . Part A – Group Exercise Simple Acquire. Analyze.

and Present Design Which Express VI would you use for following tasks? • Acquiring a sine wave from a data acquisition device • Determining the average value • Logging data to a file • Displaying data to a graph • Displaying average value DISCUSSION .Exercise 1-5. Analyze. Part A – Group Exercise Simple Acquire.

Exercise 1-5. Part B Simple Acquire. 21 GOAL . and Present VI HOMEWORK Create a simple VI that acquires data. and presents the results. Analyze. analyzes data.

Analyze.Exercise 1-5 Simple Acquire. and Present VI How do you determine the file path of the generated text file? DISCUSSION .

com/training .Summary—Quiz 1. Which function executes first: Add or Subtract? a) Add b) Subtract c) Unknown 2323 ni.

Which function executes first: Add or Subtract? a) Add b) Subtract c) Unknown 2424 ni.Summary—Quiz Answer 1.com/training .

com/training . Which function executes first: Sine or Divide? a) Sine b) Divide c) Unknown 2525 ni.Summary—Quiz 2.

Summary—Quiz Answer
2. Which function executes first:
Sine or Divide?
a) Sine
b) Divide
c) Unknown

2626

ni.com/training

Summary—Quiz
3. Which of the following
functions executes first:
Random Number, Add or
Divide?
a)
b)
c)
d)

2727

Random Number
Divide
Add
Unknown

ni.com/training

Summary—Quiz Answer
3. Which of the following
functions executes first:
Random Number, Add or
Divide?
a)
b)
c)
d)

2828

Random Number
Divide
Add
Unknown

ni.com/training

Subtract or Add? a) b) c) d) 2929 Random Number Subtract Add Unknown ni.Summary—Quiz 4.com/training . Which of the following functions executes last: Random Number.

Which of the following functions executes last: Random Number.Summary—Quiz Answer 4.com/training . Subtract or Add? a) b) c) d) 3030 Random Number Subtract Add Unknown ni.

What are the three parts of a VI? a) Front panel b) Block diagram c) Project d) Icon/Connector pane 31 ni.Summary—Quiz 5.com/training 31 .

com/training 32 .Summary—Quiz Answer 5. What are the three parts of a VI? a) Front panel b) Block diagram c) Project d) Icon/Connector pane 32 ni.

D.Lesson 2 Troubleshooting and Debugging VIs TOPICS A. C. 33 Correcting Broken VIs Debugging Techniques Undefined or Unexpected Data Error Handling ni.com/training . B.

A. Correcting Broken VIs 34 ni.com/training .

Correcting Broken VIs Broken Run arrow  VI cannot be compiled  VI cannot be executed 35 ni.com/training .

• A subVI is broken. 36 ni.com/training . • A required block diagram terminal is unwired. − You wired a numeric control to a numeric control. − You wired a Boolean control to a String indicator.Common Causes of Broken VIs • Broken wires exist on the block diagram.

Debugging Techniques Execution Highlighting Single-Stepping Probes Breakpoints 37 ni.com/training .B.

com/training .Debugging Techniques What to look for if a VI produces unexpected data or behavior: • Are there any unwired or hidden subVIs? • Is the default data correct? • Does the VI pass undefined data? • Are numeric representations correct? • Are node executed in the correct order? 38 ni.

confirm that you turned off execution highlighting in subVIs. • If the VI runs more slowly than expected.Execution Highlighting • Use execution highlighting to watch the data flow through the block diagram. 39 ni.com/training .

com/training .Single-Stepping • Single-step through the VI to view each action of the VI on the block diagram. or to go back to the beginning of the execution of the subVI. 40 ni. to control the number of times it runs. • Suspend the execution of a subVI to edit values of controls and indicators. − Open subVI and select Operate»Suspend When Called from the shortcut menu.

Probes • Use the Probe tool to observe intermediate data values and check the error output of VIs and functions. 41 ni.com/training . especially those performing I/O. • Specify to retain the values in the wires so that you can probe wires for data after execution.

42 ni. the VI pauses and the Pause button appears red.com/training 42 . • You can take the following actions at a breakpoint: − Single-step through execution using the single-stepping buttons.Breakpoints • When you reach a breakpoint during execution. − Probe wires to check intermediate values. − Change values of front panel controls. − Click the Pause button to continue running to the next breakpoint or until the VI finishes running.

com/training . Undefined or Unexpected Data 43 ni.C.

• NaN − Not a number − Produced by invalid operations. 44 ni.Undefined or Unexpected Data Check for unexpected Inf values or NaN values in your mathematical operations: • ∞ (Inf) − Infinity − Produced by dividing a number by zero.com/training . such as taking the square root of a negative number.

Exercise 2-1
Concept: Debugging

HOMEWORK
Use the debugging tools built into LabVIEW.
GOAL

Exercise 2-1
Concept: Debugging

• If you have a VI with a broken Run arrow, what should you
do first?
• After you fixed your broken Run arrow, your VI results show
unexpected data. What can you do next?
DISCUSSION

D. Error Handling
Automatic and Manual Error Handling
Merge Errors Function
Error Clusters
Warnings

47

ni.com/training

− Automatic error handling − Manual error handling 48 ni.com/training . and resolution of warnings and errors • You cannot predict every problem a user can encounter. • Error handling tells you why and where errors occur. you know only that the VI does not work properly. • Without a mechanism to check for errors. detection.Error Handling Error Handling – Anticipation.

− Highlighting the subVI or function where the error occurred. LabVIEW automatically handles any known error when a VI runs by: − Suspending execution. 49 ni. • Automatic error handling is: − Acceptable for quick prototypes. − Displaying the Error list window. − Not included in LabVIEW-built executables.com/training . − Not recommended for professional application development.Automatic Error Handling • By default.

• Terminate the error chain with a call to Simple Error Handler VI.com/training . 50 ni.Manual Error Handling • You control when dialog boxes appear. • Propagate errors by wiring the error out cluster to error in cluster of next node to execute.

DEMONSTRATION .Automatic vs. Manual Error Handling Demonstrate the difference between automatic and manual error handling.

Disable Automatic Error Handling • Options Dialog Box − Block Diagram page • Uncheck − Enable automatic error handling in new VIs − Enable automatic error handling dialogs • Other suggested changes − Front Panel page • Set Control Style for New VIs to Silver style − Block Diagram page • Uncheck − Place front panel terminals as icons • Configure Block Diagram Cleanup to customize your block diagram 52 ni.com/training .

Merge Errors • Propagate errors along wires. 53 ni.com/training . • Merge errors from different wire paths.

If no error is found. • The Merge Errors function does not concatenate errors. it returns the first warning.com/training .Merge Errors Function • Merge Errors function returns the first error found. 54 ni.

Error Clusters • Use the error cluster controls and indicators to create error inputs and outputs in subVIs.com/training . • The error in and error out clusters include the following components of information: − Status − Code − Source 55 ni.

Errors and Warnings 56 Status = TRUE Status = FALSE Code = Non-zero Error Warning ni.com/training .

57 ni.Errors and Warnings Recommendations • Report errors and warnings with the Simple Error Handler VI − Modify Type of Dialog to detect warnings.com/training . • Call the Simple Error Handler VI from the top-level VI. • Avoid error dialogs in subVIs.

58 ni.Summary—Quiz 1. b) The diagram includes a divide by zero. c) A required subVI input is unwired. d) A Boolean terminal is wired to a numeric indicator.com/training . Which of the following will result in a broken run arrow? a) A subVI is broken.

com/training . c) A required subVI input is unwired. d) A Boolean terminal is wired to a numeric indicator. b) The diagram includes a divide by zero. 59 ni. Which of the following will result in a broken run arrow? a) A subVI is broken.Summary—Quiz Answer 1.

com/training .Summary—Quiz 2. Which of the following are the components and data types of the error cluster? a) Status: Boolean b) Error: String c) Code: 32-bit integer d) Source: String 60 ni.

Which of the following are the components and data types of the error cluster? a) Status: Boolean b) Error: String c) Code: 32-bit integer d) Source: String 61 ni.com/training .Summary—Quiz Answer 2.

All errors have negative error codes and all warnings have positive error codes.Summary—Quiz 3. a) True b) False 62 ni.com/training .

a) True b) False 63 ni.Summary—Quiz Answer 3.com/training . All errors have negative error codes and all warnings have positive error codes.

Summary—Quiz 4.com/training . a) True b) False 64 ni. Merge Errors function concatenates error information from multiple sources.

Summary—Quiz Answer 4.com/training . a) True b) False 65 ni. Merge Errors function concatenates error information from multiple sources.

C. D. G. E. B.Lesson 3 Implementing a VI TOPICS A.com/training . 66 Front Panel Basics LabVIEW Data Types Documenting Code While Loops For Loops F. I. H. Timing a VI Data Feedback in Loops Plotting Data – Waveform Chart Case Structures ni.

Front Panel Basics 67 ni.A.com/training .

Front Panel Basics Front panel controls and indicators create terminals on the block diagram.com/training . 68 ni.

LabVIEW Data Types Shortcut Menu and Properties Dialog Box Numeric Types Boolean Types String Types Enums and Other Types 69 ni.com/training .B.

com/training .LabVIEW Data Types Terminals visually communicate information about the data type represented 70 ni.

right-click the object. • To access the shortcut menu.com/training 71 . • Use shortcut menu items to change the look or behavior of objects. 71 ni.Shortcut Menus • All LabVIEW objects have associated shortcut menus.

72 ni.com/training 72 . right-click the object and select Properties.Properties Dialog Box • All LabVIEW objects have properties. • Select multiple objects to simultaneously configure shared properties. • To access properties. • Property options are similar to shortcut menu options.

Numerics Various data type representations: • Floating-point • Unsigned integers • Signed integers 73 ni.com/training .

• LabVIEW chooses the representation that uses more bits.com/training . − Occurs when a node expects an input with a different representation.Numeric Conversion Coercion Dot • Coercion dots indicate that LabVIEW converted the value passed into a node to a different representation. • Avoid coercion by programmatically converting to a matching data type. 74 ni.

com/training . • Boolean have only TRUE/FALSE values.Booleans • Behavior of Boolean controls is specified by the mechanical action. 75 ni.

Mechanical Action of Booleans 76 ni.com/training .

DEMONSTRATION .Mechanical Action of Booleans Use the Properties»Operations tab of a Boolean control to learn about the different switch and latch actions.

• Strings have various display styles.com/training .Strings • A string is a sequence of ASCII characters. − Backslash codes − Password − Hex 78 ni.

− String − 16-bit Integer 79 ni.Enums • Enums give users a list of items from which to select.com/training . • Each item represents a pair of values.

com/training . • Path − Stores the location of a file or directory using the standard syntax for the platform you are using. and dt of a waveform. 80 ni. • Dynamic − Stores the information generated or acquired by an Express VI.Other Data Types Refer to LabVIEW Help for complete list of terminal symbols for different types of controls and indicators. start time. • Waveform − Carries the data.

Searching Help for Data Types Use LabVIEW Help to learn about LabVIEW data types. DEMONSTRATION .

com/training .C. Documenting Code VI Descriptions Tip Strips Labels Free Owned 82 ni.

com/training .Documenting Code VI • Name • Description 83 • • • • Front Panel Block Diagram Label Names Tip Strips Descriptions Free Labels • Label Names • Free Labels • Owned Labels • SubVI Descriptions ni.

com/training .Creating Descriptions and Tip Strips Use the Properties dialog box to create documentation for an object. 84 ni.

• Have transparent backgrounds. • Double-click in any open space to create. • Explain data contents of wires and objects. 85 ni. • Move with object. • Select Visible Items»Label from the shortcut menu to create. • Have pale yellow backgrounds.Documenting Block Diagram Code Free labels: Owned labels: • Describe algorithms.com/training .

Exercise 3-1 Temperature Warnings VI Create and document a VI. GOAL .

Temperature value is lower than the Min. Temperature value? DISCUSSION .Exercise 3-1 Temperature Warnings VI What happens if the Max.

While Loops Iteration and Conditional Terminals Tunnels Error Checking 88 ni.D.com/training .

Until Condition met.While Loops Repeat (code). End. LabVIEW While Loop 89 Flowchart Pseudo Code ni.com/training .

While Loops Iteration terminal Conditional terminal • Returns number of times loop has executed. • Has two options. • Is zero-indexed.com/training . − Stop if True − Continue if True Iteration Terminal 90 Conditional Terminal ni. • Defines when the loop stops.

91 ni. • Data pass out of a loop after the loop terminates. • When a tunnel passes data into a loop. the loop executes only after data arrive at the tunnel.While Loops – Tunnels • Tunnels transfer data into and out of structures.com/training .

com/training .While Loops – Error Checking and Error Handling Use an error cluster in a While Loop to stop the While Loop if an error occurs. 92 ni.

GOAL .Exercise 3-2 Auto Match VI DEMONSTRATION Use a While Loop and an iteration terminal and pass data through a tunnel.

Exercise 3-2 Auto Match VI How many times is the Number of Iterations indicator updated? Why? DISCUSSION .

End of Week 2 95 DISCUSSION .