Luka0204

16 bits into unsigned word/Bit String [16-bit] array

4 posts in this topic

Hi,

I have variable (named var1) with data type 'Word[Unsigned]/Bit String [16-bit]' with Array [0..7]. I want to put 16 variables with data type 'bit' in var1. Is there function for that? Also is it possible to put 16 variables (bit) like this:

var1[0].0:=bit1; var1[0].1:=bit2 etc.

I'm using GX Works 2 with CPU L02

Best Regards

Share this post


Link to post
Share on other sites

No, but you can do it by using "BITARR_TO_INT", and then from the INT (Word-Signed) convert to WORD (Word-Unsigned) by using "INT_TO_WORD"

Alternatively if you don't want to create an array of your bits, you can use "SET_BIT_OF_INT" (16 times if no loop), and then take the INT (Word-Signed) and convert it to WORD (Word-Unsigned) by using "INT_TO_WORD"

Also a combination of the two is possible, with or without loops to ease the time taken to develop.

If you clarify more what you want to achieve, and what kind of language you are using (ST, LD, STLD...) we can help you further if you have any more questions.

Share this post


Link to post
Share on other sites

Thanks for the reply. I used 'SET_BIT_OF_INT' with 'INT_TO_WORD' for my program and it is a good solution.

Once again, thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now