From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-23-2008 02:16 PM - edited 05-23-2008 02:17 PM
05-23-2008 02:54 PM
05-23-2008 04:00 PM
Don,
I think this is what the developer did.
Think of it as a 32 bit binary number with an imaginary binary point to the far left. Left to right - 1 sign bit, 31 bits for fraction. MSB - LSB
For the case of 0x40000000 Sign bit is zero so it is a positive number. fracton = 1*(2^-2) = 0.25
For the case of 0xC0000000 Sign bit is one so it is a negative number. fracton = -1*(2^-2) = -0.25
For the case of 0x70000000 fraction = 1 * (2^-2) + (2^-3) + (2^-4) = .4375 ( If I can still run my calculator right !)
If I remember correctly, LV8.5 supports fixed-point data types to deal with this kind of stuff.
05-23-2008 04:44 PM - edited 05-23-2008 04:45 PM
I don't quite get where the "exponent" comes from. Is this the same for the entire datafile?
Anyway, to get the data, you need to unflatten it from string as little endian I32 and then divide by 2^32 and multiply by the exponent.
File position 4 has a 4 byte number that seems to represent the data size in # of points (6453 in your case). The data starts at 544.
There is a lot of other information in the file, I am sure the exponent is somewhere. You need the full file specification.
Here's a quick attempt at reading the file assuming an exponent of 1. See if it get's you any closer. Good luck! 🙂
(the code is very crude. Typically you would want to take the subset with length 4x6456 before unflattening the data.)
05-27-2008 11:08 AM - edited 05-27-2008 11:09 AM
05-27-2008 11:59 AM
DonRoth wrote:
I get value of 14. Then we still need to know how to read in the data per the fixed point numbers and extract the bits.
05-27-2008 12:05 PM
Could it be the multiplier is 2^14 instead? Would make more sense.
DonRoth wrote:
I get value of 14.
05-27-2008 12:09 PM
05-27-2008 12:13 PM
05-27-2008 12:42 PM
Altenbach,
All I attempted to explain was how the floating point version of the fraction Y was arrived at.
* Data Value Formats
* ==================
* Y values are represented as fixed-point signed fractions (which are similar
* to integers except that the binary point is above the most significant bit
* rather than below the least significant) scaled by a single exponent value.
* For example, 0x40000000 represents 0.25 and 0xC0000000 represents -0.25 and
* if the exponent is 2 then they represent 1 and -1 respectively. Note that
* in the old 0x4D format, the two words in a 4-byte DP Y value are reversed.
* To convert the fixed Y values to floating point:
* FloatY = (2^Exponent)*FractionY
I'm fully aware that the overall conversion is not complete without the scaling factor ( 2^Exponent ).