04-17-2016 10:45 PM
How to convert 32bit hex number to IEEE 11073 32bit float format?
Solved! Go to Solution.
04-17-2016 11:38 PM
@kiran.holla wrote:How to convert 32bit hex number to IEEE 11073 32bit float format?
I think you mean IEEE 754.
Can you show us what you have tried thus far?
04-18-2016 12:21 AM
Thanks tyk007,
No, I ment IEEE 11073 32bit float format.
I found the way, actually in IEEE 11073 ( 1st byte is Exponential (10 pow 1st byte) and rest 3 bytes are mantissa).
04-18-2016 01:58 AM - edited 04-18-2016 01:59 AM
Hi kiran,
please check for yourself: Wikipedia IEEE 11073
When you want to convert to a base10 32bit float you need to find a library which suports this conversion (use Google or any other search engine) - or use some bit-banging to program this conversion on your own…
When you already created a VI for this conversion: please attach it here for future reference!
04-18-2016 04:15 AM
@kiran.holla wrote:I found the way, actually in IEEE 11073 ( 1st byte is Exponential (10 pow 1st byte) and rest 3 bytes are mantissa).
No sign bit?
04-18-2016 08:28 PM
Thanks GerdW for the link.
I have attached what fitts to my solution. There could be number of way.
The attached VI requires Hex array passed, will give you Temperature in Celsius. I believe even signed value is taken care.
Note: 4 Byte Array(Hex) would be in BigEndien IEEE 11073 . i.e value of 24.25 would be 79 09 00 FE
Let me know if there is any problem in it.
04-19-2016 01:38 AM
04-19-2016 09:39 AM
Stackoverflow has a thread regarding the conversion of 11073 to a java float -
04-19-2016 11:47 AM
Your code is not 100% correct. It works fine for positive numbers. BUT the mantissa is a 24bit signed integer. You are converting the mantissa string to a U32 integer and ignoring the sign bit in the string. This c-code came from the "STACKOVERFLOW" thread that PhillipBrooks mentioned. It is the conversion for a 12 bit integer. However, you can easily change the constants for a 24 bit conversion.
04-19-2016 01:46 PM - edited 04-19-2016 01:47 PM
Hi Kiran,
Let me know if there is any problem in it.
Well, I found a problem of using too much unneeded datatype conversions!
Is there a reason you need to convert U8 values to strings to be able to build other integer and DBL values from them?
Why not something simple like this:
The other case holds your version of this code…
(The shown code can be simplified even further, I just replaced your U8-to-string-to-U32 dance…)
Remark: both code version give the same result.
None give the result you expect according to your own statement:
Note: 4 Byte Array(Hex) would be in BigEndien IEEE 11073 . i.e value of 24.25 would be 79 09 00 FE
So I guess there are other problems too in your VI…