Hi,
Let’s say I had a variable called “alarms”, with the data-type BOOL[5,5]. Is there a function block that can check every BOOL in that 3D array and return a TRUE if any of them are TRUE?
I specifically want to do this in ladder logic. I understand that this can easily be done with a custom function block in libraries, but I’m curious if this can already be done with the function blocks AS comes with.
If you don’t need to know which alarm is true, you can use a simple brsmemcmp function to compare against 0 to determine if any values are true. brsmemcmp will indicate if there is a difference between IN1 and IN2. By comparing against a constant of false of the same size (125 x FALSE), the brsmemcmp will indicate if there are any true values, the only other value possible for BOOL. The DINT_TO_BOOL is there to provide a usable BOOL value with the answer.
An example ladder rung is below. NO_ALARMS is a constant of the same type as AlarmArray, 125(FALSE).
Oh wow, that’s interesting. This isn’t a very aesthetic solution, but alas I gotta avoid structure text wherever possible for this project this might be the best I got. Thank you Austin
And here the last but not least variant, which gives you also the Index of the First found Alarm. Creating a loop in LD and go over the Array. Create an Exit if one TRUE was found.
Oh nice, you’re looping ladder logic like structure text lol. Unfortunately my goal here is to base this logic off of an AB template, so readability from a ladder-logic point of view is my top priority. The first solution wasn’t pretty but it did it in one line, so I find that preferable. I didn’t know about the “jump” and “return” functions though, I’ll keep that in mind