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: 

Write to measurement file does not keep scientific notation

Hi,

 

I am having trouble saving a simple txt file using the Write to Measurement File express vi. It looks like when using the express vi, the scientific notation is not used anymore and since the data are truncated after 6 digits, for small numbers I lose information about these numbers.

As an example is a screenshot of the VI I made (right), what appears on the front panel (top left), and what is saved on the .lvm file (bottom left).

Looking to the fourth column I have lost information when the file is saved to the .lvm file. What I would like is just the vi to save everything in scientific notation so that I do not have to worry about the truncation after 6 digits. I could not find this option in the express vi. I have tried using another format such as Excel but the problem remains.

 

I am using LabView 2016.

 

Thank you very much for your help.

 

image.png

 

 

0 Kudos
Message 1 of 8
(3,117 Views)

the scientific notation is just a representation you see for the underlying datatype,

e.g. DBL (https://en.wikipedia.org/wiki/IEEE_754)

 

i don't know the function you use to write your data,

but you could use "Write Delimited Spreadsheet.vi", which has an option to set the number format (http://zone.ni.com/reference/en-XX/help/371361N-01/glang/write_delimited_spreadsheet/).


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 2 of 8
(3,107 Views)

It's good practice in general to use ExpressVI's to quickly prototype ideas, but write your own code in practice. ExpressVI's can usually do what you need them to do, but in my experience there's always something I want to change- for example, the number formatting 🙂 (Some ExpressVI's are very usable out of the box, for example the message popup ones or the timing ones, but I try to avoid Dynamic Data like the plague)

 

You can right click on the ExpressVI and choose Show Block Diagram to see the actual code it uses. Once you basically understand how the system works, do as jwscs said and use the write to spreadsheet VI's, where you can pick your own number formatting. Making a spreadsheet file from array data is what, two functions? One function if you have a control diagram for your file path. Come to think of it, I think if it's unwired it'll automatically give you a popup asking you to choose a file location.

0 Kudos
Message 3 of 8
(3,099 Views)

Thank you very for your very quick replies.

 

Yes I tried opening the express VI diagram, but was not able to get where the formating came from. But I should look more carefully.

I made the program some time ago and it was working correctly (with the sceintific notation) until last week so I did not understand where the problem came from. I am still unsure why it worked before and not anymore. Maybe I should build my own vi for saving a file with a correct format.

 

 

 

0 Kudos
Message 4 of 8
(3,089 Views)

Hi gain,

 

I managed to fix the problem by digging into the express VI hierarchy, as you have recommended. On the file that can be found on

C:\Program Files (x86)\National Instruments\LabVIEW 2016\vi.lib\express\express output\ExFileWriteBlock.llb\ex_CreateSignalChunkString.vi

which looks as shown below, I changed from ";%g" to ";%e" on the box on the top left. (I don't know if it is recommended to change these files?)image.png

 

0 Kudos
Message 5 of 8
(3,081 Views)

The formatting is buried very deeply in that Express VI.  I believe it is using %;g, but I didn't see where Precision or Significant digits is specified.

 

As has been said by the previous responders, Express VIs "bury the details" and decide for you how they are going to work.  Doing the File I/O yourself (will a Comma or Tab-delimited "Spreadsheet" file work for you?) gives you much finer control.

 

I also agree that Dynamic Wires are similarly Evil.

 

Bob Schor

0 Kudos
Message 6 of 8
(3,069 Views)

First and foremost just forget about all of the Express VI's, these were designed strictly for those four hour LabVIEW sales pitches "seminars" to show how fast you can just throw something together with LabVIEW and be recording data in minutes...

 

But as you have found they are not that useful.

 

Use Write To Delimited Spreadsheet and the %e format if you want Scientific notation.

enoCapture.PNGenoCapture2.PNG

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 8
(3,039 Views)

@Pseudomg wrote:

 

 

. On the file that can be found on

C:\Program Files (x86)\National Instruments\LabVIEW 2016\vi.lib\express\express output\ExFileWriteBlock.llb\ex_CreateSignalChunkString.vi

which looks as shown below, I changed from ";%g" to ";%e" on the box on the top left. (I don't know if it is recommended to change these files?)

 


Do NOT change that file.  If you changed it and saved that file under the vi.lib locations, you will have changed any future instance of that subVI you may use, or even past instances in other VI's.

0 Kudos
Message 8 of 8
(3,031 Views)