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: 

writing to a file doesn't have enough sig figs

Hi, I am acquiring one data point which is a reading from my ammeter.  Then, I am writing to a file using the express write to lvm vi.  The only problem is is that only 3 sig figs gets saved.  How do I get more?  Thanks.
0 Kudos
Message 1 of 9
(3,352 Views)
What's a "sig fig"? If you're only reading one data point and writing it, shouldn't you only have one signal recorded? If you're actually do the read and write inside a loop, did you set the write function to append? The other (faster way) is to just do the readings inside the loop and create an array of readings and then do the write outside the loop.
0 Kudos
Message 2 of 9
(3,336 Views)

Smiley Very Happy

So there I was browsing the message lists wondering what a "sig fig" was. Then I saw Dennis' name.

   "Dennis is a 'Proven Enthusiastic Veteran', thought I. Dennis will know, thought I."

Ok well...

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 9
(3,331 Views)

That's interesting, because I was browsing the message list and I saw Mike's name, and I thought "Mike writes interesting stuff. Even though I already accidentally clicked a link, I will go back and enter that page to see what words of wisdom Mike has. Maybe I will learn what a sig fig is..."

Oh well...

Smiley Very Happy


___________________
Try to take over the world!
0 Kudos
Message 4 of 9
(3,318 Views)
I'll make a wild guess here (although I'm also afraid to in such sompany) that "sig fig" is a reference to "significant figures" i.e. places behind the decimal point (one meaning of it at least).

If you're saving floating point numbers as text (ASCII) then you can format the number to any given "sig fig" by giving the format specifier %.xf where x are the relevant places after the decimal point (or after the comma here in mainland europe).

If using the "save to spreadsheet file" it has an inpit for this format specifier.  Wire a string with the value %.6f and you'll save an ASCII representation of your floating point number with 6 decimal places.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 5 of 9
(3,313 Views)
Althought Shane's answer is correct, it doesn't answer completely to ivrun's question, because he's using an express vi. This vi has no input for the data format.
If you stop breathing for a while and open the express vi's front panel (this will convert it to a normal vi), you can dive deeply through the subvi's. You end up (at the fifth level) in a subvi named ex_CreateSignalChunkString where you find the actual format used: "%.;%g", i.e. automatic formatting. If I correctly remember, this should grant for a maximum of 6 digits after the decimal point. Maybe scaling up the values (e.g. multiplying the signal by 1000) , if acceptable for the developer, could allow for more digits in the output.

Paolo


Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 6 of 9
(3,306 Views)
Thanks ,you are absolutely correct.  The premade VI in Labview 7 does not allow for sig fig control, apparently.  One must use the save to spreadsheet icon.  Thanks again.
0 Kudos
Message 7 of 9
(3,288 Views)
Thanks so much.  Can I have your email in case I have any more questions?  You seem like a super pro. 
0 Kudos
Message 8 of 9
(3,284 Views)

Greetings everyone,

One thing you might want to check here is the representation of the data you are writing into the "Write LVM File" VI.  When I simply wire in a double-precision number into the input, I get as many sig figs as representable with the double.  You might want to check and make sure that none of the other VIs in your program are truncating or rounding your numbers to 3 decimal places.  Another possibility is that if you are using LabVIEW to read the values from the LVM file the indicator that is displaying the data is set up to only display 3 digits of precision.  Try opening the file in notepad and scanning the data to confirm that this is not the case.  I'll attach the basic example I ran here for you to take a look at.

Hope I have added some additional useful tidbits here, if not please post again and let me know how I can help.

Regards,

Travis M
Applications Engineer
National Instruments

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 9 of 9
(3,270 Views)