Introduction to LabVIEW

Slides:



Advertisements
Similar presentations
A. Virtual Instruments (VIs)
Advertisements

Previously… We created a simulated temperature reader which alerts if too hot or too cold… Download the solved practice to keep in sync: Thermostat.vi.
LabVIEW is a graphical programming development environment for data acquisition and control, data analysis, and data presentation. With LabVIEW you can.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 2 Virtual Instruments Read Bishop, Chapter 2. Lab #2 and Homework #2 due next week. Quiz #1 next week.
Lesson 2 Navigating LabVIEW
Based on LabVIEW 2011 Student Edition
LabVIEW and G Graphical Programming Language By: Ramtin Raji Kermani.
1. 2 LabVIEW for FRC Doug Norman National Instruments January 6, 2012.
Loops in LabVIEW (while,for and case)
De la Rosa-Pohl ECE 1100 Introduction to Engineering Intro to LabVIEW: Programming for Symon University of Houston Diana de la Rosa-Pohl Len Trombetta.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 5 Loops  Read Bishop, Sections 5.1 and 5.2.  Lab #5 and Homework #5 due next week.  Exam #1 next.
Introduction to LabVIEW 8.5
Hands-On Material From National Instruments Introduction to LabVIEW Electrical Wiring Feng-Ju Hsieh ENGR 100 Section C.
CS320n –Visual Programming LabVIEW Foundations. Visual ProgrammingLabVIEW Foundations2 What We Will Do Today Hand back and review the midterm Look at.
Virtual Instrumentation With LabVIEW. Course Goals Understand the components of a Virtual Instrument Introduce LabVIEW and common LabVIEW functions Build.
PC Applications Course LabVIEW: Laboratory Virtual Instrument Engineering Workbench Graphical Programming Easy to use Faster Development Time.
Loops A.About While Loops B.About For Loops C.About Case structures D.Sequence Structures E.Formula Node You Will Learn:
1 Lesson 5 Clusters TOPICS Introduction to Clusters Cluster Functions Error Clusters.
Dan O. Popa, Intro to EE – Practicum, Spring 2015 EE 1106 : Introduction to EE Freshman Practicum Lecture 2: Signals, Systems and Circuits with Introduction.
Introduction to LabVIEW Seth Price Department of Chemical Engineering New Mexico Tech Rev. 10/5/14.
Virtual Instrumentation With LabVIEW
Course contents 1.Labview basics – virtual instruments, data flow, palettes 2.Structures – for, while, case,... – editing techniques 3.Controls&Indicators.
Lecture 13LabVIEW and GPIB LabVIEW (National Instruments) –Graphical program language –Widely used in academia (lab) and industry (R&D) General Purpose.
Infinity-project.org Engineering education for today’s classroom The Infinity Project SM LabVIEW for The Infinity Project.
How to use LabVIEW Ihor Korolov February 2011.
Virtual Instrumentation With LabVIEW. Course Goals Understand the components of a Virtual Instrument Introduce LabVIEW and common LabVIEW functions Build.
Get Real About Teaching with LabVIEW and myDAQ National Instruments Confidential2 STEM Education  Science, Technology, Engineering and Math Education.
Workshop 3 of 7 Welcome!. Today's Topics Review of Workshop 2 Loops While For Auto-indexing Shift registers Case Structure.
V1: HMFR, V2: MFNB, 2007 LabView Seminar University of Puerto Rico Mayagüez Campus.
Course contents 1.Labview basics – virtual instruments, data flow, palettes 2.Structures – for, while, case,... – editing techniques 3.Controls&Indicators.
Virtual Instrumentation With LabVIEW. Section I LabVIEW terms Components of a LabVIEW application LabVIEW programming tools Creating an application in.
Virtual Instrumentation With LabVIEW. Course Goals Understand the components of a Virtual Instrument Introduce LabVIEW and common LabVIEW functions Create.
MCEN 371 – Mechanical Engineering Lab Chapter 6: LabVIEW Part 1: Introduction.
Chapter 1 LabVIEW Basics. Features > Uses Graphic Symbols > Created by National Instruments > Virtual Instruments (VIs) > Extensive Library of VIs.
Virtual Instrumentation With LabVIEW. Front Panel Controls = Inputs Indicators = Outputs LabVIEW Programs Are Called Virtual Instruments (VIs) Block Diagram.
LabVIEW an Introduction
Introduction to LabVIEW
Biomedical Measurements & Analysis using LabVIEW
Each VI has 2 Windows Front Panel User Interface (UI) –Controls = Inputs –Indicators = Outputs Block Diagram Graphical Code –Data travels on wires from.
Design of Bio-Medical Virtual Instrumentation Tutorial 3.
LabVIEW in 3 Hours. What is Test & Measurement? Keypad Functionality Keypad Functionality LCD Testing LCD Testing Sound Quality Sound Quality Acoustic.
Part I MVRT 2011 – 2012 Season Introduction to LabVIEW.
LabView instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, room C204a
1. 2 LabVIEW Intro, Basics, Tips, Tricks Doug Norman & Stephanie Brierty National Instruments January 8, 2010.
Creating, Editing, & Debugging a VI A.How to Create VIs B.How to Edit VIs C.How to Debug VIs You Will Learn:
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 3 Editing and Debugging VIs  Read Bishop, Chapter 3.  Lab #3 and Homework #3 due next week.  Quiz.
Digital Electronics and Computer Interfacing Tim Mewes 4. LabVIEW - Advanced.
Introduction to LabVIEW 8.5
Lab 1 : Introduction to LabView 1 Southern Methodist University Bryan Rodriguez.
Design of Bio-Medical Virtual Instrumentation Tutorial 2.
Virtual Instrumentation With LabVIEW. Front Panel Controls = Inputs Indicators = Outputs Block Diagram Accompanying “program” for front panel Components.
CS320n –Visual Programming More LabVIEW Foundations.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 9 Arrays  Read Bishop, Sections 6.1 to 6.3.  Homework #9 and Lab #9 due next week.  Quiz #5 next.
Workshop 2 of 4 Welcome!. Survey While You Wait ni.com/duke >> Recent Documents >> LabVIEW Workshop Participation Survey.
Digital Electronics and Computer Interfacing Tim Mewes 2. LabVIEW Basics part II.
LabVIEW Course Course 2.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
EET 2259 Unit 3 Editing and Debugging VIs
Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1
Introduction to LabVIEW
Lesson 2: Introduction to Control programming using Labview
הודעות ריענון מהיר והרחבות כתיבה לקובץ Low-Level דגימת אות Low-Level
Chapter 1 LabVIEW Basics
LabVIEW 7.1 寒假短期教學課程 歐陽丞修 2006/02/06.
Structures- case, sequence, formula node
Introduction to LabVIEW
LabVIEW基礎課程(一) 參考書籍: LabVIEW for Everyone (Jeffrey Travis/Jim Kring)
EET 2259 Unit 2 Virtual Instruments
EET 2259 Unit 3 Editing and Debugging VIs
Presentation transcript:

Introduction to LabVIEW ES110

Graphical programming language & Data flow LabVIEW relies on graphical symbols rather than textual language to describe programming actions The principle of dataflow, in which functions execute only after receiving the necessary data, governs execution in a straightforward manner

How does LabVIEW work? LabVIEW programs are called: Virtual Instruments (VIs) because their appearance and operation imitate actual instruments. However, they are analogous to main programs, functions and subroutines from popular language like C, Fortran, Pascal, …

LabVIEW Programs Are Called Virtual Instruments (VIs) Front Panel Controls = Inputs Indicators = Outputs Block Diagram Accompanying “program” for front panel Components “wired” together LabVIEW programs are called virtual instruments (VIs). Stress that controls equal inputs, indicators equal 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 – Means of connecting a VI to other VIs. The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. Stress that controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. Every front panel control or indicator has a corresponding terminal on the block diagram. When a VI is run, values from controls flow through the block diagram, where they are used in the functions on the diagram, and the results are passed into other functions or indicators.

LabVIEW Introduction Two “sets” for development Wiring connections Front Panel Block Diagram Wiring connections LabVIEW Conventions Running LabVIEW programs

LabVIEW Front Panel All user interface goes here! Used to display Controls or Indicators Highly customizable

LabVIEW Block Diagram Actual program Invisible to user Read left to right, like a book Where the MAGIC happens!

Terminals When you place a control (or indicator) on the FRONT PANEL LabVIEW automatically creates a corresponding control (or indicator) terminal on the BLOCK DIAGRAM

Control? or Indicator? Controls = Inputs from the user = Source Terminals Indicators = Outputs to the user = Destinations

Manipulating Controls and Indicators Right click on an indicator to Change to control Change format or precision Right click on a control to Change to indicator Change mechanical action (whether to latch open or closed, and what to use as default…)

Wiring Connections Wires transport data through the block diagram Wire color indicates variable type A red “X” means something is wrong!

Wires Wires Node A LabVIEW VI is held together by wires connecting nodes and terminals; they deliver data from one source terminal to one or more destination terminals.

Broken wires If you connect more than one source or no source at all to a wire, LabVIEW DISAGREES with what you’re doing, and the wire will appear broken

Messy vs. Clean Wiring CLEAN: Easy to troubleshoot MESSY: What is going on?

Basic wires used in block diagrams and corresponding types Each wire has different style or color, depending on the data type that flows through the wire: Scalar 1D array 2D array Color Floating-point number orange Integer number blue Boolean green String pink

LabVIEW Conventions Front panel items Block diagram items Controls and indicators Block diagram items Program structures (loops, case structures, math, etc.) Controls vs. Indicators Wires attach to controls on the right (give values) Wires attach to indicators on the left (receive values) Wiring colors Wires are color coded to correspond to data types

Running LabVIEW Programs ALMOST ALWAYS put your program in some sort of loop that can be stopped with a control AVOID using the red “x” to stop your program

Lab. Equipment Oscilloscope Function Generator Digital Voltmeter (DVM) Universal Measuring Instruments Signal Generator

Wire features together to Tools palette . . . Select a feature to edit or move Add/edit text Operate a control Probe Data (troubleshoot) Wire features together to control flow of data

Insert a boolean control Controls palette . . . Insert a boolean control (button or switch) Insert a digital indicator or control

Add a structure such as for, while, and case statements Add a boolean Functions palette . . . Add a numeric operator (+,-,…) Add a structure such as for, while, and case statements Add a boolean operator (and, or…) Timing/dialog Comparison File I/O Signal analysis Data Acquisition Mathematical Functions

Subpalettes . . .

Font ring Continuous run Distribution ring Run Stop Pause Toolbar . . . Font ring Continuous run Distribution ring Run Stop Pause Alignment ring Debugging features more on this later… Reorder objects

The Run Button The Run button, which looks like an arrow, starts VI execution when you click on it It changes appearance when a VI is actually running. When a VI won’t compile, the run button is broken

Creating a VI Front Panel Window Block Diagram Window Control When you create an object on the Front Panel, a terminal will be created on the Block Diagram. These terminals give you access to the Front Panel objects from the Block Diagram code. Each terminal contains useful information about the Front Panel object it corresponds to. For example, the color and symbols provide the data type. Double-precision, floating point numbers are represented with orange terminals and the letters DBL. Boolean terminals are green with TF lettering. In general, orange terminals should wire to orange terminals, green to green, and so on. This is not a hard-and-fast rule; LabVIEW will allow a user to connect a blue terminal (integer value) to an orange terminal (fractional value), for example. But in most cases, look for a match in colors. Controls have an arrow on the right side and have a thick border. Indicators have an arrow on the left and a thin border. Logic rules apply to wiring in LabVIEW: Each wire must have one (but only one) source (or control), and each wire may have multiple destinations (or indicators). The program in this slide takes data from A and B and passes the values to both an Add function and a subtract function. The results are displayed on the appropriate indicators. Control Terminals Indicator Terminals

Example 1: Craps From the functions – numeric panel insert a pair of dice From the Controls panel insert a numeric digital indicator (on the front panel) Use the wiring tool to connect the two (in the wiring diagram) and click the “run” button repeatedly. Numbers from 0.00 to 1.00 should be displayed in the front panel

Example 1: Craps (continued) Delete the wire Add a multiplication node and a numeric constant to allow multiplication by 5 Add an addition node and numeric constant to allow addition of 1 Add a mathematical “Round to Nearest” node. Make a second copy of this structure to represent a second die and wire them together through an addition node with an output to a numeric constant This wiring diagram simulates the rolling of 2 dice and their addition to form a number from 2 through 12.

Example 2: Analog & Digital Voltmeter (simulated signal) Uniform noise used as simulated signal – Functions – Signal Processing – Signal Generation menu Absolute value function from functions – numeric menu Mean value of data series from the functions – mathematics – Probability and Statistics menu The 250 ms wait implemented from the time and dialog menu slows the “flutter” of the meter.

Example 3: Reading an analog input signal Requires A/D board to implement From the functions menu select data acquisition and then analog input. Then select either “Sample Channel” or Sample Channels” This places the sampling icon in your wiring diagram You then need to configure the channel(s) and wire the output to other parts of your program.

Example 4: Signal Analysis (continued)

Example 5: Creating Sub-VIs In wiring diagram use selection tool (mouse box) to select all items to be in the SubVI. From Edit menu select “Create SubVI” Double click on new icon and save it as a separate VI. Cut-and-paste it at will or insert it using “Functions – Select VI menu”

Section II – Elements of Typical Programs A. Loops While Loop For Loop B. Functions and SubVIs Types of Functions Creating Custom Functions (SubVI) Functions Palette & Searching C. Decision Making and File IO Case Structure Select (simple If statement) File I/O © National Instruments Corporation 35 Introduction to LabVIEW Hands-On

Loops While Loops For Loops i terminal counts iteration Always runs at least once Runs until stop condition is met For Loop For Loops i terminal counts iterations Run according to input N of count terminal 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. While Loops Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop, shown at the top right, executes a subdiagram until a condition is met. The While Loop executes the sub diagram until the conditional terminal, an input terminal, receives a specific Boolean value. The default behavior and appearance of the conditional terminal is Stop If True. When a conditional terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal receives a TRUE value. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0. For Loops A For Loop, shown above, executes a subdiagram a set number of times. The value in the count terminal (an input terminal) represented by the N, indicates how many times to repeat the subdiagram. The iteration terminal (an output terminal), shown at left, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal returns 0. Introduction to LabVIEW Hands-On 36 ni.com

Drawing a Loop 2. Enclose code to be repeated 1. Select the structure 3. Drop or drag additional nodes and then wire Place loops in your diagram by selecting them from the Structures palette of the Functions palette: When selected, the mouse cursor becomes a special pointer that you use to enclose the section of code you want to repeat. Click the mouse button to define the top-left corner, click the mouse button again at the bottom-right corner, and the While Loop boundary is created around the selected code. Drag or drop additional nodes in the While Loop if needed. © National Instruments Corporation 37 Introduction to LabVIEW Hands-On

What Types of Functions are Available? Input and Output Signal and Data Simulation Acquire and Generate Real Signals with DAQ Instrument I/O Assistant (Serial & GPIB) ActiveX for communication with other programs Analysis Signal Processing Statistics Advanced Math and Formulas Continuous Time Solver Storage File I/O Express Functions Palette LabVIEW includes several hundreds of pre-built functions that help you to acquire, analyze, and present data. You would generally use these functions as outlined on the slide above. LabVIEW Toolkits Additional toolkits are available for adding domain specific functionality to LabVIEW. These toolkits include: Application Deployment and Targeting Modules * LabVIEW PDA Module * LabVIEW Real-Time Module * LabVIEW FPGA Module * LabVIEW Vision Development Module Embedded System Deployment * DSP Test Integration Toolkit * Embedded Test Integration Toolkit * Digital Filter Design Toolkit Signal Processing and Analysis * Sound and Vibration Toolkit * Advanced Signal Processing Toolkit * Modulation Toolkit * Spectral Measurements Toolkit * Order Analysis Toolkit Software Engineering and Optimization Tools * Execution Trace Toolkit for LabVIEW Real-Time * Express VI Development Toolkit * State Diagram Toolkit * VI Analyzer Toolkit Control Design and Simulation * Control Design and Simulation Bundle * System Identification Toolkit * Control Design Toolkit * LabVIEW Simulation Module Image Processing and Acquisition * NI Vision Builder for Automated Inspection * NI-IMAQ for IEEE 1394 http://www.ni.com/toolkits/ © National Instruments Corporation 39 Introduction to LabVIEW Hands-On

Create SubVI Enclose area to be converted into a subVI. Select Edit»Create SubVI from the Edit Menu. Creating SubVIs After you build a VI, you can use it in another VI. A VI called from the block diagram of another VI is called a subVI. You can reuse a subVI in other VIs. To create a subVI, you need to build a connector pane and create an icon. A subVI node corresponds to a subroutine call in text-based programming languages. A block diagram that contains several identical subVI nodes calls the same subVI several times. The subVI controls and indicators receive data from and return data to the block diagram of the calling VI. Click the Select a VI icon or text on the Functions palette, navigate to and double-click a VI, and place the VI on a block diagram to create a subVI call to that VI. A subVI input and output terminals and the icon can be easily customized. Follow the instructions below to quickly create a subVI. Creating SubVIs from Sections of a VI Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit»Create SubVI. An icon for the new subVI replaces the selected section of the block diagram. LabVIEW creates controls and indicators for the new subVI, automatically configures the connector pane based on the number of control and indicator terminals you selected, and wires the subVI to the existing wires. See Help»Search the LabVIEW Help…»SubVIs for more information. © National Instruments Corporation 41 Introduction to LabVIEW Hands-On

LabVIEW Functions and SubVIs operate like Functions in other languages Function Pseudo Code function average (in1, in2, out) { out = (in1 + in2)/2.0; } SubVI Block Diagram Calling Program Pseudo Code main { average (in1, in2, pointavg) } Calling VI Block Diagram A subVI node corresponds to a subroutine call in text-based programming languages. The node is not the subVI itself, just as a subroutine call statement in a program is not the subroutine itself. A block diagram that contains several identical subVI nodes calls the same subVI several times. The modular approach makes applications easier to debug and maintain. The functionality of the subVI does not matter for this example. The important point is the passing of two numeric inputs and one numeric output. Introduction to LabVIEW Hands-On 42 ni.com

How Do I Make Decisions in LabVIEW? Case Structures Select (a) (b) Case Structure The Case Structure has one or more subdiagrams, or cases, exactly 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. It is found at Functions»Programming»Structures»Case Structure. Select Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE, this function returns the value wired to t. If s is FALSE, this function returns the value wired to f. The connector pane displays the default data types for this polymorphic function. It is found at Functions»Programming» Comparison»Select. Example a: Boolean input: Simple if-then case. If the Boolean input is TRUE, the true case will execute; otherwise the FALSE case will execute. Example b: Numeric input. The input value determines which box to execute. If out of range of the cases, LabVIEW will choose the default case. Example c: When the Boolean passes a TRUE value to the Select VI, the value 5 is passed to the indicator. When the Boolean passes a FALSE value to the Select VI, 0 is passed to the indicator. (c) © National Instruments Corporation 47 Introduction to LabVIEW Hands-On

Building Arrays with Loops (Auto-Indexing) Loops can accumulate arrays at their boundaries with auto-indexing For Loops auto-index by default While Loops output only the final value by default Right-click tunnel and enable/disable auto-indexing Auto-Indexing Enabled Wire becomes thicker 1D Array 0 1 2 3 4 5 Auto-Indexing Disabled Wire remains the same size For Loops and While Loops can index and accumulate arrays at their boundaries. This is known as auto-indexing. The indexing point on the boundary is called a tunnel. The For Loop default is auto-indexing enabled. The While Loop default is auto-indexing disabled. Examples: Enable auto-indexing to collect values within the loop and build the array. All values are placed in array upon exiting loop. Disable auto-indexing if you are interested only in the final value. 5 Only one value (last iteration) is passed out of the loop © National Instruments Corporation 55 Introduction to LabVIEW Hands-On

Review of Data Types Found in LabVIEW LabVIEW utilizes many common datatypes. These Datatypes include: Boolean, Numeric, Arrays, Strings, Clusters, and more. The color and symbol of each terminal indicate the data type of the control or indicator. Control terminals have a thicker border than indicator terminals. Also, arrows appear on front panel terminals to indicate whether the terminal is a control or an indicator. An arrow appears on the right if the terminal is a control, and an arrow appears on the left if the terminal is an indicator. Definitions Array: Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. An array can have one or more dimensions and as many as (231) – 1 elements per dimension, memory permitting. Cluster: Clusters group data elements of mixed types, such as a bundle of wires in a telephone cable, where each wire in the cable represents a different element of the cluster. See Help»Search the LabVIEW Help… for more information. The LabVIEW User Manual on ni.com provides additional reference for data types found in LabVIEW. © National Instruments Corporation 67 Introduction to LabVIEW Hands-On

Shift Register – Access Previous Loop Data • Available at left or right border of loop structures • Right-click the border and select Add Shift Register • Right terminal stores data on completion of iteration • Left terminal provides stored data at beginning of next iteration Initial Value Value 3 Shift registers transfer data from one iteration to the next: Right-click on the left or right side of a For Loop or a While Loop and select Add Shift Register. The right terminal stores data at the end of an iteration. Data appears at the left terminal at the start of the next iteration. A shift register adapts to any data type wired into it. An input of 0 would result in an output of 5 the first iteration, 10 the second iteration and 15 the third iteration. Said another way, shift registers are used to retain values from one iteration to the next. They are valuable for many applications that have memory or feedback between states. The feedback node is another representation of the same concept. (pictured below) Both programs pictured behave the same. See Help»Search the LabVIEW Help… for more information. Before Loop Begins First Iteration Second Iteration Last Iteration Introduction to LabVIEW Hands-On 74 ni.com