CS320n - PowerPoint PPT Presentation

About This Presentation
Title:

CS320n

Description:

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 ... – PowerPoint PPT presentation

Number of Views:11
Avg rating:3.0/5.0
Slides: 16
Provided by: sco1
Category:
Tags: cs320n | dragged

less

Transcript and Presenter's Notes

Title: CS320n


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

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

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!
5
Count value
  • Loops cant 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
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
Slowed down loop
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

9
While Loop Stopping Conditions
Stop if true
Continue if true
Right click to change
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

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?

12
Does Not Work
  • Why not?

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
14
Completed Version
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?
Write a Comment
User Comments (0)
About PowerShow.com