1

Similar documents
CLAD Sample Exam 03. C. A control that output a cluster of the controls / indicators on the tabs.

Virtual Instrumentation With LabVIEW

EKT 314/4 LABORATORIES SHEET

Certified LabVIEW Associate Developer Exam. Test Booklet

RF Data Converter Evaluation GUI file support

Certified LabVIEW Associate Developer Examination

Certified LabVIEW Associate Developer Examination

B. Including the Event Structure within a loop. C. Configuring a Timeout case within the Event Structure

Virtual Instrumentation With LabVIEW

PHY Microprocessor Interfacing Techniques LabVIEW Tutorial - Part X File Output and Input

Electronics II Physics 3620 / 6620

Learn the three palettes. Learn how data is passed in LabVIEW. Create a subvi using two different methods.

Table 1. Inputs and Outputs

Bulk Creation of Data Acquisition Parameters

Code Plug Management: Contact List Import/Export. Version 1.0, Dec 16, 2015

Hardware: Acquiring Data and Communicating with Instruments

Bitter, Rick et al "Drivers" LabVIEW Advanced Programming Techinques Boca Raton: CRC Press LLC,2001

Reference Guide. Adding a Generic File Store - Importing From a Local or Network ShipWorks Page 1 of 21

Chapter 14: Files and Streams

LabVIEW VI Analyzer Toolkit

Kulite DAQ. Data Acquisition Software User s Manual. Version 3.2.0

GUIDE TO STORAGE CHARGEBACKS WITH DATADVANTAGE

Lab 1: Getting familiar with LabVIEW: Part I

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Part 2 Uploading and Working with WebCT's File Manager and Student Management INDEX

PC-based data acquisition II

2. The LabView Environment Two panes will open, one is the Front panel, and one is the Block Diagram

Certified LabVIEW Associate Developer Sample Exam 1. Test Booklet

LabVIEW VI Analyzer Toolkit

CLAD Exam Preparation Guide using LabVIEW NXG

LabVIEW. Table of Contents. Lesson 1. Pre-reqs/Technical Skills Basic computer use

File Storage Techniques in LabVIEW

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

DCAMAPI Library for LabVIEW

CLAD_80.questions.

OPENING A LEADS.TXT FILE IN EXCEL 2010

Using LabVIEW to Send Commands via RS232 to Ontrack Control Systems ADR Interfaces

LabVIEW Academy. 12. óra event, property node

LabVIEW Real-Time Module for Mac OS X User Manual Addendum

INTRODUCTION TO LABVIEW

Labview Lab 2. Vern Lindberg. April 16, 2012

PHYC 500: Introduction to LabView. Exercise 8 (v 1.3) M.P. Hasselbeck, University of New Mexico. Arrays, XY Graphs, Disk I/O

Dept. of Electrical, Computer and Biomedical Engineering. Data Acquisition Systems and the NI LabVIEW environment

File Importing - Text Files

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Lesson 4 Implementing a VI

Graduate-Credit Programming Project

Intermediate Programming, Spring 2017*

The Power and Ease of use of the EasyVSM Software

Creating a new form with check boxes, drop-down list boxes, and text box fill-ins. Customizing each of the three form fields.

SECTION 2: PROGRAMMING WITH MATLAB. MAE 4020/5020 Numerical Methods with MATLAB

Hands-on Lab 2: LabVIEW NI-DAQ Basics 2

ME 224: EXPERIMENTAL ENGINEERING. Lecture 2

LabVIEW Basics I: Introduction Course

TRANSFERRING MRI DATA FROM THE WORKSTATION

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

AN408. A Web-Configurable LabVIEW Virtual Instrument for a BL2600 and RN1100

LabVIEW programming II

Concept: Debugging. Goal. Description. Implementation. Use the debugging tools built into LabVIEW.

Importing Flat File Sources in Test Data Management

Chapter 5. File and Memory Management

Computer Interfacing Using LabView

Representing Data Elements

RoboDAQ7. By John Buzzi. Masters of Engineering Report. Cornell University

LabVIEW Express VI Development Toolkit User Guide

Introduction to LabVIEW Exercise-1

SanctionCheck 5 CSV File Tutorial

Data Storage and Query Answering. Data Storage and Disk Structure (4)

DATA STRUCTURE AND ALGORITHM USING PYTHON

How to Setup QuickLicense And Safe Activation

Determination of Drag Coefficient

13 File Structures. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Field Types and Import/Export Formats

Introduction to LabVIEW

A. Front Panel Design Lesson 4 Implementing a VI

1.1 Information representation

N2KExtractor. NMEA 2000 Data Extractor Software. User s Manual

Instruction Sets: Characteristics and Functions

Part 1. Summary of For Loops and While Loops

ni.com Preparing for the CLAD Exam

LabVIEW programming II

Using the LabVIEW Shared Variable

Bitter, Rick et al "LabVIEW Features" LabVIEW Advanced Programming Techinques Boca Raton: CRC Press LLC,2001

LabVIEW DataFinder Toolkit

Exercise 5: Basic LabVIEW Programming

LabVIEW Real-Time Module Release and Upgrade Notes

2. create the workbook file

LabVIEW Datalogging and Supervisory Control Module

Upload, Model, Analyze, and Report

SREAL File Converter. Overview. Content

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Arcus Technology DMX Series Steppers and LabVIEW An Introduction to DMX Series Stepper Motor Automation With LabVIEW Application Note 001

Arrays. Collection of data elements that are of same type

SMART TS XL DEPLOYMENT TIMELINE

Writing to and reading from files

NAME EET 2259 Lab 3 The Boolean Data Type

Preview. COSC350 System Software, Fall

CSV Import Guide. Public FINAL V

Importing data in txt format

LabView instrumentoinnissa, 55492, 3op Labview in instrumentation

Transcription:

0

1

4

Because a refnum is a temporary pointer to an open object, it is valid only for the period during which the object is open. If you close the object, LabVIEW disassociates the refnum with the object, and the refnum becomes obsolete. If you open the object again, LabVIEW creates a new refnum that is different from the first refnum. LabVIEW allocates memory for an object that is associated with a refnum. Close the refnum to release the object from memory. 5

7

Use text format files (ASCII files) for your data: To make the data available to other users or applications If disk space and file I/O speed are not crucial If performing random access reads or writes is unnecessary If numeric precision is not important Use binary format files for your data: When numeric precision is important When you need to randomly access stored data When efficiency is important A specific type of binary file, known as a Datalog file, is the easiest method for logging cluster data to file Stores arrays of clusters in a binary representation The storage format for Datalog files is complex, and therefore the data is difficult to access in any environment except LabVIEW Use TDMS files for the following purposes: To store test or measurement data To create a structure for grouping your data To store information about your data To read and write data at high speeds 8 TDMS file format:

Point out the high-level functions and low-level functions on the palette. High-level and low-level I/O applies to many areas, such as DAQ and TCP/IP. 9

High-level file I/O VIs perform all the steps: opening/creation of a file, reading/writing, closing the file. They also offer additional features, e.g. they can perform formatting of the data before they get written to the file. 10

If writing to or reading from a file occurs inside a loop and has o be iterated many times, it is worth using low-level functions for file access. There are separate functions for each of the steps: opening/creation of a file, reading from a file, writing to a file, closing a file. This gives the programmer more control and ability to decide when each phase of file access should happen. For example, for streaming data to disk (as shown in the slide) it is best to open and close the file only once - outside the loop. Only write (or read) functions are executed inside the loop, which results in better performance. 11

What would happen if you used the Write to Measurement File Express VI inside a While loop? The VI would run slower and be more inefficient. Because the Write to Measurement File Express VI is a high-level File I/O VI, the While Loop would open, write, and close the file in every iteration of the While Loop. Instead, you should use low-level File I/O functions when streaming data to a file in a loop, so that you only open the file once at the beginning of the VI and close the file once at the end of the VI. The idea of high- and low-level VIs holds also to other resources that have to be opened, read from or written to, and closed. 12

14

LabVIEW represents each data type in specific ways when writing to a binary file. Here is some additional information on how the data is stored. See the next slide for the importance of knowing how the data is stored. Multi-byte integers are broken into separate bytes and are stored in files in either littleendian or big-endian byte order. Using the Write to Binary File function, you can choose whether you store your data in little-endian or big-endian format. For more information on endian-ness see this ni.com article: What Does the Term "Endian" Mean? (http://digital.ni.com/public.nsf/allkb/8224f2391418fdf6862568f00051d091) Because strings are stored as a series of unsigned 8-bit integers, each of which has a value in the ASCII Character Code Equivalents Table, there is no difference between writing strings with the Binary File Functions and writing them with the Text File Functions Clusters are best represented in binary files by using Datalog Files. Arrays are represented as a sequential list of the elements. Element representation depends upon the element type. A header contains a 32-bit integer representing the size of each dimension. Example : A 2D array with a header contains: number of rows (integer), number of columns (integer), then array data. 15

There are two main methodologies to reading/writing binary files: random and sequential. Random is when to pick a point in the file and read X amount, then you might go to another section and read Y amount. Sequential, on the other hand, starts at the beginning and continues until you say stop or the end of the file is reached. In either case, you need to have some knowledge of the file contents, meaning the data type expected. Therefore, the Read from Binary File can chunk the bytes appropriately and return logical data. If the file contains numeric (double) data and you tell it to read strings, the binary will be chunked as if it were doubles and will return gibberish data. For Random Access: Use the Set File Position function to set the read offset to the point in the file you want to begin reading The offset is in bytes; therefore, you must calculate the offset based upon the layout of the file For Sequential Access: You can call the Get File Size function and use the result to calculate the number of items in the file, based upon the size of each item and the layout of the file. You can then wire the number of items to the count terminal of the Read from Binary File function. Alternately, you can sequentially access the file one item at a time by repeatedly calling the Read from Binary File VI with the default count of 1. You can check for the End of File error after calling the Read from Binary File VI or calculate the number of reads necessary to reach the end of the file by using the Get File Size VI. 16

As you might imagine after reading the previous slide, File I/O on the binary level can be quite tedious. To maintain the precision and small file size benefits of binary files and to make reading/writing to the file easier, the TDMS file was developed. A TDMS is actually 2 files: the *.tdms file and the *.tdms_index file. The former holds all the data and the latter facilitates accessing the data, which increases the read/write speeds. Use TDMS files for the following purposes: To store test or measurement data To create a structure for grouping your data To store information about your data To read and write data at high speeds All the information in the TDMS_Index file is also contained in the TDMS file. This is why the TDMS_Index file can be automatically regenerated from the TDMS file. For this reason, you only need to distribute one file the TDMS file. The internal structure of the TDMS file format is publicly documented, so it is possible to create 3 rd party programs to write and read TDMS files. In addition, there is a TDM Excel Add-In Tool (located at ni.com/tdm) you can install to load *.TDMS files into Excel. 17

One thing unique about TDMS files is that you can organize them into channels and channel groups. For example, if you are logging temperature on three different set-ups and at various locations within the set-up, you can create a channel for each temperature sensor and then group them according to which set-up they belong to. Furthermore, you can add properties to either the file, the channel group, or the individual channel to record things such as the operator that installed the set-ups or the location of the sensor within the set-up. Now imagine if you had hundreds of sensors on fifty set-ups. You will need a way to keep everything organized, and the tdms file can help. 18

One thing unique about TDMS files is that you can organize them into channels and channel groups. For example, if you are logging temperature on three different set-ups and at various locations within the set-up, you can create a channel for each temperature sensor and then group them according to which set-up they belong to. Furthermore, you can add properties to either the file, the channel group, or the individual channel to record things such as the operator that installed the set-ups or the location of the sensor within the set-up. Now imagine if you had hundreds of sensors on fifty set-ups. You will need a way to keep everything organized, and the tdms file can help. 19

There are multiple ways to use TDMS files including: express Vis and LabVIEW functions (subvis, API). Also, the Excel Add-In tool is available. Express VI: you will need to select the TDMS radio button in the configuration window API: example block diagrams using the API are in the next couple slides.

You have several option in selecting a method for creating filenames and destination directories. Until now, we have used the File Dialog to specify a file name and location. However, it is often desirable to programmatically create folders and file paths.

With relative instead of hard-coded paths, it is easier to transfer the application to other computers or different folders on the same computer. Use the Application Directory VI to get project directory paths. If your VI is part of a project, Application Directory VI returns path to this project s directory. If your VI is not part of a project, Application Directory VI returns path to the directory with the top-level VI of your application. If your VI is not saved to disk, Application Directory VI returns <Not a Path>. Use the Get System Directory VI to get system directory paths, for example: User Documents, User Desktop, User Temporary Directory. Refer to Context Help or LabVIEW Help for more information about the presented functions and VIs. 23

You may use e.g. Write to Spreadsheet File VI or Write To Measurement File Express VI. When you finish writing the code, run your VI. Then find the file it just created, open it in a text editor and verify if the data were written correctly. If yes, you should also be able to open your text file in a spreadsheet application. 24

You may use the VIs Average Temperature or Temperature Limits created as previous homeworks (see homeworks for the module Implementing a VI ). Add streaming current temperature data to a text (ASCII) file. Remember to open and close the file outside the main program loop. Inside the loop, perform writing to the file (use Write to Text File function). You may want to use a function that converts numeric data to a string these functions are available in Functions >> Programming >> String >> Number/String Conversion palette. You might also find Format Into String function useful (Functions >> Programming >> String >> Format Into String) it can create strings that include data of various types written as text (just as printf function in C language). To create relative path to the file, please refer to slide Creating Relative Paths in this presentation. A more advanced version of this task is to write to the file more than one channel of data. If you are modifying Average Temperature VI, you might save to file the current and averaged temperatures; if you are modifying Temperature Limits VI, you may save current temperature, low limit and high limit (and/or information whether the temperature is within the limits). You may also log the times at which the samples were taken (either a real timestamp date and hour or the time that elapsed sinse the beginning of the measurement). 25 Use string functions to create a string of tab-delimited or comma-delimited values and

You may use Read From Spreadsheet File VI. If you read multicolumn spreadsheet files, remember to set the same separator (tab, comma, ) while reading as was used when the file was written. You may read the values as an array of strings or an array of numeric values. You have to remember that the file might contain a string header in the first row. If you want to get only the numeric values from such a file, you have to remove this header from the array that was read from the file before you use the numeric values. Run the VIs that you created for both previous homeworks: Write Spreadsheet File (if you used Write to Spreadsheet File VI in it) and Logging Data. You should be able to read the files created by them using your Read Spreadsheet File VI. 26