Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS320n –Visual Programming More LabVIEW Control Structures.

Similar presentations


Presentation on theme: "CS320n –Visual Programming More LabVIEW Control Structures."— Presentation transcript:

1 CS320n –Visual Programming More LabVIEW Control Structures

2 Visual ProgrammingLabVIEW Control Structures2 What We Will Do Today Learn about other LabVIEW control structures

3 Visual ProgrammingLabVIEW Control Structures3 Case Structures conditional execution like a if – else in Alice or other languages 2 or more sub diagrams the diagram that executes is based on the input of a selector Selector can be boolean, numeric, or a string

4 Visual ProgrammingLabVIEW Control Structures4 Case Structure

5 Visual ProgrammingLabVIEW Control Structures5 Case Structure Current Case Sub Diagram. Can only view one case at a time. Selector input. Will change based on data type of input: boolean, numeric String

6 Visual ProgrammingLabVIEW Control Structures6 Case Structure Example Create an instrument that can convert degrees F to degrees C or degrees C to degrees F Must choose which conversion to make use a switch on front panel to select which conversion to perform

7 Visual ProgrammingLabVIEW Control Structures7 Block Diagram Choose sub diagram by clicking on increment / decrement arrows or clicking on the down arrow and selecting from the menu.

8 Visual ProgrammingLabVIEW Control Structures8 Use Sub VIs Add the C to F and F to C sub VIs to the block diagram

9 Visual ProgrammingLabVIEW Control Structures9 Partial Block Diagram Problems with tunnels. If data comes out from one case outputs a value, all cases must have an output for that value. Not the same for input

10 Visual ProgrammingLabVIEW Control Structures10 Completed Block Diagram

11 Visual ProgrammingLabVIEW Control Structures11 Completed Front Panel

12 Visual ProgrammingLabVIEW Control Structures12 One More Thing… Any way to make instrument more user friendly than input label of “Temp In” and output label of “Converted Temp”?

13 Visual ProgrammingLabVIEW Control Structures13 Different Selectors In example selector was boolean –only two cases, true or false selector can be numeric or string control for numeric selector can be any numeric type but will get converted to int for string and numeric selector many possible cases right click on selector to add cases

14 Visual ProgrammingLabVIEW Control Structures14 Select Function simple alternative to if-else type case structure a boolean input if boolean is true pass on the value wired to t if boolean is false pass on the value wired to f can handle other data types

15 Visual ProgrammingLabVIEW Control Structures15 Sequence Structure In LabVIEW, execution is driven by data flow when the input data is ready, functions execute sometimes no way of telling which order things will execute in most programming languages, flow of control is not driven by data, but is sequential based on order of statements in program

16 Visual ProgrammingLabVIEW Control Structures16 Sequence Structure Flat Sequence structure with 2 more frames added. Frames execute in order. Alternative to Flat Sequence Structure is a Stacked Sequence Structure. Visually different in that only one frame visible at a time, but functionally equivalent.

17 Visual ProgrammingLabVIEW Control Structures17 Class work This exercise makes use of loops, but does not require case structures. Monte Carlo method for determining Pi pi is the ratio of the circumference of a circle to its diameter, no matter which circle you use to compute it.

18 Visual ProgrammingLabVIEW Control Structures18 Monte Carlo method imagine a quarter of a unit circle. (radius = 1) pick points at random –random value of x and y, between 0 and 1 use distance formula to determine if point is inside or outside circle –square root of (x^2 + y^2) tally up points inside circle pick lot of points estimate of pi = 4 * (points inside / total number of points) 1,1 x y 1,0 0,1. inside. outside

19 Visual ProgrammingLabVIEW Control Structures19 Class work write a LabVIEW program that picks random points to estimate pi. Allow control for number of random points to pick display resulting estimate of pi


Download ppt "CS320n –Visual Programming More LabVIEW Control Structures."

Similar presentations


Ads by Google