10-26-2014 08:13 PM
@johnsold wrote:
Byte 2 (LSB): decimal 232 = hex E8 = binary 11101000. Byte 1 (MSB): Decimal and hex 3 = binary 11. Combined: hex 3E8 = binary 1111101000 = decimal 1000.
From that, it sounds like it should simply be combine the two bytes into an I16 and then divide by 100. I am assuming 2's compliment here, but I have seen this done many times.
10-26-2014 08:19 PM
Agreed. I did not want to guess because there are so many different ways equipment manufacturers map the data.
Lynn
11-10-2014 08:25 AM
I was wondering...
if I know I should get a 16 bit number, which could be negative or poitive - but a real number.
I don't get the converstion correct because only 16 bit of the double variable are used.
is it possible to know which bits are used in the convesion and than mask them?
for example:
??????110103040 * 00000111111 = 000000110103040
11-10-2014 08:41 AM
Masking is easy. Knowing which bits to mask you can only get from the instrument manual or someone from the manufacturer who knows how they encoded the information. There is nothing in the data itself which tells you that.
Lynn
11-10-2014 09:56 AM
the data is output in 16 bits always (2 bytes).
the type casting to double is done in Labiew to 64 bit.
I can mask it if the casting places the bits at the first \ last or other known bits.
this is a labview question.
11-10-2014 11:31 AM
11-10-2014 12:08 PM
Read the Detailed Help for the Type Cast function:
"
This function can generate unexpected data if x and type are not the same size. If x requires more bits of storage than type, this function uses the upper bytes of x and discards the remaining lower bytes. If xis of a smaller data type than type, this function moves the data in x to the upper bytes of type and fills the remaining bytes with zeros. For example, an 8-bit unsigned integer with value 1 type cast to a 16-bit unsigned integer results in a value of 256."
LabVIEW stores doubles like this:
"
Double-precision floating-point numbers have a 64-bit IEEE double-precision format.

bit 63 is sign. bits 62-52 are exponent. bits 51 to 0 are mantissa.
Type casting from 16 bits to double will likely NOT produce the results you expect. Look at the attached VI for some insight into what might happen.
Lynn
11-10-2014 01:38 PM