Workshop 2 of 4 Welcome!. Survey While You Wait ni.com/duke >> Recent Documents >> LabVIEW Workshop Participation Survey.

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.
Additional Programming Concepts MVRT 2011 – 2012 Season.
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.
TP4: S TATE M ACHINE D ESIGN P ATTERN  Definition  Infrastructure  Transition Code  Conclusion.
Room: Rapson Hall 54 Time: 4-5 PM.
1. 2 LabVIEW for FRC Doug Norman National Instruments January 6, 2012.
Welcome! Workshop 2 of 7.
Workshop 1 of 7 Welcome!. Who am I? Dilim Nwobu Computer Engineering ‘12 Fall 2011 Software Developer for NI LabVIEW Student Ambassador for Texas A&M.
Developing User Interfaces with Event-driven Programming
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.
Introduction to LabVIEW
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.
CS320n –Visual Programming LabVIEW Foundations. Visual ProgrammingLabVIEW Foundations2 What We Will Do Today Hand back and review the midterm Look at.
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.
Introduction to LabVIEW Seth Price Department of Chemical Engineering New Mexico Tech Rev. 10/5/14.
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.
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. 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
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 instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, room C204a
Samuel Alberg Thrysøe, PhD, PostDoc, Kontakt info: Tlf:
EET 2259 Unit 7 Case Structures; Sequence Structures  Read Bishop, Sections 5.4 and 5.5.  Lab #7 and Homework #7 due next week.  Quiz #3 next week.
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:
Digital Electronics and Computer Interfacing Tim Mewes 4. LabVIEW - Advanced.
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.
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.
Week 3 Data Structures and Common Tools. Common Tools in Labview Automatic Tool Selector Using the Operating Tool Using the Positioning Tool to Select.
Workshop 5 of 7 Welcome!. Today's Topics Review from Workshop 4 Modularity & subVIs Documentation File Input/Output Introduction.
Workshop 2 of 7 Welcome!. Today’s Topics -Review of: -LabVIEW Project -Mechanical Action of Booleans -Custom Controls and Type Definitions.
Week 3 Labview exercises
Welcome! Workshop 3 of 7.
Quiz Which types of folders are available in a LabVIEW Project?
EE 200 Design Tools Laboratory 14
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
Lab 2 : Structures Muhammad Zaigham Abbas Shah DIGITAL INSTRUMENTATION SYSTEMS.
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
LabVIEW.
Structures- case, sequence, formula node
Introduction to LabVIEW
LabVIEW基礎課程(一) 參考書籍: LabVIEW for Everyone (Jeffrey Travis/Jim Kring)
EET 2259 Unit 7 Case Structures; Sequence Structures
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
EET 2259 Unit 2 Virtual Instruments
Presentation transcript:

Workshop 2 of 4 Welcome!

Survey While You Wait ni.com/duke >> Recent Documents >> LabVIEW Workshop Participation Survey

Today's Topics Review of Workshop 1 More Structures Sequence, Disable, Conditional, Case Enumerations State Machine – Activity: build a state machine Timing Event Structure

Review Question 1 Which of the following are the three parts of a VI? a)Front Panel b)Project c)Block Diagram d)Connector Pane/Icon

Review Question 1 Which of the following are the three parts of a VI? a)Front Panel b)Project c)Block Diagram d)Connector Pane/Icon

Use LabVIEW Projects to: Group LabVIEW files and non-LabVIEW files Create build specifications (i.e. stand-alone applications) Deploy or download files to targets (i.e. FPGA target) 6 Project Explorer Right Click!

Answer: a LabVIEW program 1. Front Panel User interface (UI) – Controls = inputs – Indicators = outputs 2. Block Diagram Graphical source code – Data travels on wires from control terminals through functions to indicator terminals – Blocks execute by data flow 3. Icon/Connector Pane Graphical representation of a VI Means of connecting VIs (subVIs) What is a Virtual Instrument (VI)? * Conn. pane available from FP only

Review Question 2 1.Which identifies the control or indicator on the block diagram? a)Caption b)Location c)Label d)Value

Review Question 2 1.Which identifies the control or indicator on the block diagram? a)Caption b)Location c)Label d)Value

Review Question 3 Which of the following are not a nodes? a)Terminals b)Structures (while loop, for loop) c)subVIs d)Wires e)Functions

Review Question 3 Which of the following are not a nodes? a)Terminals b)Structures (while loop, for loop, etc.) c)subVIs d)Wires e)Functions

Block Diagram Nodes Objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs Analogous to statements, operators, functions, and subroutines in text-based programming languages Functions Fundamental operating elements of LabVIEW Do not have front panels or block diagrams, but do have connector panes Double-clicking a function only selects the function – does not open it like a VI Has a pale yellow background on its icon subVIs VIs that you build to use inside of another VI Any VI has potential to become a subVI Double-clicking a subVI will open it (exception: Express VIs – config. window opens) Icon represents subVI in main VI Structures While loops, for loops, event structures More discussion later

Which function executes first: Add or Subtract? a)Add b)Subtract c)Unknown 13 Review Question 4

Which function executes first: Add or Subtract? a)Add b)Subtract c)Unknown 14 Review Question 4

Data Flow Block diagram execution is dependent on the flow of data Block diagram does NOT execute left to right Node executes when data is available to ALL input terminals Nodes supply data to all output terminals when done If the computer running this code had multiple processors, these two pieces of code could run independently without additional coding

True or False? 1.Arrays can contain only one data type. 2.An array must contain at least one element. 3.The Bundle function can be used to add elements to a cluster. 4.Clusters can contain both controls and indicators within the same shell; however, arrays cannot. 5.It is possible to have clusters containing arrays as well as arrays containing clusters. 16 Review Question 5

True or False? 1.Arrays can contain only one data type. TRUE 2.An array must contain at least one element. FALSE 3.The Bundle function can be used to add elements to a cluster. FALSE 4.Clusters can contain both controls and indicators within the same shell; however, arrays cannot. FALSE 5.It is possible to have clusters containing arrays as well as arrays containing clusters. TRUE 17 Review Question 5

Clusters differ from arrays in that they are a fixed size Clusters can contain mixed data types; arrays contain only one data type Like an array, a cluster is either a control or an indicator and cannot contain a mixture of controls and indicators 18 Clusters vs. Arrays

Match the icon with its name and description. 1.Iteration terminal – tells how many time the loop has executed. 2.Count terminal – receives value to tell how of times a for loop will execute 3.Conditional terminal – tells the loop to stop if the condition is met 19 Review Question 6

Match the icon with its name and description. 1.Iteration terminal – tells how many time the loop has executed. 2.Count terminal – receives value to tell how of times a for loop will execute 3.Conditional terminal – tells the loop to stop if the condition is met 20 Review Question 6

Loops  While Loop  Terminal counts iterations  Always runs at least once  Runs until stop condition is met  For Loop  Terminal counts iterations  Runs according to input N of count terminal While Loop For Loop i = zero indexed N = one indexed

What will be the value in output once this VI finishes? a)11 b)9 c)3 d)4 22 Review Question 7

What will be the value in output once this VI finishes? a)11 b)9 c)3 d)4 23 Review Question 7

Shift Registers - 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 - stacked: registers remember values from multiple previous iterations and carry those values to the next iterations (right-click -> Add Element) Before Loop Begins First Iteration Second Iteration Last Iteration Value 15 Initial Value

New Stuff

Sequence Structures Flat Sequence Structure Executes frames from left to right and when all data values wired to a frame are available The input of one frame can depend on the output of another frame Stacked Sequence Structure Stacks each frame so you see only one frame at a time and executes frame 0, then frame 1, and so on until the last frame executes Returns data only after the last frame executes

Diagram Disable & Conditional Structures Use the Diagram Disable structure to disable specific code on the block diagram Multiple subdiagrams possible – only one enabled Use the Conditional Disable structure to define conditions that indicate which code on the block diagram executes

Case Structure 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 Case Selector Label Selector Terminal

You can create multiple input and output tunnels Inputs are available to all cases if needed You must define each output tunnel for each case Case Structure: Inputs & Outputs Data TypeDefault Value Numeric0 BooleanFALSE StringEmpty

Case Structure

If the error cluster is wired to the selector, the border of the case structure automatically turns red or green for the error and non-error cases, respectively Case Structure Holy automatic coloring, Batman!

Enumeration An enum represents a pair of values, a string and a numeric, where the enum can be one of a defined list of values

Custom Controls & Type Definitions Control No connection between the one you saved and the instance in the VI Update the file, but the instances are not updated Type Def Connection between the saved file and all instances Forces the data type of each instance to be identical (clusters, enum) Changes made to file will populate throughout each instance Strict Type Def Connection between saved file and all instances Forces everything about an instance to be identical to the strict type definition, except: label description default value - Use custom controls and indicators to extend the available set of front panel objects

Custom Controls & Type Definitions How to create: -Right click on the control; select Advanced >> Customize -Select Type Def or Strict Type Def in the menu before saving

Let’s put it all together…

Scenario Want to create a program that does the following: 1.Reads a voltage 2.Tells user to turn on power supply 3.Read the voltage again now that power is on 4.Tell the user to turn off the power.

Programming Designs: Sequential

Sequential Programming

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?

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 Structure Shift Register State Machine Enum

State Functionality Code: this state was entered to perform what function? Transition Code: which state is next? State Machine: Transition Code

Activity 1: Creating a state machine 1.Start a project 2.Create a new VI 3.Create a cluster on the front panel with 3 buttons: -“Do This” -“Do That” -“Stop” 4. Create a state machine Make a type def. enum for the selector input -Initialize -Idle -Do this -Do that -Stop 5. Run the VI Functions for each state: -Initialize: turn on an LED that is labeled “Running?” -Idle: read button values, choose state based on button values -Do this: send dialog to user that “This is Done” -Do that: send dialog to user that “That is Done” -Stop: end VI execution and turn “Running?” LED off

Timing Functions Control the frequency at which a loop executes Provide the processor with time to complete other tasks, such as processing the user interface Uses the operating system millisecond clock 10 ms20 ms30 ms

VI Timing Types Execution Timing Provides the design pattern with a function that specifically allows the processor time to complete other tasks In some cases, a Wait function is not necessary Use of Timeout inputs can provide execution timing Software Control Timing Timing (pauses, waits, time checks) you put in place to make the code execute after a certain amount of time. Example: If you must acquire data for 5 minutes, you could remain in the acquisition state until the 5 minutes elapses. However, during that time you cannot process any user interface actions such as stopping the VI. To process user interface actions, you must implement timing (checking if 5 min has passed since the start of acquisition) so that the VI continually executes for the specified time

47 Software Control Timing Execution Timing VI Timing

Events and Event Structure Event — An asynchronous notification that something has occurred 48 Timeout Event Selector Label Event Data Node Event Filter Node Event Data Node Identifies the data LabVIEW provides when the event occurs; similar to the Unbundle By Name function Event Filter Node Identifies the subset of data available in the Event Data node that the event case can modify

Notify Events User action has already occurred LabVIEW has processed the event Available only in the Event Data node Filter Events User action has already occurred LabVIEW has NOT processed the event Allows you to override default behavior for event Available in the Event Filter node and Event Data node Notify and Filter Events

Events Event Sources Configured Events Right-click the border and select Edit Events Handled by This Case Normally used in a While Loop Event structure handles exactly one event per iteration Sleeps when no events occur Using and Configuring Event Structures

Notify Events (green arrow) User action has already occurred Filter Events (red arrow) User performed action but event is not processed. Allows you to customize event handling. Notify and Filter Events in Config. Window

Better State Machine Update your state machine to include: -An event structure in the Idle state to monitor button presses instead of polling the value -Add execution timing in the while loop so the processor can be free to update the front panel -Add software timing in the Do This state so that it stays in the Do This state for 5 seconds. -Bonus: display the 5 second wait on the front panel