Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

05-23-2008 02:16 PM - edited 05-23-2008 02:17 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

* 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 can read the header from the format spec in the documentatino. I obtained the exponent value from the header. I just don't really understand how to read in the data values, and I am not sure I understand the example the developer gives regarding "0x40000000 represents 0.25 and 0xC0000000 represents -0.25 and

* if the exponent is 2 then they represent 1 and -1 respectively."

Header appears to be 512 bytes long looking at this file in a Hex editor (the other header length options were 224 and 246 depending on the file age).

Sincerely,

Don

Message Edited by DonRoth on 05-23-2008 02:17 PM

05-23-2008 02:54 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

05-23-2008 04:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.)

Message Edited by altenbach on 05-23-2008 02:45 PM

05-27-2008 11:08 AM - edited 05-27-2008 11:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Centerbolt - I don't understand your math. You have 1*(2^2) = 0.25? Yes, LabVIEW does fixed point but I am not sure how to extract the bits from the fixed point number using LabVIEW functionality in order to do the calculation. So the examples the developer gives are still not clear.

Sincerely,

Don

Message Edited by DonRoth on 05-27-2008 11:09 AM

05-27-2008 11:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

Unless the multiplier is an integer power of two, you cannot directly cast it as fixed point type. Use my code to read it and multiply the DBL result by the multiplier.

Do you really need the result in FXP or is DBL sufficient? The problem is that the FXP representation probably needs to be adjusted depending on the multiplier value else you'll possibly discard bits.

05-27-2008 12:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

2 raised to the (-2) power = 0.25

05-27-2008 12:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

05-27-2008 12:42 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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 ).