LabVIEW Case and Loop Structures ABE 4423/6423 Dr. Filip To Ag and Bio Engineering, Mississippi State University

Similar documents
LabVIEW Basics. Based on LabVIEW 2011 Student Edition

Lesson 4 Implementing a VI

PHYC 500: Introduction to LabView. Exercise 1 (v 1.3) M.P. Hasselbeck, University of New Mexico

TIMSS 2011 Fourth Grade Mathematics Item Descriptions developed during the TIMSS 2011 Benchmarking

Summer Packet 7 th into 8 th grade. Name. Integer Operations = 2. (-7)(6)(-4) = = = = 6.

Part 1. Creating an Array of Controls or Indicators

ASSIGNMENT 2. COMP-202A, Fall 2013, All Sections. Due: October 20 th, 2013 (23:59)

A. Front Panel Design Lesson 4 Implementing a VI

Area. Domain 4 Lesson 25. Getting the Idea

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

NI LabView READ THIS DOCUMENT CAREFULLY AND FOLLOW THE INSTRIUCTIONS IN THE EXERCISES

Originally released in 1986, LabVIEW (short for Laboratory Virtual Instrumentation

CW Middle School. Math RtI 7 A. 4 Pro cient I can add and subtract positive fractions with unlike denominators and simplify the result.

[ the academy_of_code] Senior Beginners

The Cover Sheet - MS Word

Table 1. Inputs and Outputs

Dept. of Electrical, Computer and Biomedical Engineering. Data Acquisition Systems and the NI LabVIEW environment

Introduction to LabVIEW

Engineering Innovation Center LabVIEW Basics

How to Do Word Problems. Study of Integers

CLAD Sample Exam 03. C. A control that output a cluster of the controls / indicators on the tabs.

CISC 1600, Lab 3.1: Processing

With the help of Adobe and a dash of creativity, we can create all kinds of fun things just using the shapes found in our tool box.

Unit 7: 3D Figures 10.1 & D formulas & Area of Regular Polygon

Using Number Skills. Addition and Subtraction

University of Pennsylvania. Department of Electrical and Systems Engineering. ESE Undergraduate Laboratory. Introduction to LabView

ECE 463 Lab 1: Introduction to LabVIEW

Band Editor User Guide Version 1.3 Last Updated 9/19/07

CIRCLES ON TAKS NAME CLASS PD DUE

Chapter 1: Problem Solving Skills Introduction to Programming GENG 200

3RD GRADE COMMON CORE VOCABULARY M-Z

CISC 1600 Lecture 3.1 Introduction to Processing

Geometry: Semester 2 Practice Final Unofficial Worked Out Solutions by Earl Whitney

Unit #13 : Integration to Find Areas and Volumes, Volumes of Revolution

Part 1. Summary of For Loops and While Loops

February 07, Dimensional Geometry Notebook.notebook. Glossary & Standards. Prisms and Cylinders. Return to Table of Contents

SFPL Reference Manual

Shift Register: Exercise # 1: Shift Register Example VI. 1. Build the following front panel. Figure (8.1): Shift register exercise front panel

Introduction to LabVIEW Exercise-1

LECTURE 5 Control Structures Part 2

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Flying Start AS Computer Science. September 2015

Certified LabVIEW Associate Developer Examination

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

CISC 1600, Lab 2.1: Processing

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015

FRC LabVIEW Sub vi Example

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

Measurement 1 PYTHAGOREAN THEOREM. The area of the square on the hypotenuse of a right triangle is equal to the sum of the areas of

Certified LabVIEW Associate Developer Examination

Guided Problem Solving

National 5 Mathematics Assessment Practice 5: The Theorem of Pythagoras and vectors (Topics 16-17)

Year 6 Term 1 and

Generating Vectors Overview

11.4 Volume of Prisms and Cylinders

Vocabulary. Term Page Definition Clarifying Example. cone. cube. cylinder. edge of a threedimensional. figure. face of a polyhedron.

3. Area and perimeter.notebook November 13, All rectangles with area 12cm 2 have the same perimeter. True or false?

University of Manitoba Open Programming Contest September 22, General Instructions:

Measurement and Geometry: Area and Volume of Geometric Figures and Objects *

Certified LabVIEW Associate Developer Exam. Test Booklet

Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives


Lesson 24: Surface Area

DINO. Language Reference Manual. Author: Manu Jain

5 th Grade MCA3 Standards, Benchmarks, Examples, Test Specifications & Sampler Questions

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

A Step-by-step guide to creating a Professional PowerPoint Presentation

ABE Math TABE Modules 1-10

Creating Icons for Leopard Buttons

Relational & Logical Operators, Selection Statements

Decimals. Chapter Five

WHOLE NUMBER AND DECIMAL OPERATIONS

LabVIEW: Visual Programming Using a Dataflow Model Extended With Graphical Control Structures. Outline

Maths Key Stage 3 Scheme of Work Number and measures Place value Calculations Calculator Measures

Advanced Reporting Tool

2 + (-2) = 0. Hinojosa 7 th. Math Vocabulary Words. Unit 1. Word Definition Picture. The opposite of a number. Additive Inverse

12 m. 30 m. The Volume of a sphere is 36 cubic units. Find the length of the radius.

Fill in the Blank Modeling and Prototypes. Name: Class: Date:

BE/EE189 Design and Construction of Biodevices Lecture 2. BE/EE189 Design and Construction of Biodevices - Caltech

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

UNIT 11 VOLUME AND THE PYTHAGOREAN THEOREM

Area. Angle where two rays. Acute angle. Addend. a number to be added. an angle measuring less than 90 degrees. or line segments share an endpoint

3You can use the formula A = C G to find

Warm-Up 12 Solutions. Peter S. Simon. December 8, 2004

Selection Statements

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

Table of Contents. Student Practice Pages. Number Lines and Operations Numbers. Inverse Operations and Checking Answers... 40

Grade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem

Small rectangles (and sometimes squares like this

Interactive Math Glossary Terms and Definitions

Date Lesson Text TOPIC Homework. SA of Prisms & Pyramids Pg. 441 # 1, 3, 5a, 7b, 11bc, 16. Surface Area of Cylinders WS 6.6

2012 Pascal Contest (Grade 9)

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Intermediate Microsoft Word 2010

Methods in Mathematics

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Lab 1: Getting familiar with LabVIEW: Part I

1. Complete these exercises to practice creating user functions in small sketches.

STAAR Category 3 Grade 8 Mathematics TEKS 8.6A/8.6B/8.7A. Student Activity 1

Transcription:

LabVIEW Case and Loop Structures ABE 4423/6423 Dr. Filip To Ag and Bio Engineering, Mississippi State University

Recap Previous Homework Following Instruction Create a Pressure Conversion VI that takes a value in PSI from the user and converts it to five other pressure units (Inch H2O, Inch Hg, Bar, Pascal, and mmhg). Use Gage Indicators (it looks like a round pressure gage) for displaying the results and make each indicator shows its digital value as well. Make the numeric objects to have SGL (single precision number) representation, and make the format to show 2 decimal points. Also make the block diagram objects be in small icons. Name your object logically, you may display captions instead of labels on the front panel in order to be more descriptive. Align the objects in the front panel and in the block diagram and tidy up the wires in the block diagram and space them equally. Other cosmetics of the objects are up to you. Put your name on the front panel, run your program so that your printout shows it. Follow the instructions in How To Print LabVIEW in PDF, include front panel and block diagram and all hidden frames if any, and submit the PDF printout in the designated Drop Box.

Purpose of Case and Loop Structures A Case Structure is used to do conditional execution of code segments (sub-diagrams) based on a selection criteria. A CASE structure works just like IF THEN ELSE constructs in traditional (text based) programming. A Loop structure is used to control the execution of program that requires repetition or iterations of a block of code. The number of repetitions is controlled by some conditions such as count or occurrence of a given condition. Case and Loop structures are LabVIEW objects in Structures category, they are used to control flow of execution of a VI

The Structure Category in Functions Pallet Structure functions are Block Diagram objects in the Functions Pallet. They have no Front Panel Representation.

Example Scenario Operating on Two Operands The scenario: We have two numeric inputs: Operand1 and Operand2, and we have one numeric output: Answer. We have a Text Ring that contains the following items: Add, Subtract, Multiply, Divide, Sum of Square, and Square of Sum We want to perform Answer = Operand1 Operand2 if Subtract is chosen in the Text Ring; We want to perform Answer = Operand1^2 + Operand2^2 if Sum of Square is chosen in the Text Ring, etc. We have to have six subsets of code that we want to execute conditionally based on the selection in the Text Ring. We will use a case structure in the program and we have six cases (conditions) to do.

Case Structure A CASE structure is a multi-layer frames of containers with a subdiagram in each frame. When there is no sub-diagram inside a frame it is a DO NOTHING case. Each layer of frame in the case structure is a CASE, it contains the code needed to execute when that case is selected (like the scenario presented previously, one case will contain the code to do Operand1-Operand2), and each of the other cases will have the code to do each of the other operations). A CASE structure has a Case Selector and a Case ID for each CASE. The Case Selector (the? icon at the frame border) is wired to data for selecting individual cases, and that data can be numeric, Boolean, or String. For the scenario presented previously the Case Selector should be connected to a numeric data (the output of the Text Ring) because we have six cases: 0, 1, 2, 3, 4, and 5. If the Case Selector is connected to a Boolean data then we have only two cases: TRUE, and FALSE.

Case Structure Regardless of the data type of a Case Selector, a case structure must have a DEFAULT case. Any case can be assigned to a default case by appending,default in the Case ID box. A case ID with only DEFAULT in it will execute when not of the other cases meets the condition specified by the Case Selector. A case structure can have only one DEFAULT case. Recommendation: Implement the scenario presented previously on your own before test#1

Case Structure Diagram Case Identification Case Structure Frame Case Selector. Case type: Boolean (Green) The code inside this frame is executed when the data of the Case Selector is TRUE otherwise the FALSE case is executed.

Different Case Selector Data Boolean Case; wire = Green; two case: True/False Type Case ID is Boolean String Case; Pink; case ID = string in quotes; one default case; number of cases unlimited Numeric Case; Blue (Integer); case ID = numeric; Can have many case as you like, one Default Case

In-class Example Boolean Case Write a program with RED and Green LED (Boolean) indicators and two Boolean controls (switches) so that when the first switch is TRUE, the RED led is active (ON/True) and Green is inactive (OFF/False) when the second switch is FALSE (off), and GREEN led is active (ON/True) while RED is inactive when that switch is in True position. Both LEDs are off when the first switch is FALSE (the first switch serves as an enabler). Why didn t I put the LED indicators inside the Case structure?

In-class Example: Numeric Case Write a VI with an integer numeric control and a String indicator. Make the string indicator shows NUMBER ONE if the value in the Numeric control is 1, NUMBER FIVE if the value in the Numeric control is 5, and DUNO THIS NUMBER if the value is anything else. How do I add, remove cases? How do I make the numeric input Blue or ORANGE? Is 0 needed in the default case?

In-class Example: String Case Write a VI that has one string control called Letter and three LEDs, red green and blue. If the data in Letter is a or A the green LED is on and the others are off; if z or Z the blue LED is on and others are off; if the letter is m or M the green and red LEDs are on and others are off; x or X all LEDs are off, and all other letters will cause all LEDs to turn on.

Common Knowledge about Case Can CASE structures be nested? Yes Can CASE structures be in parallel? Yes Structure How deep of a nested CASE structure is allowed? No limit How do you do a case that says execute this case if a value is between 1 and 19? 1 19 (one dot dot dot 19) How do you do a case that says execute this case if the value if greater than or equal to 6? Find this in HELP When a wire is connected to the frame of a case structure a square connector is created what s this? Tunnel Data sent into a case structure does not have to be wired in all the cases. Data sent out from a case structure MUST be wired in all cases (all cases must be fully defined). Not fully defined cases is indicated by the Output Tunnels (the tunnels that send data out of the case structure) look like squares that are not filled (white spot in the middle)

Select Function Select function is a block diagram object that is used to send data from one of two sources. Unlike Case structure it has only two input terminals and one Boolean selector Terminal. It only conveys data and it does not execute sub-diagram like a Case structure. Example:

Homework Create a VI that performs computation in a two-parameter area calculator with pictures of shapes. It calculates the area of a shape using the two input parameters (Numeric controls) and the shape chosen by the user. The shapes are: triangle (base and height), Cone (radius and height), and rectangle (width and length). Use a Text Ring object as the data source to select the shape to be computed, use String indicators with the labels hidden and position them on top of each input parameters. The contents of these indicators are to be changed programmatically. For example: They display Base and Height if a triangle is selected, they display Radius and Height if cone is selected, etc.) The two input parameters are numeric controls with their labels made hidden (because you are using the string indicators to overlay on top of them). In addition to the two numeric controls and two string indicators, your VI should also have one numeric indicator for displaying the computation result (the area), and a 2D Picture object (Graph -> Controls -> 2D Picture) for showing the shape. Your VI displays the picture of the shape being computed in addition to the result of computation. Make the size of the picture is 200 x 200 pixels. So, the user select a shape from the RING, click RUN, the area is computed, the input parameter texts show the appropriate strings and the picture of that shape is shown. You must read the context help and the detailed help of the 2D picture object in order to figure out how to draw shapes programmatically if you have never done it yet. Feel free to use your internet resources for this.

Hint: Drawing Shape Programmatically Front Panel: Graph ècontrols è2d Picture, adjust the properties so that you know its size (example: make it 200 x 200 pixels) Draw a Circle in the 2D Picture Box: Block Diagram: Graphics and Sound èpicture Functions è Draw Circle By Radius. Wire the New Picture to the 2D Picture object. Create a constant for Picture Center and make it 100,100 (rihgt-click on the Pixel Center terminal and choose CREATE CONSTANT); Create a constant for Radius and make it 50, run it and see what it looks like. You may have to draw multiple objects (like cone).