From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate options to save data in different format

Hello, 

 

I want to log data continuously with time stamps in .xlsx, .csv and .txt format. Any one format can be chosen by the user. I tried to do that with "write to measurement file"  vi but it is only good for .xlsx format.

 

How should I use case structure for this problem??

 

For example, If user selects to save data in .csv format than data .csv file should be generated and data should be logged in that file with timestamps.

 

I am sorry for my bad english.

 

THANKS IN ADVANCE FOR HELP

 

 

0 Kudos
Message 1 of 4
(1,170 Views)

There is a very simple answer that will also serve you well when you do any form of Data Acquisition (or Control) in LabVIEW -- Do Not Use the Dreaded DAQ Assistant!!

 

DAQmx is really quite simple to use.  There are a number of excellent White Papers written by NI, including the one that showed me how easy it could be, called "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications" (or words very similar to that).  If you put the first 5 words into a Google search, you should find this article.

 

The basic principle is the following:

  1. Open MAX.  Find the Device you want to use (say, an A/D converter on some piece of NI Hardware that is plugged into your PC).
  2. Open that Device and configure a Task that does what you want.  For example, you want to sample 4 Voltage inputs on a USB-6002, you may name them in MAX, you specify the Voltage Range, whether single or double-ended, the kind of sampling (probably Continuous Sampling), the sampling rate, sample size, etc.  Save the Task with a better name than MyVoltageTask.
  3. Now open your VI.  Open a Block Diagram.  Right-click, open "Measurement I/O", then "DAQmx".  Drop the following functions:  Create Channel, Start, Read, and Stop.  Wire them together in that order.  On the "Task In" input of "Create Channel", drop a Constant.  Click on the down-pointing Triangle on this (empty) Channel and choose Browse -- it should go to MAX and find the A/D Task you created in Step 2.
  4. Now all you need is to put a While Loop around the Read, put code inside the While to do "what you want" with the data, etc.  For example, if you want to spool the data to a CSV file, create the CSV file before entering the Loop, write the data to the file inside the loop, and close the File when you exit.  If you are writing to a Text file, open a Text file, etc.  The "tricky" part comes if you want to write an Excel file.  For this, you might need the Report Generation Toolkit from NI, which might be included on your License.  You can also write in other file formats (XML and SQL come to mind) ...

Bob Schor

0 Kudos
Message 2 of 4
(1,128 Views)

Thank you so much for help.

 

But I don't have hardware nd I am simulating NI 9181 and NI 9203 virtually.

 

Can I use your solution for this situation?? and if yes thn how should I connect chart with this model.

 

I really appreciate your help.

 

thanks again

 

0 Kudos
Message 3 of 4
(1,125 Views)

@Winkyy303 wrote:

...

I want to log data continuously with time stamps in .xlsx, .csv and .txt format...


None of those formats are suitable for continuous logging. I suggest you use tdms and if the user wants data in another format let them export into that format.

Certified LabVIEW Architect
0 Kudos
Message 4 of 4
(1,104 Views)