1 / 15

CS320n –Visual Programming

CS320n –Visual Programming. LabVIEW Control Structures. What We Will Do Today. Learn about control structures in LabVIEW class work working with control structures. For Loop. Just like in Alice, execute some code a fixed number of times

tamal
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 LabVIEW Control Structures

  2. What We Will Do Today • Learn about control structures in LabVIEW • class work working with control structures LabVIEW Control Structures

  3. For Loop • Just like in Alice, execute some code a fixed number of times • In LabVIEW the loop is dragged around the components to be executed repeatedly LabVIEW Control Structures

  4. For Loop Mechanics Count terminal. Wire a number to this. Could be constant orresult of operation Iteration terminal. Which execution of the loop is this? Starts at 0, not 1! LabVIEW Control Structures

  5. Count value • Loops can’t execute fractional times • 0, 1, 2, 3, 4 … • Try wiring a floating point number to the count terminal • Not an error • normal rounding Coercion Dot LabVIEW Control Structures

  6. Expected Output? • how many times does the loop execute? • what is the first value of the iteration counter? the last? • tough to see • add time delay LabVIEW Control Structures

  7. Slowed down loop LabVIEW Control Structures

  8. While loop • continue executing until while some condition is true (or until some condition is false) • condition can be anything that has a boolean output • output of function or result of a switch or button LabVIEW Control Structures

  9. While Loop – Stopping Conditions Stop if true Continue if true Right click to change LabVIEW Control Structures

  10. While loop • Pick and display random numbers until a number greater than .99 is selected • Tunnel – takes information out of a loop when finished LabVIEW Control Structures

  11. Shift Registers • To get information from one iteration of a loop to the next shift register are used • Pick random numbers and add them together until the sum exceeds 1000 • How to keep a running total of them sum? LabVIEW Control Structures

  12. Does Not Work • Why not? LabVIEW Control Structures

  13. Fix with Shift Register • right click on loop boundary and choose “add shift register” Data from last iteration of loop. Give initial value. Data to nextiteration of loop LabVIEW Control Structures

  14. Completed Version LabVIEW Control Structures

  15. Class work • Create a LabVIEW program that picks random numbers • Pick random numbers until a value greater than 0.9999 is picked – while loop • Display how many picks it takes to get a result greater than 0.9999 • Run the experiment 10,000 times • What is the average number of picks required? – use a for loop • When that is finished add to the program to answer these questions: • What were the maximum and minimum number of picks required? LabVIEW Control Structures

More Related