noorloai

setting BOOL [64] in Studio 5000

8 posts in this topic

Hi,

I need to set an output of bool[64] array when condition triggered but when I download the code to the controller it cause major fault see attached.

Can someone help me with that?

Thanks

 

code fault.png

major fault.jpg

Share this post


Link to post
Share on other sites

If you have declared an array as BOOL[64], there are 64 elements numbered 0 through 63. You should limit check your code to make sure the subscript tag is valid before using it.

Share this post


Link to post
Share on other sites

Thanks, but how can I do that in ladder ?

Share this post


Link to post
Share on other sites

oh do you mean I have to use LIM instruction to check my range and if its not within this range I write 0 then execute this rung ?

Share this post


Link to post
Share on other sites

for this specific problem, you just have to change   BOOL[64] data declaration to  BOOL[65]  and you can use  BOOL[64] bit in your program

Share this post


Link to post
Share on other sites

I would use the LIM instruction. What sets that index address? That code should also limit itself to a valid range of values.

For example, if you're indexing through them in order using an ADD instruction, you should have a GRT instruction right after the ADD that checks for it being greater than 63 (the highest valid value) and writing a 0 to it if it is.

 

Share this post


Link to post
Share on other sites

Be warned you can't ever let the pointer get bigger than the array!!

For example the line GRT Pointer 63 mov 63 pointer will still produce a fault, because pointer is 65 during the prescan.

You need to use a line GRt Pre_pointer 63 mov 63 Pre_pointer and then mov Pre_pointer Pointer.

At least in the Pre 20 versions of logix 5000 this was a necessity.

Share this post


Link to post
Share on other sites

also note that OTE instruction ALWAYS writes to memory location - regardless if condition in front of it is true or false.

therefore setting LIM before OTE will do nothing to prevent out of bound errors...!

since 64 is binary power multiple, you may consider using mask to constrain (modify) index value

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