BOOL_TO_INT Converstion 16bit data to 1 Integer

Dear Experts,

Please suggest a libray block or ST code to pack ( convert ) boolean data to integer.

my requirement is that i have to send few data to 3rd party device in integer data type.
My tags are Bool data type tags which gets on/off. I can only send integer data type, so i am trying to write a particular bit in the integer so i can use 1 integer data type to send 16 bit data tags.

i am hoping to find a similar fb which converts bit by bit to integer so i can my work will be easy.

You can easily access each bit of a variable in ST by adding a dot ‘.’ after the variable, you can then write each bit individually like this simple example

2 Likes

You can also consider Bit2Byte and Byte2Bit() from the SYS_Lib library.
B&R Online Help - Bit2Byte
AS v4 Help GUID: 217d46cc-424d-4ab7-be6f-20433d202519
B&R Online Help - Byte2Bit
AS v4 Help GUID: 21ac1f45-64f1-4016-bfee-7eb100fc311a

-Austin

1 Like

Thanks a lot , i didn’t know we can do this bit wise ..