Top Banner
ni.com/ training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ
66

Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

Mar 31, 2015

Download

Documents

Lily Pell
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

LabVIEW Workshop #1

Diego TorresLabVIEW Student Ambassador

Fall 2011ITESM CQ

Page 2: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

TOPICS

ni.com/training

A. Compiled graphical development environmentB. Development time reduction of four to ten timesC. Tools to acquire, analyze, and present your data

What is LabVIEW?Laboratory Virtual Instrumentation Engineering Workbench

Page 3: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

TOPICS

ni.com/training

Navigating LabVIEW

A. Virtual Instruments (VIs)B. Parts of a VIC. Starting a VID. Project ExplorerE. Front PanelF. Block Diagram

G. Searching for Controls, VIs and Functions

H. Selecting a ToolI. DataflowJ. Polymorphism

3

Page 4: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

A. Virtual Instruments (VIs)

The appearance and operation of VIs imitate physical instruments, such as oscilloscopes and digital multimeters.

4

Virtual Instrument (VI) – A LabVIEW program

Page 5: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

B. Parts of a VI

LabVIEW VIs contain three main components:1. Front Panel 2. Block Diagram 3. Icon/Connector Pane

5

Page 6: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

B. Parts of a VI – Front Panel

You build the front panel with controls (inputs) and indicators (outputs)

6

Front Panel – User interface for the VI

Page 7: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

B. Parts of a VI – Block Diagram

Front panel objects appear as terminals on the block diagram

7

Block Diagram – Contains the graphical source code

Page 8: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

B. Parts of a VI – Icon/Connector Pane

• Icon: graphical representation of a VI• Connector Pane: map of the inputs and outputs of a VI• Icons and connector panes are necessary to use a VI as

a subVI− A subVI is a VI that is inside of another VI− Similar to a function in a text-based programming

language Icon Connector Pane

8

Page 9: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DEMONSTRATION

C. Starting a VI

Demonstrate using the Getting Started dialog box and the New dialog box to start a VI.

Page 10: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

D. Project Explorer

Use LabVIEW Projects to:• Group LabVIEW files and non-LabVIEW files• Create build specifications• Deploy or download files to targets

10

Page 11: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DEMONSTRATION

Using the Project Explorer

Demonstrate creating a project, adding files, and removing files.

Page 12: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Controls Palette

• Contains the controls and indicators you use to create the front panel

• Access from the front panel by selecting View»Controls Palette

12

Page 13: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Front Panel Toolbar

13

Page 14: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Controls & Indicators

• Controls− Knobs, push buttons, dials, and other input devices− Simulate instrument input devices and supply data to the block

diagram of the VI• Indicators

− Graphs, LEDs, and other displays− Simulate instrument output devices and display data the block

diagram acquires or generates

14

Page 15: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Numeric Controls/Indicators

The numeric data type can represent numbers of various types, such as integer or real

15

Numeric Indicator

Numeric Control

Increment/Decrement Buttons

Page 16: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Boolean Controls/Indicators

• The Boolean data type represents data that only has two parts, such as True and False or On and Off• Use Boolean controls and indicators to enter and display

Boolean (True or False) values• Boolean objects simulate switches, push buttons, and LEDs

16

BooleanControl

BooleanIndicator

Page 17: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Strings

• The string data type is a sequence of ASCII characters • Use string controls to receive text from the user such as a

password or user name• Use string indicators to display text to the user

17

Page 18: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

LabVIEW Data Types – Terminals

Terminals visually communicate information about the data type represented

Page 19: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

LabVIEW Data Types – Numerics

• The numeric data type represents numbers of various types• To change the representation

of a numeric, right-click the control, indicator, or constant, and select Representationfrom the shortcut menu

Page 20: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

LabVIEW Data Types – Boolean

• Behavior of Boolean controls is specified by the mechanical action• In LabVIEW, the Boolean

data type is represented with the color green

Page 21: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Mechanical Action of Booleans

Use the Mechanical Action of Booleans VI located in the NI Example Finder to learn about the different switch and latch actions.

Page 22: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Data Types – String

• A sequence of displayable or non-displayable ASCII characters• On the front panel, strings appear as tables,

text entry boxes, and labels• Change the display type from the short-cut

menu: Normal, ‘\’ Codes, Password and Hex• Edit and manipulate strings with the String functions on the

block diagram• In LabVIEW, the string data type is represented with the color

pink

Page 23: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Data Types – Enum

An enum represents a pair of values, a string and a numeric, where the enum can be one of a defined list of values

Page 24: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Data Types – Enum

• Enum: enumerated control, constant, or indicator• Enums are useful because it is easier

to manipulate numbers than strings on the block diagram

Page 25: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Data Types – Dynamic

• Stores the information generated or acquired by an Express VI• Non-Express VIs do not accept the dynamic data type

− To use a built-in VI or function to analyze or process the dynamic data type, you must convert the data type

− Numeric, waveform, or Boolean data indicators or inputs automatically convert the dynamic data type when wired

• In LabVIEW, the dynamic data type is represented with the color dark blue

Page 26: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Shortcut Menus

• All LabVIEW objects have associated shortcut menus

• As you create a VI, use the shortcut menu items to change the look or behavior of front panel and block diagram objects

• To access the shortcut menu, right-click the object

26

Page 27: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Property Dialog Box

• Right-click a front panel object and select Properties to display

• The options available on the property dialog box are similar to the options available on the shortcut menu for that object

27

Page 28: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

E. Front Panel – Configure Multiple Objects

• Select multiple objects to simultaneously configure shared properties

28

Page 29: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram

Block diagram objects include the following:

• Terminals• SubVIs• Functions• Constants• Structures• Wires

29

Page 30: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Functions Palette

Contains the VIs, functions, and constants you use to create the block diagram

30

Page 31: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Block Diagram Toolbar

31

Page 32: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Terminals

• Terminals are:− Block diagram appearance of front panel objects− Entry and exit ports that exchange information between the

front panel and block diagram− Analogous to parameters and constants in text-based

programming languages• Change the view type of a terminal by toggling the View as

Icon selection from the context menu

32

Page 33: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram Terminals

33

Page 34: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Nodes

• Objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs• Analogous to statements, operators, functions, and

subroutines in text-based programming languages• Nodes can be functions, subVIs, or structures

34

Nodes

Page 35: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Function Nodes

• Fundamental operating elements of LabVIEW• Do not have front panels or block diagrams, but do have

connector panes• Double-clicking a function only selects the function – does

not open it like a VI• Has a pale yellow background on its icon

35

Page 36: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – SubVI Nodes

• SubVI: VIs that you build to use inside of another VI• Any VI has the potential to be used as a subVI• When you double-click a subVI on the block diagram, you

can view the front panel and block diagram of the subVI− The upper right corner of the front panel and block diagram

displays the icon for the current VI− This is the icon that appears when you place the VI on a block

diagram as a subVI

36

Page 37: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – SubVI Nodes

• Express VIs are a special type of subVI− Require minimal wiring because you configure them

with dialog boxes− Save the configuration of an Express VI as a subVI• Icons for Express VIs appear on the block diagram

as icons surrounded by a blue field

37

Page 38: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Icons/Expandable Nodes

38

Page 39: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Wires

• Transfer data between block diagram objects through wires• Wires are different colors, styles, and thicknesses,

depending on their data types• A broken wire appears as a dashed

black line with a red X in the middle

39

Scalar1D Array2D Array

DBL Numeric Integer Numeric String

Page 40: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Wiring Tips

• Press <Ctrl>-B to delete all broken wires• Right-click and select Clean Up Wire to reroute the wire

40

Page 41: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

F. Block Diagram – Wiring Tips

Use the Clean Up Diagram tool to reroute multiple wires and objects to improve readability

1. Select a section of your block diagram2. Click the Clean Up Diagram button on the block diagram

toolbar

41

Page 42: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

GOAL

Exercise 2-1Concept: Exploring a VI

Identify the parts of an existing VI.

Page 43: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DISCUSSION

Exercise 2-1Concept: Exploring a VI

• What are constants and when should you use them?• What are free labels and when should you use them?

Page 44: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

G. Searching for Controls, VIs & Functions

Find controls, functions, and VIs using the Search button on the Controls and Functions palette.

44

Page 45: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

G. Global Search

The Search bar in the top right of the Front Panel and Block Diagram windows can be used to search the palettes, help, and ni.com.

45

Page 46: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

GOAL

Exercise 2-2Concept: Navigating Palettes

Learn to use the palettes and search for controls, functions and VIs.

Page 47: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DISCUSSION

Exercise 2-2Concept: Navigating Palettes

• Why would you want to add a function to the Favorites category in the Functions palette?

Page 48: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

H. Selecting A Tool

• Create, modify, and debug VIs using the tools provided by LabVIEW• A tool is a special operating mode of the

mouse cursor• The operating mode of the cursor corresponds to the icon of

the tool selected• When using the Automatic Tool Selection, LabVIEW

chooses which tool to select based on the current location of the mouse

48

Page 49: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

GOAL

Exercise 2-3Concept: Selecting A Tool

Gain experience using the Automatic Tool Selection to select which tool to use.

Page 50: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DISCUSSION

Exercise 2-3Concept: Selecting A Tool

• How do you enable automatic tool selection?

Page 51: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

I. Dataflow

LabVIEW follows a dataflow model for running VIs• A node executes only when data are available at all of its

input terminals• A node supplies data to the output terminals only when the

node finishes execution

51

Page 52: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

I. Dataflow – Quiz

Which node executes first? a) Addb) Subtractc) Random Numberd) Divide e) Sine

52

Page 53: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

I. Dataflow – Quiz Answers

NO CORRECT ANSWER

Which node executes first? a) Add – possiblyb) Subtract – definitely notc) Random Number – possiblyd) Divide – possiblye) Sine – definitely not

53

Page 54: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

GOAL

Exercise 2-4Concept: Dataflow

Understand how dataflow determines the execution order in a VI.

Page 55: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

DISCUSSION

Exercise 2-4Concept: Dataflow

• Should a well-designed block diagram flow in a particular direction?

Page 56: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

J. Polymorphism

Definition: a programming language feature that allows values of different data types to be handled using a uniform interface.

In LabVIEW: the ability of VIs and functions to automatically adapt to accept input data of different data types

i.e. Numeric Functions Useful when performing the same

operation on different data types

Page 57: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz

1. Which function executes first: Add or Subtract?a) Addb) Subtractc) Unknown

57

Page 58: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz Answer

1. Which function executes first: Add or Subtract?a) Addb) Subtractc) Unknown

58

Page 59: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz

2. Which function executes first: Sine or Divide?a) Sineb) Dividec) Unknown

59

Page 60: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz Answer

2. Which function executes first: Sine or Divide?a) Sineb) Dividec) Unknown

60

Page 61: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz

3. Which of the following functions executes first: Random Number, Add or Divide?a) Random Numberb) Dividec) Addd) Unknown

61

Page 62: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz Answer

3. Which of the following functions executes first: Random Number, Add or Divide?a) Random Numberb) Dividec) Addd) Unknown

62

Page 63: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz

4. Which of the following functions execute last: Random Number, Subtract or Add?a) Random Numberb) Subtractc) Addd) Unknown

63

Page 64: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz Answer

4. Which of the following functions execute last: Random Number, Subtract or Add?a) Random Numberb) Subtractc) Addd) Unknown

64

Page 65: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz

5. What are the three parts of a VI?a) Front Panelb) Block Diagramc) Projectd) Icon/Connector Pane

65

Page 66: Ni.com/training LabVIEW Workshop #1 Diego Torres LabVIEW Student Ambassador Fall 2011 ITESM CQ.

ni.com/training

Summary—Quiz Answer

5. What are the three parts of a VI?a) Front Panelb) Block Diagramc) Projectd) Icon/Connector Pane

66