LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving data from DAQ in excel with times on 1st column and data on 2nd column

Hello everyone.
I am a new user of labview. having difficulty in solving a problem. kindly help me.


I am trying to get the data from the pressure sensor using DAQ, draw a graph and also make an excel sheet. 

1. I want to show the data graphically with time (absolute) on the x-axis and data on Y-axis.

2. Also, I want to save the data in the form of an excel sheet with time (in milli or microseconds) on the first column and the data on the second column.

 

I tried many methods by using "Write to measurement file" and  "Write on a delimited spreadsheet" VI. either I got just the last value of the data or I get very random data.  

 

Attached is the VI. 
The attached Picture represents the results I want.

Thanks In Advance

0 Kudos
Message 1 of 7
(3,516 Views)

Hi Tahseen,

 


@Tahseen476 wrote:

1. I want to show the data graphically with time (absolute) on the x-axis and data on Y-axis.

2. Also, I want to save the data in the form of an excel sheet with time (in milli or microseconds) on the first column and the data on the second column.


DAQmx can give you the samples with their respective timestamps - as soon as you use waveforms!

 

See this:

 

That being said: your example VI also shows how to use the TDMS-saving built into the DAQmx driver: you can open those TDMS files also using Excel when you install the TDMSImport AddOn, that comes with LabVIEW…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,490 Views)

You are mis-using the term "Excel" (which you spell "excel").  Excel is the name of a proprietary SpreadSheet program created by Microsoft, and has a native File type called a .xls or .xlsx file.  What you are using is a "delimited Spreadsheet", a text file that represents rows of data by lines ot text, and separates sequential row entries with a "separator character", most commonly a <tab> (the LabVIEW default) or a <comma>, in which case the file is often given the extension ".csv", for "comma-separated variables".

 

For reasons known only to Microsoft, Windows represents this non-proprietary Text format with an icon that looks very similar to the Excel .xlsx icon.  So what you really want to do is to "Save data from DAQ in a Text file (as a delimited Spreadsheet file) with Time and Data columns".

 

Bob Schor

0 Kudos
Message 3 of 7
(3,482 Views)

Thankyou GredW. this method worked.   I tried another method. it gives me better results according to my requirement.  for this, I just need to save the data file with the ".xls" extension. it saves the data in an Excel file. I attached the VI.

I also added the VI to save the data in the form of the chart where on the X-axis is an absolute time and on Y-axis is the data from the pressure value.   I have 2 queries now.

1. on the x-axis I want the many values of times, with a space of approximately a millisecond (as shown in the attached picture) now my chart only showing the starting and ending time not the between values.

 

. I am not sure the chart and data are saved in the "delimited spreadsheet" is the same or not.  I used 2 different "get date and time" VIs.  

0 Kudos
Message 4 of 7
(3,457 Views)

Thank you Bob for clarification.

I want to use the value, not the text. so I was trying to save the data in an Excel sheet. but wasn't successful. I just save the data file with the extension.xls and was able to get the data in the Excel file.

Thanks for the help.

0 Kudos
Message 5 of 7
(3,454 Views)

Hi Tehsaan,

 


@Tahseen476 wrote:

Thankyou GredW. this method worked.   I tried another method. it gives me better results according to my requirement.  for this, I just need to save the data file with the ".xls" extension. it saves the data in an Excel file. I attached the VI.


You still create a delimited text file, so you should NOT name it *.xls! It is NOT an "Excel file"!

Excel is able to read CSV/TXT files containing delimited data, so please name them correctly as other software might have problems because of your wrong file suffix…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(3,442 Views)

@Tahseen476 wrote:

I want to use the value, not the text. so I was trying to save the data in an Excel sheet. but wasn't successful. I just save the data file with the extension.xls and was able to get the data in the Excel file.


You can tell Excel to open almost any file, but most of them won't really make sense.  Renaming a .csv file (which, as I tried to explain, Excel has been programmed to "know" it is a Text file, with commas serving as column separators and <cr><lf> serving as row separators, and present the data in a "semi-intelligent" way (it recognizes numeric data as "numbers" and string data as "string", for example).  Changing the extension to .xls doesn't really help -- it just says to Excel "This is not a Text File, but a file in your 10-year-old proprietary file format" (which isn't true, but Excel forgives you ...).

 

You can purchase LabVIEW's "Report Generation Toolkit", which has the ability to write and read true Excel files, namely those with the extension .xlsx (and xls) that conform to Microsoft's proprietary standard.  This includes the ability to create WorkBooks with multiple WorkSheets, add Excel Charts to your WorkBook, do some limited Formatting (such as shading rows, columns, or cells).  

 

Bob Schor

0 Kudos
Message 7 of 7
(3,434 Views)