chapter 2 labview
TRANSCRIPT
![Page 2: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/2.jpg)
Minhhuy Le, EEE, Phenikaa Uni.
Chapter 21. LabVIEW Programming Development
2. Loops and Waveform Graphs
3. Data Files and Character Strings
4. Important Programming Structures: cases, shift registers...
Outline
2
![Page 3: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/3.jpg)
Minhhuy Le, EEE, Phenikaa Uni.
Outline
3
Sensor DAQ Algorithm
Display
Save data
DAQ Output
Load data
PC
![Page 4: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/4.jpg)
Minhhuy Le, EEE, Phenikaa Uni.
2.2 Loops and Waveform Graphs
4
While loop
While loops
Condition met?
Code
End
Repeat (code)Until condition met;End;
While (condition met):{Code;}
Flowchart Pseudo Code C code
![Page 5: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/5.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 5
While loops
Right-click on Block diagram-> Structures-> While loop
2.2 Loops and Waveform Graphs While loop
![Page 6: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/6.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 6
While loops
Left-mouse drag & drop While loopError ???
No Stop-condition
Iteration
2.2 Loops and Waveform Graphs While loop
![Page 7: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/7.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 7
Example: generate a random value in range (0,1) and offset by a “Center numeric” valueBoolean to control stop of while loop
2.2 Loops and Waveform Graphs While loop
![Page 8: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/8.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 8
While loop
Right-click on Block diagram-> Structures-> For loop
2.2 Loops and Waveform Graphs While loop
![Page 9: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/9.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 9
For loop
Example: generate a random value in range (0,1) and offset by a “Center numeric” value
Numeric: number of loops“Loops” = “Numeric” - 1
2.2 Loops and Waveform Graphs For loop
![Page 10: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/10.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 10
While loop <-> For loop
Right-click on the boundary of loop-> Replace with For Loop
2.2 Loops and Waveform Graphs For loop
Convert While -> For loop
Wire: error
![Page 11: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/11.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 11
Tunnel Modes:Last valueIndexingConcatenatingConditional
2.2 Loops and Waveform Graphs For loop
Right-click
![Page 12: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/12.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 12
Tunnel Modes:Last valueIndexingConcatenatingConditional
2.2 Loops and Waveform Graphs For loop
Last value
Indexing: build array
![Page 13: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/13.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 13
Timing:Tick Count: current time in ms
Wait: stop execution in an amount of timeWait until next ms
Multiple: Execute loop in an interval time
2.2 Loops and Waveform Graphs Timing
![Page 14: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/14.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 14
Timing:Tick Count: current time in ms
Wait: stop execution in an amount of timeWait until next ms
Multiple: Execute loop in an interval time
2.2 Loops and Waveform Graphs Timing
Interval = 100ms
![Page 15: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/15.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 15
Case structure = If, else
2.2 Loops and Waveform Graphs Case structure
True
False
![Page 16: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/16.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 16
Waveform graphs:Right click on Front panel -> Modern -> GraphChartGraphXY Graph3D Graphs...
2.2 Loops and Waveform Graphs Waveform graphs
![Page 17: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/17.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 17
Waveform Chart: Update by a single value
2.2 Loops and Waveform Graphs Waveform graphs
![Page 18: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/18.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 18
Waveform Chart: Click on Waveform graph variable on Block diagram - > Ctrl + H -> Show Context Help -> Input data to the graph
2.2 Loops and Waveform Graphs Waveform graphs
Ctrl + H
N points-> N Charts
![Page 19: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/19.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 19
Waveform Chart: Plot legend can be adjust plot styles, color, line style, line width ....
2.2 Loops and Waveform Graphs Waveform graphs
Plot legend Multiple plot -> multiple legends
Plot properties
![Page 20: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/20.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 20
Waveform Graph: Input an array
2.2 Loops and Waveform Graphs Waveform graphs
Single value1D array
![Page 21: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/21.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 21
XY Graph: Input 2 arrays: x array, y array -> BundleMultiple bundles -> Multiple XY Graphs
2.2 Loops and Waveform Graphs Waveform graphs
Bundle
![Page 22: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/22.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 22
Data types on Wires:Different data types cannot be wired
2.2 Loops and Waveform Graphs Waveform graphs
![Page 23: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/23.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 23
3D Graphs: surface, mesh, surface graph ...
2.2 Loops and Waveform Graphs 3D graphs
Plot helper-> Input data
Plot variable: display
Empty 3D surface graph
![Page 24: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/24.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 24
2.2 Loops and Waveform Graphs 3D graphs
3D Graphs: Example
Data generationPlot helper
Display
![Page 25: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/25.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 25
2.2 Loops and Waveform Graphs 3D graphs
Find examples:On an VI -> Help-> Find Examples...-> Enter keyword(s)
![Page 26: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/26.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 26
2.2 Loops and Waveform Graphs 3D graphs
Graph example coding: x = a*sin(2*pi*f*t + phi) + b
Sin waveform generator
Waveform graph
![Page 27: Chapter 2 LabVIEW](https://reader034.vdocuments.mx/reader034/viewer/2022050207/626daec25c75652b51722b14/html5/thumbnails/27.jpg)
Minhhuy Le, EEE, Phenikaa Uni. 27
2.2 Loops and Waveform Graphs Summary
Summary:• For & While loops• Case structure (if/else)• Waveform chart• Waveform graph• XY graph• 3D Graphs
Homework: x = a*cos(2*pi*f*t - phi) + b• Waveform chart in while/for loop• XY graph: x-axis: time t; y-axis: x value