LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Result not displaying after decimal

Solved!
Go to solution

Hi All,

 

I will be grateful if someone can help me with the attached VI. The weight value is read in from a digital scale via RS232, the weight is read and displayed correctly however when I try and write the value to a csv or txt file the digits after the decimal is not logged. e.g. 108.5g is logged as 108. 

 

Best regards,

 

Maiz

0 Kudos
Message 1 of 10
(2,960 Views)
Solution
Accepted by topic author Maiz

Since you are sending a string to the Write to Spreadsheet File function, don't use a format specifier of %.10f.  Delete it so that it uses the default %s which is string.

 

If you were sending it a numeric array, the using %.10f would have been appropriate.

Message 2 of 10
(2,945 Views)

You are feeding an array of strings into the "Write To Spreadsheet". The format string "%.10f" is meaningless to an array of strings. It has already be formated from a double to a string

 

The %.2f is formating teh 108.2 correctly. if you need 10 digits, that is the one that needs to "%.10f"

Omar
Message 3 of 10
(2,942 Views)

Thank you!! Omar

0 Kudos
Message 4 of 10
(2,930 Views)

Thank you RavensFan.

0 Kudos
Message 5 of 10
(2,929 Views)

Maiz,

 

Is the desired display shown on "read string"? 

 

%10f is not a valid format for a string input to string output so Write to Spreadsheet File probably defaults to %s which just puts in the file the strings you put into the input.

 

It apears that you want a customized format with a serial number (including alpha- and numeric characters?), timestamp, and numeric values with different precision. Perhaps the easiest way to do that is to format the individual values separately to a string and then use the Write to Text File function.

 

Use a queue to pass the data to the file loop. Then the loop will only run when data is actaully available. Your timing probably does not work the way you expect. The Read/Write loop almost certainly takes longer than 5 ms to execute. Just receiving 6 bytes at 9600 baud is more than 5 ms. Having the file loop trying to run at 1 ms intervals seems wasteful. If the Read/Write loop is really running close to 200 times per second, the user will have no chance of capturing the particular data point desired.

 

Lynn

Message 6 of 10
(2,919 Views)

Hi Lynn,

 

Thank you for your valued guidenance, I will try and implement what you have suggested. I will give you an feedback when I can, Iam very new to labview so it may take a while to work out what you have suggested lol.

 

Thank you!

 

Best regards,

 

Maiz

0 Kudos
Message 7 of 10
(2,911 Views)

Hi RavensFan,

 

Your solution works but there is an empty row between the data logged, what am I doing wrong?

 

Best regards,

 

Maiz

0 Kudos
Message 8 of 10
(2,906 Views)

Maiz wrote:

Hi RavensFan,

 

Your solution works but there is an empty row between the data logged, what am I doing wrong?

 

Best regards,

 

Maiz


I didn't get a chance to mess with your code since my copy of LabVIEW is in use collecting data; however, I would guess that your Digital Scale outputs RS232 data with a "/n" character at the end of the signal to denote the end of the line.  I've used a digital scale before that used this type of ouput format.  (It should state this in the manual for your device.) 

 

It may be worth trying something like this with Search and Replace String: 

 

string replace.png 

 

Note:  This code is borrowed from another thread on the forums and should be used as an example.  It may not be EXACTLY what you need. 😄

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Message 9 of 10
(2,900 Views)

I will try this and give you a feedback.

 

Best regards,

 

Maiz

0 Kudos
Message 10 of 10
(2,882 Views)