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
(12,803 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
(12,794 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
(12,792 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
(12,784 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
(12,776 Views)
Solution
Accepted by 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
(12,773 Views)