LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert byte array to float

Solved!
Go to solution

I have a byte array which I get from the sensor. I have manage to seperate the payload into three 4 sections. A and B and C are float values: A=+43.57, B=+1.88, C=-2.02. How may I proceed? I have tried type casting and converting to big endian. It doesnt work. Any ideas?

 

 

Capture2.PNG

Download All
0 Kudos
Message 1 of 6
(9,787 Views)

You are searching for FA but the attached VI with default doesnt contain FA.

Share us the data payload which you got and the expected decimal Value. will help you in converting using LabVIEW.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 6
(9,778 Views)

In my project everything is correct. I duplicated the file and have mistakenly typed AA in the field. It should be FA.

a.png

 

0 Kudos
Message 3 of 6
(9,776 Views)

I hope i i did similiar conversion couple of years before, i rememeber i gave the reference for typecast is SGL instead of DBL.

Just have  a try.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 4 of 6
(9,768 Views)

@aan928 wrote:

In my project everything is correct. I duplicated the file and have mistakenly typed AA in the field. It should be FA.

a.png

 


 Its Working Just try this

DataConversion.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 5 of 6
(9,760 Views)
Solution
Accepted by topic author aan928

Hi aan,

 

each part, consisting of 4 bytes, should be typecasted to a SGL value.

- Right now you typecast to DBL - FAIL 😄

- When the byte order is wrong you should use Reverse1DArray on those 4 byte-parts. Using SwapBytes/Words is wrong too…

- You can also use UnflattenFromString, which gives you the option to change the byte order for free…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(9,757 Views)