Example Code

Efficiently Acquire Signals and Write to a Spreadsheet

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

The example demonstrates how to acquire analog signals while logging the values to a ASCII file.

 

Description

To log acquired data to a file there are several possibilities: You can write the data more efficiently in a binary format (either custom or standardized like TDMS) or in a human-readable format normally called text or ASCII format.

This example demonstrates how to write data acquired with the very common NI-DAQmx driver to a text file. But you can easily use the same functions to log data acquired with other or 3rd party drivers too.

To improve performance, the example opens a file reference before starting to acquire data and close the reference only after the logging has been finished.

Also the example shows how to log additional information (meta data) to the file.

 

Requirements

 Software

  • LabVIEW 2012 Base Development System (or compatible)
  • NI-DAQmx 14.0 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Open the attached file
  2. Select the Physical Channels you want to acquire
  3. If you do not have a DAQmx device at hand you can also simulate a device:
    What are NI-DAQmx Simulated Devices and How Do I Use Them?
    http://digital.ni.com/public.nsf/allkb/75CF478A58545DFC86256FCC006E25A2
  4. Check the settings for minimum and maximum values
  5. Set the rate at which you want to acquire the specified channels
  6. Set 'Samples to Read' to a value that is approximately at 10-100% of the sample rate so the graph is updated between every 100 ms to 1 s
  7. Run the VI

 

Additional Information or References

DAQmx Write Data To Spreadsheet File - Front Panel.png

DAQmx Write Data To Spreadsheet File - Block Diagram.png

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
KKNG
Member
Member
on

Can you convert it to 8.5? It can most likely fit to my application. it's great.

G-Money
NI Employee (retired)
on

Done!!

hich1109
Member
Member
on

please can you convert it to 8.2

Ben_S
Active Participant
Active Participant
on

Sure!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
hich1109
Member
Member
on

thanks friend

HunterSeeker
Member
Member
on

Could you please add some screenshots of your code to this example?