Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS320n –Visual Programming LabVIEW Control Structures.

Similar presentations


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

1 CS320n –Visual Programming LabVIEW Control Structures

2 Visual ProgrammingLabVIEW Control Structures2 What We Will Do Today Learn about control structures in LabVIEW class work working with control structures

3 Visual ProgrammingLabVIEW Control Structures3 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

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

5 Visual ProgrammingLabVIEW Control Structures5 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

6 Visual ProgrammingLabVIEW Control Structures6 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

7 Visual ProgrammingLabVIEW Control Structures7 Slowed down loop

8 Visual ProgrammingLabVIEW Control Structures8 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

9 Visual ProgrammingLabVIEW Control Structures9 While Loop – Stopping Conditions Stop if true Continue if true Right click to change

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

11 Visual ProgrammingLabVIEW Control Structures11 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?

12 Visual ProgrammingLabVIEW Control Structures12 Does Not Work Why not?

13 Visual ProgrammingLabVIEW Control Structures13 Fix with Shift Register right click on loop boundary and choose “add shift register” Data to next iteration of loop Data from last iteration of loop. Give initial value.

14 Visual ProgrammingLabVIEW Control Structures14 Completed Version

15 Visual ProgrammingLabVIEW Control Structures15 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?


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

Similar presentations


Ads by Google