LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Byte Array in a float structure

Hello,

I am in an evaluation process of LabView 7 and trying to communicate with a 8-Bit Microcontroller.
The Interface works fine, but the values received in LabView are Byte Arrays and i want to convert them to the
corresponding structure (especially floating point values) and back to Byte Arrays. I wrote a small vi to convert a 4-Byte Array to the corresponding floating point value, but I think that there must be a better way (library function) for this and I have not the time to write a vi converting floating point values to 4-Byte Arrays.
0 Kudos
Message 1 of 3
(4,388 Views)
It really depends on the endianess of your number format. If it is a big endian format you are fine with just using the Typecast function. If it is littel endian you will basically first have to tranlate the byte array into the structure you want to create replacing any single precision float with an uInt32. Then wire this through the  Byte Swap and Byte Word function and then Typecast it into the definitive cluster. There is an example about Typecasting floating points into and from byte arrays/strings for little Endian systems (x86) on Developer Exchange somewhere.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 3
(4,379 Views)
Thanks for the fast reply, but I think my first problem is the correct use of the typecast function in this case. But now I know, that the typecast function is the right way to find a solution to my problem.
0 Kudos
Message 3 of 3
(4,375 Views)