Chris Elston

Sysmac Studio INT(Bits) to ARRAY of BOOL

3 posts in this topic

Still working on the Allen Bradley conversion to Omron NJ project...has proven to be alot harder than I thought. This time I have an TAG which is an INT, that I want to map to the first 8 bits of an ARRAY of BOOLs

TAG_INT (int) to TAG_ARRAY of 0-96 BOOL

TAG_INT.0 = TAG_ARRAY[0]
TAG_INT.1 = TAG_ARRAY[1]
TAG_INT.2 = TAG_ARRAY[2]
TAG_INT.3 = TAG_ARRAY[3]
TAG_INT.4 = TAG_ARRAY[4]
TAG_INT.5 = TAG_ARRAY[5]
TAG_INT.6 = TAG_ARRAY[6]
TAG_INT.7 = TAG_ARRAY[7]

In Allen Bradley, you can refer to a INT by bit numbers with a DOT (then bit number), it seems Omron doesn't like that. There doesn't seem to an INTtoARRAYofBITS function, but there is an ARRAYtoBIT function.

Any suggestions with this one?

Share this post


Link to post
Share on other sites

You can create a union of WORD and ARRAY[0..15] OF BOOL.

Then you can do something like this:

yourUnion.wordInUnion := INT_TO_WORD(yourINT);

Then you are able to address the bits in the array.

If you need to combine the 8 first elements of 8 arrays in one singe array with 96 elements you can do this with the AryMove instruction. I haven't given this much thought tough, there may be a more suitable approach.

Share this post


Link to post
Share on other sites

Nedward's suggestion is the preferred method. I've made one for WORD and another for DWORD then make it standard practice to copy and paste these in every program I start. I'll also break out the BYTE level whether I use it or not.

Mr_PLC_Union.PNG.b0cdb121e1470d324a6b2b0

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