s2-labview docentes
DESCRIPTION
LabTRANSCRIPT
![Page 1: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/1.jpg)
TOPICS
Lesson 1, Slide 1
LabVIEW Core 1
![Page 2: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/2.jpg)
TOPICS
Lesson 3, Slide
Lesson 3Implementing a VI
A. Front Panel BasicsB. LabVIEW Data TypesC. Documenting CodeD. While LoopsE. For Loops
F. Timing a VIG. Data Feedback in LoopsH. Plotting Data – Waveform ChartI. Case Structures
1
![Page 3: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/3.jpg)
Lesson 3, Slide
A. Front Panel Basics
2
![Page 4: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/4.jpg)
Lesson 3, Slide
Front Panel Basics
Front panel controls and indicators create terminals on the block diagram.
3
![Page 5: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/5.jpg)
Lesson 3, Slide
B. LabVIEW Data Types
Shortcut Menu and Properties Dialog BoxNumeric TypesBoolean TypesString TypesEnums and Other Types
4
![Page 6: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/6.jpg)
Lesson 3, Slide
LabVIEW Data Types
Terminals visually communicate information about the data type represented
5
![Page 7: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/7.jpg)
Lesson 3, Slide
Shortcut Menus• All LabVIEW objects have
associated shortcut menus.• Use shortcut menu items to
change the look or behavior of objects.• To access the shortcut
menu, right-click the object.
6
![Page 8: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/8.jpg)
Lesson 3, Slide
Properties Dialog Box• All LabVIEW objects have
properties.• To access properties,
right-click the object and select Properties.• Property options are
similar to shortcut menu options.• Select multiple objects to
simultaneously configure shared properties.
7
![Page 9: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/9.jpg)
Lesson 3, Slide
Numerics
Various data type representations:• Floating-point• Unsigned integers• Signed integers
8
![Page 10: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/10.jpg)
Lesson 3, Slide
Numeric Conversion
• Coercion dots indicate that LabVIEW converted the value passed into a node to a different representation.− Occurs when a node expects an input with a
different representation.
• LabVIEW chooses the representation that uses more bits.
• Avoid coercion by programmatically converting to a matching data type.
Coercion Dot
9
![Page 11: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/11.jpg)
Lesson 3, Slide
Booleans• Behavior of Boolean
controls is specified by the mechanical action.
• Boolean have only TRUE/FALSE values.
10
![Page 12: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/12.jpg)
Lesson 3, Slide
Mechanical Action of Booleans
11
![Page 13: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/13.jpg)
Lesson 3, Slide
Strings• A string is a sequence of
ASCII characters.• Strings have various
display styles.− Backslash codes− Password− Hex
13
![Page 14: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/14.jpg)
Lesson 3, Slide
Enums
• Enums give users a list of items from which to select.• Each item represents a
pair of values.− String− 16-bit Integer
14
![Page 15: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/15.jpg)
Lesson 3, Slide
Other Data Types
Refer to LabVIEW Help for complete list of terminal symbols for different types of controls and indicators.• Dynamic
− Stores the information generated or acquired by an Express VI.• Path
− Stores the location of a file or directory using the standard syntax for the platform you are using.
• Waveform− Carries the data, start time, and dt of a waveform.
15
![Page 16: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/16.jpg)
Lesson 3, Slide
D. While Loops
Iteration and Conditional TerminalsTunnelsError Checking
23
![Page 17: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/17.jpg)
Lesson 3, Slide
While Loops
LabVIEW While Loop Flowchart Pseudo Code
Repeat (code);
Until Condition met;
End;
24
![Page 18: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/18.jpg)
Lesson 3, Slide
While LoopsIteration terminal• Returns number of times loop
has executed.• Is zero-indexed.
Conditional terminal• Defines when the loop stops.• Has two options.
− Stop if True− Continue if True
Iteration Terminal Conditional Terminal
25
![Page 19: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/19.jpg)
Lesson 3, Slide
While Loops – Tunnels • Tunnels transfer data into and out of structures.• Data pass out of a loop after the loop terminates.• When a tunnel passes
data into a loop, the loop executes only after data arrive at the tunnel.
26
![Page 20: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/20.jpg)
Lesson 3, Slide
E. For Loops
Conditional TerminalComparison with While LoopsNumeric Conversion for Count Terminal
30
![Page 21: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/21.jpg)
Lesson 3, Slide
For Loops
LabVIEW For Loop Flowchart Pseudo Code
N=100;
i=0;
Until i=N:
Repeat (code;i=i+1);
End;
31
![Page 22: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/22.jpg)
Lesson 3, Slide
For Loops
• Create a For Loop the same way you create a While Loop.• You can replace a While Loop with a For Loop by right-
clicking the border of the While Loop and selectingReplace with For Loop from the shortcut menu.• The value in the count terminal (an input terminal)
indicates how many times to repeat the subdiagram in the For Loop.
32
![Page 23: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/23.jpg)
Lesson 3, Slide
For Loops – Conditional TerminalYou can add a conditional terminal to configure a For Loop to stop when a Boolean condition is true or an error occurs.
33
![Page 24: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/24.jpg)
Lesson 3, Slide
For Loops – Conditional TerminalFor Loops configured with a conditional terminal have:• A red glyph next to the count terminal. • A conditional terminal in the lower right corner
34
![Page 25: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/25.jpg)
Lesson 3, Slide
For Loop/While Loop ComparisonFor Loop• Executes a set number of times
unless a conditional terminal is added.
• Can execute zero times.• Tunnels automatically output an
array of data.
While Loop• Stops executing only if the value
at the conditional terminal meets the condition.
• Must execute at least once.• Tunnels automatically output the
last value.
35
![Page 26: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/26.jpg)
Lesson 3, Slide
For Loops – Numeric Conversion• The number of iterations a For Loop executes must be specified in
non-negative integers.• If you wire a double-precision, floating-point numeric value to the
count terminal, LabVIEW converts the numeric value to a 32-bit signed integer.
36
![Page 27: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/27.jpg)
Lesson 3, Slide
F. Timing a VI
Reasons To Use TimingWait Functions and Express VIs
38
![Page 28: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/28.jpg)
Lesson 3, Slide
Timing a VI
Why do you need timing in a VI?• To control the frequency at which a loop executes.• To provide the processor with time to complete other tasks,
such as processing the user interface.
39
![Page 29: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/29.jpg)
Lesson 3, Slide
Wait FunctionsA wait function inside a loop:• Allows the VI to sleep for a set amount of time.• Allows the processor to address other tasks during the wait
time.• Uses the operating system millisecond clock.
40
![Page 30: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/30.jpg)
Lesson 3, Slide
Elapsed Time Express VI• Determines how much time elapses after some point in
your VI.• Keeps track of time while the VI continues to execute.• Does not provide the processor with
time to complete other tasks.
41
![Page 31: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/31.jpg)
Lesson 3, Slide
G. Data Feedback in Loops
Shift RegistersInitializing Shift RegistersDefault for Unwired ValuesCompound Shift Registers
43
![Page 32: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/32.jpg)
Lesson 3, Slide
Data Feedback in Loops• When programming with loops, you often need to know the
values of data from previous iterations of the loop.• Shift registers transfer values from one loop iteration to the
next.
44
![Page 33: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/33.jpg)
Lesson 3, Slide
Shift Registers• Right-click the border and select Add Shift Register from
the shortcut menu.• Right shift register stores data on completion of an iteration.• Left shift register provides stored data at beginning of the
next iteration.
45
![Page 34: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/34.jpg)
Lesson 3, Slide
Block Diagram 1st run 2nd run
InitializedShiftRegister
Output = 5 Output = 5
Not InitializedShiftRegister
Output = 4 Output = 8
Initializing Shift RegistersVI finishes Run againRun once
46
![Page 35: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/35.jpg)
Lesson 3, Slide
Use Default if Unwired
Default values vary by data type:
Uninitialized shift registers use default values for first run.
Data Type Default Value
Numeric 0
Boolean FALSE
String Empty
47
![Page 36: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/36.jpg)
Lesson 3, Slide
Multiple Previous Iterations• Stacked shift registers remember values from multiple
previous iterations and carry those values to the next iterations.• Right-click the left shift register and select Add Element
from the shortcut menu to stack a shift register.
48
![Page 37: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/37.jpg)
Lesson 3, Slide
I. Case Structures
Parts of a Case StructureEnum Case StructuresError Case StructuresInput and Output Tunnels
56
![Page 38: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/38.jpg)
Lesson 3, Slide
Case Structures• Have two or more subdiagrams or cases.• Use an input value to determine which case to execute.• Execute and display only one case at a time.• Are similar to case statements or if...then...else statements
in text-based programming languages.
57
![Page 39: S2-Labview Docentes](https://reader035.vdocuments.net/reader035/viewer/2022062519/563dbb07550346aa9aa9abaf/html5/thumbnails/39.jpg)
Lesson 3, Slide
Case Structures
Case Selector Label
Selector Terminal
• Case Selector Label− Contains the name of the current
case.− Has decrement and increment
arrows.
• Selector Terminal− Lets you wire an input value, or
selector, to determine which case executes.
58