LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read this bin file!

Addendum. The string is 3600 characters long. If you assume that you are dealing with 32-bit values, then every 8 characters would be a 32-bit value. That would give you 450 values. Does that make any sense based on the supposed measurement?

0 Kudos
Message 11 of 22
(1,889 Views)

Thanks smercurio_fc,

 

Indeed! Used the documentation to find out in what way they stored the data. Although I tried to figure everything out, it is still a question to me what is what! The pdf file (attached file), page 27, decribes de decoding process.

 

When I read the data set, in sets of 12 (e.g. F930EFFED010), does this represent kolomn a-f. According to the manual acc x,y,z are both stored as 12 bits. I don't seem to find a way to get from hex to negative numbers. In this case I could backtrace it.

 

Does anybody know how you can go from hexadecimal to negative numbers?

 

Thanks in advance

Download All
0 Kudos
Message 12 of 22
(1,863 Views)

You have the basic idea correct. You have two ways to do this:

 

  • Read out chunks of 12 characters at a time and use the Hexadecimal String to Number function. However, you need to use a 64-bit integer, not a 32-bit integer. Then you can use Boolean and Shift functions to get the individual values.
  • Read out chunks of 12 characters at a time then chop up that 12 character string to the various lengths and convert each number. 

Attached is a modification of your VI that uses the first method. Modify as needed.

0 Kudos
Message 13 of 22
(1,852 Views)

@manzur wrote:

https://decibel.ni.com/content/docs/DOC-22475

 

Java based implementation


Manzur, you are aware that there exists not something like a generic bin to whatever converter, since there is no standardized bin format?

And double posting of links to close to commercial documents leave a sour taste with most readers.

 

From a comment in that article you link too, I assume your tool allows to convert raw LabVIEW binary data files, although I have no good idea what you mean by that. The OP of this thread has definitely a different format to tackle so your post is not even relevant to this thread.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 14 of 22
(1,828 Views)

Rolf, the user is essentially SPAMMing the board, trying to get users to look at the article so they can download the trial, and then pay for the full version. I have reported the user to the moderator.

0 Kudos
Message 15 of 22
(1,806 Views)

Hi Smercurio_fc,

 

Thanks for this VI, it definitly helped me further in understanding the problem. Unfortunately, I've not yet cracked it! I'm strugling with convertion of the hexadecimal to negative numbers!!.

 

The first row numbers of x, y, and z-axis should be (-0,4683, 0,9253, -0,0358). What I've found out was that for this I need to use a two complement conversion (e.g. 0xFFFFFFF = -1, 8-bit), where I go from hex to bits, reverse them and add +1 (acc to literature)

 

I've used the example VI, Hexadecimal string to double - bit swap.vi to check this, but when I put F93 in I get 927

 

Any help would be appreciated!

 

0 Kudos
Message 16 of 22
(1,769 Views)

I think you may have confused "invert" with "reverse" as there is no need to reverse the bit order.  There's also no need for the "Insert Into Array" functions.  You seem to have omitted or ignored the scaling factors described in the manual.  Let's take just the first point of data, 0.6427.  When we do the scaling (using the X gain and offset) we get output = (0.6427 * 25615 - 563) / 100 = 159 (rounded to an int) = 0x9F hex.  Not coincidentally, the first three characters from the hex string are 09F.  So, you can take 3 characters at a time and feed each 3-character string to "Hexadecimal String to Number."  Make the default value have a type of I16.  To correct the sign, shift the value 4 bytes left, then use the "multiply by power of 2" function with a power of -4 to shift back to the right, which will move the bits back to the expected location and do the sign extension.  Finally, use the scaling factors to get the data.  Here's some quick code that gets the first X,Y,Z values:

12-bit hex to values FP.png

12-bit hex to values.png

 

0 Kudos
Message 17 of 22
(1,744 Views)

Hi guys,

 

I've managed to subtract the y value of the hexadecimal number thanks to smercurio_fc and nathand, but I'm rather stuck with obtaining the x and z-axis value! Yet again, I'm a fairly new with LabView so sorry if I miss the obvious solution for this.

 

The x value should be (-0.0524) and the z value (0.0650). Can somebody explain what I'm doing wrong

Thanks

0 Kudos
Message 18 of 22
(1,702 Views)

I think you have more than one issue here.  One issue is that when I plug your numbers and string into my (working) code posted above, I don't get the values you indicate, so either your scaling values are incorrect, the expected values are wrong, the string is incomplete, or it's in a different format than you posted previously.  Any of those make it difficult to determine the problem with your code.

 

The other issue I see is that you're losing the sign bits.  Do you understand how 2's complement works?  You cannot simply extend a signed 12-bit value to 16 bits by putting 4 bits of 0 at the front.  If the highest-order bit of the 12-bit value is a 1, then the value is negative and you need to put 4 1's in front to maintain the sign.  Try doing it as I suggested above, or modify your code as follows: shift by 4 fewer bits (ie, shift by -32, -20, and -8).  After shifting, convert to a signed 16-bit value.  Then use "Scale By Power of 2" with a scale of -4 to shift the remaining distance while maintaining the sign.  When I make this change, though, I still don't get the values you claim are correct, which is why I think there's another problem as well.

0 Kudos
Message 19 of 22
(1,697 Views)

Hi,

 

I´ve managed to solve the two´s complement problem, but can I get any suggestions in simplifying this Vi.

 

| To correct the sign, shift the value 4 bytes left, then use the "multiply by power of 2" function with a power of -4 to shift back to the right, which will move the bits back to the expected location and do the sign extension |.

 

@Nathand, I don't understand how you previously detected the sign bit with the logical shift function and multiply by power of 2 function. It shifts the bits left or right depending on the y value. The idea is, if I'm correct that depending on the sign bit being positive (0) or negative (1) it should add or substract the other bits from the most sign bit value. For example having F93 --> 111110010011 sign bit is positive results in a negative number starting from -2048 downwards (011110010011 = 1939) so the real decimal value should be -109.

 

Another issue I want to address is when I read my textfile, I need to substract every ...lines, 300 lines of hexidecimal numbers, plus it must automatically change the gain and offset whenever I load a new file in.

 

Any help woud be appreciated

 

Ty

 

0 Kudos
Message 20 of 22
(1,668 Views)