LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to increase Digits of Precision of write to measurement file

I want use write to measurement file to write data from my instrument with 9 digits of precision. but output of Write to Measurement have only 6 digits. here is simple example

 

0 Kudos
Message 1 of 8
(8,244 Views)

Hi VMI,

 

I cannot open your LV2015 VI, but most WriteMeasurement functions have an input to specify the format.

What does the help for the function tell you about this topic?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(8,239 Views)
Hi gerdW

My example simple is a controlled (DBL %.9f) to write to measurement file.vi
Ex: 0.123456789 but when I open excel file, the value is 0.123457,
0 Kudos
Message 3 of 8
(8,213 Views)

Wow that really sucks.  Just another reason I hate using those express VIs.  For those without 2015 it is just one Write to Mesurement File express VI configured to write as an XLSX file.  If you convert the express VI to a normal VI you can open the source, but boy will you be confused.  Many nested layers, and overly complicated code in my opinion.  It appears the limitation comes from a constant on the block diagram, stating how to convert floating point numbers to strings.  The format defined for an array of doubles is %.;%f and can be found in:

 

vi.lib\express\express shared\NI_ExcelFile\SubVIs\rd_initialFormat.vi

 

I would not recommend changing this, because you would be editing system VIs but for completness I thought I mention where it comes from.

 

Unfortunatly there is no easy work around for this.  This same limitation is set on DDT, and Waveform data types.  And this function doesn't support writing strings.  If it did you could do the conversion yourself and tell it to write the string.  You are either going to have to live with the limitation, apply a scaling factor (say multiply all numbers by 1000), or write your own file logging functions, and logging to XLSX will require a toolkit of some kind, CSV would be trivial.

0 Kudos
Message 4 of 8
(8,189 Views)

Before you rip the LabVIEW apart, are you sure it isn't in the Excel?

 

If I open Excel and type 0.123456789 into a cell, it will initially display as 0.123457 until I increase the decimals.

 

Rod.

 

0 Kudos
Message 5 of 8
(8,172 Views)

I used the format into string with the format defined in the VI and it does round up after 6 decimal places.  I also made a file as described by OP and set the cell formatting in Excel to be Numeric and to show 10 digits of precision, but it only showed the .1234570000 so I do believe this if how the file is being written and is a limitation of the express VI.  Using the format of %.;%.9f would define 9 digits of precision.

0 Kudos
Message 6 of 8
(8,163 Views)
So have any other method to save data to excel like that? I very like write to measurement file because it allow to make excel file before run program, it work perfect with while loop and it write data immediately, and if my program has beeb crashed, I don't lost data before. Only limited is I cannot config digits of precision.
0 Kudos
Message 7 of 8
(8,132 Views)

Writing data to a TSV or CSV with your desired resolution is very simple in LabVIEW.  Look at Help > Find Examples... Fundamentals > File input and Output > Spreadsheet > Tab-Delimited Data.lvproj.  That example has a very easy example of opening, formatting data, writing to file, and closing the file in the VI called Write Tab-Delimited File.vi.  You will see that there is a format specifier that is set to %.3f (3 digits).  That is what you have to change to %.9f.  Dump the silly ExpressVIs and learn the primitives that have power that you can control.  Format into File.vi and Format into string.vi are also your friends. Smiley Happy

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 8 of 8
(8,117 Views)