LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert unsigned 8-bit array to Boolean array

Hi,

 

I am reading continuous samples using DAQ PCI 6534, write to TDMS file and attached image of LabVIEW vi code. This vi writes the approx. file size 180MB for 120sec acquisition period. 

I will need to acquire the data for few hours. The final output will be large size file (In range of GB).

How to convert the unsigned 8-bit array to Boolean array. I have to convert the unsigned 8-bit array to Boolean array.

 

Thanks in advance.

Any reply will be appreciated.

 

0 Kudos
Message 1 of 7
(1,759 Views)

Hi Sandeep,

 

I may or may not have understood your question correctly.

Do you just want to get values over a certain value to be considered TRUE and lower values to be considered FALSE?

If so, using a for loop with auto indexing can work. I am not very knowledgeable so there might be a better solution.

 

Please see if the attached VI suit your needs.

Andeagon - LabVIEW 2015
0 Kudos
Message 2 of 7
(1,748 Views)

Use the Not Equal To Zero primitive.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(1,742 Views)

From what I understood:

 

u8 to Boolean.png

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

@Sandeep_Vishwakarma wrote:

How to convert the unsigned 8-bit array to Boolean array. I have to convert the unsigned 8-bit array to Boolean array.

 


I am not familiar with your hardware, but you need to explain exactly what you have. If the U8 array is just zeroes and ones, the !=0 will do the trick (But then you might as well configure the read to output a boolean array directly). How many lines per port do you have? If (up to) all eight bits of the U8 are important and you want to convert it to a boolean array that has 8x more elements, a different solution is required. Please define the problem exactly!

 

Here are a few potential solutions depending on the problem.

 

altenbach_0-1659975749541.png

 

Still, none of this is probably needed if you set the read function to output booleans. 😄

 

... and please don't call a truncated and partially redacted picture "Actual LabVIEW vi"! It is not.

 

 

.

 

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

How to convert the unsigned 8-bit array to Boolean array.

 

There are several ways; if you're lucky, one of them will do what you want.

 

If 0 = false and not 0 = true, then it's easy - just use NOT EQUAL TO ZERO on the array, and you get a boolean array.

NOTE THAT YOU DO NOT SAVE SPACE WITH THIS !

A boolean is stored as a byte (using all 8 bits) for internal speed reasons.

 

If you want to save space, you have to spend time: take a U64 and shift each new boolean into the U64. When you have done 64 bits, stash the U64 into an array of U64.  Then each bit of the U64s is used.

 

If you want to split the U8 into 8 separate booleans, then use a mask and shift operations to test each bit as you go.  

NOTE THAT YOU INCREASE STORAGE SPACE WITH THIS!
Since booleans take up 8 bits, your storage space is 8 x what it was.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 6 of 7
(1,682 Views)

Thanks a lot for reply.

0 Kudos
Message 7 of 7
(1,612 Views)