LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert UINT into single bitstreams

I am trying to take a large array of UINT8 values from a digital input and convert them into 8 arrays of 1 bit values based on their bit position.

 

For example, as a simplified case, I have an array containing the following digital words (for brevity): 0b00110101, 0b00000000, 0b11111111, ....

 

I want to turn this 1D array of IU8 into 8 individual IU8 arrays:

MSB: 0,0,1 (Essentially the result of AND'ing the incoming stream with 0b10000000)

LSB: 1,0,1 (Essentially the result of AND'ing the incoming stream with 0b00000001)

 

Where I can then do further signal processing on the bitstream. Essentially I am acquiring N independent signals and need to separate back out the array that is coming from the Digital Read DAQmx block. There may be an option in the Digital Read to change the way that the data comes out but I couldn't easily find it. I'm trying to do this somewhat effeciently since the dataset is several MB.

 

Thanks,

Drew

 

0 Kudos
Message 1 of 7
(5,947 Views)

I'm not sure about the bit order, but I think this is what you want.  See attached VI, in LV2009, also included a picture.

 

HSDIO_BitsToNumbers.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(5,934 Views)

tbob,

 

Thanks for the quick reply. This isn't quite what I was looking for, but I think it can easily be modified to do what I want.


This is essentially taking the bits and them recombining them into a U8.  I actually just want a single bit array. So the output arrays will be U8, but will only have the value of 0 or 1.

 

To make it more clear why I am doing this, the input signal that I am converting is the output of an array of single bit sigma delta modulators. So I will take this 0,1 bitstream do some level shifting and then take the FFT of it.

 

Thanks,

Drew

 

0 Kudos
Message 3 of 7
(5,931 Views)

I think TBob gave you what you were asking for, but just when a lot further with other math.

 

If you take his 3 U8 input values, the conversion to boolean arrays, the building of that into a 2-D array of booleans, then just index out the 0th and 7th column, you will then have two 1-D boolean arrays.  One for the msb, the other for the lsb.

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

Don't forget that we also have the 4.x version of typecast, which turns each U8 number into an 8 bit array containing the bits.

 

So, simply cast the U8 array to a boolean array in 4.x mode, reshape, and slice out the desired columns.

 

The attached demo should get you started. 😉

 

 

Message Edited by altenbach on 06-08-2010 11:24 PM
Download All
Message 5 of 7
(5,897 Views)

Altenbach, you are on a Type Cast roll.  Why don't you post a nugget about all of the functions with version 4x.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 7
(5,868 Views)

altenbach wrote:

Don't forget that we also have the 4.x version of typecast, which turns each U8 number into an 8 bit array containing the bits.

 

So, simply cast the U8 array to a boolean array in 4.x mode, reshape, and slice out the desired columns.

 



One of my favorite little Type Cast tricks is 4.x mode.  I find it amusing that you would remove the index display from the boolean constant yet leave the controls and indicators as icons.  As a style role model you are liable to make that fashionable, and now we'll have Type Cast chaos and unwieldy icons running amok.  Smiley Very Happy

Message 7 of 7
(5,857 Views)