04-28-2010 02:50 AM
04-28-2010 02:50 AM
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
04-28-2010 03:00 AM
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
04-28-2010 03:05 AM
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
04-28-2010 03:30 AM
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.
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
04-28-2010 03:43 AM
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
04-28-2010 03:50 AM
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
05-29-2011 09:02 AM
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.
05-29-2011 09:06 AM
Please post what you have tried with typical data saved as default. Also indicate what you think the correct output should be.
Lynn
05-29-2011 10:39 AM
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