08-08-2022 10:39 AM
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.
08-08-2022 10:53 AM - edited 08-08-2022 10:54 AM
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.
08-08-2022 11:02 AM
Use the Not Equal To Zero primitive.
08-08-2022 11:20 AM
From what I understood:
08-08-2022 11:23 AM - edited 08-08-2022 11:33 AM
@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.
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.
.
08-08-2022 02:07 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
08-11-2022 12:10 AM
Thanks a lot for reply.