Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 29

3.

3 Loops and Charts


• While Loops
• Waveform Charts
• For Loops

1
While Loops

• What is while loop?


• Location in Structure subpalette
• Enclose the section of circuit
• Iteration terminal
• Conditional terminal

2
What is while loop?

3
Location in Structure subpalette

4
Enclose the section of circuit

5
Iteration terminal

6
Conditional terminal

7
While Loop Summary
1. Select While Loop 2. Enclose code to be repeated

3. Drop or drag additional nodes and then wire

Do

(Execute diagram
inside Loop)

While Condition is TRUE

8
While Loop Summary
• Right-click on Conditional Terminal to define
when the loop stops

Iteration Terminal Conditional Terminal

9
Waveform Charts
• Open a waveform chart
• Wiring single chart
• Change chart scale
• Scale format
• Zoom graph

10
Open a waveform chart

Click Waveform Chart and place


the cart on the front panel.
11
Wiring single chart

12
Change chart scale

13
Scale format

14
Zoom graph

15
Exercise 1: Auto Match VI
• Students build Auto Match.vi
• This exercise is to build a VI that generates
random numbers until matches a specified
number. The loop count terminal records the
number of iterations before a match occurs.
• This VI will be used in a later exercise.
Time to complete: 30 min.

16
Exercise 1: front panel

17
Exercise 1: block diagram

18
Exercise 1a: Auto Match Range VI
• Students build Auto Match Range.vi
• This exercise modify from Auto Match.vi and is to
build a VI that generates random numbers until it
falls in a specified range. The loop count terminal
records the number of iterations before a match
occurs.
• This VI will be used in a later exercise.
Time to complete: 30 min.

19
For Loops

• Diagram
• Location in Structure subpalette
• Count terminal
• Data conversion
• Iteration terminal
• Different between for and while loop

20
Diagram

21
Location in Structure subpalette

22
Count terminal

23
Data conversion

24
Iteration terminal

25
Different between for and while loop

26
For Loop Summary
• In Structures subpalette of Functions palette
• Enclose code to be repeated and/or resize and
add nodes inside boundary
• Executes diagram inside of loop a predetermined
number of times
• Shift registers can be created at the border

Count terminal
(Numerical input)

27
Can “For” loop be used in
Exercise 1 (Auto Match.vi) ?
• Exercise 1 is to build a VI that generates random
numbers until matches a specified
number. The loop count terminal records the
number of iterations before a match occurs.
• What is the different between “for” and “while”
loops?

28
Tut 3.3.1 : Loops
• Try to finish the Tut 3.3.1

29

You might also like