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.

Slides:



Advertisements
Similar presentations
Unit 4 - I Said Stop!. Introduction New Topics Timing Parallelism Sequence of Operations New Features NXT terminals New Functions Wait For.
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.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 6 Shift Registers Read Bishop, Section 5.3. Midterm Exam this week. Lab #6 and Homework #6 due next.
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.
Based on LabVIEW 2011 Student Edition
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 10 Clusters and Matrices  Read Bishop, Sections 6.4 to  Lab #10 and Homework #10 due next week.
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
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:
CS320n –Visual Programming LabVIEW Control Structures.
Introduction to LabVIEW Seth Price Department of Chemical Engineering New Mexico Tech Rev. 10/5/14.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 4 SubVIs  Read Bishop, Chapter 4.  Lab #4 and Homework #4 due next week.
Workshop 3 of 7 Welcome!. Today's Topics Review of Workshop 2 Loops While For Auto-indexing Shift registers Case Structure.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 8 Other Structures; Local Variables  Read Bishop, Sections 5.6 to  Lab #8 and Homework #8 due.
MCEN 371 – Mechanical Engineering Lab Chapter 6: LabVIEW Part 1: Introduction.
LabVIEW an Introduction
Introduction to LabVIEW
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
LabView instrumentoinnissa, 55492, 3op Labview in instrumentation Lecturer: Heikki Ojala, room C204a
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
CS320n –Visual Programming More LabVIEW Control Structures.
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:
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.
30/10/ Iteration Loops Do While (condition is true) … Loop.
Digital Electronics and Computer Interfacing Tim Mewes 4. LabVIEW - Advanced.
Lab 1 : Introduction to LabView 1 Southern Methodist University Bryan Rodriguez.
Design of Bio-Medical Virtual Instrumentation Tutorial 2.
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.
Programming Fundamentals. The setw Manipulator setw changes the field width of output. The setw manipulator causes the number (or string) that follows.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Digital Electronics and Computer Interfacing Tim Mewes 2. LabVIEW Basics part II.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
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.
Quiz Which types of folders are available in a LabVIEW Project?
EET 2259 Unit 11 Charts and Graphs
Chapter 4 C Program Control Part I
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
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Lab 2 : Structures Muhammad Zaigham Abbas Shah DIGITAL INSTRUMENTATION SYSTEMS.
Chapter 5 Structures.
Doing some Boolean: On/Off
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Coding Concepts (Basics)
EET 2259 Unit 6 Shift Registers
LabVIEW.
Fundamentals of visual basic
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
EET 2259 Unit 7 Case Structures; Sequence Structures
EET 2259 Unit 5 Loops Read Bishop, Sections 5.1 and 5.2.
EET 2259 Unit 11 Charts and Graphs
EET 2259 Unit 2 Virtual Instruments
EET 2259 Unit 6 Shift Registers
EET 2259 Unit 8 Other Structures; Local Variables
EET 2259 Unit 3 Editing and Debugging VIs
Presentation transcript:

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

Floyd, Digital Fundamentals, 10 th ed Structures  Structures control the flow of a program’s execution.  This week we look at two kinds: For Loops While Loops  Later we’ll look at other kinds: Sequence Structures Case Structures … (Bishop, p. 213)

Floyd, Digital Fundamentals, 10 th ed For Loop  A For Loop executes the code inside its borders a specified number of times.  The code inside the For Loop’s borders is called a subdiagram.  A For Loop has two terminals: the count terminal and the iteration terminal. (Bishop, p. 214)

Floyd, Digital Fundamentals, 10 th ed For Loop Example

Floyd, Digital Fundamentals, 10 th ed Placing a For Loop  For Loops are found on the Functions>> Programming>> Structures palette.  Click it, and then drag to create a loop on the block diagram.  Then place items inside the loop to build your subdiagram. (Bishop, p. 214)

Floyd, Digital Fundamentals, 10 th ed Be Careful to Place Items Inside the Loop  If you’re not careful, you can end up with items “hovering” over a loop instead of being located inside the loop. Correctly located inside the loop. Not inside the loop, but hovering over it.

Floyd, Digital Fundamentals, 10 th ed Count Terminal  A For Loop’s Count Terminal, labeled N, lets you set how many times the loop will execute.  You can set the count to a constant, or to a value set by the user through a control, or to the output of a function, etc.  The count is available to be used inside the loop. (Bishop, p. 214)

Floyd, Digital Fundamentals, 10 th ed Iteration Terminal  A For Loop’s Iteration Terminal, labeled i, contains the number of loop iterations that have been completed.  The iteration number is available to be used inside the loop.  It starts at 0 and increases to N-1. (Bishop, p. 214)

Floyd, Digital Fundamentals, 10 th ed Inserting a Time Delay  Loops usually run so quickly that the user can’t see what’s happening.  To add a time delay, use either the old- fashioned Wait (ms) function or the newer Time Delay Express VI. Both are found on the Functions>> Programming >>Timing palette.  Place either one anywhere inside the loop.

Floyd, Digital Fundamentals, 10 th ed Good Practice: Include a Time Delay in All Loops  What if you don’t want to slow down the loop to “human speed,” but want it to run as fast as possible?  It’s still a good programming practice to include a small (10 ms) delay in your loop. This prevents LabVIEW from consuming all of your processor’s time, and lets the operating system perform necessary tasks.

Floyd, Digital Fundamentals, 10 th ed Tunnels  If a wire crosses the border of a loop (or other structure), a tunnel automatically appears on the border.  Doing this can be useful, but can also lead to confusion unless you keep in mind the following point….

Floyd, Digital Fundamentals, 10 th ed Tunnels and Data Flow  No data passes into or out of a structure while the structure is executing.  Input data is read before the structure executes; subsequent changes to the input values are ignored.  Output data is not available until after the structure finishes executing.

Floyd, Digital Fundamentals, 10 th ed Example For Loop in BASIC  The type of loop we’ve been discussing is called a “For Loop” because in text-based programming languages (such as BASIC or C++) it is coded using the word FOR.  Example: CLS FOR i = 1 TO 15 PRINT i, 2 * i NEXT i

Floyd, Digital Fundamentals, 10 th ed Integer Representations  Recall that blue terminals and blue wires represent integers.  Integer terminals can be further categorized into byte signed integer ( I 8), word signed integer ( I16 ), long signed integer ( I32 ), etc.  This is called the “representation” of the number, and you can change it by right- clicking on a terminal and choosing “Representation.”

Floyd, Digital Fundamentals, 10 th ed Integer Representations (Continued)  These representations differ in the range of values they can handle and the amount of memory they use. RepresentationMax. ValueMemory Bytes Byte signed integer ( I 8) Word signed integer ( I16 ) 32,767 2 Long signed integer ( I32 ) 2,147,483,647 4 Quad signed integer ( I64 )  1  Byte unsigned integer (U8) 2551 Word unsigned integer ( U16 ) 65,5352 Long unsigned integer ( U32 ) 4,294,967,2954 Quad unsigned integer ( U64 )  2 

Floyd, Digital Fundamentals, 10 th ed Floating-Point Representations  Recall that orange terminals and orange wires represent floating–point numbers.  Floating-point terminals can be further categorized into single precision, double precision, and extended precision.

Floyd, Digital Fundamentals, 10 th ed Floating-Point Representations (Continued)  These representations differ in the range of values they can handle and the amount of memory they use. RepresentationMax. ValueMemory Bytes Single-precision ( SGL )  3.40 x Double-precision ( DBL )  1.79 x Extended-precision ( EXT )  1.19 x

Floyd, Digital Fundamentals, 10 th ed Coercion Dots  If you wire together two terminals of different numeric representations, LabVIEW must convert the number from one representation to the other.  In these cases a red dot called a coercion dot will appear on the terminal where the conversion takes place.  Coercion dots are bad. They waste memory, and can lead to rounding errors that are difficult to find. (Bishop, p. 216)

Floyd, Digital Fundamentals, 10 th ed Numeric Conversion Functions  LabVIEW has functions for converting a number of any representation to any other representation. (For example, the To Word Integer function converts any number to the I 16 representation.)  These functions are found on the Functions > Numeric > Conversion palette.  These are sometimes useful in eliminating coercion dots.

Floyd, Digital Fundamentals, 10 th ed While Loop  A While Loop executes the code inside its borders repeatedly until a certain condition is met.  A While Loop has two terminals: the iteration terminal and the conditional terminal. (Bishop, p. 221)

Floyd, Digital Fundamentals, 10 th ed While Loop Example

Floyd, Digital Fundamentals, 10 th ed Placing a While Loop  While Loops are found on the Functions >> Programming>> Structures palette.  Click it, and then drag to create a loop on the block diagram.  Then place items inside the loop to build your subdiagram.

Floyd, Digital Fundamentals, 10 th ed Iteration Terminal  A While Loop’s Iteration Terminal, labeled i, contains the number of loop iterations that have been completed.  It behaves just like a For Loop’s iteration terminal.  The iteration number is available to be used inside the loop. (Bishop, p. 221)

Floyd, Digital Fundamentals, 10 th ed Conditional Terminal  A While Loop’s Conditional Terminal determines at the end of each loop execution whether the loop will be executed again.  You set the Conditional Terminal to either Stop if True or Continue if True.  Usually you’ll wire a Boolean control or the output of a Boolean function to this terminal. (Bishop, p. 221)

Floyd, Digital Fundamentals, 10 th ed Conditional Terminal: Stop if True  When the Conditional Terminal is set to Stop if True, it looks like a red stop sign on the block diagram.  A true condition will cause the loop to stop executing, but a false condition will cause it to execute again. (Bishop, p. 221)

Floyd, Digital Fundamentals, 10 th ed Conditional Terminal: Continue if True  When the Conditional Terminal is set to Continue if True, it looks like a green looping arrow on the block diagram.  A true condition will cause the loop to execute again, but a false condition will cause it to stop executing. (Bishop, p. 221)

Floyd, Digital Fundamentals, 10 th ed Example While Loop in BASIC  This type of loop is called a “While Loop” because in text-based programming languages it is coded using the word WHILE.  Example: CLS INPUT “Guess my age. ”, guess WHILE guess <> 46 INPUT “No. Try again. ”, guess WEND PRINT “You got it!”

Floyd, Digital Fundamentals, 10 th ed For Loop With a Conditional Terminal  It’s possible to add a conditional terminal to a For Loop, creating a loop that behaves like a cross between a For Loop and a While Loop.  To do this, right-click a For Loop’s border and select Conditional Terminal. (Bishop, p.220)  We won’t use this feature in this course: Whenever I refer to a For Loop, I mean a plain For Loop without a conditional terminal.