09-17-2015 01:30 PM
Hi!
I am very new to LabView and trying to read data from an OHAUS pioneer pa-313 electronic scale through RS232 serial port. I am using the VISA. I can read the data and see it as a string on the screen but when I try to convert it to a double, it just gets the integer and decimal numbers are gone. Here is the question: What can be the problem? How can I have the decimals as well?
Solved! Go to Solution.
09-17-2015 01:32 PM - edited 09-17-2015 01:35 PM
Use Fract/Exp String to Number instead.
There might be some bit of Whitespace at the beginning of that string (from the looks of a small gap there). You could try using the Trim Whitespace VI as well if the above function doesn't work. If Trim Whitespace doesn't work, then it's a different type of delimiter that you'll need to remove manually. If you right click the string indicator, you can choose to use "\" display. This will show you the whitespace character.
"Give me six hours to chop down a tree and I will spend the first four sharpening the axe." - Abraham Lincoln
Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.
-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)
Learn NI Training Resource Videos
6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-17-2015 01:41 PM
What is your normal decimal point? . or , ?
09-17-2015 02:24 PM
Thanks for the reply!
I tried the Trim Whitespace VI but it didn't solve the issue.
I also tried Fract/Exp String to Number and it gave the same result as you can see in the attachment.
09-17-2015 02:27 PM - edited 09-17-2015 02:31 PM
The number in the read buffer is shown with a point decimal. Can it be different in the settings of Labview? How can it be changed?
Edit: I think this is the problem. Since my OS is Turkish and Turkey use comma instead of points to separate decimals the default settings of Labview can be commas for separators. How can I change it to points?
09-17-2015 02:32 PM
Your code should work. 2 things to check
1. your wire is comming from the output and not offset (most likely otherwise your wire would be blue)
2. your terminal is setup to show more than 1 significatnt digit (ie 0.133 is displayed as 0)
3. Internationalization, the pc is setup to parse , insteds of . for decimal. The scale is displaying a decimal but this doesnt tell us about the PC convention.
09-17-2015 02:47 PM
Yeah, it looks like it's most likely a comma vs period issue. Try hard-coding (creating a string contant) that uses a comma instead of a period.
If that solves the conversion issue, then you need to do one of two things:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-17-2015 02:48 PM
I changed the country settings of Windows and restarted my pc. Now it works! Thank you all for your interest and help!
09-17-2015 03:04 PM
also if it is an internationalization issue, you can actualy specify thius in the string formater (use period is %f).
also change your string to hex display and make sure you do not have non printable characters attached to the number, this is not uncommon on scales to have other indo hiden in the return string. it would have thrown an error on the parsing and returned 0 for the output. if you have auto error handling off you will not know.