取消
显示结果 
搜索替代 
您的意思是: 

String to Number conversion

已解决!
转到解答

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"... 眨眼表情

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 项奖励
31 条消息(共 46 条)
3,357 次查看

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 项奖励
32 条消息(共 46 条)
3,356 次查看

GerdW, That's all I wanted to "hear"! Not possible... 冷淡表情

 

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 项奖励
33 条消息(共 46 条)
3,352 次查看

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 项奖励
34 条消息(共 46 条)
3,344 次查看

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 

35 条消息(共 46 条)
3,328 次查看

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 项奖励
36 条消息(共 46 条)
3,323 次查看

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 项奖励
37 条消息(共 46 条)
3,318 次查看

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 项奖励
38 条消息(共 46 条)
3,065 次查看

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

 

Lynn

0 项奖励
39 条消息(共 46 条)
3,064 次查看

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 项奖励
40 条消息(共 46 条)
3,043 次查看