08-30-2010 01:20 PM
@_Faust wrote:
Yes that did the trick, but why isnt the 16 bit type cast enough to accurately transform the number? Its only 4 digits long.
I used the word typecast because the modbus library takes words, but that isnt necessary?
FYI, a SGL is stored as sign bit + 8 bit exponent + 23-bit significand. You convert to a floating point by finding significand * 2^exponent (with some bit fiddling). When you lop off the last 16 bits, you are left with a 7-bit significand, the smallest significand you can represent is 1/2^7 or 1/128. For your value of 12.33, the exponent is 3, so the smallest value you can represent here is 1/128*2^3 = 1/16, so 12.3125 is your original value rounded down to the nearest multiple of 1/16.
08-30-2010 03:52 PM
Thank you all for your expert knowledge!