LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Floating Point

I am receiving numbers from a Tinius Olsen Model 290 Universal Testing System.  I made a little program to send commands to the machine and receive the responses back as strings.  For the decimal value 3.7620 I get the floating point number EDC57040.  This is obviously not correct.  The correct floating point representation is 4070C5ED, which is accomplished by swapping all the bits.  I need to know how to do this in labview, basically go from the string representation of the floating point to the correct swapped floating point.
0 Kudos
Message 1 of 10
(3,519 Views)
Use "unflatten from string" and select little endian for the "byte order" input.
0 Kudos
Message 2 of 10
(3,513 Views)
Here is a simple example:

Be aware that if you have an ancient version of LabVIEW, this option (byte order) is not available and you need to swap the bytes manually. No big deal, really. 😉

Message Edited by altenbach on 05-08-2007 01:15 PM

Message 3 of 10
(3,510 Views)
i tried your method and keep getting a result of like 7.26 something.  not sure what I'm doing wrong, sorry I am pretty new to labview.
0 Kudos
Message 4 of 10
(3,482 Views)

make sure your string display is set to hex display (right-click it). If you leave it at normal, the string EDC57040 would translate to 7.27425E-7. Could that be it?

If it still does not work, please attach a simplified version of your code.

0 Kudos
Message 5 of 10
(3,477 Views)
I tried your little test program just to be sure and that works correctly.  I have included a bitmap of the relevant section of the program below.  Basically what I need to know is how to get the string I read from the Tinius Olsen machine into the correct format so that I can use the unflatten from string function.  I tried just changing the format of the string to Hex but that gives me 4 number combos (ex. 1234 5678 9101 1234) and then the wrong value for the number.
0 Kudos
Message 6 of 10
(3,458 Views)
If you get 8 characters, chances are that your string is hex formatted ASCII. This means you probably need to use "hexadecimal string to number". Just reverse the string first to get the right byte order.
 
How does the string look like in normal display? Does it contain only characters 0..F?
 
(Also remember, the display format is just a cosmetic property, it does not change the underlying data).

Message Edited by altenbach on 05-09-2007 01:42 PM

0 Kudos
Message 7 of 10
(3,455 Views)
yeah the manual says its ASCII. The string in the display after I get it from the machine looks like EDC57040.  So I need to take that string, do the lower endian unflatten from string, then take the resulting string and perform the hexadecimal string to number to get the correct value?
0 Kudos
Message 8 of 10
(3,448 Views)
First, you need to scan the string using e.g. "hexadecimal string to number", cast the resulting U32 to a string, then unflatten it as little endian SGL.
 
 
(There are also a few other ways to do it)
 
 

Message Edited by altenbach on 05-09-2007 02:19 PM

Message 9 of 10
(3,439 Views)
works like a champ, thanks a lot for your help
0 Kudos
Message 10 of 10
(3,411 Views)