1 / 19

CS320n –Visual Programming

Learn about LabVIEW case structures and how to create an instrument for temperature conversion with selector switches. Utilize sub diagrams, handle data tunnels, and enhance user experience through different selectors and select functions. Dive into the Monte Carlo method to estimate pi in a class exercise.

Download Presentation

CS320n –Visual Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS320n –Visual Programming More LabVIEW Control Structures

  2. What We Will Do Today • Learn about other LabVIEW control structures LabVIEW Control Structures

  3. 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 LabVIEW Control Structures

  4. Case Structure LabVIEW Control Structures

  5. 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 LabVIEW Control Structures

  6. 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 LabVIEW Control Structures

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

  8. Use Sub VIs • Add the C to F and F to C sub VIs to the block diagram LabVIEW Control Structures

  9. 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 LabVIEW Control Structures

  10. Completed Block Diagram LabVIEW Control Structures

  11. Completed Front Panel LabVIEW Control Structures

  12. One More Thing… • Any way to make instrument more user friendly than input label of “Temp In” and output label of “Converted Temp”? LabVIEW Control Structures

  13. 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 LabVIEW Control Structures

  14. 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 LabVIEW Control Structures

  15. 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 LabVIEW Control Structures

  16. 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. LabVIEW Control Structures

  17. 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. LabVIEW Control Structures

  18. 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) Monte Carlo method 1,1 0,1 . outside . inside y 1,0 x LabVIEW Control Structures

  19. 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 LabVIEW Control Structures

More Related