LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing sensor data in excel

Solved!
Go to solution

Hello All,

 

I have a basic question regarding saving the analog data in an excel file (or as a matter of fact any other format).

 

A basic info about the setup. I have 2 linear actuators (motors) along x and y direction. On one X motor, a panasonic distance measuring sensor is mounted. This sensor acts as a scanner to read in the distances of an object. In the end i have x,y,z coordinates and i can generate a surface plot. 

 

The problem is excel saves the data in three columns. But i want to save the data as specified in the attached picture. Would like to know whether saving in this fomat is possible? I am not able to find any specifics regarding this issue. 

 

Hope to hear from the community soon.

 

0 Kudos
Message 1 of 15
(4,421 Views)

Well it looks to me like X and Y are preset steps and you are measuring Z?

 

So only write Z instead of writing X,Y,Z everytime.

 

You will still have to write X and Y but only where needed.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 15
(4,405 Views)

You don't say how the data is collected, or how you write the data to a file.  My thought would be to collect the data in LabVIEW in a 2D array while the data is being acquired, and write this array to file on completion.  That way you can control the row/column arrangement of the data.

0 Kudos
Message 3 of 15
(4,401 Views)

Excel will save the data in the format that you give it.  If you give it 3 columns of x,y,z data, that is what it will record.  If you want something different, you'll need to rearrange the data inside of Labview and then save it. 

 

Are you writing to an actual Excel file (XLSX) using the Report Generation Toolkit or are you using the Write to Spreadsheet VI (which in older versions of Labview will write to a CSV or text file, and in newer versions of Labview will write to a native Excel file)?  CSV is not a native Excel file, although Excel does recognize and open them, as do most, if not all, other spreadsheet programs.  It is basically a text file (no formatting) containing values that are separated by commas (hence the acronym CSV),

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 15
(4,399 Views)

As RTSLVU said, what you want to write is the Z result for a collection of different pairs of X,Y. 

If you wanted to do this with a CSV file, you can use the Write Text File function at the most basic level. This will allow you to pass a string that you can form from your results, using nested For loops for row (Y) and column (X) with the first row being just the X column headers preceeded by perhaps an empty cell.

 

 


GCentral
0 Kudos
Message 5 of 15
(4,397 Views)

@aputman wrote:

 

Are you writing to an actual Excel file (XLSX) using the Report Generation Toolkit or are you using the Write to Spreadsheet VI (which in older versions of Labview will write to a CSV or text file, and in newer versions of Labview will write to a native Excel file)? 


If by "newer" you mean LabVIEW 2016 (I just got 2017, but haven't had time to install it), the Write Delimited Spreadsheet function does not write "a native Excel File".  According to its Help Document, "To format with Microsoft Excel, use ActiveX with LabVIEW or Report Generation Toolkit".  The Delimited Spreadsheet format  of rows separated by <New Lines>, columns separated by (something, typically <Tab> or <Comma>) can be read into Excel and manipulated, but it is not an "Excel file" (to my Purist Way of Thinking).

 

Bob Schor

0 Kudos
Message 6 of 15
(4,349 Views)

I will try to sum up all the answers here.

1. Theoretically x and y should be preset steps. But lately I realized that my moving motor (on which the sensor is also mounted) is not saving the steps exactly as the steps in previous run. But the range is always between 3000-29000 steps (thats the area which i want to scan).

2. Currently I am using Write to spreadsheet.vi, and the data is saved in 4 columns Time, X, Y and Z as received. And saving in native xlxs format. (But format for me is secondry thing as the data would later be used by third party imaging software so CSV, TDMS formats are also ok)

3. On X direction the steps are fixed and at specific intervals. But on Y direction I don’t have any influence on steps recorded. 

Hope to hear some suggestions on that

0 Kudos
Message 7 of 15
(4,341 Views)

@Bob_Schor wrote:

@aputman wrote:

 

Are you writing to an actual Excel file (XLSX) using the Report Generation Toolkit or are you using the Write to Spreadsheet VI (which in older versions of Labview will write to a CSV or text file, and in newer versions of Labview will write to a native Excel file)? 


If by "newer" you mean LabVIEW 2016 (I just got 2017, but haven't had time to install it), the Write Delimited Spreadsheet function does not write "a native Excel File".  According to its Help Document, "To format with Microsoft Excel, use ActiveX with LabVIEW or Report Generation Toolkit".  The Delimited Spreadsheet format  of rows separated by <New Lines>, columns separated by (something, typically <Tab> or <Comma>) can be read into Excel and manipulated, but it is not an "Excel file" (to my Purist Way of Thinking).

 

Bob Schor


Bob, you are correct.  I was thinking about the express VI for writing data to a measurement file that has Excel support.  And that feature has been available since 2013 (which is newer than my 2012.  Smiley Very Happy)

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 8 of 15
(4,324 Views)

So if X and Y are both "reproducible positions" (and thus trace out an X-Y lattice of points) and you have a Z measurement at some or all of these points, you could, indeed, do as cbutcher suggested and create a 2-D "spreadsheet" where the column headers were the (reproducible) X values, the row headers were the (reproducible) Y values, and you put a non-blank value in each X-Y cell where you made a measurement.

 

If your data are saved as strings, leaving a cell empty (blank string) means "No measurement here".  For numeric data, you may want to put a "special value" in the cell to indicate "No measurement".

 

On the other hand, if your X and Y values are not reproducible, then recording all of the X, Y, Z triples (as you seem to be doing) is probably the way to go.

 

Bob Schor

0 Kudos
Message 9 of 15
(4,309 Views)

"If you wanted to do this with a CSV file, you can use the Write Text File function at the most basic level. This will allow you to pass a string that you can form from your results, using nested For loops for row (Y) and column (X) with the first row being just the X column headers preceeded by perhaps an empty cell."

 

Is there any practical example, how this can be realized in practice. Or how the nested for loops can be used for saving data in this fashion.

 

Sorry i am still a beginner and in learning phases. 

0 Kudos
Message 10 of 15
(4,265 Views)