You are on page 1of 13

Chapter 2

LabVIEW
Dr. Minhhuy Le
606-A4, EEE, Phenikaa Uni.
huy.leminh@phenikaa-uni.edu.vn

1
Check Homework – Student practice
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

x = a*sin(2*pi*f*t + phi) + b

Minhhuy Le, EEE, Phenikaa Uni. 2


Check Homework – Student practice
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
Problems:
t = i: -> 2*pi*f*1 ~2*pi*f*N -> cyclic -> x values
are different only because numeric calculation
error

Solution:
t = 0:Tmax with resolution of 1/fs -> t = 0:1/fs:T
If using “i” -> divided by fs: ti = i/fs

Minhhuy Le, EEE, Phenikaa Uni. 3


Outline

Chapter 2
1. LabVIEW Programming Development
2. Loops and Waveform Graphs
3. Data Files and Character Strings
4. Important Programming Structures: cases, shift registers...

Minhhuy Le, EEE, Phenikaa Uni. 4


Outline

Sensor DAQ Algorithm DAQ Output

Display

Load data
Save data

PC

Minhhuy Le, EEE, Phenikaa Uni. 5


2.3 Data Files and Character Strings
Right-click on
Block diagram Ctrl + H
-> File I/O
-> Write
delimited
spreadsheet.vi

• Open/create/rep
lace file
• Write text file
• Read text file
• Close file

Minhhuy Le, EEE, Phenikaa Uni. 6


2.3 Data Files and Character Strings
Example: Save to .csv file

Minhhuy Le, EEE, Phenikaa Uni. 7


2.3 Data Files and Character Strings
Example: Read from .csv file

Minhhuy Le, EEE, Phenikaa Uni. 8


2.3 Data Files and Character Strings
Example: Logging from DAQ Assistant to .csv file
(Practice) – Students come to code

Minhhuy Le, EEE, Phenikaa Uni. 9


2.3 Data Files and Character Strings
Previous problem: manual create a file or must select file before running
Wants: Type a file name -> Record data -> How to do ???

Right-click on “file path” -> choose folders

Minhhuy Le, EEE, Phenikaa Uni. 10


2.3 Data Files and Character Strings
Wants: Type a file name -> Record data -> How to do ???

Right-click on Front panel


-> String & Path
-> String control

Minhhuy Le, EEE, Phenikaa Uni. 11


2.3 Data Files and Character Strings
Wants: Type a file name -> Record data -> How to do ???
Build a file path with a file name

Set file path, then only enter file name


Minhhuy Le, EEE, Phenikaa Uni. 12
Summary

• Check homework: student practice


• Save data to a file
• Read data file
• Character strings with file name
• Code practice

Homework:
• Program GUI interface
• Save data to file
• Read data from file
Minhhuy Le, EEE, Phenikaa Uni. 13

You might also like