Function Block Variable bit addressing

2 posts in this topic


How can I get bit addressing of defined variable in function block?

For example:

- I define variable type DUINT with name Double_VarI_INT.

- I want to get or set one bit out of it (its double word).

- If I use Double_VarI_INT.0 I got error.

Best regards.

Share this post

Link to post
Share on other sites

I found a possible way to do it. You have to make a second function block in ladder an call that one from the STL function block using the correct arguments. The reason for using MOV (should actually be MOVL for UDINT) is because you can't pass an input to an output. The value of resultUDINT will change according to the bit number you put in myBIT (0-31). It may even be possible to make the function call simpler with some tweaking, I haven't really thought it through. You can use the same route to read a certain bit, by calling a ladder function block with arguments taken from your STL program.



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