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 to use the boolean data of a cluster as a byte

Solved!
Go to solution

Hi Dear Members

I have a cluster of boolean data I want to send the data via VISA write function. How can I transfer each 8 boolean indicators as a byte to VISA write function?

Thanks

0 Kudos
Message 1 of 14
(2,903 Views)
Solution
Accepted by topic author Laian

Hi Laian,

 

this is quite easy:

Convert the cluster into an array, then convert the boolean array to a number, then make sure to get a byte (aka U8)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 14
(2,891 Views)

Oops, I misread the original post.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 14
(2,887 Views)

Hi Mr GerdW

I have error "Polymorphic terminal cannot accept this data type"

see the attach image

thanks

0 Kudos
Message 4 of 14
(2,846 Views)

Hi Laian,

 

then your cluster does not contain just boolean values!

 

Your question was:

How can I transfer each 8 boolean indicators as a byte

and I presented a solution to convert a cluster containing just 8 boolean values…

 

When your cluster contains more than just 8 booleans then use Unbundle(ByName) and BuildArray to create the boolean array instead of ClusterToArray!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 14
(2,829 Views)

Hi dear members

Thanks Mr GerdW

another issue: for reading process by VISA as  the attachment I have used unflatten from string to connect my cluster. as it is shown it gets 20 bytes from VISA read function and should convert these 160 bits to 160 boolean value. But it seems that it sets each byte for each boolean indicator instead of each bit to each boolean indicator?

thanks

Regards

0 Kudos
Message 6 of 14
(2,779 Views)

previous post edited:also I should add that I have corrected my cluster to 160 boolean control displays. just boolean not other types

thanks

0 Kudos
Message 7 of 14
(2,759 Views)

next edit: I have found that Labview stores a boolean data as a byte. So the question is how to change it for a single bit?

thanks

0 Kudos
Message 8 of 14
(2,746 Views)
Solution
Accepted by topic author Laian

Hi Laian,

 


@Laian wrote:

next edit: I have found that Labview stores a boolean data as a byte. So the question is how to change it for a single bit?


As is written in the LabVIEW help! (So you did read the help? :-))

Why do you need to change the way how LabVIEW handles boolean values internally?

I already have shown how to create a boolean array and to combine several bits into one byte: what is the real problem?

 

as it is shown it gets 20 bytes from VISA read function and should convert these 160 bits to 160 boolean value. But it seems that it sets each byte for each boolean indicator instead of each bit to each boolean indicator?

This seems to be the real problem:

Read those 20 bytes. Convert the string to an U8 array. Convert each U8 value into a boolean array. Concatenate all boolean arrays into a larger one holding all 160 bits:

Or read the help for TypeCast, especially the paragraph mentioning older "Early" versions of LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 14
(2,741 Views)

Thanks it works on the array

but it doesn't show in my boolean cluster I/O.

333.png

0 Kudos
Message 10 of 14
(2,706 Views)