07-07-2011 10:07 AM
I am reading modbus data from a DUT from two holding registers- 40609 and 40610. The register content I get is an array of two elements (12458, 14019). I want to convert these numbers into a floating point value. Does modbus library has a VI that does it? If not, how do you convert it?
Thanks!
Solved! Go to Solution.
07-07-2011 10:41 AM - edited 07-07-2011 10:42 AM
07-07-2011 01:07 PM
Thanks.
But, I am getting a different number than yours.
07-07-2011 01:17 PM
In Ravens Fan's example the array elements are I16. Your array in your example is I32. That's why you have a different answer. What is the bit size of the elements in the array? When you say float are you referring to a 32-bit float (SGL), or 64-bit (DBL)?
Also note that you can wire the array directly to Type Cast without having to use Index Array and Join Numbers.
07-07-2011 01:42 PM
I am reading modbus holding registers, which I believe are 16-bit, right? I want to convert to a 64-bit double.
07-07-2011 01:50 PM
Actually, my elements are U16. It looks like you made your array elements either U32 or I32.
Yes, Modbus registers are 16 bit. So you if have two registers you can only combine them to become a 32 bit number, which as a float means a single precision floating point number.
You can't combine them to a 64 bit double precision number.
07-11-2011 10:14 AM
Ok. So, if I have two hex numbers reading from two holding registers, how do I convert it into a SGL float.
For example,
FBF1
411F
That is equivalent to my DUT output, 9.99.
When I follow your suggestion, i am getting a huge number.
Thanks
07-11-2011 10:53 AM
Swap the order of the numbers going into the Join function.