Sign in to follow this  
Followers 0
JackE

Addressing Bit Inside an INT

9 posts in this topic

Siemens I could do this.... however on Sysmac Studio i can't seem to do this...

 

I just want to be able to set the first bit of an integer...or even a word!

 

Is there a way of doing this without using Unions etc?

Share this post


Link to post
Share on other sites

It's possible by bit string such as BYTE, WORD, DWORD and LWORD.

 

By using the function:

- OutAbit 

- ResetABit

- SetABit

 

You can convert a word to integer afterwards

1 person likes this

Share this post


Link to post
Share on other sites

I still prefer using a union so that I can assign unique comments to each bit.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks.

I used a Union in the end and it works rather well.

Sysmac has some quirks which I still need to get used to!

If anyone is reading this, just go to data types > union. See pic.

 

6p3YKs8.png

 

Edited by JackE
1 person likes this

Share this post


Link to post
Share on other sites
1 hour ago, KoenW said:

It's possible by bit string such as BYTE, WORD, DWORD and LWORD.

 

By using the function:

- OutAbit 

- ResetABit

- SetABit

 

You can convert a word to integer afterwards

 

Just seems a finnicky way of doing it, such a basic function is rather long winded.

 

Unions are the way to go I think! Thanks anyway!

Share this post


Link to post
Share on other sites

It took me some time to get used to as well.  You are spot on with Sysmac having some quirks.  Once you get used to them though Sysmac really starts to feel like one of the best programming environments on the market- at least compared to Portal or Studio.

I have gotten into the habit of just creating a BYTE, Word, Dword, and Lword union in each of my projects; and then I can just create symbols as whichever type I need as I go.

Share this post


Link to post
Share on other sites

why look for 'special' function and not use generic ones that are literally available on every platform?

OR instruction and suitable mask does the job.

 

Share this post


Link to post
Share on other sites
7 hours ago, panic mode said:

why look for 'special' function and not use generic ones that are literally available on every platform?

OR instruction and suitable mask does the job.

 

What i was trying to do wasn't special. In Siemens I can address a BIT inside an INT without having to make a union.

Share this post


Link to post
Share on other sites
8 hours ago, JackE said:

What i was trying to do wasn't special. In Siemens I can address a BIT inside an INT without having to make a union.

You can also do this with Omron's older non-tag based systems (W0 as an integer or W0.15 to access bit 15).  There are pluses and minuses to both styles.  

In fact, you can also do this with Sysmac Studio.  You just have to assign addresses.   See below:

First, define two tags, one that points at W0 and is an integer and one that points at W0.15 and is BOOL format:

5c6da06e915a8_ATVars.jpg.56b4b5a4954330d

Then when you turn on the bit, it will also affect the INT:

5c6da0bbbc03f_BitINT.jpg.1f2cafafc0acdeb

The result of -32768 is of course a signed integer, you can see the binary results if you change the display as shown below:

Binarydisp.thumb.jpg.d86374cd7142bae13d5

If you are using an NX1P2 or NX102, there is an additional step to enable the W memory area first.

2 people like this

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
Sign in to follow this  
Followers 0