What is LabVIEW

Download Report

Transcript What is LabVIEW

LabVIEW an Introduction

Alan Holloway

1

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.

Getting started with LabVIEW http://www.ni.com

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

1-2

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.

Getting started with LabVIEW http://www.ni.com

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

1-3

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

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 Getting started with LabVIEW http://www.ni.com

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

1-5

LabVIEW front panel

Getting started with LabVIEW http://www.ni.com

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

1-6

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

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.

Getting started with LabVIEW http://www.ni.com

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

1-8

Front panel & corresponding block diagram

Getting started with LabVIEW http://www.ni.com

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

1-9

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. Getting started with LabVIEW http://www.ni.com

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

1-10

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.

Getting started with LabVIEW http://www.ni.com

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

1-11

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.

Getting started with LabVIEW http://www.ni.com

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

1-12

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 Getting started with LabVIEW http://www.ni.com

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

1-13

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 Getting started with LabVIEW http://www.ni.com

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

1-14

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.

Getting started with LabVIEW http://www.ni.com

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

1-15

Drawing loops

 1 Select the structure required  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

1-16

Loops

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

1-17

Loops

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

1-18

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

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. Getting started with LabVIEW http://www.ni.com

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

1-20

Case statement

 Boolean True/False  Numeric 0,1,2,3 …..n

 String "Alan", "Mark", "Graham" etc Getting started with LabVIEW http://www.ni.com

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

1-21

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

. Getting started with LabVIEW http://www.ni.com

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

While loop executes every 250ms

1-22

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 Getting started with LabVIEW http://www.ni.com

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

1-23