LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Scan Value Function

Solved!
Go to solution

Hello everyone,

 

I have a problem with this function. I send data with arduino using VISA, with string format. The problem is: if I send "28,30" there is no problem, it reats 28,30, but if I send "28.30" it reads the value 28,00. I have already tried with %f. %.; and I can`t find a solution. Smiley Frustrated

 

Best Regards,

Jose S.

0 Kudos
Message 1 of 4
(3,199 Views)
Solution
Accepted by topic author Corzu
Use %.;%f as format string.

Regards, Jens
Kudos are welcome...
Message 2 of 4
(3,178 Views)
Solution
Accepted by topic author Corzu

I'm guessing that you are using the comma (,) as a "decimal separator", i.e. 28,30 means 28-and-30-hundredths (what I would write as 28.30, as I use a period instead of a comma).

 

By default, LabVIEW should use whatever your PC uses as the default, so the string "28,30 28.30" read with format "%f %f" should give you "28,30" and "28", that is, a 4-digit floating decimal number and a two-digit number, with the period signalling to LabVIEW to stop scanning because a non-floating-point-character (the period) was encountered.

 

You can set the comma or period (or set "use what the PC uses") by putting the Format code %,; (use comma), %.; (use period, or %; (use system default).  Thus if you wanted to read "28,30 28.30" as two floats, and you knew the first used a comma, the second a period, you would specify "%,;%f %.;%f" (you specify the separator before specifying that you want to parse a Float).

 

You can find this yourself by reading the Help for "Scan from String" and then clicking on the "format string" link in the Help text.

 

Bob Schor

Message 3 of 4
(3,159 Views)

Thank you! very well explained.

 

Best Regards,

Jose S.

0 Kudos
Message 4 of 4
(3,125 Views)