LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Number conversion

Solved!
Go to solution

Hi Jick,

 

you can force it permanently by setting that option in the preferences. But not temporarily.

 

Either obey OS settings or deny them. But not "I can't decide what to do"... Smiley Wink

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 31 of 46
(2,189 Views)

Jick wrote:

But your VI converts from number to string and I am interested in conversion from string (which includes ",") to number (which includes ".")...

 

Jick


A number does not include  a decimal sign. A numeric display does.

You can use the following formatter with the 'Scan from string' function:

'%,;%f' 

 

But now I am really confused, where does this string with a comma come from?

Not from the uC I assume. Could you show some code you have? Especially the code that takes a number (orange datatype) and send it to the uC.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 32 of 46
(2,188 Views)

GerdW, That's all I wanted to "hear"! Not possible... Smiley Indifferent

 

TCPlomp, The string with "." comes from the uC which likes them. But in LV, string to number conversion converts also my "." to "," which the uC doesn't like...

Sorry, I don't have any code to send right now.

 

Jick

0 Kudos
Message 33 of 46
(2,184 Views)

Jick wrote:

GerdW, That's all I wanted to "hear"!

not true, you can per action specify which symbol to use!

 

 

TCPlomp, The string with "." comes from the uC which likes them. But in LV, string to number conversion converts also my "." to "," which the uC doesn't like...

Sorry, I don't have any code to send right now.

 

Jick


Allright, I guess you made a typo.

Once more, the 'string to number' does not add a comma. The number to string function creates a comma.

 

Sorry if I sound a little bit agitated, but it sounds like you have a nice spot working with microcontrollers, however this means you have to understand some basic computer/programmer technology.

 

Hope this all helps!

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 34 of 46
(2,176 Views)

Ok, let´s sum the information:

 

1.) You have uC, that gives you a string that includes a number like -73.28 , which means you have a floating point with a "." as decimal character

2.) You want to make some calculations with the value in LabVIEW and / or Teststand

3.) You have to send the calculated value back to the uC, again as floating point with decimal character "."

 

The following code does all you need for that.

FormatFromAndIntoString.png

 

Please take yourself some minutes to recapitulate that there is a difference between a data type that is used inside the PC for calculating and the representation of the data type at the frontpanel

Example1 : The ASCII character "A" is nothing else than a 1 byte data in memory with the decimal value 65 or hex x41.

Example 2: The ASCII string "41" is a set of two bytes in memory with the decimal value  52 and 49.

 

Regards 

Stefan 

Message 35 of 46
(2,160 Views)

Just to add some info for the TestStand part:

Using the Str()-command, you can use the parameters of this command to format the string which is the the result of this function.

Please refer to the help of Str() in order to see the parameters and possible options there.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 36 of 46
(2,155 Views)

SK@NIG, Ok. I have to modify my TS code a bit and bring all calculations to LV and then give the resulting string back to TS. Let's hope it works.

 

Thanks!

 

Jick

0 Kudos
Message 37 of 46
(2,150 Views)

I have used this -Scan from String- and write -- %f,;%f -- but there is error occured. Error: there are too system specifier. if I wrote just %f its ok, but I need string to number conversion like %f,;%f

 

Could anyone can help?

 

 

bEst.

0 Kudos
Message 38 of 46
(1,897 Views)

Please post what you have tried with typical data saved as default.  Also indicate what you think the correct output should be.

 

Lynn

0 Kudos
Message 39 of 46
(1,896 Views)

ok

 

measured value: +0.054847-3 -as string

conversed       :   5,4847E-5 -as number

 

I have writen as -%.;%f to scan from string. I vant my value as it is but only difference should be :

 

measured value:  +0.054847-3 -as string   "."

conversed       :   +0,054847-3 -as number   ","

 

bEst

0 Kudos
Message 40 of 46
(1,875 Views)