annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

String to Number conversion

Risolto!
Vai alla soluzione

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 Strizza l'occhio

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Messaggio 31 di 46
3.311Visualizzazioni

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
Messaggio 32 di 46
3.310Visualizzazioni

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

 

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
Messaggio 33 di 46
3.306Visualizzazioni

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
Messaggio 34 di 46
3.298Visualizzazioni

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 

Messaggio 35 di 46
3.282Visualizzazioni

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
Messaggio 36 di 46
3.277Visualizzazioni

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
Messaggio 37 di 46
3.272Visualizzazioni

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
Messaggio 38 di 46
3.019Visualizzazioni

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
Messaggio 39 di 46
3.018Visualizzazioni

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
Messaggio 40 di 46
2.997Visualizzazioni