05-14-2012 02:52 PM
Hello,
I am using the basic serial read and write vi to communicate with a device. The response I am getting (displayed in hexadecimal form) is 4606 8D3B, which from what I understand (from this discussion: http://forums.ni.com/t5/LabVIEW/string-to-number-conversion-a-very-interesting-observation/m-p/32170... ) the data is not actually hexadecimal but rather binary and is just displayed hexadecimal for the user.
The manual of my device says this piece of information is "Float - 4 byte ANSII standard single precision, low to high" and I am trying to convert this string into a decimal value. (it should be 0.004 or 4.xx e-3) So far I have written a program that seperates the bytes into an array of 4 bytes, converts each to binary, then unbundles all the binary bits and am trying to bundle back the binary bits into the exponent and mantissa to calculate the value, but this seems rather convoluted and I am hoping there is a simpler function in that does all of this automatically. Also, since the response is low to high I understand I need to first flip the number to 3B8D 0646 to make it high to low, but I think I have done that already, it's just the conversion that I am not sure how to do.
Any help would be appreciated, thanks
Alex
Solved! Go to Solution.
05-14-2012 03:02 PM - edited 05-14-2012 03:03 PM
Try this:
05-14-2012 03:25 PM
With that I am getting "Error 74". (Maybe I just set it up wrong, I am relatively new to labview)
05-14-2012 03:30 PM
Your constant is a DBL and the hex string is not what you said was the response - 4606 8D3B.
05-14-2012 03:36 PM
Ahh I see, I thought I had to reverse the number first. Changing the constant to SGL and inputing 4606 8D3B gives me 0.00430373, which is correct. Thank you!