04-26-2010 03:41 AM
Hi,
I am passing it first to Teststand and there to microcontroller via serial bus (RS232).
Jick
04-26-2010 04:16 AM
To make things clear:
You have a string like -73.28
--> If you want to calculate something, it´s useful to convert this string into a number, in that case into a floating point - also short called double (DBL) for having maximum resolution, so that the CPU can do number handling.
A DBL (double) is nothing else than a 8 byte data value with a defined structure that can be handled inside the OS/CPU.
For us simple "stupid" humans, to make is more readable, the representation of this 8 bytes is done in a human readable format--> this depends on what system settings you have/country where you are.
i.e. Germany -> it´s the , --> US --> it´s the .
This does not mean, that the number that is hold in the memory has really a commata or a point in it!
This is the reason, why you have to give your "format" function the information if the source data contains a point or commata.
If systems setting is ",", formatting -73.28 results in -73,0 (i.e. on german systems.)
The same happens, if you have the string "-73,28" and convert it on an english system, the result is -73.0
So for your special problem:
If you have a string -73.28 and you have to give it to Teststand and then to a uC - if you do not have to make any calculations in between, why do you not transfer the string from LV to TS and to the uC?
Stefan
04-26-2010 04:35 AM
Yes, I undestand country specific styles between "," and ".".
My procedure is:
1. Parse number out from a string i.e "... -73.12..." in LV.
2. Convert it to -73.12 number. Pass it to TS.
3. Make some basic calculations like plus and minus with other results in TS.
4. Convert it to string and send to uC.
So if the number includes comma "," in step 3. and/or step 4. I'll get an error.
Jick
04-26-2010 04:49 AM
Very simple solution to the location problem:
Why don't you just do a search and replace function that you can run on all your Strings (numerics) that you output from your program that replaces all commas with decimal points?
input 1: 71.28
output 1: 71.28
input 2: 71,28
output 2: 71.28
input 3: 73
output 3: 73
2 controls: "String", "Is numeric"
1 Indicator: "Processed string"
James
04-26-2010 05:18 AM
I ended up to change my OS's regional settings. Thanks to everyone!
Jick
04-26-2010 05:26 AM
Word of warning:
Changing the regional settings works.... until you port the code onto another machine and forget why you have the failure. I suspect many people would agree with me when I suggest you fix the problem properly in the LabVIEW code so you don't see it again rather than risk a headache in 6 months time when you've forgotten why this is happening and your PC has just been replaced!
You will probably pay later for your "laziness" now.
James
04-26-2010 05:49 AM
04-26-2010 07:23 AM
Jick wrote:Yes, I undestand country specific styles between "," and ".".
My procedure is:
1. Parse number out from a string i.e "... -73.12..." in LV.
2. Convert it to -73.12 number. Pass it to TS.
3. Make some basic calculations like plus and minus with other results in TS.
4. Convert it to string and send to uC.
So if the number includes comma "," in step 3. and/or step 4. I'll get an error.
Jick
So the problem is more Teststand related?
Or do you do step 4 in LabVIEW?
For conversion, you should use the 'Format into string' function with a '%.;' at the start of the formatter, this instruct LabVIEW to use a '.' as decimal sign.
Ton
04-26-2010 07:30 AM
The problem is/was my microcontroller which does not understand "," as a decimal separator. In LV when converting string i.e. "-22.22" to number I get -22,22 instead of -22.22. I already changed OS's settings about decimal separator.
Jick
04-26-2010 07:52 AM