ahmet ozmen

43
AHMET OZMEN

Upload: willem

Post on 23-Feb-2016

44 views

Category:

Documents


0 download

DESCRIPTION

AHMET OZMEN. Virtual Instruments (VIs). LabVIEW programs are called virtual instruments, or VIs Appearance and operation imitate physical instruments, such as oscilloscopes and digital multimeters. Parts of a VI. LabVIEW VIs contain three main components: Front Panel - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: AHMET OZMEN

AHMET OZMEN

Page 2: AHMET OZMEN

2

Virtual Instruments (VIs)

•LabVIEW programs are called virtual instruments, or VIs•Appearance and operation imitate physical instruments, such as oscilloscopes and digital multimeters

Page 3: AHMET OZMEN

3

Parts of a VI

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

Page 4: AHMET OZMEN

The LabVIEW Environment“VI” = program or function

“Front Panel” = user interface “Block Diagram” = code

Page 5: AHMET OZMEN

Front Panel-Controls & Indicators• Knobs/Dials• Graphs/Charts• Buttons• Digital Displays• Sliders• Thermometers• Customize and

create your own

Page 6: AHMET OZMEN

6

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

Page 7: AHMET OZMEN

7

Front Panel – Front Panel Toolbar

Page 8: AHMET OZMEN

8

Block Diagram

Block diagram objects include the following:

–Terminals–SubVIs–Functions–Constants–Structures–Wires

Page 9: AHMET OZMEN

9

Block Diagram – Functions Palette• Contains the VIs, functions, and

constants you use to create the block diagram

Page 10: AHMET OZMEN

10

Block Diagram – Block Diagram Toolbar

Page 11: AHMET OZMEN

11

Block Diagram Terminals

Page 12: AHMET OZMEN

12

Searching for Controls, VIs & Functions

• Find controls, function, and VIs using the Search button on the Controls and Functions palette

Page 13: AHMET OZMEN

13

DataflowLabVIEW 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

Page 14: AHMET OZMEN

Dataflow Programming

123

Comparison waits until all inputs are present, then executesOnce executed, output from comparison continues through code

Both Simulate Signal Express VIs execute simultaneously

1 2 3

Block

Diagram

Page 15: AHMET OZMEN

15

Building a Simple VI

Page 16: AHMET OZMEN

16

Building a Simple VI – Acquire

Acquire Express VIs:

• DAQ Assistant Express VI

• Instrument I/O Assistant Express VI

• Simulate Signal Express VI

• Read from Measurement File Express VI

Page 17: AHMET OZMEN

17

Building a Simple VI – Analyze Analyze Express VIs:

• Amplitude and Level Measurements Express VI

• Statistics Express VI

• Spectral Measurements Express VI

• Tone Measurements Express VI

• Filter Express VI

Page 18: AHMET OZMEN

Built-in Programming Assistance

Highlight Execution

Block Diagram Cleanup

Context Help

Page 19: AHMET OZMEN

PC-Based Data Acquisition (DAQ)

Page 20: AHMET OZMEN

DAQ Demo

Page 21: AHMET OZMEN

While Loops

LabVIEW While Loop Flowchart Pseudo Code

Repeat (code);Until Condition met;End;

Page 22: AHMET OZMEN

While Loops• Iteration terminal: returns number of times

loop has executed; zero indexed• Conditional terminal: defines when the loop

stops

Iteration Terminal Conditional Terminal

Page 23: AHMET OZMEN

While Loops – Tunnels

• Tunnels transfer data into and out of structures• The tunnel adopts the color of the data type wired to

the tunnel• 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

Page 24: AHMET OZMEN

While Loops - Error Checking and Error Handling

• Use an error cluster in a While Loop to stop the While Loop if an error occurs

Page 25: AHMET OZMEN

For Loops

LabVIEW For Loop Flowchart Pseudo Code

N=100;i=0;Until i=N:Repeat (code;i=i+1);

End;

Page 26: AHMET OZMEN

For Loops

• Create a For Loop the same way you create a While Loop

• If you need to replace an existing While Loop with a For Loop, right-click the border of the While Loop, and select Replace with For Loop from the shortcut menu

• The value in the count terminal (an input terminal) indicates how many times to repeat the subdiagram

Page 27: AHMET OZMEN

Timing a VI

Why do you need timing in a VI?• Control the frequency at which a loop

executes• Provide the processor with time to complete

other tasks, such as processing the user interface

Page 28: AHMET OZMEN

Timing a VI – Wait Functions

• A wait function inside a loop allows the VI to sleep for a set amount of time

• Allows the processor to address other tasks during the wait time

• Uses the operating system millisecond clock

Page 29: AHMET OZMEN

Timing Methods– Wait VI – Constant time of execution– Execute A, Execute B, sleep 10 ms

– Wait Until Next Multiple VI – Variable time of execution

– Execute A, Execute B, sleep until OS timer reaches next multiple of 20 ms

29

Page 30: AHMET OZMEN

Timing a VI – Elapsed Time Express VI

• Determines how much time elapses after some point in your VI

• Keep track of time while the VI continues to execute

• Does not provide the processor with time to complete other tasks

Page 31: AHMET OZMEN

Iterative Data Transfer – Shift Registers

• Right-click the border and select Add Shift Register from the shortcut menu

• Right shift register stores data on completion of an iteration• Left shift register provides stored data at beginning of the next

iteration

Page 32: AHMET OZMEN

Case Structures• Have two or more subdiagrams or cases• Execute and displays only one case at a time• An input value determines which subdiagram to execute• Similar to case statements or if...then...else

statements in text-based programming languages

Page 33: AHMET OZMEN

Case Structures

• Case Selector Label: contains the name of the current case and decrement and increment buttons on each side

• Selector Terminal: Wire an input value, or selector, to determine which case executes

Page 34: AHMET OZMEN

Case Structures – Default Case• You can specify a default

case for the Case structure– If you specified cases for 1, 2,

and 3, but you get an input of 4, the Case structure executes the default case

• Right-click the Case structure border to add, duplicate, remove, or rearrange cases and to select a default case

Page 35: AHMET OZMEN

State Programming

Although Sequence structures or sequentially wired subVIs accomplish the purpose, it is not always the best choice:– What if you need to change the order of the sequence? – What if you need to repeat one item in the sequence

more often than the other items? – What if some items in the sequence execute only when

certain conditions are met? – What if you need to stop the program immediately,

rather than waiting until the end of the sequence?

Page 36: AHMET OZMEN

State Machines

– The state machine design pattern implements a state diagram or flow chart

– When to use state machines?• Commonly used to create user interfaces, where

different user actions send the user interface into different states • Commonly used for process tests, where a state

represents each segment of the process

Page 37: AHMET OZMEN

State Machines – Infrastructure

– A state machine consists of a set of states and a transition function that maps to the next state

– Each state can lead to one or multiple states or end the process flow

While Loop

Case StructureShift Register

Page 38: AHMET OZMEN

State Machines – Default Transition

Page 39: AHMET OZMEN

Parallelism

– Often, you need to program multiple tasks so that they execute at the same time

– In LabVIEW, tasks can run in parallel if they do not have a data dependency between them, and if they do not use the same shared resource• An example of a shared resource is a file, or an

instrument

Page 40: AHMET OZMEN

• LabVIEW automatically divides each application into multiple execution threads (introduced in 1998 with LabVIEW 5.0)

• Parallel code paths will execute in unique threads

Automatic Multithreading in LabVIEW

thread

thread

thread

Page 41: AHMET OZMEN

Multiple Loop Architectures

41

Page 42: AHMET OZMEN

Triggered Acquisition Demo

Page 43: AHMET OZMEN

THANK YOU!