LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW...

46
LabVIEW Lecture 1 Ertugrul Karademir

Transcript of LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW...

Page 1: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

LabVIEW Lecture 1

Ertugrul Karademir

Page 2: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

What is LabVIEW?

• Graphical programming environment

• Measurement, testing, control applications

• Hardware control

• Flowchart representation• Flowchart representation

• Object Oriented Approach

Page 3: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

What is LabVIEW?

Page 4: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

What is LabVIEW?

Page 5: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Virtual Instrument

• LabVIEW programming paradigm

1. Program control with a front panel

2. Algorithm with block diagram

• Easy to debug

• Hard to program

Page 6: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Front Panel

t

Controls Palette

View > Controls Palette

Page 7: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Block Diagram

Functions Palette

View > Functions Palette

Page 8: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Front Panel – Block Diagram

• To toggle between two panels

Ctrl + E

Page 9: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Context Help

Ctrl + H

Page 10: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Detailed help

Page 11: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Three fashions of variables

• Mixture of GUI and console

1. Controls

– User input (In Java: TextBox GUI Component)

2. Indicators2. Indicators

– Program output (In Java: Label GUI Component)

3. Constants

– Predefined constants (In Java: Class variables

with constconstconstconst definer)

Page 12: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Controls

• Selected from Controls Palette

• Usually Express Palette is

enoughenough

Page 13: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Controls

Page 14: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Controls

• Each control has a proxy in the Block

diagram

• Note that proxy has only OUTPUT node

Page 15: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Indicators

• Also Selected from Controls Palette

• Usually Express Palette is

enoughenough

Page 16: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Indicators

Page 17: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Indicators

• Each indicator also has a proxy in the

Block diagram

• Note that proxy has only INPUT node

Page 18: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Constants

• You can use functions

palette to insert constantspalette to insert constants

Page 19: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Constants

• Constants only live in Block diagram

Page 20: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Search

• You can always seach for the item

• Click on the search button on the palettes

Page 21: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Types

• All standard types are present

– Integer (signed, unsigned, long, word, byte, quad)

– Floating point (single precision, double precision,

extended precision)extended precision)

– Boolean

– String

• All of above can be arranged in arrays,

matrices, clusters

Page 22: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Flow Chart Paradigm

• Flow of execution is done by following nodes

in a flow diagram

NODE NODE NODE NODELEVEL 1

NODE NODE NODE NODELEVEL 2 NODE

And so on...

Page 23: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Wiring

• Defines the direction of flow

NODE

NODE

Page 24: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Wiring

• One to many connection is acceptable

• Many to one connection is illegal

Page 25: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Wiring

• Application of algorithm is done by wiring

• Color of the wire indicates type• Blue: Integer , Orange: Floating Point

• Purple: String, Green: Boolean

Red dot indicates

that “wrong type

has wired but it’s

OK, he has made

the type-casting”.

Page 26: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Algorithm Construction

All algoritm structures lies in Programming

Sub-Palette

Page 27: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Algorithm Construction

Program flow structures are under Structures

Sub-sub-palette

Page 28: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Program Control

PAUSE

RUN RUN

CONTINUOUSLY

STOP

PAUSE

Page 29: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Debugging

HIGHLIGHT

EXECUTION

Page 30: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Debugging

• Broken Arrow Means ERROR

• Click to see Error List

Page 31: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Program Flow Control

• For loops

• While loops

• Sequences

– Flat sequence– Flat sequence

– Stacked sequence

• And many more

• Compansates for: Event handling, Top-to-

bottom execution, OOP, etc.

Page 32: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop

• Loop for limited

iterations

• Must know the iteration

amount before-handamount before-hand

• Loop count can-not be

change once set

Page 33: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop

Another way to create

variables: Right clicking

onto the node

Page 34: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

• Get some number from the user

• Add 3 to it 10 times

• Display the result

Page 35: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

Page 36: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

Shift registers convey

result of one iteration

to the next iteration

Page 37: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

Page 38: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

Do not limit your

imagination

Page 39: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

For loop example

User only interacts with three objects

Page 40: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

While loop

•Loops until the loop

condition is satisfied

•Or while the loop

condition is not

satisfiedsatisfied

•Select by clicking

on the loop

condition

Page 41: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

While loop example

Page 42: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

While loop example

Employ boolean and comparison palette

controls to manage loop condition

Page 43: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

While loop example

Page 44: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Flat sequence

Executes contents of each

frame one by one

Page 45: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Flat sequence

Page 46: LabVIEW Lecture 1 - Bilkent Universityphysics/phys580/files/LabVIEW_Lecture_1.pdf · LabVIEW Lecture 1 Ertugrul Karademir. What is LabVIEW? • Graphical programming environment •

Flat sequence