I'm trying to read data from a spectrophotometer through RS-232. Manufacturer specs on communication: every 80 msec the following sequence generated
1Ssimmmm 0mmmmmmm 0mmmmmmm 0mmmmmme 0eeeeeee
S,s,i - some auxiliary bits; m - mantissa; e - exponent. MSB is to the left. Bit7 is set to 0, except for the first byte, to synchronize receiving. When the machine shows ~0.3534 on its little screen I read from the port (hex) 85 53 12 43 7F, which is, if I'm not mistaken,
10000101 01010011 00010010 01000011 01111111
Removing aux bits I get the following float point words
01011010 01100100 10100001 11111111
No matter how I try to convert this thing I do not get anything even close to 0.3. The format manufacturer describes is not quite IEEE 754 (MSB would be to the right). Can anybody help me to decipher what manufacturer meant?
P.S. It's Knauer K2501 spectrophotometer, I contacted Knauer already, but not sure if they will get back to me.
]
Last byte ... Is a signed byte.. 00000000H = 0D , 01111111H = 127D BUT ..... 10000000H = -128D and 11111111H = -1D ...
Sorry, I'm new to all this thing, so I still don't get it.
Do you mean that the exponent part has a designated sign bit?
Which one is the sign bit for the fraction?
In your conversion you are getting roughly 0.03, which is way better than anything I had, but still not 0.3 the machine showed...
Do you mean that the exponent part has a designated sign bit?
Yes, that's how I interpret GeamlinSA's post. (I'm not sure, however, what you mean by "designated" here. It definitely does have a sign bit.
Which one is the sign bit for the fraction?
Perhaps one of the "auxiliary" bits we don't know anything about? There are two labeled "S" and "s" which could be good candidates. Or perhaps a sign bit wouldn't make sense at all in the context of the instrument the data comes from and so there is none?
In your conversion you are getting roughly 0.03, which is way better than anything I had, but still not 0.3 the machine showed...
Perhaps the value measured by your instrument "floats" a bit and your display readout and the binary data you got actually belong to different samples? Your display readout and GremlinSA's converted value just slightly over 0.5% apart.
Nice tool to check a given bit pattern , for instance what you get out of your conversion routine (but then again, why not simply output it from your program?), but IMO for understanding the IEEE 754 floating point format this one is better: http://en.wikipedia.org/wiki/Single_...g-point_format
I'm afraid you won't get away without some bit-juggling of your own, unless Knauer provide you a conversion routine (probably as source code, but perhaps not in the language you're using).
Last edited by Eri523; September 15th, 2011 at 03:36 PM.
Reason: Corrected my spec of the deviation between the two values
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Perhaps one of the "auxiliary" bits we don't know anything about?
S shows if the data belongs to wavelength scan; s indicates whether the data are from the initial moment of reading, i is set to 1 if the machine deems data invalid for some reason. Nothing about sign. The instrument measures observed light absorbance, which can be either positive or negative.
01000011 11010011 11100010 00000001 is supposed to mean ~ +1.059
10111111 11111000 00100101 00000000 is supposed to mean ~ -0.500
btw, if they say exponent is the right most group of bits, then how I number bits in these words? Left most is number 0?
Last edited by artirm; September 16th, 2011 at 12:59 AM.
the strings you posted work as follows..
The mantisa (or significand) is signed, and the Exponent is signed. .. How ever the Exponent decides how you calculate the significand, and not applied afterwards..
Because you've not really specified what language so i did a Excel Spreadsheet with the 3 samples you posted, that should calculate just about any binary you put into it... ( it works out the Exponent and all)
Hope it helps you work out your own code to decode this...
Hope it helps you work out your own code to decode this...
Wow, it really did! Thanks a lot. I'm coding in C#, so it was not too difficult to write my own code based on your algorithm. Works like a charm and is so much better than reading data through analog output :-)
So, it seems like both exponent and mantissa are biased, although I'm not sure if it is standard in IEEE 754. Where could I read more about these things?
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.