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.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 5: Repetition and Loop Statements Problem Solving & Program.
A. Virtual Instruments (VIs)
Gruppo di Misure Meccaniche e Termiche UNIBS - DIMI A. File Formats At their lowest level, all files written to your computers hard drive are a series.
LabVIEW is a graphical programming development environment for data acquisition and control, data analysis, and data presentation. With LabVIEW you can.
Lesson 2 Navigating LabVIEW
Exercise 1: Install PC Software & NXT Firmware
Based on LabVIEW 2011 Student Edition
TE Sessions Supported by: Basic Concepts of Programming November 3, 2012.
Room: Rapson Hall 54 Time: 4-5 PM.
Chapter 8 Improving the User Interface
L6:CSC © Dr. Basheer M. Nasef Lecture #6 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
Programming with Microsoft Visual Basic th Edition
Welcome! Workshop 2 of 7.
Loops in LabVIEW (while,for and case)
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.
CS320n –Visual Programming LabVIEW Control Structures.
Introduction to LabVIEW Seth Price Department of Chemical Engineering New Mexico Tech Rev. 10/5/14.
Fundamentals of Python: From First Programs Through Data Structures
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.
Workshop 3 of 7 Welcome!. Today's Topics Review of Workshop 2 Loops While For Auto-indexing Shift registers Case Structure.
Virtual Instrumentation With LabVIEW. Course Goals Understand the components of a Virtual Instrument Introduce LabVIEW and common LabVIEW functions Create.
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.
Chapter 12: How Long Can This Go On?
LabView instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, room C204a
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.
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.
Lab 1 : Introduction to LabView 1 Southern Methodist University Bryan Rodriguez.
CS320n –Visual Programming
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.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
CS320n – Elements of Visual Programming Assignment Help Session.
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.
Workshop 5 of 7 Welcome!. Today's Topics Review from Workshop 4 Modularity & subVIs Documentation File Input/Output Introduction.
Week 3 Labview exercises
Quiz Which types of folders are available in a LabVIEW Project?
Course Learning Map Lesson # Lesson Title Lesson 3 Lesson 2 Lesson 1
EE 200 Design Tools Laboratory 14
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
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.
הודעות ריענון מהיר והרחבות כתיבה לקובץ Low-Level דגימת אות Low-Level
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
LabVIEW 7.1 寒假短期教學課程 歐陽丞修 2006/02/06.
Structures- case, sequence, formula node
CST-115 Introduction to Computer Programming
EET 2259 Unit 9 Arrays Read Bishop, Sections 6.1 to 6.3.
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.
Presentation transcript:

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 28.09.2012

D. While Loops LabVIEW While Loop Flowchart Pseudo Code 28.09.2012 Repeat (code); Until Condition met; End; Demonstrate creation of while loop: To create a While Loop complete the following: Select the While Loop from the palette Use the cursor to drag a selection rectangle around the section of the block diagram you want to repeat When you release the mouse button, a While Loop boundary encloses the section you selected Add block diagram objects to the While Loop by dragging and dropping them inside the While Loop LabVIEW While Loop Flowchart Pseudo Code 28.09.2012

D. While Loops Iteration terminal: returns number of times loop has executed; zero indexed Conditional terminal: defines when the loop stops Iteration Terminal Conditional Terminal 28.09.2012

Practice Add a STOP button to the previous practice, then include everything in a while loop in order to stop the program when the user hit STOP. Add a CHART and display the current iteration number on it. Please note: from now on the RUN CONTINOUSLY button won’t be used, use the RUN button instead. AVOID HITTING THE ABORT BUTTON AT ALL COSTS!! 28.09.2012

D. 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 28.09.2012

Practice Please open again the previous vi. Using an input tunnel display the time the vi has been active (in seconds) and stop it when such time is MORE THAN 20s or if the user hits the STOP button. Think about this: what are the differences between a simple wire and a tunnel? Can a wire HOLD data? Can a tunnel? 28.09.2012

F. 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

F. 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

F. 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

Practice Open task manager and run the previous vi. Add to the previous practice the proper wait function in order to force the loop time to 200ms Open task manager and run the vi again. Add to the previous practice the proper function in order to display a string version of time elapsed

E. For Loops LabVIEW For Loop Flowchart Pseudo Code 28.09.2012 N=100; Until i=N: Repeat (code;i=i+1); End; LabVIEW For Loop Flowchart Pseudo Code 28.09.2012

E. 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 28.09.2012

E. For Loops – Conditional Terminal You can add a conditional terminal to configure a For Loop to stop when a Boolean condition or an error occurs

E. For Loops – Numeric Conversion The number of iterations a For Loop executes must be specified in nonnegative integers If you wire a double-precision, floating-point numeric value to the count terminal, LabVIEW converts the larger numeric value to a 32-bit signed integer

E. For Loops – Numeric Conversion Normally, when you wire different representation types to the inputs of a function, the function returns an output in the larger or wider format LabVIEW chooses the representation that uses more bits However, the For Loop count terminal always coerces to a 32-bit signed integer Coercion Dot If you use a signed integer with an unsigned integer, it will coerce to the unsigned integer. If you use an unsigned integer with a floating point, it will coerce to the floating point. If you use a floating point integer with a complex integer, it will coerce to the complex integer. If you use two numbers of the same type with different bit widths, LabVIEW will coerce to the larger of the two bit widths. However, the For Loop count terminal may work in the opposite manner. If you wire a double-precision, floating-point numeric value to the 32-bit count terminal, LabVIEW coerces the larger numeric value to a 32-bit signed integer. Although the conversion is contrary to normal conversion standards, it is necessary, because a For Loop can only execute an integer number of times. The For Loop count terminal will always coerce to a 32-bit signed integer data type.

E. For Loops – Numeric Conversion Avoid coercion for better performance Choose matching data type Programmatically convert to the matching data type

Practice Reproduce the following block diagram What will be the result displayed in A? in B? in C? When? What will be the content of D? 28.09.2012

E. For Loops – Conditional Terminal For Loops configured for a conditional exit have: Red glyph next to the count terminal Conditional terminal in the lower right corner

E. For Loop/While Loop Comparison Executes a set number of times unless a conditional terminal is added Can execute zero times Tunnels automatically output an array of data While Loop Stops executing only if the value at the conditional terminal meets the condition Must execute at least once Tunnels automatically output the last value 28.10.2012

A. Arrays An array consists of elements and dimensions Elements: data that make up the array Dimension: 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 Consider using arrays when you work with a collection of similar data and when you perform repetitive computations 28.09.2012

A. Arrays The first element shown in the array (3.00) is at index 1 and the second element (1.00) is at index 2 The element at index 0 is not shown in this image, because element 1 is selected in the index display The element selected in the index display always refers to the element shown in the upper left corner of the element display 28.09.2012

A. Arrays – Creating Place an array shell on the front panel Drag a data object or element into the array shell 28.09.2012

A. Arrays – 2D Array Stores elements in a grid Requires a column index and a row index to locate an element, both of which are zero-based To create a multidimensional array on the front panel, right-click the index display and select Add Dimension from the shortcut menu You also can resize the index display until you have as many dimensions as you want

A. Arrays – Initializing You can initialize an array, or leave it uninitialized For initialized arrays, you define the number of elements in each dimension, and the contents of each element Uninitialized arrays have dimension but no elements

A. Arrays – Creating Constants To create an array constant: Select an array constant on the Functions palette Place the array shell on the block diagram Place a constant in the array shell You can use an array constant to store constant data or as a basis for comparison with another array Array constants also are useful for passing data into a subVI

A. Arrays – Auto-indexing If you wire an array to or from a For Loop or While Loop, you can link each iteration of the loop to an element in that array by enabling auto-indexing on tunnel The tunnel changes from a solid square to the image shown above to indicate auto-indexing 28.09.2012

A. Arrays – Auto-indexing Input For Loop executes a number of times equal to the number of elements in the array 28.09.2012

A. Arrays – Auto-indexing Input If the iteration count terminal is wired and arrays of different sizes are wired to auto-indexed tunnels, the actual number of iterations becomes the smallest of the choices. LabVIEW does not exceed the array size. This helps to protect against programming error. LabVIEW mathematical functions work the same way—if you wire a 10 element array to the x input of the Add function, and a 5 element array to the y input of the Add function, the output is a 5 element array. Although the for loop runs 5 times, the iterations are zero based, therefore the value of the Iterations indicators is 4. 28.09.2012

Practice Create a new VI having the following block diagram Which values will be displayed by A,B and C? 28.09.2012

A. Arrays – Auto-indexing Output When you auto-index an array output tunnel, the output array receives a new element from every iteration of the loop Auto-indexed output arrays are always equal in size to the number of iterations 28.09.2012

A. Arrays – Creating 2D Arrays You can use two For Loops, one inside the other, to create a 2D array

Practice @HOME Open the thermostat practice VI, Instead of generating a single temperature value per cycle, create a set of 100 samples, put them in an array. Display all the 100 samples on both the CHART and the GRAPH, while controlling the boolean indicators only on the AVERAGE of the array Please try to keep you block diagram as tidy as possible 28.09.2012