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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you read in and work with I24 binary data into LabView?

Hi there,

 

I have a program that is reading binary data in as 16 bits per sample.  I have some binary input files that were saved as 24 bits per sample.  How do I convert my old program to handle this data.  I realize that LabView doesn't have built in I24 conversion - how do I do this myself? I found a post that referred to using a boolean array to create your own 24 bit number - but I don't understand what that means...  Any help would be appreciated!

 

Thanks so much!

 

 

0 Kudos
Message 1 of 7
(4,367 Views)

You'll need to read the data into a string (or an array of U8), group the data into three bytes/characters, and convert to a 32-bit value that contains 24 bits of data. Here's one way to do it that I suggested in an older thread.

24 bit values in string to array of I32.png

Message 2 of 7
(4,342 Views)

Do you have the data in binary (0,1) representarion? This may help:

bin_string_to_i32.png

0 Kudos
Message 3 of 7
(4,327 Views)

@PA_UW wrote:

Hi there,

 

I have a program that is reading binary data in as 16 bits per sample.  I have some binary input files that were saved as 24 bits per sample.  How do I convert my old program to handle this data.  I realize that LabView doesn't have built in I24 conversion - how do I do this myself? I found a post that referred to using a boolean array to create your own 24 bit number - but I don't understand what that means...  Any help would be appreciated!

 

Thanks so much!

 

 


It means create an array with 24 boolean elements and process that as you wish

0 Kudos
Message 4 of 7
(4,308 Views)

Do you know the format of the saved 24-bit data?  Can you share some data with us, along with what you think the values are?  If it is I24, then every three bytes represents a 24-bit (signed) integer.  The first question to answer is "What is the order of the bytes"?  How do you want to represent these data?  The obvious choices are as an I32, but since the rest of your data is I16, you might choose I16, instead.

 

To convert I24 into I16, you can simply return the high two bytes.  To convert I24 to I32, you need to set a high byte that replicates the sign (saved in the most significant bit of the third byte).  One way to do this is to consider the third byte as an I8 quantity -- if it is positive, set the high byte to 0, and if it is negative, set the high byte to -1.

 

Bob Schor

0 Kudos
Message 5 of 7
(4,289 Views)

@chembo wrote:

Do you have the data in binary (0,1) representarion? This may help:


chembo - "binary" here does NOT mean a string composed of 1s and 0s. It means that the contents of the file represent the actual numeric data, rather than characters that form a human-readable representation of the data.

0 Kudos
Message 6 of 7
(4,284 Views)

Thank-you - I will give this a try! 

0 Kudos
Message 7 of 7
(4,257 Views)