19
Logging Data to Text Files in LabVIEW Hans-Pe8er Halvorsen h8ps://www.halvorsen.blog

LabVIEW - Logging Data to Text Files

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LabVIEW - Logging Data to Text Files

Logging Data to Text Files in LabVIEW

Hans-Pe8er Halvorsen

h8ps://www.halvorsen.blog

Page 2: LabVIEW - Logging Data to Text Files

Datalogging• When acquiring data from a DAQ device or an I/O

Module you typically want to store the data to either a File, a Database or an OPC Server

• Here we will use the “Write To Measurement File” in LabVIEW as an example

• If you don’t have a DAQ device or an I/O Module you can create a simple Simulator as exemplified later in this tutorial

Page 3: LabVIEW - Logging Data to Text Files

Contents

1. Using DAQ or I/O Module in LabVIEW

2. Write To Measurement File3. Temperature Simulator

Page 4: LabVIEW - Logging Data to Text Files

Using DAQ or I/O Module in LabVIEW

Hans-Petter Halvorsen

h@ps://www.halvorsen.blog

Page 5: LabVIEW - Logging Data to Text Files

Data Acquisi+on Pale1e in LabVIEWFor more “advanced” DAQ we use these func+ons

For basic DAQ we use the DAQ Assistant

Students: Make sure that you have this palette installed. If not, install the latestDAQmx driver!

Functions Palette: “Measurement I/O” -> “NI DAQmx”

Page 6: LabVIEW - Logging Data to Text Files

LabVIEW DAQ Assistant

When you place the DAQ Assistant on the Block Diagram, a Wizard automatically pops up where you configure what you want to do, i.e., if you want to Read or Write Data, Analog or Digital signals, which channel you want to use, etc.

Page 7: LabVIEW - Logging Data to Text Files

Basic DAQ Example

Page 8: LabVIEW - Logging Data to Text Files

Write To Measurement File

Hans-Pe4er Halvorsen

h4ps://www.halvorsen.blog

Page 9: LabVIEW - Logging Data to Text Files

Save Data to File (Datalogging)Right-click-Properties

Recommended Se;ngs

Page 10: LabVIEW - Logging Data to Text Files

Recommended Settings

Page 11: LabVIEW - Logging Data to Text Files

Datalogging Example

Page 12: LabVIEW - Logging Data to Text Files

Students: (1) Log Temperature Data, both Celsius and Fahrenheit (use SubVI) to a “Measurement File”. (2) Then Plot the Data in the File in Excel.(3) You should also create a new VI in LabVIEW where you plot the data from the File in a Graph and in an Array.

Datalogging Example – Block Diagram

Page 13: LabVIEW - Logging Data to Text Files

Read from Measurement File - Example

Right-click-Properties

Block Diagram

Recommended Se>ngs

Page 14: LabVIEW - Logging Data to Text Files

Recommended Settings

Page 15: LabVIEW - Logging Data to Text Files

Temperature Simulator

Hans-Pe3er Halvorsen

h3ps://www.halvorsen.blog

Page 16: LabVIEW - Logging Data to Text Files

Temperature Simulator Example❗If you do not have the TC01 device available, you can create and use a

simple “Temperature Simulator” instead A simple SubVI that simulates a Temperature value using a

Random Generator:

In this way you can easily switch between

the real Temperature sensor (TC-01) and

the Simulator

Case Structure

While Loop

Case Structure

While Loop

Students: Create a “Temperature Simulator”.

Here you just see a simple example - feel free to

create a more realisOc Temperature Simulator

Use e.g., an “Enum”

Control (or just a String

or Numeric Control)

Example

Page 17: LabVIEW - Logging Data to Text Files

How to create an “Enum” in LabVIEW

1 2 3

4

5

6

(used in the Temperature Simulator Example)

Page 18: LabVIEW - Logging Data to Text Files

Log Datato File

Simple Example of how to log data to a Measurement File using the “Write To Measurement File” function in LabVIEW

In this example we get data from a simulator.

You can turn logging On/Off

Example

Page 19: LabVIEW - Logging Data to Text Files

Hans-Pe(er Halvorsen

University of South-Eastern Norwaywww.usn.no

E-mail: [email protected]: h(ps://www.halvorsen.blog