LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

URGENT!!! Can we converse a string of 4 bytes to 32-bit real number?

We have a feedback from our instrument contains a string of 4 bytes representing a 32-bit real number but we can not convert it, can some one help?

 

Here is a string:     'ffffffee'           

 

Is there any VI or sample available?

 

Thank for help  Smiley Sad

0 Kudos
Message 1 of 12
(3,479 Views)

Yes, if you have the string of actual 8 bit data, just separate out each individual unsigned 8 bit number and then combine them using the "Join Numbers" function.  Then join the two 16 bit numbers with another join numbers function.

 

This function is on the "Numeric Palette" -> "Data Manipulation"  

LabVIEW ChampionLabVIEW Channel Wires

0 Kudos
Message 2 of 12
(3,475 Views)

Check this... and this, maybe is what you need.

 

 

0 Kudos
Message 3 of 12
(3,468 Views)
Are you sure you've got the right string? According to IEEE 754 that's not a valid representation in Hex of a 32-bit single-precision number.
Message 4 of 12
(3,467 Views)

Thank for help but I did try & look does not work. I attach my VI so that you can see why I am not right (the number suppose to be -1.xxxxxxxE-3

 

Can you help one more time?

 

0 Kudos
Message 5 of 12
(3,455 Views)

Yes, it is a right STRING, however it is required doing 2 complement ... because it is a negative number!

 

 

I did have another number & it is said to do conversion already (no need to do 2 complement)  bf 53 4c 78   ... but I still in-vain to convert it!

 

You have any idea?

0 Kudos
Message 6 of 12
(3,435 Views)

SORRY gentlements, those 2 strings I was mistaken from the inteprete reading, it shows the equivalent number from the byte  (ie:   '0' ---> 0x03 = 30), so sorry about confuse all of you.

 

Therefore: 'fffffffee'  is real 4 bytes of  ÿÿÿî

 

I hope that now we are clear than before! Sorry abot the confusion!

0 Kudos
Message 7 of 12
(3,429 Views)

OK, This is getting silly. Please attach a VI that has the correct string as a diagram constant. Or change your string display to hex and paste the hex representation.

 

 Do you know if your string is little endian or big endian? ALso tell us what SGL number you expexct as result.

 

Most likely, all you need is typecast the string. (If it is little endian, use "unflatten from string" and select the correct byte order)

 

Message Edited by altenbach on 09-09-2008 07:31 PM
Message 8 of 12
(3,406 Views)

plit string wrote:

Yes, it is a right STRING, however it is required doing 2 complement ... because it is a negative number!


 Typecasting will take care of this automatically.


plit string wrote:

I did have another number & it is said to do conversion already (no need to do 2 complement)  bf 53 4c 78   ... but I still in-vain to convert it!


My code would turn a strong of BF53 4C78 (in hex display) into a SGL of -0.825386. Sounds reasonable?

Message 9 of 12
(3,400 Views)

By your explanation, I did setup the instrument with corrected 64-bit reading (since in LabView does not have the 32-bit but DOUBLE instead), so that I use 8 bytes then it works perfectly as your suggested casting

 

Many thanks Smiley Happy

0 Kudos
Message 10 of 12
(3,374 Views)