0% found this document useful (0 votes)
52 views13 pages

Chapter 2 - 3

This document discusses LabVIEW programming and includes chapters on loops, waveform graphs, data files, character strings, and important programming structures. It provides examples of saving data to a .csv file from a DAQ assistant and reading data from a .csv file. It also demonstrates using a string control on the front panel to allow the user to type a file name and build the file path to record data. The homework assignment is to program a GUI interface to save data to a file and read data from a file.

Uploaded by

Phong Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views13 pages

Chapter 2 - 3

This document discusses LabVIEW programming and includes chapters on loops, waveform graphs, data files, character strings, and important programming structures. It provides examples of saving data to a .csv file from a DAQ assistant and reading data from a .csv file. It also demonstrates using a string control on the front panel to allow the user to type a file name and build the file path to record data. The homework assignment is to program a GUI interface to save data to a file and read data from a file.

Uploaded by

Phong Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter 2

LabVIEW
Dr. Minhhuy Le
606-A4, EEE, Phenikaa Uni.
[email protected]

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