LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing 16bit bibary stream to file with 12bit steam

I need to write binary to file with 12bit stream.
What do I need to do?
Thanks in advance
0 Kudos
Message 1 of 4
(2,656 Views)
Hi park,

you have to do some bit operations with your words and splitting words into bytes.

Assuming you want the low 12 bit of your 16 bit word (U16) you have to do the following:

With odd words AND it with 0x0FFF. Then use Split number in the Advaced>>Data Manipulation palette to get the low and high byte.

With even words AND with 0x0FFF. Shift the word 4 bits to the left. Then use split number to get the low and high byte. OR the low byte to the high byte of the odd word.

Concatenate the three bytes (low byte of odd word, the ORed byte and the high byte of even word) to an array of U8.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 4
(2,656 Views)
Thank you Waldemar
I converted my data to an array of U8.
But, I need to write the array of U8 to a file with binary stream.
How can I do that?
0 Kudos
Message 3 of 4
(2,656 Views)
Hi park,

You have two solutions:

1: Convert your U8 array to string and use "Write characters to File.vi" be sure that "convert EOL" is FALSE.

2: Use "Open/Create/Replace File.vi" to open the file. Then use "Write File" to write the data. You can directly connect the U8 array to the data input. After you have done all writing use "Close File" to close the file.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 4
(2,656 Views)