LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Units of precision / rounding ?

Hi,
I am trying to read information from 3 thermocouples. The thermocouples are only accurate to 0.3 degrees Celcius.
On my graph and indicators, I know how to change the precision to only 1 decimal place.
I cannot, however, do this for my 'write to LabVIEW measurement file'.
How can I change how many digits of precision are written for each data point?

Thanks for your help,
Cory
Cory K
0 Kudos
Message 1 of 10
(3,623 Views)
Hi Cory,
where do the values come from? If you have an array you can also use the "Write2SpreadsheetFile" function. Before that you can use string functions to set decimal precision.

Mike
0 Kudos
Message 2 of 10
(3,611 Views)
The display of the data is different from the value of the data. The Write To Measurement File is saving the actual values. If the values are DBL, they're saved as DBL. How you view the values is secondary. Are you trying to make smaller files, or something? If you explicitly want to save it that way you would need to use a string, though I don't see much point in that.
Message 3 of 10
(3,603 Views)

I'm not trying to make smaller files, I only want to save the accurate data.
If the thermocouple is only accurate to 0.3 degrees Celcius, what would be the point of saving 8 decimal places?
None of those last 7 are correct, that is why i am trying to get rid of them.

- Cory

Cory K
0 Kudos
Message 4 of 10
(3,596 Views)
If the number is accurate to .3 then you will need at least a digit or in other words, it has to be accurate to .01. If space is not a problem, I would not try a truncation, as it will add some minor roundoff error.
 
One thing, you must have some special thermocouple devices. Most thermocouple generally is in the order of 3 deg. We have some special thermocouple devices and it was only accurate to 1 deg. Are you sure, you are talking about thermocouples or other devices
0 Kudos
Message 5 of 10
(3,580 Views)

Maybe I am mistaken about the precision of the thermocouple I am using,
But either way, could you help me figure out how to change the precision of a measured value.
It would be a valueable piece of information for me to know in the future.

Thanks,
Cory

Cory K
0 Kudos
Message 6 of 10
(3,573 Views)

You are using Write to Measurement File which does not provide for a lot of flexibility. You could right click on it and select 'Open Front Panel'. This will convert it to a regular VI. You can dig down and find where the data is being formatted. I never use the Express VI so I don't know how deep you have to dig. As already mentioned, you can use the Write to Spreadsheet function. This gives you the ability to specify a format. The default is %.3f. Write to Spreadsheet File is using the Array to Spreadsheet function so you could also use this and the more primitive Write to Text File.

Another option is the Export Waveforms to Spreadsheet file. At the top level, you don't have the ability to specify a format but if you look at the block diagram, you will see that the Y array is converted to strings with the Number to Exponential String function. It uses a default of 6 for precision. This might be easier for you to modify than the Write to Measurement file. If you do modify it, be sure to save it with a new name and in a new location.



Message Edited by Dennis Knutson on 06-02-2008 12:01 PM
0 Kudos
Message 7 of 10
(3,567 Views)
Use the Write To Spreadsheet File VI, as previously mentioned. This will save your data as text to whatever precision you want.
0 Kudos
Message 8 of 10
(3,563 Views)

What exactly is %.3f?

Is that 3 decimal places or to the nearest 3/10?

- Cory

Cory K
0 Kudos
Message 9 of 10
(3,561 Views)
That's floating point conversion with 3 digits of precision. From the LabVIEW Help (a wondeful little tool):

Format Specifier Syntax

For functions that produce a string as an output, such as Format Into String and Array To Spreadsheet String, a format specifier uses the following syntax elements. Double brackets ( [] ) enclose optional elements.

%[$][-][+][#][^][0][Width][.Precision || _SignificantDigits][{Unit}][<Embedded information>]Conversion Code

where Width must be a number greater than zero and .Precision and _SignificantDigits must be a number greater than or equal to zero.

examples:

Type Argument(s) Format String Resulting String Comments
Automatic Formatting (%g) 12.00 %#g 12 If you specify #, LabVIEW removes trailing zeroes. If you specify g, LabVIEW chooses exponential notation or floating-point notation based on the number to format.
12000000 %#g 1.2E+6
Decimal (%f) 12.67 score= %.0f%% score= 13% When you specify %f, LabVIEW rounds the argument. Use %% to format a single %. Use .0 to remove decimal.
Floating-Point (%f) 12.67 Temp: %5.1f Temp: 12.7 The 5 in the Format String section specifies a width of 5, and the 1 specifies the number of digits to the right of the decimal, or precision.
12.67 N %5.3f 12.670 N Units are valid only if you use the Format Into String or Scan From String functions. These are examples of physical quantity input. The second example shows how you can convert from one unit to another. The question mark indicates when the unit in the format specifier is in conflict with the input unit.
12.67 N %5.3{mN}f 1267.000 mN
12.67 N %5.3{kg}f 12.670 ?kg

0 Kudos
Message 10 of 10
(3,550 Views)