AndrejP

Function Block Variable bit addressing

2 posts in this topic

Hello.

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.

 

setBit_STL.PNG.289df1de11a8b975108fc9939setbit2_stl.PNG.93cc00f1c93ea1b42e90e2bb

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