+ All Categories
Home > Documents > 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language...

1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language...

Date post: 26-Dec-2015
Category:
Upload: coral-townsend
View: 225 times
Download: 0 times
Share this document with a friend
Popular Tags:
23
1 LabVIEW an Introduction Alan Holloway
Transcript
Page 1: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

1

LabVIEW an Introduction

Alan Holloway

Page 2: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

What is LabVIEW

LabVIEW is a graphical programming language that uses icons instead of lines of text to create applications.

In contrast to text-based programming languages, where instructions determine program execution, LabVIEW uses dataflow programming, where data determine execution.

1-2

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 3: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Using LabVIEW

In LabVIEW, you build a user interface by using a set of tools and objects.

The user interface is known as the front panel. You then add code using graphical representations of functions to control the front panel objects.

The block diagram contains this code. If organized properly, the block diagram resembles a flowchart.

1-3

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 4: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Virtual Instruments (VI)

LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters.

1-4

Page 5: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Front Panel

The front panel is the user interface of the VI. You build the front panel with controls and indicators, which are the interactive input and output terminals of the VI, respectively.

Controls are knobs, push buttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays.

Controls simulate instrument input devices and supply data to the block diagram of the VI. Indicators simulate instrument output devices and display data the block diagram acquires or generates

1-5

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 6: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

LabVIEW front panel

1-6Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 7: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Block diagram

After you build the front panel, you add code using graphical representations of functions to control the front panel objects.

The block diagram contains this graphical source code.

Front panel objects appear as terminals on the block diagram.

You cannot delete a terminal from the block diagram. The terminal disappears only after you delete its corresponding object on the front panel.

1-7

Page 8: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Block diagram

Every control or indicator on the front panel has a corresponding terminal on the block diagram.

Additionally, the block diagram contains functions and structures from built-in LabVIEW VI libraries.

Wires connect each of the nodes on the block diagram, including control and indicator terminals, functions and structures.

1-8

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 9: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Front panel & corresponding block diagram

1-9

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 10: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Tools palette The Tools palette is available on the front

panel and the block diagram. A tool is a special operating mode of the

mouse cursor. When you select a tool, the cursor icon changes to the tool icon.

Use the tools to operate and modify front panel and block diagram objects.

Select View»Tools Palette from the taskbar to display the Tools palette.

1-10

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 11: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Controls palette The Controls palette is only

available on the front panel. The Controls palette contains the front panel controls and indicators you use to create the user interface.

Select View» Controls Palette or right-click the front panel workspace to display the Controls palette.

1-11

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 12: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Functions palette The Functions palette is available

only on the block diagram. The Functions palette contains the objects you use to program your VI, such as arithmetic, instrument I/O, file I/O, and data acquisition operations.

Select View» Functions Palette from the taskbar or right-click the block diagram workspace to display the Functions palette.

1-12Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 13: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Status Toolbar

Click the Run button to run the VI. While the VI runs, the Run button appears with a black arrow if the VI is a top-level VI, meaning it has no callers and therefore is not a subVI.

• While the VI runs, the Abort Execution button appears. Click this button to stop the VI immediately.

• Note: Avoid using the Abort Execution button to stop a VI. Either let the VI complete its data flow or design a method to stop the VI programmatically

1-13Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 14: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Elements of typical programs

A - Loops While loop For loop

B - Decision making & file I/O Case structure (if statement) Event structure

C - Functions & sub VIs Built in LabVIEW functions Creating sub VI's

1-14

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 15: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Loops

Nearly all programs involve some sort of loop where all or sections of the program must be repeated.

Both the While and For Loops are located on the Functions»Structures palette.

The For Loop differs from the While Loop in that the For Loop executes a set number of times.

A While Loop stops executing the subdiagram only if the value at the conditional terminal exists.

1-15Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 16: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Drawing loops

1 Select the structure required

1-16

2 Enclose the code to be repeated (looped)

3 Wire the appropriate loop conditions

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 17: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Loops

While loops Runs until the stop condition is met Always runs at least once Counts number of iterations

1-17

Page 18: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Loops

For loop Runs according to input N number of iterations Counts the number of iterations

1-18

Page 19: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

LabVIEW Functions

What types of function are available Analysis

Signal processing Statistics Advanced math & formulae

Storage File I/O Zip

ARM specific Simulation Read digital I/O

+Many more!

1-19

Page 20: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Decision making

The case structure has one or more subdiagrams, or cases, one of which executes when the structure executes.

The value wired to the selector terminal determines which case to execute and can be Boolean, string, integer or enumerated type.

Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case.

1-20Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 21: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Case statement

Boolean - True/False

Numeric 0,1,2,3 …..n

String "Alan", "Mark", "Graham" etc

1-21Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 22: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Timing

It may be necessary to add some sort of timing to your program.

You can add a timing delay using the Wait Until Next ms Multiple Function

Waits until the value of the millisecond timer becomes a multiple of the specified millisecond multiple.

1-22

While loop executes every 250ms

Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com

Page 23: 1 LabVIEW an Introduction Alan Holloway. What is LabVIEW LabVIEW is a graphical programming language that uses icons instead of lines of text to create.

Summary

LabVIEW programs are called virtual instruments (VIs). Controls are inputs and indicators are outputs. Each VI contains three main parts:

• Front panel – How the user interacts with the VI• Block diagram – The code that controls the program• Icon/connector – The means of connecting a VI to

other VIs

1-23Getting started with LabVIEW http://www.ni.com Introduction to LabVIEW in 3 Hours http://www.ni.com


Recommended