Continuous Data Recording – Labview Function


To save a Labview application data which is taken continuously required good planning so that stored data can be opened quickly and can be well presented. The following is Labview program simulation to display the chart for every 100 milliseconds:

Example 1

Which block diagram as follow

When the program runs the data will be obtained as follows

In Excel look like

Cause the data taken in 100 milliseconds, then for a second we have 10 data (10 rows in Excel Form), it means that the data is very large if the program runs more than one day, in one day we got 10x60x60x24=86.640.000 data. This will be very difficult for us to re-open data, especially if the data needs are presented. A good idea to save those data, is to classify the data based on date and time where the data is taken. By storing data base on the date and time, every time can open the stored data easily and quickly.

What we need is to construct folder and file name as follows:

  • Data storage folder with the following construction



  • YYYY = Year
  • MM = Month
  • DD = Day of Month
  • Data file name with the following construction



  • HH = Hour
  • NN = Minute
  • SS = Second
  • EXT = The Extension of File, i.e. TXT, XLS, DAT etc.

For this purpose, we use the function TimeInString (Refer to Displays The Time With Custom Pattern that we have discussed in the previous chapter).

Thus the diagram in Example 1 will be modified into the following, call example 2.

Example 2

Which block diagram as follow

In the example 2 above, folder and file names given by function TimeInString have not been in the link with Write to Spreadsheet File Function because it will cause an error. Error arises because we set the folder that is not necessarily available in a system environment that we use. To ensure availability of the folder that we want, take advantage of the function  as discussed in the previous chapter (refer to Create a Folder Anywhere Chapter).

We modified the diagram example 2 to example 3 as follow

Example 3

Which block diagram as follow

Because data is stored every second, then each file contains a maximum of 10 data, to increase the amount of data per file, we change the pattern of storage per minute with a maximum capacity 600 data per file as follow

Or per hours as follow with a maximum capacity 36000 data per file as follow

To improve performance use the function DiskInfo Function to select a best storage location for your application. With DiskInfo  you can specify the volume that has the largest free space, so that applications can run smoothly and at any time can move the location of data storage if required.

Refer to Data Storage Information in previous chapter.

Download Labview program :

Posted in Custom Functions | Tagged , | Leave a comment

Data Storage Information – Labview Function



DiskInfo Function - Labview Program Example

This function is used to retrieve information about storage media available on your computer.


  • Unit  is the unit used to measure the disk capacity.

Return Value

  • Volume is an array that contains the volume available in your system.
  • Size is an array that contains the capacity of each volume available in your system.
  • Used is an array that contains the usage of each volume in your system.
  • Free is an array that contains the free space of each volume in your system.
  • MaxFreeAt is the volume of the largest free space.
  • MaxFreeSpace is the capacity of MaxFreeAt.
  • MaxUsedAt is the volume of the largest usage.
  • MaxUsed is the usage of MaxUsedAt.
  • BiggestSpaceAt is the volume of the largest space.
  • BiggestSpace is the capacity of BiggestSpaceAt.


Build In Function required

  • Array Size Function

  • Volume Info Function

  • Not A Number Path Refnum Function

  • Insert Into Array Function

  • Divide Function

  • Array Max & Min Function

  • Index Array Function


Block Diagram

DiskInfo Diagram - Labview Program Example

Front Panel

DiskInfo Panel


Download Labview program : DiskInfo

Posted in Custom Functions | Tagged , | Leave a comment

Labview File I/O


File I/O operation pass data to and from files. Use the File I/O build in functions to handle all aspect of file I/O, including the following:

  • Opening data file.
  • Closing data file.
  • Reading data from file, e.g. reading configuration file.
  • Writing data to file, e.g. writing data to file in various formats.
  • Moving file/folder.
  • Rename file/folder.
  • Changing file/folder properties.

Build In IO Function

For the purposes of data storage applications, Labview provides three file formats, i.e.

  • Text.

Write To Spreadsheet File

  • Binary.

Read From I16 File

  • Datalog.

Write Waveforms to File

The format you use depends on the data you acquire or create and the applications that will access that data. Use the following basic guidelines to determine which format to use:

  • If you want to make your data available to other applications, such as Microsoft Excel, use text files because they are the most common and the most portable.
  • If you need to perform random access file reads or writes or if speed and compact disk space are crucial, use binary files because they are more efficient than text files in disk space and in speed.
  • If you want to manipulate complex records of data or different data types in LabVIEW, use datalog files because they are the best way to store data if you intend to access the data only from LabVIEW and you need to store complex data structures.

When to Use Text Files

Use text format files for your data to make it available to other users or applications, if disk space and file I/O speed are not crucial, if you do not need to perform random access reads or writes, and if numeric precision is not important.

Text files are the easiest format to use and to share. Almost any computer can read from or write to a text file. A variety of text-based programs can read text-based files. Most instrument control applications use text strings.

Store data in text files when you want to access it from another application, such as a word processing or spreadsheet application. To store data in text format, use the String functions to convert all data to text strings. Text files can contain information of different data types.

Text files typically take up more memory than the other type (i.e. binary and datalog) files if the data is not originally in text form, such as graph or chart data, because the ASCII representation of data usually is larger than the data itself. For example, you can store the number –123.4567 in 4 bytes as a single-precision floating-point number. However, its ASCII representation takes 9 bytes, one for each character.

In addition, it is difficult to randomly access numeric data in text files. Although each character in a string takes up exactly 1 byte of space, the space required to express a number as text typically is not fixed. To find the ninth number in a text file, LabVIEW must first read and convert the preceding eight numbers.

You might lose precision if you store numeric data in text files. Computers store numeric data as binary data, and typically you write numeric data to a text file in decimal notation. A loss of precision might occur when you write the data to the text file. Loss of precision is not an issue with binary files.

Use the File I/O VIs and functions to read from or write to text files and to read from or write to spreadsheet files.

Refer to the following VIs for examples of using file I/O with text files:

\program files\national instruments\ labview xxx\examples\file\smplfile.llb

\program files\national instruments\ labview xxx\examples\file\sprdsht.llb

When to Use Binary Files

Storing binary data, such as an integer, uses a fixed number of bytes on disk. For example, storing any number from 0 to 4 billion in binary format, such as 1, 1,000, or 1,000,000, takes up 4 bytes for each number.

Use binary files to save numeric data and to access specific numbers from a file or randomly access numbers from a file. Binary files are machine readable only, unlike text files, which are human readable. Binary files are the most compact and fastest format for storing data. You can use multiple data types in binary files, but it is uncommon.

Binary files are more efficient because they use less disk space and because you do not need to convert data to and from a text representation when you store and retrieve data. A binary file can represent 256 values in 1 byte of disk space. Often, binary files contain a byte-for-byte image of the data as it was stored in memory, except for cases like extended and complex numeric values. When the file contains a byte-for-byte image of the data as it was stored in memory, reading the file is faster because conversion is not necessary.


Text and binary files are both known as byte stream files, which means they store data as a sequence of characters or bytes.

Use the Labview Build in functions to read from and write to binary files. Consider using the binary file functions if you want to read numeric data from or write numeric data to a file or if you want to create text files for use on multiple operating systems.

Refer to the following VIs for examples of reading and writing an array of double-precision floating-point values from and to a binary file, respectively:

Read Binary File: \program files\national instruments\labview xxx\examples\file\smplfile.llb

Write Binary File:  \program files\national instruments\labview xxx\examples\file\smplfile.llb

When to Use Datalog Files

Use datalog files to access and manipulate data only in LabVIEW and to store complex data structures quickly and easily.

A datalog file stores data as a sequence of identically structured records, similar to a spreadsheet, where each row represents a record. Each record in a datalog file must have the same data types associated with it. LabVIEW writes each record to the file as a cluster containing the data to store. However, the components of a datalog record can be any data type, which you determine when you create the file.

For example, you can create a datalog whose record data type is a cluster of a string and a number. Then, each record of the datalog is a cluster of a string and a number. However, the first record could be (“LABVIEW”,1), while the next record could be (“DATALOGER”,2).

Using datalog files requires little manipulation, which makes writing and reading much faster. It also simplifies data retrieval because you can read the original blocks of data back as a record without having to read all records that precede it in the file. Random access is fast and easy with datalog files because all you need to access the record is the record number. LabVIEW sequentially assigns the record number to each record when it creates the datalog file.

You can access datalog files from the front panel and from the block diagram.

LabVIEW writes a record to a datalog file each time the associated VI runs. You cannot overwrite a record after LabVIEW writes it to a datalog file. When you read a datalog file, you can read one or more records at a time.

Note:  You might need to change the format of files if the system requirements change during development and you need to add additional data to a file. Changing the format of datalog files causes the files to become unusable. Use the Storage VIs to avoid this problem.

Another way to create a datalog file is by using front panel datalogging, which records data for use in other VIs and in reports.

Refer to the \program files\national instruments\labview xxx\examples\file\datalog.llb for examples of reading and writing datalog files.



Posted in Custom Functions | Leave a comment